Add backward-delete-char/eof action (#1891)

'backward-delete-char/eof' will either abort if query is
empty or delete one character backwards.
This commit is contained in:
James Wright
2020-02-27 10:38:32 -07:00
committed by GitHub
parent d8cb5c1cf5
commit 9f0626da64
4 changed files with 72 additions and 47 deletions

View File

@@ -187,6 +187,7 @@ const (
actAcceptNonEmpty
actBackwardChar
actBackwardDeleteChar
actBackwardDeleteCharEOF
actBackwardWord
actCancel
actClearScreen
@@ -1846,6 +1847,13 @@ func (t *Terminal) Loop() {
t.input = []rune{}
t.cx = 0
}
case actBackwardDeleteCharEOF:
if len(t.input) == 0 {
req(reqQuit)
} else if t.cx > 0 {
t.input = append(t.input[:t.cx-1], t.input[t.cx:]...)
t.cx--
}
case actForwardChar:
if t.cx < len(t.input) {
t.cx++