diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2020-08-23 10:13:56 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2020-08-23 14:29:18 +1000 |
commit | ade54b38c12079ba133e9c8810af2a3760afb0f3 (patch) | |
tree | 791315bd05894635ac0dee3f0e6b9c1acbea8f90 /pkg/gui | |
parent | 0dd2c869a8808e937c69f8ce0ba04015e5a9075e (diff) |
cleanup
Diffstat (limited to 'pkg/gui')
-rw-r--r-- | pkg/gui/context.go | 16 | ||||
-rw-r--r-- | pkg/gui/list_context.go | 13 | ||||
-rw-r--r-- | pkg/gui/patch_options_panel.go | 4 | ||||
-rw-r--r-- | pkg/gui/sub_commits_panel.go | 2 | ||||
-rw-r--r-- | pkg/gui/window.go | 2 |
5 files changed, 17 insertions, 20 deletions
diff --git a/pkg/gui/context.go b/pkg/gui/context.go index 78aafba37..fe444321c 100644 --- a/pkg/gui/context.go +++ b/pkg/gui/context.go @@ -210,7 +210,7 @@ func (gui *Gui) contextTree() ContextTree { }, Kind: MAIN_CONTEXT, ViewName: "main", - Key: "normal", + Key: MAIN_NORMAL_CONTEXT_KEY, }, }, Staging: SimpleContextNode{ @@ -222,7 +222,7 @@ func (gui *Gui) contextTree() ContextTree { }, Kind: MAIN_CONTEXT, ViewName: "main", - Key: "staging", + Key: MAIN_STAGING_CONTEXT_KEY, }, }, PatchBuilding: SimpleContextNode{ @@ -234,7 +234,7 @@ func (gui *Gui) contextTree() ContextTree { }, Kind: MAIN_CONTEXT, ViewName: "main", - Key: "patchBuilding", + Key: MAIN_PATCH_BUILDING_CONTEXT_KEY, }, }, Merging: SimpleContextNode{ @@ -246,7 +246,7 @@ func (gui *Gui) contextTree() ContextTree { }, Kind: MAIN_CONTEXT, ViewName: "main", - Key: "merging", + Key: MAIN_MERGING_CONTEXT_KEY, }, }, Credentials: SimpleContextNode{ @@ -254,7 +254,7 @@ func (gui *Gui) contextTree() ContextTree { OnFocus: func() error { return gui.handleCredentialsViewFocused() }, Kind: PERSISTENT_POPUP, ViewName: "credentials", - Key: "credentials", + Key: CREDENTIALS_CONTEXT_KEY, }, }, Confirmation: SimpleContextNode{ @@ -262,7 +262,7 @@ func (gui *Gui) contextTree() ContextTree { OnFocus: func() error { return nil }, Kind: TEMPORARY_POPUP, ViewName: "confirmation", - Key: "confirmation", + Key: CONFIRMATION_CONTEXT_KEY, }, }, CommitMessage: SimpleContextNode{ @@ -270,7 +270,7 @@ func (gui *Gui) contextTree() ContextTree { OnFocus: func() error { return gui.handleCommitMessageFocused() }, Kind: PERSISTENT_POPUP, ViewName: "commitMessage", - Key: "commitMessage", + Key: COMMIT_MESSAGE_CONTEXT_KEY, }, }, Search: SimpleContextNode{ @@ -278,7 +278,7 @@ func (gui *Gui) contextTree() ContextTree { OnFocus: func() error { return nil }, Kind: PERSISTENT_POPUP, ViewName: "search", - Key: "search", + Key: SEARCH_CONTEXT_KEY, }, }, } diff --git a/pkg/gui/list_context.go b/pkg/gui/list_context.go index d3894d7a3..23a96952d 100644 --- a/pkg/gui/list_context.go +++ b/pkg/gui/list_context.go @@ -232,13 +232,12 @@ func (lc *ListContext) onSearchSelect(selectedLineIdx int) error { func (gui *Gui) menuListContext() *ListContext { return &ListContext{ - ViewName: "menu", - ContextKey: "menu", - GetItemsLength: func() int { return gui.getMenuView().LinesHeight() }, - GetPanelState: func() IListPanelState { return gui.State.Panels.Menu }, - OnFocus: gui.handleMenuSelect, - // need to add a layer of indirection here because the callback changes during runtime - OnClickSelectedItem: func() error { return gui.State.Panels.Menu.OnPress() }, + ViewName: "menu", + ContextKey: "menu", + GetItemsLength: func() int { return gui.getMenuView().LinesHeight() }, + GetPanelState: func() IListPanelState { return gui.State.Panels.Menu }, + OnFocus: gui.handleMenuSelect, + OnClickSelectedItem: func() error { return gui.onMenuPress() }, Gui: gui, ResetMainViewOriginOnFocus: false, Kind: PERSISTENT_POPUP, diff --git a/pkg/gui/patch_options_panel.go b/pkg/gui/patch_options_panel.go index 20b008459..1eb6cffa7 100644 --- a/pkg/gui/patch_options_panel.go +++ b/pkg/gui/patch_options_panel.go @@ -42,7 +42,7 @@ func (gui *Gui) handleCreatePatchOptionsMenu(g *gocui.Gui, v *gocui.View) error }, }...) - if gui.currentContext() == gui.Contexts.BranchCommits.Context { + if gui.currentContext().GetKey() == gui.Contexts.BranchCommits.Context.GetKey() { selectedCommit := gui.getSelectedLocalCommit() if selectedCommit != nil && gui.GitCommand.PatchManager.To != selectedCommit.Sha { // adding this option to index 1 @@ -84,7 +84,7 @@ func (gui *Gui) validateNormalWorkingTreeState() (bool, error) { } func (gui *Gui) returnFocusFromLineByLinePanelIfNecessary() error { - if gui.State.MainContext == "patchBuilding" { + if gui.State.MainContext == MAIN_PATCH_BUILDING_CONTEXT_KEY { return gui.handleEscapePatchBuildingPanel() } return nil diff --git a/pkg/gui/sub_commits_panel.go b/pkg/gui/sub_commits_panel.go index 46c45fd3a..1c2762faf 100644 --- a/pkg/gui/sub_commits_panel.go +++ b/pkg/gui/sub_commits_panel.go @@ -107,7 +107,5 @@ func (gui *Gui) handleSwitchToSubCommits() error { return nil } - gui.Log.Warn(currentContext.GetKey()) - return gui.switchToSubCommitsContext(currentContext.GetSelectedItemId()) } diff --git a/pkg/gui/window.go b/pkg/gui/window.go index 8931ff07b..c3fffc637 100644 --- a/pkg/gui/window.go +++ b/pkg/gui/window.go @@ -4,7 +4,7 @@ package gui // 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. +// is a view that moves between windows func (gui *Gui) getViewNameForWindow(window string) string { viewName, ok := gui.State.WindowViewNameMap[window] |