From f481e7fca96172297b978b95795618acbdd75f7c Mon Sep 17 00:00:00 2001 From: Alex Goodman Date: Fri, 2 Nov 2018 08:20:29 -0400 Subject: [PATCH] keybindings belong to a specific view (fixes #55) --- ui/filetreeview.go | 14 +++++++------- ui/layerview.go | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ui/filetreeview.go b/ui/filetreeview.go index 185dbe01..c3045554 100644 --- a/ui/filetreeview.go +++ b/ui/filetreeview.go @@ -95,37 +95,37 @@ func (view *FileTreeView) Setup(v *gocui.View, header *gocui.View) error { } for _, key := range view.keybindingPageUp { - if err := view.gui.SetKeybinding("", key.value, key.modifier, func(*gocui.Gui, *gocui.View) error { return view.PageUp() }); err != nil { + if err := view.gui.SetKeybinding(view.Name, key.value, key.modifier, func(*gocui.Gui, *gocui.View) error { return view.PageUp() }); err != nil { return err } } for _, key := range view.keybindingPageDown { - if err := view.gui.SetKeybinding("", key.value, key.modifier, func(*gocui.Gui, *gocui.View) error { return view.PageDown() }); err != nil { + if err := view.gui.SetKeybinding(view.Name, key.value, key.modifier, func(*gocui.Gui, *gocui.View) error { return view.PageDown() }); err != nil { return err } } for _, key := range view.keybindingToggleCollapse { - if err := view.gui.SetKeybinding("", key.value, key.modifier, func(*gocui.Gui, *gocui.View) error { return view.toggleCollapse() }); err != nil { + if err := view.gui.SetKeybinding(view.Name, key.value, key.modifier, func(*gocui.Gui, *gocui.View) error { return view.toggleCollapse() }); err != nil { return err } } for _, key := range view.keybindingToggleAdded { - if err := view.gui.SetKeybinding("", key.value, key.modifier, func(*gocui.Gui, *gocui.View) error { return view.toggleShowDiffType(filetree.Added) }); err != nil { + if err := view.gui.SetKeybinding(view.Name, key.value, key.modifier, func(*gocui.Gui, *gocui.View) error { return view.toggleShowDiffType(filetree.Added) }); err != nil { return err } } for _, key := range view.keybindingToggleRemoved { - if err := view.gui.SetKeybinding("", key.value, key.modifier, func(*gocui.Gui, *gocui.View) error { return view.toggleShowDiffType(filetree.Removed) }); err != nil { + if err := view.gui.SetKeybinding(view.Name, key.value, key.modifier, func(*gocui.Gui, *gocui.View) error { return view.toggleShowDiffType(filetree.Removed) }); err != nil { return err } } for _, key := range view.keybindingToggleModified { - if err := view.gui.SetKeybinding("", key.value, key.modifier, func(*gocui.Gui, *gocui.View) error { return view.toggleShowDiffType(filetree.Changed) }); err != nil { + if err := view.gui.SetKeybinding(view.Name, key.value, key.modifier, func(*gocui.Gui, *gocui.View) error { return view.toggleShowDiffType(filetree.Changed) }); err != nil { return err } } for _, key := range view.keybindingToggleUnchanged { - if err := view.gui.SetKeybinding("", key.value, key.modifier, func(*gocui.Gui, *gocui.View) error { return view.toggleShowDiffType(filetree.Unchanged) }); err != nil { + if err := view.gui.SetKeybinding(view.Name, key.value, key.modifier, func(*gocui.Gui, *gocui.View) error { return view.toggleShowDiffType(filetree.Unchanged) }); err != nil { return err } } diff --git a/ui/layerview.go b/ui/layerview.go index 599c25d9..cf8a8a63 100644 --- a/ui/layerview.go +++ b/ui/layerview.go @@ -66,13 +66,13 @@ func (view *LayerView) Setup(v *gocui.View, header *gocui.View) error { } for _, key := range view.keybindingCompareLayer { - if err := view.gui.SetKeybinding("", key.value, key.modifier, func(*gocui.Gui, *gocui.View) error { return view.setCompareMode(CompareLayer) }); err != nil { + if err := view.gui.SetKeybinding(view.Name, key.value, key.modifier, func(*gocui.Gui, *gocui.View) error { return view.setCompareMode(CompareLayer) }); err != nil { return err } } for _, key := range view.keybindingCompareAll { - if err := view.gui.SetKeybinding("", key.value, key.modifier, func(*gocui.Gui, *gocui.View) error { return view.setCompareMode(CompareAll) }); err != nil { + if err := view.gui.SetKeybinding(view.Name, key.value, key.modifier, func(*gocui.Gui, *gocui.View) error { return view.setCompareMode(CompareAll) }); err != nil { return err } }