summaryrefslogtreecommitdiffstats
path: root/pkg/gui/context.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-08-22 08:49:02 +1000
committerJesse Duffield <jessedduffield@gmail.com>2020-08-23 14:29:18 +1000
commit974c6510b8fbda23b79f365efb18f2091cd757a6 (patch)
tree3b0e87827f2785cf37b7c8e09a64c7bac69fec33 /pkg/gui/context.go
parent41df63cdc4d799ce7d78ecb0b1ed96dea65f1739 (diff)
add sub commit context
Diffstat (limited to 'pkg/gui/context.go')
-rw-r--r--pkg/gui/context.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/pkg/gui/context.go b/pkg/gui/context.go
index 05f8212ee..9167f8fe7 100644
--- a/pkg/gui/context.go
+++ b/pkg/gui/context.go
@@ -3,6 +3,7 @@ package gui
import (
"fmt"
+ "github.com/davecgh/go-spew/spew"
"github.com/jesseduffield/gocui"
)
@@ -22,6 +23,7 @@ const (
TAGS_CONTEXT_KEY = "tags"
BRANCH_COMMITS_CONTEXT_KEY = "commits"
REFLOG_COMMITS_CONTEXT_KEY = "reflogCommits"
+ SUB_COMMITS_CONTEXT_KEY = "subCommits"
COMMIT_FILES_CONTEXT_KEY = "commitFiles"
STASH_CONTEXT_KEY = "stash"
MAIN_NORMAL_CONTEXT_KEY = "normal"
@@ -129,6 +131,7 @@ type ContextTree struct {
BranchCommits SimpleContextNode
CommitFiles SimpleContextNode
ReflogCommits SimpleContextNode
+ SubCommits SimpleContextNode
Stash SimpleContextNode
Normal SimpleContextNode
Staging SimpleContextNode
@@ -160,6 +163,7 @@ func (gui *Gui) allContexts() []Context {
gui.Contexts.Staging.Context,
gui.Contexts.Merging.Context,
gui.Contexts.PatchBuilding.Context,
+ gui.Contexts.SubCommits.Context,
}
}
@@ -194,6 +198,9 @@ func (gui *Gui) contextTree() ContextTree {
ReflogCommits: SimpleContextNode{
Context: gui.reflogCommitsListContext(),
},
+ SubCommits: SimpleContextNode{
+ Context: gui.subCommitsListContext(),
+ },
Branches: SimpleContextNode{
Context: gui.branchesListContext(),
},
@@ -510,6 +517,31 @@ func (gui *Gui) currentContext() Context {
return gui.State.ContextStack[len(gui.State.ContextStack)-1]
}
+func (gui *Gui) currentSideContext() *ListContext {
+ stack := gui.State.ContextStack
+
+ // on startup the stack can be empty so we'll return an empty string in that case
+ if len(stack) == 0 {
+ return nil
+ }
+
+ // find the first context in the stack with the type of SIDE_CONTEXT
+ for i := range stack {
+ context := stack[len(stack)-1-i]
+
+ if context.GetKind() == SIDE_CONTEXT {
+ gui.Log.Warn(spew.Sdump(context.GetKey()))
+ return context.(*ListContext)
+ }
+ }
+
+ return nil
+}
+
+func (gui *Gui) defaultSideContext() Context {
+ return gui.Contexts.Files.Context
+}
+
func (gui *Gui) setInitialViewContexts() {
// arguably we should only have our ViewContextMap and we should do away with
// contexts on views, or vice versa