From 0165c4a40ac729b1c0c70b91163fbf47943db789 Mon Sep 17 00:00:00 2001 From: Zachary Yedidia Date: Sun, 11 Jun 2017 20:40:11 -0400 Subject: [PATCH] Allow binding runes to actions This new functionality would make it possible to emulate vim keybindings pretty easily, for example. --- cmd/micro/view.go | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/cmd/micro/view.go b/cmd/micro/view.go index fef81ed4..3a058fbf 100644 --- a/cmd/micro/view.go +++ b/cmd/micro/view.go @@ -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 {