summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2020-06-07 23:07:03 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2020-06-07 23:07:03 +0900
commita7aa08ce07e2c21ac9ed8621e46cbe989228f3cd (patch)
treec2b82601fe5ab28177098a69e84541639aa926ee /src
parent06d63a862e900dcc6ee6c2335120cc8cb939698f (diff)
Add backward-eof event for --bind
Diffstat (limited to 'src')
-rw-r--r--src/options.go2
-rw-r--r--src/terminal.go10
-rw-r--r--src/tui/tui.go1
3 files changed, 13 insertions, 0 deletions
diff --git a/src/options.go b/src/options.go
index 32c50af5..2979da6b 100644
--- a/src/options.go
+++ b/src/options.go
@@ -464,6 +464,8 @@ func parseKeyChords(str string, message string) map[int]string {
chord = tui.CtrlRightBracket
case "change":
chord = tui.Change
+ case "backward-eof":
+ chord = tui.BackwardEOF
case "alt-enter", "alt-return":
chord = tui.CtrlAltM
case "alt-space":
diff --git a/src/terminal.go b/src/terminal.go
index 7bc79398..a5dfe491 100644
--- a/src/terminal.go
+++ b/src/terminal.go
@@ -1738,6 +1738,7 @@ func (t *Terminal) Loop() {
for looping {
var newCommand *string
changed := false
+ beof := false
queryChanged := false
event := t.tui.GetChar()
@@ -1881,6 +1882,7 @@ func (t *Terminal) Loop() {
t.cx++
}
case actBackwardDeleteChar:
+ beof = len(t.input) == 0
if t.cx > 0 {
t.input = append(t.input[:t.cx-1], t.input[t.cx:]...)
t.cx--
@@ -1973,16 +1975,19 @@ func (t *Terminal) Loop() {
t.vset(0)
req(reqList)
case actUnixLineDiscard:
+ beof = len(t.input) == 0
if t.cx > 0 {
t.yanked = copySlice(t.input[:t.cx])
t.input = t.input[t.cx:]
t.cx = 0
}
case actUnixWordRubout:
+ beof = len(t.input) == 0
if t.cx > 0 {
t.rubout("\\s\\S")
}
case actBackwardKillWord:
+ beof = len(t.input) == 0
if t.cx > 0 {
t.rubout(t.wordRubout)
}
@@ -2145,6 +2150,11 @@ func (t *Terminal) Loop() {
continue
}
}
+ if onEOFs, prs := t.keymap[tui.BackwardEOF]; beof && prs {
+ if !doActions(onEOFs, tui.BackwardEOF) {
+ continue
+ }
+ }
} else {
if mapkey == tui.Rune {
if idx := strings.IndexRune(t.jumpLabels, event.Char); idx >= 0 && idx < t.maxItems() && idx < t.merger.Length() {
diff --git a/src/tui/tui.go b/src/tui/tui.go
index f5ebb161..3ed794f7 100644
--- a/src/tui/tui.go
+++ b/src/tui/tui.go
@@ -87,6 +87,7 @@ const (
F12
Change
+ BackwardEOF
AltSpace
AltSlash