diff options
author | Giorgio Previtera <giorgioprevitera@gmail.com> | 2019-07-27 12:16:26 +0100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2019-10-27 12:39:08 +1100 |
commit | 3524f6baa95f73cbe6cbd90335cebaeb158667a3 (patch) | |
tree | 612b1979aafbf5f6fdc884b06587142005e965c8 /pkg/gui/keybindings.go | |
parent | ac5cbc1d2cbfc9dd0dd6b9099f034354367d859d (diff) |
480 - remove duplication by using a decorator
Also use a for loop to append the new keybindings
Diffstat (limited to 'pkg/gui/keybindings.go')
-rw-r--r-- | pkg/gui/keybindings.go | 35 |
1 files changed, 5 insertions, 30 deletions
diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go index 30eca5615..24fd5a854 100644 --- a/pkg/gui/keybindings.go +++ b/pkg/gui/keybindings.go @@ -523,36 +523,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { Handler: gui.handleOpenOldCommitFile, Description: gui.Tr.SLocalize("openFile"), }, - { - ViewName: "", - Key: '1', - Modifier: gocui.ModNone, - Handler: gui.goToStatus, - }, - { - ViewName: "", - Key: '2', - Modifier: gocui.ModNone, - Handler: gui.goToFiles, - }, - { - ViewName: "", - Key: '3', - Modifier: gocui.ModNone, - Handler: gui.goToBranches, - }, - { - ViewName: "", - Key: '4', - Modifier: gocui.ModNone, - Handler: gui.goToCommits, - }, - { - ViewName: "", - Key: '5', - Modifier: gocui.ModNone, - Handler: gui.goToStash, - }, } for _, viewName := range []string{"status", "branches", "files", "commits", "commitFiles", "stash", "menu"} { @@ -565,6 +535,11 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { }...) } + // Appends keybindings to jump to a particular sideView using numbers + for i, viewName := range []string{"status", "files", "branches", "commits", "stash"} { + bindings = append(bindings, &Binding{ViewName: "", Key: rune(i+1) + '0', Modifier: gocui.ModNone, Handler: gui.goToSideView(viewName)}) + } + listPanelMap := map[string]struct { prevLine func(*gocui.Gui, *gocui.View) error nextLine func(*gocui.Gui, *gocui.View) error |