Merge pull request #2959 from JoeKar/fix/raw-esc-sequence

bindings: Allow raw escape sequence to be bound with `bind`
This commit is contained in:
Dmytro Maluka
2024-03-14 04:38:05 +01:00
committed by GitHub
2 changed files with 16 additions and 4 deletions

View File

@@ -88,6 +88,10 @@ func BindKey(k, v string, bind func(e Event, a string)) {
return
}
if strings.HasPrefix(k, "\x1b") {
screen.Screen.RegisterRawSeq(k)
}
bind(event, v)
// switch e := event.(type) {
@@ -153,7 +157,6 @@ modSearch:
k = k[5:]
modifiers |= tcell.ModShift
case strings.HasPrefix(k, "\x1b"):
screen.Screen.RegisterRawSeq(k)
return RawEvent{
esc: k,
}, true
@@ -331,6 +334,10 @@ func UnbindKey(k string) error {
}
}
if strings.HasPrefix(k, "\x1b") {
screen.Screen.UnregisterRawSeq(k)
}
defaults := DefaultBindings("buffer")
if a, ok := defaults[k]; ok {
BindKey(k, a, Binder["buffer"])