From 2236a7d7b3df15cf0aea1b97f26dd89907ff8a55 Mon Sep 17 00:00:00 2001 From: Hubert Hirtz Date: Wed, 3 Jun 2020 19:25:07 +0200 Subject: typing=done --- ui/ui.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'ui') 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) { -- cgit v1.2.3