mirror of
https://github.com/Hopiu/micro.git
synced 2026-04-27 17:44:42 +00:00
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:
parent
3270acdd00
commit
0165c4a40a
1 changed files with 11 additions and 13 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue