summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHubert Hirtz <hubert.hirtz@laposte.net>2020-06-03 19:25:07 +0200
committerHubert Hirtz <hubert.hirtz@laposte.net>2020-06-03 19:25:07 +0200
commit2236a7d7b3df15cf0aea1b97f26dd89907ff8a55 (patch)
tree7012145f39f78531b3cb4863f4469143f71f245d
parentPart Join Typing (diff)
typing=done
-rw-r--r--cmd/irc/main.go5
-rw-r--r--ui/ui.go12
2 files changed, 14 insertions, 3 deletions
diff --git a/cmd/irc/main.go b/cmd/irc/main.go
index 61ee39f..06db1cb 100644
--- a/cmd/irc/main.go
+++ b/cmd/irc/main.go
@@ -94,7 +94,10 @@ func main() {
app.InputLeft()
}
case tcell.KeyBackspace2:
- app.InputBackspace()
+ ok := app.InputBackspace()
+ if ok && app.InputLen() == 0 {
+ s.TypingStop(app.CurrentBuffer())
+ }
case tcell.KeyEnter:
buffer := app.CurrentBuffer()
input := app.InputEnter()
diff --git a/ui/ui.go b/ui/ui.go
index 04d3f25..3306a2c 100644
--- a/ui/ui.go
+++ b/ui/ui.go
@@ -129,6 +129,10 @@ func (ui *UI) Input() string {
return string(ui.textInput)
}
+func (ui *UI) InputLen() int {
+ return len(ui.textInput)
+}
+
func (ui *UI) InputRune(r rune) {
ui.textInput = append(ui.textInput, r)
ui.textCursor++
@@ -149,14 +153,18 @@ func (ui *UI) InputLeft() {
}
}
-func (ui *UI) InputBackspace() {
- if 0 < len(ui.textInput) {
+func (ui *UI) InputBackspace() (ok bool) {
+ ok = 0 < len(ui.textInput)
+
+ if ok {
ui.textInput = ui.textInput[:len(ui.textInput)-1]
if len(ui.textInput) < ui.textCursor {
ui.textCursor = len(ui.textInput)
}
ui.drawEditor()
}
+
+ return
}
func (ui *UI) InputEnter() (content string) {