summaryrefslogtreecommitdiffstats
path: root/pkg/gui
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2022-01-16 14:46:53 +1100
committerJesse Duffield <jessedduffield@gmail.com>2022-03-17 19:13:40 +1100
commit1dd7307fde033dae5fececac15810a99e26c3d91 (patch)
tree4e851c9e3229a6fe3b4191f6311d05d7a9142960 /pkg/gui
parenta90b6efded49abcfa2516db794d7875b0396f558 (diff)
start moving commit panel handlers into controller
more and more move rebase commit refreshing into existing abstraction and more and more WIP and more handling clicks properly fix merge conflicts update cheatsheet lots more preparation to start moving things into controllers WIP better typing expand on remotes controller moving more code into controllers
Diffstat (limited to 'pkg/gui')
-rw-r--r--pkg/gui/app_status_manager.go4
-rw-r--r--pkg/gui/arrangement.go11
-rw-r--r--pkg/gui/basic_context.go26
-rw-r--r--pkg/gui/bisect.go219
-rw-r--r--pkg/gui/branches_panel.go265
-rw-r--r--pkg/gui/cherry_picking.go43
-rw-r--r--pkg/gui/command_log_panel.go14
-rw-r--r--pkg/gui/commit_files_panel.go110
-rw-r--r--pkg/gui/commit_message_panel.go20
-rw-r--r--pkg/gui/commits_panel.go701
-rw-r--r--pkg/gui/confirmation_panel.go21
-rw-r--r--pkg/gui/context.go104
-rw-r--r--pkg/gui/context/context.go98
-rw-r--r--pkg/gui/context_config.go179
-rw-r--r--pkg/gui/controllers/bisect_controller.go273
-rw-r--r--pkg/gui/controllers/controller_common.go10
-rw-r--r--pkg/gui/controllers/files_controller.go737
-rw-r--r--pkg/gui/controllers/local_commits_controller.go783
-rw-r--r--pkg/gui/controllers/menu_controller.go70
-rw-r--r--pkg/gui/controllers/remotes_controller.go204
-rw-r--r--pkg/gui/controllers/submodules_controller.go60
-rw-r--r--pkg/gui/controllers/sync_controller.go253
-rw-r--r--pkg/gui/controllers/tags_controller.go229
-rw-r--r--pkg/gui/controllers/types.go53
-rw-r--r--pkg/gui/controllers/undo_controller.go (renamed from pkg/gui/undoing.go)230
-rw-r--r--pkg/gui/credentials_panel.go15
-rw-r--r--pkg/gui/custom_commands.go66
-rw-r--r--pkg/gui/diff_context_size.go18
-rw-r--r--pkg/gui/diff_context_size_test.go50
-rw-r--r--pkg/gui/diffing.go26
-rw-r--r--pkg/gui/discard_changes_menu_panel.go46
-rw-r--r--pkg/gui/editors.go4
-rw-r--r--pkg/gui/extras_panel.go17
-rw-r--r--pkg/gui/file_helper.go51
-rw-r--r--pkg/gui/file_watching.go4
-rw-r--r--pkg/gui/files_panel.go815
-rw-r--r--pkg/gui/filetree/commit_file_node.go4
-rw-r--r--pkg/gui/filetree/file_node.go4
-rw-r--r--pkg/gui/filtering.go28
-rw-r--r--pkg/gui/filtering_menu_panel.go14
-rw-r--r--pkg/gui/git_flow.go20
-rw-r--r--pkg/gui/global_handlers.go38
-rw-r--r--pkg/gui/gpg.go18
-rw-r--r--pkg/gui/gui.go241
-rw-r--r--pkg/gui/gui_common.go53
-rw-r--r--pkg/gui/information_panel.go10
-rw-r--r--pkg/gui/keybindings.go751
-rw-r--r--pkg/gui/layout.go37
-rw-r--r--pkg/gui/line_by_line_panel.go8
-rw-r--r--pkg/gui/list_context.go116
-rw-r--r--pkg/gui/list_context_config.go204
-rw-r--r--pkg/gui/main_panels.go2
-rw-r--r--pkg/gui/menu_panel.go25
-rw-r--r--pkg/gui/merge_panel.go47
-rw-r--r--pkg/gui/misc.go19
-rw-r--r--pkg/gui/modes.go16
-rw-r--r--pkg/gui/options_menu_panel.go4
-rw-r--r--pkg/gui/patch_building_panel.go24
-rw-r--r--pkg/gui/patch_options_panel.go72
-rw-r--r--pkg/gui/popup/popup_handler.go26
-rw-r--r--pkg/gui/pty.go4
-rw-r--r--pkg/gui/pull_request_menu_panel.go20
-rw-r--r--pkg/gui/quitting.go10
-rw-r--r--pkg/gui/rebase_options_panel.go46
-rw-r--r--pkg/gui/recent_repos_panel.go27
-rw-r--r--pkg/gui/ref_helper.go137
-rw-r--r--pkg/gui/reflog_panel.go31
-rw-r--r--pkg/gui/remote_branches_panel.go36
-rw-r--r--pkg/gui/remotes_panel.go136
-rw-r--r--pkg/gui/reset_menu_panel.go53
-rw-r--r--pkg/gui/searching.go4
-rw-r--r--pkg/gui/staging_panel.go30
-rw-r--r--pkg/gui/stash_panel.go76
-rw-r--r--pkg/gui/status_panel.go22
-rw-r--r--pkg/gui/style/style_test.go15
-rw-r--r--pkg/gui/sub_commits_panel.go31
-rw-r--r--pkg/gui/submodules_panel.go6
-rw-r--r--pkg/gui/suggestions_helper.go (renamed from pkg/gui/find_suggestions.go)90
-rw-r--r--pkg/gui/tags_panel.go106
-rw-r--r--pkg/gui/tasks_adapter.go8
-rw-r--r--pkg/gui/types/common_commands.go7
-rw-r--r--pkg/gui/types/context.go87
-rw-r--r--pkg/gui/types/keybindings.go9
-rw-r--r--pkg/gui/types/refresh.go1
-rw-r--r--pkg/gui/updates.go14
-rw-r--r--pkg/gui/view_helpers.go96
-rw-r--r--pkg/gui/whitespace-toggle.go6
-rw-r--r--pkg/gui/working_tree_helper.go50
-rw-r--r--pkg/gui/workspace_reset_options_panel.go62
89 files changed, 4822 insertions, 4008 deletions
diff --git a/pkg/gui/app_status_manager.go b/pkg/gui/app_status_manager.go
index 825bb8801..4c32f79b5 100644
--- a/pkg/gui/app_status_manager.go
+++ b/pkg/gui/app_status_manager.go
@@ -83,7 +83,7 @@ func (m *statusManager) getStatusString() string {
return topStatus.message
}
-func (gui *Gui) raiseToast(message string) {
+func (gui *Gui) toast(message string) {
gui.statusManager.addToastStatus(message)
gui.renderAppStatus()
@@ -119,7 +119,7 @@ func (gui *Gui) withWaitingStatus(message string, f func() error) error {
if err := f(); err != nil {
gui.OnUIThread(func() error {
- return gui.PopupHandler.Error(err)
+ return gui.c.Error(err)
})
}
})
diff --git a/pkg/gui/arrangement.go b/pkg/gui/arrangement.go
index fa2e7f29d..944391d75 100644
--- a/pkg/gui/arrangement.go
+++ b/pkg/gui/arrangement.go
@@ -2,6 +2,7 @@ package gui
import (
"github.com/jesseduffield/lazygit/pkg/gui/boxlayout"
+ "github.com/jesseduffield/lazygit/pkg/gui/types"
"github.com/jesseduffield/lazygit/pkg/utils"
)
@@ -44,7 +45,7 @@ func (gui *Gui) getMidSectionWeights() (int, int) {
currentWindow := gui.currentWindow()
// we originally specified this as a ratio i.e. .20 would correspond to a weight of 1 against 4
- sidePanelWidthRatio := gui.UserConfig.Gui.SidePanelWidth
+ sidePanelWidthRatio := gui.c.UserConfig.Gui.SidePanelWidth
// we could make this better by creating ratios like 2:3 rather than always 1:something
mainSectionWeight := int(1/sidePanelWidthRatio) - 1
sideSectionWeight := 1
@@ -115,7 +116,7 @@ func (gui *Gui) splitMainPanelSideBySide() bool {
return false
}
- mainPanelSplitMode := gui.UserConfig.Gui.MainPanelSplitMode
+ mainPanelSplitMode := gui.c.UserConfig.Gui.MainPanelSplitMode
width, height := gui.g.Size()
switch mainPanelSplitMode {
@@ -143,7 +144,7 @@ func (gui *Gui) getExtrasWindowSize(screenHeight int) int {
} else if screenHeight < 40 {
baseSize = 1
} else {
- baseSize = gui.UserConfig.Gui.CommandLogSize
+ baseSize = gui.c.UserConfig.Gui.CommandLogSize
}
frameSize := 2
@@ -259,7 +260,7 @@ func (gui *Gui) sidePanelChildren(width int, height int) []*boxlayout.Box {
fullHeightBox("stash"),
}
} else if height >= 28 {
- accordionMode := gui.UserConfig.Gui.ExpandFocusedSidePanel
+ accordionMode := gui.c.UserConfig.Gui.ExpandFocusedSidePanel
accordionBox := func(defaultBox *boxlayout.Box) *boxlayout.Box {
if accordionMode && defaultBox.Window == currentWindow {
return &boxlayout.Box{
@@ -320,7 +321,7 @@ func (gui *Gui) currentSideWindowName() string {
reversedIdx := len(gui.State.ContextManager.ContextStack) - 1 - idx
context := gui.State.ContextManager.ContextStack[reversedIdx]
- if context.GetKind() == SIDE_CONTEXT {
+ if context.GetKind() == types.SIDE_CONTEXT {
return context.GetWindowName()
}
}
diff --git a/pkg/gui/basic_context.go b/pkg/gui/basic_context.go
index 1db80ee4a..1043cca89 100644
--- a/pkg/gui/basic_context.go
+++ b/pkg/gui/basic_context.go
@@ -1,22 +1,28 @@
package gui
+import (
+ "github.com/jesseduffield/lazygit/pkg/gui/types"
+)
+
type BasicContext struct {
- OnFocus func(opts ...OnFocusOpts) error
+ OnFocus func(opts ...types.OnFocusOpts) error
OnFocusLost func() error
OnRender func() error
// this is for pushing some content to the main view
- OnRenderToMain func(opts ...OnFocusOpts) error
- Kind ContextKind
- Key ContextKey
+ OnRenderToMain func(opts ...types.OnFocusOpts) error
+ Kind types.ContextKind
+ Key types.ContextKey
ViewName string
WindowName string
OnGetOptionsMap func() map[string]string
- ParentContext Context
+ ParentContext types.Context
// we can't know on the calling end whether a Context is actually a nil value without reflection, so we're storing this flag here to tell us. There has got to be a better way around this
hasParent bool
}
+var _ types.Context = &BasicContext{}
+
func (self *BasicContext) GetOptionsMap() map[string]string {
if self.OnGetOptionsMap != nil {
return self.OnGetOptionsMap()
@@ -24,12 +30,12 @@ func (self *BasicContext) GetOptionsMap() map[string]string {
return nil
}
-func (self *BasicContext) SetParentContext(context Context) {
+func (self *BasicContext) SetParentContext(context types.Context) {
self.ParentContext = context
self.hasParent = true
}
-func (self *BasicContext) GetParentContext() (Context, bool) {
+func (self *BasicContext) GetParentContext() (types.Context, bool) {
return self.ParentContext, self.hasParent
}
@@ -59,7 +65,7 @@ func (self *BasicContext) GetViewName() string {
return self.ViewName
}
-func (self *BasicContext) HandleFocus(opts ...OnFocusOpts) error {
+func (self *BasicContext) HandleFocus(opts ...types.OnFocusOpts) error {
if self.OnFocus != nil {
if err := self.OnFocus(opts...); err != nil {
return err
@@ -90,10 +96,10 @@ func (self *BasicContext) HandleRenderToMain() error {
return nil
}
-func (self *BasicContext) GetKind() ContextKind {
+func (self *BasicContext) GetKind() types.ContextKind {
return self.Kind
}
-func (self *BasicContext) GetKey() ContextKey {
+func (self *BasicContext) GetKey() types.ContextKey {
return self.Key
}
diff --git a/pkg/gui/bisect.go b/pkg/gui/bisect.go
deleted file mode 100644
index 5c46460ac..000000000
--- a/pkg/gui/bisect.go
+++ /dev/null
@@ -1,219 +0,0 @@
-package gui
-
-import (
- "fmt"
- "strings"
-
- "github.com/jesseduffield/lazygit/pkg/commands/git_commands"
- "github.com/jesseduffield/lazygit/pkg/commands/models"
-)
-
-func (gui *Gui) handleOpenBisectMenu() error {
- if ok, err := gui.validateNotInFilterMode(); err != nil || !ok {
- return err
- }
-
- // no shame in getting this directly rather than using the cached value
- // given how cheap it is to obtain
- info := gui.Git.Bisect.GetInfo()
- commit := gui.getSelectedLocalCommit()
- if info.Started() {
- return gui.openMidBisectMenu(info, commit)
- } else {
- return gui.openStartBisectMenu(info, commit)
- }
-}
-
-func (gui *Gui) openMidBisectMenu(info *git_commands.BisectInfo, commit *models.Commit) error {
- // if there is not yet a 'current' bisect commit, or if we have
- // selected the current commit, we need to jump to the next 'current' commit
- // after we perform a bisect action. The reason we don't unconditionally jump
- // is that sometimes the user will want to go and mark a few commits as skipped
- // in a row and they wouldn't want to be jumped back to the current bisect
- // commit each time.
- // Originally we were allowing the user to, from the bisect menu, select whether
- // they were talking about the selected commit or the current bisect commit,
- // and that was a bit confusing (and required extra keypresses).
- selectCurrentAfter := info.GetCurrentSha() == "" || info.GetCurrentSha() == commit.Sha
- // we need to wait to reselect if our bisect commits aren't ancestors of our 'start'
- // ref, because we'll be reloading our commits in that case.
- waitToReselect := selectCurrentAfter && !gui.Git.Bisect.ReachableFromStart(info)
-
- menuItems := []*menuItem{
- {
- displayString: fmt.Sprintf(gui.Tr.Bisect.Mark, commit.ShortSha(), info.NewTerm()),
- onPress: func() error {
- gui.logAction(gui.Tr.Actions.BisectMark)
- if err := gui.Git.Bisect.Mark(commit.Sha, info.NewTerm()); err != nil {
- return gui.surfaceError(err)
- }
-
- return gui.afterMark(selectCurrentAfter, waitToReselect)
- },
- },
- {
- displayString: fmt.Sprintf(gui.Tr.Bisect.Mark, commit.ShortSha(), info.OldTerm()),
- onPress: func() error {
- gui.logAction(gui.Tr.Actions.BisectMark)
- if err := gui.Git.Bisect.Mark(commit.Sha, info.OldTerm()); err != nil {
- return gui.surfaceError(err)
- }
-
- return gui.afterMark(selectCurrentAfter, waitToReselect)
- },
- },
- {
- displayString: fmt.Sprintf(gui.Tr.Bisect.Skip, commit.ShortSha()),
- onPress: func() error {
- gui.logAction(gui.Tr.Actions.BisectSkip)
- if err := gui.Git.Bisect.Skip(commit.Sha); err != nil {
- return gui.surfaceError(err)
- }
-
- return gui.afterMark(selectCurrentAfter, waitToReselect)
- },
- },
- {
- displayString: gui.Tr.Bisect.ResetOption,
- onPress: func() error {
- return gui.resetBisect()
- },
- },
- }
-
- return gui.createMenu(
- gui.Tr.Bisect.BisectMenuTitle,
- menuItems,
- createMenuOptions{showCancel: true},
- )
-}
-
-func (gui *Gui) openStartBisectMenu(info *git_commands.BisectInfo, commit *models.Commit) error {
- return gui.createMenu(
- gui.Tr.Bisect.BisectMenuTitle,
- []*menuItem{
- {
- displayString: fmt.Sprintf(gui.Tr.Bisect.MarkStart, commit.ShortSha(), info.NewTerm()),
- onPress: func() error {
- gui.logAction(gui.Tr.Actions.StartBisect)
- if err := gui.Git.Bisect.Start(); err != nil {
- return gui.surfaceError(err)
- }
-
- if err := gui.Git.Bisect.Mark(commit.Sha, info.NewTerm()); err != nil {
- return gui.surfaceError(err)
- }
-
- return gui.postBisectCommandRefresh()
- },
- },
- {
- displayString: fmt.Sprintf(gui.Tr.Bisect.MarkStart, commit.ShortSha(), info.OldTerm()),
- onPress: func() error {
- gui.logAction(gui.Tr.Actions.StartBisect)
- if err := gui.Git.Bisect.Start(); err != nil {
- return gui.surfaceError(err)
- }
-