x-backend #2
@ -38,10 +38,14 @@ func main () {
|
|||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
|
|
||||||
case stone.EventPress:
|
case stone.EventPress:
|
||||||
event := event.(stone.EventPress)
|
button := stone.Button(event.(stone.EventPress))
|
||||||
if stone.event.Printable() {
|
if button.Printable() {
|
||||||
application.SetRune(caret, 0, rune(stone.event))
|
application.SetRune(caret, 0, rune(button))
|
||||||
caret ++
|
caret ++
|
||||||
|
width, _ := application.Size()
|
||||||
|
if caret >= width {
|
||||||
|
caret = 0
|
||||||
|
}
|
||||||
application.Draw()
|
application.Draw()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
7
input.go
7
input.go
@ -1,5 +1,7 @@
|
|||||||
package stone
|
package stone
|
||||||
|
|
||||||
|
import "unicode"
|
||||||
|
|
||||||
type Button int
|
type Button int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -69,3 +71,8 @@ const (
|
|||||||
KeyF11 Button = 154
|
KeyF11 Button = 154
|
||||||
KeyF12 Button = 155
|
KeyF12 Button = 155
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func (button Button) Printable () (printable bool) {
|
||||||
|
printable = unicode.IsPrint(rune(button))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user