Allow binding runes to actions

This new functionality would make it possible to emulate vim keybindings
pretty easily, for example.
This commit is contained in:
Zachary Yedidia
2017-06-11 20:40:11 -04:00
parent 3270acdd00
commit 0165c4a40a

View File

@@ -491,21 +491,19 @@ func (v *View) HandleEvent(event tcell.Event) {
case *tcell.EventKey:
// Check first if input is a key binding, if it is we 'eat' the input and don't insert a rune
isBinding := false
if e.Key() != tcell.KeyRune || e.Modifiers() != 0 {
for key, actions := range bindings {
if e.Key() == key.keyCode {
if e.Key() == tcell.KeyRune {
if e.Rune() != key.r {
continue
}
}
if e.Modifiers() == key.modifiers {
relocate = false
isBinding = true
relocate = v.ExecuteActions(actions)
break
for key, actions := range bindings {
if e.Key() == key.keyCode {
if e.Key() == tcell.KeyRune {
if e.Rune() != key.r {
continue
}
}
if e.Modifiers() == key.modifiers {
relocate = false
isBinding = true
relocate = v.ExecuteActions(actions)
break
}
}
}
if !isBinding && e.Key() == tcell.KeyRune {