summaryrefslogtreecommitdiffstats
path: root/pkg/gui/view_helpers.go
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 /pkg/gui/view_helpers.go
parenta045313e080d2c083425e89cfd8a004cbcf72ef7 (diff)
#480 Allow cycling side panels with number keys
Diffstat (limited to 'pkg/gui/view_helpers.go')
-rw-r--r--pkg/gui/view_helpers.go40
1 files changed, 40 insertions, 0 deletions
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 {