Skip to content

Commit 0c29f2e

Browse files
committed
Add class MainContext
In this state of the code it isn't worth much because it's not any more than a SimpleContext, but we'll add things to it later in the branch.
1 parent 4af4a56 commit 0c29f2e

File tree

2 files changed

+45
-32
lines changed

2 files changed

+45
-32
lines changed

pkg/gui/context/main_context.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package context
2+
3+
import (
4+
"github.com/jesseduffield/gocui"
5+
"github.com/jesseduffield/lazygit/pkg/gui/types"
6+
)
7+
8+
type MainContext struct {
9+
*SimpleContext
10+
}
11+
12+
func NewMainContext(
13+
view *gocui.View,
14+
windowName string,
15+
key types.ContextKey,
16+
) *MainContext {
17+
ctx := &MainContext{
18+
SimpleContext: NewSimpleContext(
19+
NewBaseContext(NewBaseContextOpts{
20+
Kind: types.MAIN_CONTEXT,
21+
View: view,
22+
WindowName: windowName,
23+
Key: key,
24+
Focusable: false,
25+
})),
26+
}
27+
28+
return ctx
29+
}

pkg/gui/context/setup.go

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -25,38 +25,22 @@ func NewContextTree(c *ContextCommon) *ContextTree {
2525
Focusable: true,
2626
}),
2727
),
28-
Files: NewWorkingTreeContext(c),
29-
Submodules: NewSubmodulesContext(c),
30-
Menu: NewMenuContext(c),
31-
Remotes: NewRemotesContext(c),
32-
Worktrees: NewWorktreesContext(c),
33-
RemoteBranches: NewRemoteBranchesContext(c),
34-
LocalCommits: NewLocalCommitsContext(c),
35-
CommitFiles: commitFilesContext,
36-
ReflogCommits: NewReflogCommitsContext(c),
37-
SubCommits: NewSubCommitsContext(c),
38-
Branches: NewBranchesContext(c),
39-
Tags: NewTagsContext(c),
40-
Stash: NewStashContext(c),
41-
Suggestions: NewSuggestionsContext(c),
42-
Normal: NewSimpleContext(
43-
NewBaseContext(NewBaseContextOpts{
44-
Kind: types.MAIN_CONTEXT,
45-
View: c.Views().Main,
46-
WindowName: "main",
47-
Key: NORMAL_MAIN_CONTEXT_KEY,
48-
Focusable: false,
49-
}),
50-
),
51-
NormalSecondary: NewSimpleContext(
52-
NewBaseContext(NewBaseContextOpts{
53-
Kind: types.MAIN_CONTEXT,
54-
View: c.Views().Secondary,
55-
WindowName: "secondary",
56-
Key: NORMAL_SECONDARY_CONTEXT_KEY,
57-
Focusable: false,
58-
}),
59-
),
28+
Files: NewWorkingTreeContext(c),
29+
Submodules: NewSubmodulesContext(c),
30+
Menu: NewMenuContext(c),
31+
Remotes: NewRemotesContext(c),
32+
Worktrees: NewWorktreesContext(c),
33+
RemoteBranches: NewRemoteBranchesContext(c),
34+
LocalCommits: NewLocalCommitsContext(c),
35+
CommitFiles: commitFilesContext,
36+
ReflogCommits: NewReflogCommitsContext(c),
37+
SubCommits: NewSubCommitsContext(c),
38+
Branches: NewBranchesContext(c),
39+
Tags: NewTagsContext(c),
40+
Stash: NewStashContext(c),
41+
Suggestions: NewSuggestionsContext(c),
42+
Normal: NewMainContext(c.Views().Main, "main", NORMAL_MAIN_CONTEXT_KEY),
43+
NormalSecondary: NewMainContext(c.Views().Secondary, "secondary", NORMAL_SECONDARY_CONTEXT_KEY),
6044
Staging: NewPatchExplorerContext(
6145
c.Views().Staging,
6246
"main",

0 commit comments

Comments
 (0)