commit 2236a7d
Hubert Hirtz
·
2020-06-03 17:25:07 +0000 UTC
parent 9a732d4
typing=done
2 files changed,
+14,
-3
+4,
-1
1@@ -94,7 +94,10 @@ func main() {
2 app.InputLeft()
3 }
4 case tcell.KeyBackspace2:
5- app.InputBackspace()
6+ ok := app.InputBackspace()
7+ if ok && app.InputLen() == 0 {
8+ s.TypingStop(app.CurrentBuffer())
9+ }
10 case tcell.KeyEnter:
11 buffer := app.CurrentBuffer()
12 input := app.InputEnter()
M
ui/ui.go
+10,
-2
1@@ -129,6 +129,10 @@ func (ui *UI) Input() string {
2 return string(ui.textInput)
3 }
4
5+func (ui *UI) InputLen() int {
6+ return len(ui.textInput)
7+}
8+
9 func (ui *UI) InputRune(r rune) {
10 ui.textInput = append(ui.textInput, r)
11 ui.textCursor++
12@@ -149,14 +153,18 @@ func (ui *UI) InputLeft() {
13 }
14 }
15
16-func (ui *UI) InputBackspace() {
17- if 0 < len(ui.textInput) {
18+func (ui *UI) InputBackspace() (ok bool) {
19+ ok = 0 < len(ui.textInput)
20+
21+ if ok {
22 ui.textInput = ui.textInput[:len(ui.textInput)-1]
23 if len(ui.textInput) < ui.textCursor {
24 ui.textCursor = len(ui.textInput)
25 }
26 ui.drawEditor()
27 }
28+
29+ return
30 }
31
32 func (ui *UI) InputEnter() (content string) {