summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGiorgio Previtera <gprevitera@equalexperts.com>2019-07-14 14:39:31 +0100
committerJesse Duffield <jessedduffield@gmail.com>2019-10-27 12:39:08 +1100
commitac5cbc1d2cbfc9dd0dd6b9099f034354367d859d (patch)
tree26ba1c26ced6c227f8cc9d90b40095ddfd8e6725
parenta045313e080d2c083425e89cfd8a004cbcf72ef7 (diff)
#480 Allow cycling side panels with number keys
-rw-r--r--pkg/gui/gui.go1
-rw-r--r--pkg/gui/keybindings.go30
-rw-r--r--pkg/gui/view_helpers.go40
-rw-r--r--pkg/i18n/dutch.go3
-rw-r--r--pkg/i18n/english.go3
-rw-r--r--pkg/i18n/polish.go3
6 files changed, 80 insertions, 0 deletions
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go
index e82beea03..21dde6dd9 100644
--- a/pkg/gui/gui.go
+++ b/pkg/gui/gui.go
@@ -609,6 +609,7 @@ func (gui *Gui) renderGlobalOptions() error {
"← → ↑ ↓": gui.Tr.SLocalize("navigate"),
"esc/q": gui.Tr.SLocalize("close"),
"x": gui.Tr.SLocalize("menu"),
+ "1-5": gui.Tr.SLocalize("jump"),
})
}
diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go
index ce12cf66f..30eca5615 100644
--- a/pkg/gui/keybindings.go
+++ b/pkg/gui/keybindings.go
@@ -523,6 +523,36 @@ 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"} {
diff --git a/pkg/gui/view_helpers.go b/pkg/gui/view_helpers.go
index f6e449989..ca3ababd1 100644
--- a/pkg/gui/view_helpers.go
+++ b/pkg/gui/view_helpers.go
@@ -139,6 +139,46 @@ func (gui *Gui) returnFocus(g *gocui.Gui, v *gocui.View) error {
return gui.switchFocus(g, v, previousView)
}
+func (gui *Gui) goToStatus(g *gocui.Gui, v *gocui.View) error {
+ view, err := g.View("status")
+ if err != nil {
+ gui.Log.Error(err)
+ }
+ return gui.switchFocus(g, nil, view)
+}
+
+func (gui *Gui) goToFiles(g *gocui.Gui, v *gocui.View) error {
+ view, err := g.View("files")
+ if err != nil {
+ gui.Log.Error(err)
+ }
+ return gui.switchFocus(g, nil, view)
+}
+
+func (gui *Gui) goToBranches(g *gocui.Gui, v *gocui.View) error {
+ view, err := g.View("branches")
+ if err != nil {
+ gui.Log.Error(err)
+ }
+ return gui.switchFocus(g, nil, view)
+}
+
+func (gui *Gui) goToCommits(g *gocui.Gui, v *gocui.View) error {
+ view, err := g.View("commits")
+ if err != nil {
+ gui.Log.Error(err)
+ }
+ return gui.switchFocus(g, nil, view)
+}
+
+func (gui *Gui) goToStash(g *gocui.Gui, v *gocui.View) error {
+ view, err := g.View("stash")
+ if err != nil {
+ gui.Log.Error(err)
+ }
+ return gui.switchFocus(g, nil, view)
+}
+
// pass in oldView = nil if you don't want to be able to return to your old view
// TODO: move some of this logic into our onFocusLost and onFocus hooks
func (gui *Gui) switchFocus(g *gocui.Gui, oldView, newView *gocui.View) error {
diff --git a/pkg/i18n/dutch.go b/pkg/i18n/dutch.go
index eba4dd972..a8b75cbe4 100644
--- a/pkg/i18n/dutch.go
+++ b/pkg/i18n/dutch.go
@@ -751,6 +751,9 @@ func addDutch(i18nObject *i18n.Bundle) error {
}, &i18n.Message{
ID: "notARepository",
Other: "Error: must be run inside a git repository",
+ }, &i18n.Message{
+ ID: "jump",
+ Other: "jump to panel",
},
)
}
diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go
index 8768d6d7b..2de69d4d6 100644
--- a/pkg/i18n/english.go
+++ b/pkg/i18n/english.go
@@ -774,6 +774,9 @@ func addEnglish(i18nObject *i18n.Bundle) error {
}, &i18n.Message{
ID: "notARepository",
Other: "Error: must be run inside a git repository",
+ }, &i18n.Message{
+ ID: "jump",
+ Other: "jump to panel",
},
)
}
diff --git a/pkg/i18n/polish.go b/pkg/i18n/polish.go
index cc2393090..6c55a5d30 100644
--- a/pkg/i18n/polish.go
+++ b/pkg/i18n/polish.go
@@ -734,6 +734,9 @@ func addPolish(i18nObject *i18n.Bundle) error {
}, &i18n.Message{
ID: "notARepository",
Other: "Error: must be run inside a git repository",
+ }, &i18n.Message{
+ ID: "jump",
+ Other: "jump to panel",
},
)
}