summaryrefslogtreecommitdiffstats
path: root/pkg/gui/context/setup.go
blob: ec14a502898aae41615161eeace97e0ce48d218e (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
package context

import "github.com/jesseduffield/lazygit/pkg/gui/types"

func NewContextTree(c *ContextCommon) *ContextTree {
	commitFilesContext := NewCommitFilesContext(c)

	return &ContextTree{
		Global: NewSimpleContext(
			NewBaseContext(NewBaseContextOpts{
				Kind:                  types.GLOBAL_CONTEXT,
				View:                  nil, // TODO: see if this breaks anything
				WindowName:            "",
				Key:                   GLOBAL_CONTEXT_KEY,
				Focusable:             false,
				HasUncontrolledBounds: true, // setting to true because the global context doesn't even have a view
			}),
		),
		Status: NewSimpleContext(
			NewBaseContext(NewBaseContextOpts{
				Kind:       types.SIDE_CONTEXT,
				View:       c.Views().Status,
				WindowName: "status",
				Key:        STATUS_CONTEXT_KEY,
				Focusable:  true,
			}),
		),
		Files:          NewWorkingTreeContext(c),
		Submodules:     NewSubmodulesContext(c),
		Menu:           NewMenuContext(c),
		Remotes:        NewRemotesContext(c),
		Worktrees:      NewWorktreesContext(c),
		RemoteBranches: NewRemoteBranchesContext(c),
		LocalCommits:   NewLocalCommitsContext(c),
		CommitFiles:    commitFilesContext,
		ReflogCommits:  NewReflogCommitsContext(c),
		SubCommits:     NewSubCommitsContext(c),
		Branches:       NewBranchesContext(c),
		Tags:           NewTagsContext(c),
		Stash:          NewStashContext(c),
		Suggestions:    NewSuggestionsContext(c),
		Normal: NewSimpleContext(
			NewBaseContext(NewBaseContextOpts{
				Kind:       types.MAIN_CONTEXT,
				View:       c.Views().Main,
				WindowName: "main",
				Key:        NORMAL_MAIN_CONTEXT_KEY,
				Focusable:  false,
			}),
		),
		NormalSecondary: NewSimpleContext(
			NewBaseContext(NewBaseContextOpts{
				Kind:       types.MAIN_CONTEXT,
				View:       c.Views().Secondary,
				WindowName: "secondary",
				Key:        NORMAL_SECONDARY_CONTEXT_KEY,
				Focusable:  false,
			}),
		),
		Staging: NewPatchExplorerContext(
			c.Views().Staging,
			"main",
			STAGING_MAIN_CONTEXT_KEY,
			func() []int { return nil },
			c,
		),
		StagingSecondary: NewPatchExplorerContext(
			c.Views().StagingSecondary,
			"secondary",
			STAGING_SECONDARY_CONTEXT_KEY,
			func() []int { return nil },
			c,
		),
		CustomPatchBuilder: NewPatchExplorerContext(
			c.Views().PatchBuilding,
			"main",
			PATCH_BUILDING_MAIN_CONTEXT_KEY,
			func() []int {
				filename := commitFilesContext.GetSelectedPath()
				includedLineIndices, err := c.Git().Patch.PatchBuilder.GetFileIncLineIndices(filename)
				if err != nil {
					c.Log.Error(err)
					return nil
				}

				return includedLineIndices
			},
			c,
		),
		CustomPatchBuilderSecondary: NewSimpleContext(
			NewBaseContext(NewBaseContextOpts{
				Kind:       types.MAIN_CONTEXT,
				View:       c.Views().PatchBuildingSecondary,
				WindowName: "secondary",
				Key:        PATCH_BUILDING_SECONDARY_CONTEXT_KEY,
				Focusable:  false,
			}),
		),
		MergeConflicts: NewMergeConflictsContext(
			c,
		),
		Confirmation:  NewConfirmationContext(c),
		CommitMessage: NewCommitMessageContext(c),
		CommitDescription: NewSimpleContext(
			NewBaseContext(NewBaseContextOpts{
				Kind:                  types.PERSISTENT_POPUP,
				View:                  c.Views().CommitDescription,
				WindowName:            "commitDescription",
				Key:                   COMMIT_DESCRIPTION_CONTEXT_KEY,
				Focusable:             true,
				HasUncontrolledBounds: true,
			}),
		),
		Search: NewSimpleContext(
			NewBaseContext(NewBaseContextOpts{
				Kind:       types.PERSISTENT_POPUP,
				View:       c.Views().Search,
				WindowName: "search",
				Key:        SEARCH_CONTEXT_KEY,
				Focusable:  true,
			}),
		),
		CommandLog: NewSimpleContext(
			NewBaseContext(NewBaseContextOpts{
				Kind:       types.EXTRAS_CONTEXT,
				View:       c.Views().Extras,
				WindowName: "extras",
				Key:        COMMAND_LOG_CONTEXT_KEY,
				Focusable:  true,
			}),
		),
		Snake: NewSimpleContext(
			NewBaseContext(NewBaseContextOpts{
				Kind:       types.SIDE_CONTEXT,
				View:       c.Views().Snake,
				WindowName: "files",
				Key:        SNAKE_CONTEXT_KEY,
				Focusable:  true,
			}),
		),
		Options:       NewDisplayContext(OPTIONS_CONTEXT_KEY, c.Views().Options, "options"),
		AppStatus:     NewDisplayContext(APP_STATUS_CONTEXT_KEY, c.Views().AppStatus, "appStatus"),
		SearchPrefix:  NewDisplayContext(SEARCH_PREFIX_CONTEXT_KEY, c.Views().SearchPrefix, "searchPrefix"),
		Information:   NewDisplayContext(INFORMATION_CONTEXT_KEY, c.Views().Information, "information"),
		Limit:         NewDisplayContext(LIMIT_CONTEXT_KEY, c.Views().Limit, "limit"),
		StatusSpacer1: NewDisplayContext(STATUS_SPACER1_CONTEXT_KEY, c.Views().StatusSpacer1, "statusSpacer1"),
		StatusSpacer2: NewDisplayContext(STATUS_SPACER2_CONTEXT_KEY, c.Views().StatusSpacer2, "statusSpacer2"),
	}
}