summaryrefslogtreecommitdiffstats
path: root/pkg/gui/side_window.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-08-16 13:58:29 +1000
committerJesse Duffield <jessedduffield@gmail.com>2020-08-23 14:29:18 +1000
commit7f89113245307be8a1642105014e9ce51a47210f (patch)
tree0b1237c4bdd4a465bedb7cc49c8372d0bfc46ea5 /pkg/gui/side_window.go
parent0ea0c486310558e26af7ad6e4fcf17f57c2b62e3 (diff)
WIP
Diffstat (limited to 'pkg/gui/side_window.go')
-rw-r--r--pkg/gui/side_window.go66
1 files changed, 66 insertions, 0 deletions
diff --git a/pkg/gui/side_window.go b/pkg/gui/side_window.go
new file mode 100644
index 000000000..5d50984bb
--- /dev/null
+++ b/pkg/gui/side_window.go
@@ -0,0 +1,66 @@
+package gui
+
+import "github.com/jesseduffield/gocui"
+
+func (gui *Gui) nextSideWindow() error {
+ windows := gui.getCyclableWindows()
+ currentWindow := gui.currentWindow()
+ var newWindow string
+ if currentWindow == "" || currentWindow == windows[len(windows)-1] {
+ newWindow = windows[0]
+ } else {
+ for i := range windows {
+ if currentWindow == windows[i] {
+ newWindow = windows[i+1]
+ break
+ }
+ if i == len(windows)-1 {
+ return nil
+ }
+ }
+ }
+ if err := gui.resetOrigin(gui.getMainView()); err != nil {
+ return err
+ }
+
+ viewName := gui.getViewNameForWindow(newWindow)
+
+ return gui.switchContext(gui.State.ViewContextMap[viewName])
+}
+
+func (gui *Gui) previousSideWindow() error {
+ windows := gui.getCyclableWindows()
+ currentWindow := gui.currentWindow()
+ var newWindow string
+ if currentWindow == "" || currentWindow == windows[0] {
+ newWindow = windows[len(windows)-1]
+ } else {
+ for i := range windows {
+ if currentWindow == windows[i] {
+ newWindow = windows[i-1]
+ break
+ }
+ if i == len(windows)-1 {
+ return nil
+ }
+ }
+ }
+ if err := gui.resetOrigin(gui.getMainView()); err != nil {
+ return err
+ }
+
+ viewName := gui.getViewNameForWindow(newWindow)
+
+ return gui.switchContext(gui.State.ViewContextMap[viewName])
+}
+
+func (gui *Gui) goToSideWindow(sideViewName string) func(g *gocui.Gui, v *gocui.View) error {
+ return func(g *gocui.Gui, v *gocui.View) error {
+ err := gui.closePopupPanels()
+ if err != nil {
+ gui.Log.Error(err)
+ return nil
+ }
+ return gui.switchContext(gui.State.ViewContextMap[sideViewName])
+ }
+}