diff options
Diffstat (limited to 'pkg/gui')
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) |