summaryrefslogtreecommitdiffstats
path: root/pkg/gui/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/window.go
parent0ea0c486310558e26af7ad6e4fcf17f57c2b62e3 (diff)
WIP
Diffstat (limited to 'pkg/gui/window.go')
-rw-r--r--pkg/gui/window.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/pkg/gui/window.go b/pkg/gui/window.go
new file mode 100644
index 000000000..bec14d863
--- /dev/null
+++ b/pkg/gui/window.go
@@ -0,0 +1,37 @@
+package gui
+
+// A window refers to a place on the screen which can hold one or more views.
+// A view is a box that renders content, and within a window only one view will
+// appear at a time. When a view appears within a window, it occupies the whole
+// space. Right now most windows are 1:1 with views, except for commitFiles which
+// is a view belonging to the 'commits' window, alongside the 'commits' view.
+
+func (gui *Gui) getViewNameForWindow(window string) string {
+ viewName, ok := gui.State.WindowViewNameMap[window]
+ if !ok {
+ return window
+ }
+
+ return viewName
+}
+
+func (gui *Gui) getWindowForViewName(viewName string) string {
+ // should soft-code this
+ if viewName == "commitFiles" {
+ return "commits"
+ }
+
+ return viewName
+}
+
+func (gui *Gui) setViewAsActiveForWindow(viewName string) {
+ if gui.State.WindowViewNameMap == nil {
+ gui.State.WindowViewNameMap = map[string]string{}
+ }
+
+ gui.State.WindowViewNameMap[gui.getWindowForViewName(viewName)] = viewName
+}
+
+func (gui *Gui) currentWindow() string {
+ return gui.getWindowForViewName(gui.currentViewName())
+}