diff options
Diffstat (limited to 'src/terminal.go')
-rw-r--r-- | src/terminal.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/terminal.go b/src/terminal.go index 7800714b..90d2807a 100644 --- a/src/terminal.go +++ b/src/terminal.go @@ -136,6 +136,7 @@ type Terminal struct { delimiter Delimiter expect map[tui.Event]string keymap map[tui.Event][]*action + keymapOrg map[tui.Event][]*action pressed string printQuery bool history *History @@ -313,6 +314,7 @@ const ( actSelect actDeselect actUnbind + actRebind ) type placeholderFlags struct { @@ -501,6 +503,10 @@ func NewTerminal(opts *Options, eventBox *util.EventBox) *Terminal { wordRubout = fmt.Sprintf("%s[^%s]", sep, sep) wordNext = fmt.Sprintf("[^%s]%s|(.$)", sep, sep) } + keymapCopy := make(map[tui.Event][]*action) + for key, action := range opts.Keymap { + keymapCopy[key] = action + } t := Terminal{ initDelay: delay, infoStyle: opts.InfoStyle, @@ -526,6 +532,7 @@ func NewTerminal(opts *Options, eventBox *util.EventBox) *Terminal { delimiter: opts.Delimiter, expect: opts.Expect, keymap: opts.Keymap, + keymapOrg: keymapCopy, pressed: "", printQuery: opts.PrintQuery, history: opts.History, @@ -2734,6 +2741,13 @@ func (t *Terminal) Loop() { for key := range keys { delete(t.keymap, key) } + case actRebind: + keys := parseKeyChords(a.a, "PANIC") + for key := range keys { + if originalAction, found := t.keymapOrg[key]; found { + t.keymap[key] = originalAction + } + } case actChangePreview: if t.previewOpts.command != a.a { togglePreview(len(a.a) > 0) |