diff options
author | Tommy Nguyen <remyabel@gmail.com> | 2018-08-21 09:00:16 -0400 |
---|---|---|
committer | Tommy Nguyen <remyabel@gmail.com> | 2018-08-21 09:00:16 -0400 |
commit | eff931a1387dc042b77701ece91e4028bb15aeda (patch) | |
tree | 6af855c012c63a0f0ca290d629a7d63a82cb5631 | |
parent | cd4063c7630395ab91d8a47ee86025dda823f6e8 (diff) |
Update gocui fork
-rw-r--r-- | Gopkg.lock | 2 | ||||
-rw-r--r-- | vendor/github.com/jesseduffield/gocui/gui.go | 28 | ||||
-rw-r--r-- | vendor/github.com/jesseduffield/gocui/keybinding.go | 3 |
3 files changed, 22 insertions, 11 deletions
diff --git a/Gopkg.lock b/Gopkg.lock index 6efc5a34e..9c715f884 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -77,7 +77,7 @@ branch = "master" name = "github.com/jesseduffield/gocui" packages = ["."] - revision = "432b7f6215f81ef1aaa1b2d9b69887822923cf79" + revision = "76a959bb4b0df223fd046b96b68f0162dd609e4b" [[projects]] name = "github.com/kevinburke/ssh_config" diff --git a/vendor/github.com/jesseduffield/gocui/gui.go b/vendor/github.com/jesseduffield/gocui/gui.go index 28a52d1cd..24ff49808 100644 --- a/vendor/github.com/jesseduffield/gocui/gui.go +++ b/vendor/github.com/jesseduffield/gocui/gui.go @@ -653,17 +653,31 @@ func (g *Gui) onKey(ev *termbox.Event) error { // execKeybindings executes the keybinding handlers that match the passed view // and event. The value of matched is true if there is a match and no errors. func (g *Gui) execKeybindings(v *View, ev *termbox.Event) (matched bool, err error) { - matched = false + var globalKb *keybinding for _, kb := range g.keybindings { if kb.handler == nil { continue } - if kb.matchKeypress(Key(ev.Key), ev.Ch, Modifier(ev.Mod)) && kb.matchView(v) { - if err := kb.handler(g, v); err != nil { - return false, err - } - matched = true + if !kb.matchKeypress(Key(ev.Key), ev.Ch, Modifier(ev.Mod)) { + continue + } + if kb.matchView(v) { + return g.execKeybinding(v, kb) + } + if kb.viewName == "" { + globalKb = kb } } - return matched, nil + if globalKb != nil { + return g.execKeybinding(v, globalKb) + } + return false, nil +} + +// execKeybinding executes a given keybinding +func (g *Gui) execKeybinding(v *View, kb *keybinding) (bool, error) { + if err := kb.handler(g, v); err != nil { + return false, err + } + return true, nil } diff --git a/vendor/github.com/jesseduffield/gocui/keybinding.go b/vendor/github.com/jesseduffield/gocui/keybinding.go index 7efdb75c6..82d1acc9f 100644 --- a/vendor/github.com/jesseduffield/gocui/keybinding.go +++ b/vendor/github.com/jesseduffield/gocui/keybinding.go @@ -38,9 +38,6 @@ func (kb *keybinding) matchView(v *View) bool { if v.Editable == true && kb.ch != 0 { return false } - if kb.viewName == "" { - return true - } return v != nil && kb.viewName == v.name } |