Compare commits
3 Commits
feature/sd
...
feature/da
| Author | SHA1 | Date | |
|---|---|---|---|
| cb20f95dc9 | |||
| 536005af66 | |||
| 9d7ee00bf9 |
@@ -558,7 +558,7 @@ func (self *BasicRuntime) sdlEvents() error {
|
||||
case *sdl.QuitEvent:
|
||||
self.setMode(MODE_QUIT)
|
||||
case *sdl.TextInputEvent:
|
||||
// This is LAZY and WRONG but it works on US ASCII keyboards so I guess
|
||||
// This is LAZY but it works on US ASCII keyboards so I guess
|
||||
// international users go EFF themselves? It's how we did it in the old days...
|
||||
ir = rune(t.Text[0])
|
||||
if ( unicode.IsPrint(ir) ) {
|
||||
@@ -576,21 +576,44 @@ func (self *BasicRuntime) sdlEvents() error {
|
||||
self.advanceCursor(1, 0)
|
||||
}
|
||||
case *sdl.KeyboardEvent:
|
||||
err = self.drawText(
|
||||
(self.cursorX * int32(self.fontWidth)),
|
||||
(self.cursorY * int32(self.fontHeight)),
|
||||
" ",
|
||||
true)
|
||||
if ( t.Type == sdl.KEYUP ) {
|
||||
//fmt.Printf("Key released: %s (Scancode: %d, Keycode: %d)\n", sdl.GetKeyName(t.Keysym.Sym), t.Keysym.Scancode, t.Keysym.Sym)
|
||||
ir = self.runeForSDLScancode(t.Keysym)
|
||||
//fmt.Printf("Rune: %c", ir)
|
||||
if ( ir == sdl.K_BACKSPACE ) {
|
||||
if ( ir == sdl.K_LEFT ) {
|
||||
if ( self.userlineIndex == 0 ) {
|
||||
return nil
|
||||
}
|
||||
err = self.drawText(
|
||||
(self.cursorX * int32(self.fontWidth)),
|
||||
(self.cursorY * int32(self.fontHeight)),
|
||||
string(self.lineInProgress[self.userlineIndex]),
|
||||
true)
|
||||
self.userlineIndex -= 1
|
||||
self.advanceCursor(-1, 0)
|
||||
} else if ( ir == sdl.K_RIGHT ) {
|
||||
if ( self.userlineIndex >= MAX_LINE_LENGTH ||
|
||||
self.lineInProgress[self.userlineIndex] == 0 ) {
|
||||
return nil
|
||||
}
|
||||
err = self.drawText(
|
||||
(self.cursorX * int32(self.fontWidth)),
|
||||
(self.cursorY * int32(self.fontHeight)),
|
||||
string(self.lineInProgress[self.userlineIndex]),
|
||||
true)
|
||||
self.userlineIndex += 1
|
||||
self.advanceCursor(+1, 0)
|
||||
} else if ( ir == sdl.K_BACKSPACE ) {
|
||||
if ( self.userlineIndex == 0 ) {
|
||||
return nil
|
||||
}
|
||||
self.lineInProgress[self.userlineIndex-1] = 0
|
||||
self.userlineIndex -= 1
|
||||
err = self.drawText(
|
||||
(self.cursorX * int32(self.fontWidth)),
|
||||
(self.cursorY * int32(self.fontHeight)),
|
||||
" ",
|
||||
true)
|
||||
if ( err != nil ) {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user