}
m.HandleEvent(event)
+
+ if m.cursorx < 0 {
+ // Cancel
+ m.hasPrompt = false
+ }
}
m.Reset()
case *tcell.EventKey:
switch e.Key() {
case tcell.KeyLeft:
- m.cursorx--
+ if m.cursorx > 0 {
+ m.cursorx--
+ }
case tcell.KeyRight:
- m.cursorx++
+ if m.cursorx < Count(m.response) {
+ m.cursorx++
+ }
case tcell.KeyBackspace2:
if m.cursorx > 0 {
m.response = string([]rune(m.response)[:Count(m.response)-1])
- m.cursorx--
}
+ m.cursorx--
case tcell.KeySpace:
m.response += " "
m.cursorx++
m.cursorx++
}
}
- if m.cursorx < 0 {
- m.cursorx = 0
- }
}
// Reset resets the messenger's cursor, message and response