blob: 8931ff07b68354da5bb85846fd8eae9779406a4d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
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 {
if viewName == "commitFiles" {
return gui.Contexts.CommitFiles.Context.GetWindowName()
}
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())
}
func (gui *Gui) resetWindowForView(viewName string) {
window := gui.getWindowForViewName(viewName)
// we assume here that the window contains as its default view a view with the same name as the window
gui.State.WindowViewNameMap[window] = window
}
|