summaryrefslogtreecommitdiffstats
path: root/pkg/gui/gui.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2019-11-16 12:41:04 +1100
committerJesse Duffield <jessedduffield@gmail.com>2019-11-21 22:07:14 +1100
commit7e0a8f235ef6971a98fba9c91c7fa159ca842180 (patch)
tree888c1e23b7b49e438226d9dee2c75316532d58ae /pkg/gui/gui.go
parent44bbc106a9668b8886f22812651635ec00a156fa (diff)
add contexts to views
Diffstat (limited to 'pkg/gui/gui.go')
-rw-r--r--pkg/gui/gui.go16
1 files changed, 12 insertions, 4 deletions
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go
index f7a6d1b68..9ad461bc7 100644
--- a/pkg/gui/gui.go
+++ b/pkg/gui/gui.go
@@ -167,7 +167,7 @@ type guiState struct {
Updating bool
Panels *panelStates
WorkingTreeState string // one of "merging", "rebasing", "normal"
- Context string // important not to set this value directly but to use gui.changeContext("new context")
+ MainContext string // used to keep the main and secondary views' contexts in sync
CherryPickedCommits []*commands.Commit
SplitMainPanel bool
RetainOriginalDir bool
@@ -315,11 +315,11 @@ func (gui *Gui) onFocusLost(v *gocui.View, newView *gocui.View) error {
}
case "main":
// if we have lost focus to a first-class panel, we need to do some cleanup
- if err := gui.changeContext("normal"); err != nil {
+ if err := gui.changeMainViewsContext("normal"); err != nil {
return err
}
case "commitFiles":
- if gui.State.Context != "patch-building" {
+ if gui.State.MainContext != "patch-building" {
if _, err := gui.g.SetViewOnBottom(v.Name()); err != nil {
return err
}
@@ -582,7 +582,7 @@ func (gui *Gui) layout(g *gocui.Gui) error {
}
// doing this here because it'll only happen once
- if err := gui.loadNewRepo(); err != nil {
+ if err := gui.onInitialViewsCreation(); err != nil {
return err
}
}
@@ -627,6 +627,14 @@ func (gui *Gui) layout(g *gocui.Gui) error {
return gui.resizeCurrentPopupPanel(g)
}
+func (gui *Gui) onInitialViewsCreation() error {
+ if err := gui.changeMainViewsContext("normal"); err != nil {
+ return err
+ }
+
+ return gui.loadNewRepo()
+}
+
func (gui *Gui) loadNewRepo() error {
gui.Updater.CheckForNewUpdate(gui.onBackgroundUpdateCheckFinish, false)
if err := gui.updateRecentRepoList(); err != nil {