summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pkg/gui/arrangement.go10
-rw-r--r--pkg/gui/context/branches_context.go16
-rw-r--r--pkg/gui/filtering.go8
-rw-r--r--pkg/gui/global_handlers.go8
-rw-r--r--pkg/gui/gui.go28
-rw-r--r--pkg/gui/list_context_config.go15
-rw-r--r--pkg/gui/types/common.go13
7 files changed, 52 insertions, 46 deletions
diff --git a/pkg/gui/arrangement.go b/pkg/gui/arrangement.go
index d656f16d5..5177d4683 100644
--- a/pkg/gui/arrangement.go
+++ b/pkg/gui/arrangement.go
@@ -100,7 +100,7 @@ func (self *WindowArranger) mainSectionChildren() []*boxlayout.Box {
// if we're not in split mode we can just show the one main panel. Likewise if
// the main panel is focused and we're in full-screen mode
- if !self.gui.isMainPanelSplit() || (self.gui.State.ScreenMode == SCREEN_FULL && currentWindow == "main") {
+ if !self.gui.isMainPanelSplit() || (self.gui.State.ScreenMode == types.SCREEN_FULL && currentWindow == "main") {
return []*boxlayout.Box{
{
Window: "main",
@@ -135,13 +135,13 @@ func (self *WindowArranger) getMidSectionWeights() (int, int) {
}
if currentWindow == "main" {
- if self.gui.State.ScreenMode == SCREEN_HALF || self.gui.State.ScreenMode == SCREEN_FULL {
+ if self.gui.State.ScreenMode == types.SCREEN_HALF || self.gui.State.ScreenMode == types.SCREEN_FULL {
sideSectionWeight = 0
}
} else {
- if self.gui.State.ScreenMode == SCREEN_HALF {
+ if self.gui.State.ScreenMode == types.SCREEN_HALF {
mainSectionWeight = 1
- } else if self.gui.State.ScreenMode == SCREEN_FULL {
+ } else if self.gui.State.ScreenMode == types.SCREEN_FULL {
mainSectionWeight = 0
}
}
@@ -255,7 +255,7 @@ func (self *WindowArranger) getDefaultStashWindowBox() *boxlayout.Box {
func (self *WindowArranger) sidePanelChildren(width int, height int) []*boxlayout.Box {
currentWindow := self.currentSideWindowName()
- if self.gui.State.ScreenMode == SCREEN_FULL || self.gui.State.ScreenMode == SCREEN_HALF {
+ if self.gui.State.ScreenMode == types.SCREEN_FULL || self.gui.State.ScreenMode == types.SCREEN_HALF {
fullHeightBox := func(window string) *boxlayout.Box {
if window == currentWindow {
return &boxlayout.Box{
diff --git a/pkg/gui/context/branches_context.go b/pkg/gui/context/branches_context.go
index 6b624ca57..81b289cec 100644
--- a/pkg/gui/context/branches_context.go
+++ b/pkg/gui/context/branches_context.go
@@ -2,6 +2,7 @@ package context
import (
"github.com/jesseduffield/lazygit/pkg/commands/models"
+ "github.com/jesseduffield/lazygit/pkg/gui/presentation"
"github.com/jesseduffield/lazygit/pkg/gui/types"
)
@@ -15,13 +16,18 @@ var (
_ types.DiffableContext = (*BranchesContext)(nil)
)
-func NewBranchesContext(
- getDisplayStrings func(startIdx int, length int) [][]string,
-
- c *types.HelperCommon,
-) *BranchesContext {
+func NewBranchesContext(c *types.HelperCommon) *BranchesContext {
viewModel := NewBasicViewModel(func() []*models.Branch { return c.Model().Branches })
+ getDisplayStrings := func(startIdx int, length int) [][]string {
+ return presentation.GetBranchListDisplayStrings(
+ c.Model().Branches,
+ c.State().GetRepoState().GetScreenMode() != types.SCREEN_NORMAL,
+ c.Modes().Diffing.Ref,
+ c.Tr,
+ )
+ }
+
self := &BranchesContext{
BasicViewModel: viewModel,
ListContextTrait: &ListContextTrait{
diff --git a/pkg/gui/filtering.go b/pkg/gui/filtering.go
index 6d8279992..99aa6638e 100644
--- a/pkg/gui/filtering.go
+++ b/pkg/gui/filtering.go
@@ -23,8 +23,8 @@ func (gui *Gui) exitFilterMode() error {
func (gui *Gui) clearFiltering() error {
gui.State.Modes.Filtering.Reset()
- if gui.State.ScreenMode == SCREEN_HALF {
- gui.State.ScreenMode = SCREEN_NORMAL
+ if gui.State.ScreenMode == types.SCREEN_HALF {
+ gui.State.ScreenMode = types.SCREEN_NORMAL
}
return gui.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.COMMITS}})
@@ -32,8 +32,8 @@ func (gui *Gui) clearFiltering() error {
func (gui *Gui) setFiltering(path string) error {
gui.State.Modes.Filtering.SetPath(path)
- if gui.State.ScreenMode == SCREEN_NORMAL {
- gui.State.ScreenMode = SCREEN_HALF
+ if gui.State.ScreenMode == types.SCREEN_NORMAL {
+ gui.State.ScreenMode = types.SCREEN_HALF
}
if err := gui.c.PushContext(gui.State.Contexts.LocalCommits); err != nil {
diff --git a/pkg/gui/global_handlers.go b/pkg/gui/global_handlers.go
index f2c762cc6..0bf705ba8 100644
--- a/pkg/gui/global_handlers.go
+++ b/pkg/gui/global_handlers.go
@@ -24,7 +24,7 @@ func (gui *Gui) rerenderViewsWithScreenModeDependentContent() error {
return nil
}
-func nextIntInCycle(sl []WindowMaximisation, current WindowMaximisation) WindowMaximisation {
+func nextIntInCycle(sl []types.WindowMaximisation, current types.WindowMaximisation) types.WindowMaximisation {
for i, val := range sl {
if val == current {
if i == len(sl)-1 {
@@ -36,7 +36,7 @@ func nextIntInCycle(sl []WindowMaximisation, current WindowMaximisation) WindowM
return sl[0]
}
-func prevIntInCycle(sl []WindowMaximisation, current WindowMaximisation) WindowMaximisation {
+func prevIntInCycle(sl []types.WindowMaximisation, current types.WindowMaximisation) types.WindowMaximisation {
for i, val := range sl {
if val == current {
if i > 0 {
@@ -49,13 +49,13 @@ func prevIntInCycle(sl []WindowMaximisation, current WindowMaximisation) WindowM
}
func (gui *Gui) nextScreenMode() error {
- gui.State.ScreenMode = nextIntInCycle([]WindowMaximisation{SCREEN_NORMAL, SCREEN_HALF, SCREEN_FULL}, gui.State.ScreenMode)
+ gui.State.ScreenMode = nextIntInCycle([]types.WindowMaximisation{types.SCREEN_NORMAL, types.SCREEN_HALF, types.SCREEN_FULL}, gui.State.ScreenMode)
return gui.rerenderViewsWithScreenModeDependentContent()
}
func (gui *Gui) prevScreenMode() error {
- gui.State.ScreenMode = prevIntInCycle([]WindowMaximisation{SCREEN_NORMAL, SCREEN_HALF, SCREEN_FULL}, gui.State.ScreenMode)
+ gui.State.ScreenMode = prevIntInCycle([]types.WindowMaximisation{types.SCREEN_NORMAL, types.SCREEN_HALF, types.SCREEN_FULL}, gui.State.ScreenMode)
return gui.rerenderViewsWithScreenModeDependentContent()
}
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go
index 4b6a0fb8a..1b2918759 100644
--- a/pkg/gui/gui.go
+++ b/pkg/gui/gui.go
@@ -42,18 +42,6 @@ import (
"gopkg.in/ozeidan/fuzzy-patricia.v3/patricia"
)
-// screen sizing determines how much space your selected window takes up (window
-// as in panel, not your terminal's window). Sometimes you want a bit more space
-// to see the contents of a panel, and this keeps track of how much maximisation
-// you've set
-type WindowMaximisation int
-
-const (
- SCREEN_NORMAL WindowMaximisation = iota
- SCREEN_HALF
- SCREEN_FULL
-)
-
const StartupPopupVersion = 5
// OverlappingEdges determines if panel edges overlap
@@ -216,7 +204,7 @@ type GuiRepoState struct {
// panel without committing or if our commit failed
savedCommitMessage string
- ScreenMode WindowMaximisation
+ ScreenMode types.WindowMaximisation
CurrentPopupOpts *types.CreatePopupPanelOpts
}
@@ -247,6 +235,10 @@ func (self *GuiRepoState) SetCurrentPopupOpts(value *types.CreatePopupPanelOpts)
self.CurrentPopupOpts = value
}
+func (self *GuiRepoState) GetScreenMode() types.WindowMaximisation {
+ return self.ScreenMode
+}
+
type searchingState struct {
view *gocui.View
isSearching bool
@@ -353,19 +345,19 @@ func initialWindowViewNameMap(contextTree *context.ContextTree) *utils.ThreadSaf
return result
}
-func initialScreenMode(startArgs appTypes.StartArgs, config config.AppConfigurer) WindowMaximisation {
+func initialScreenMode(startArgs appTypes.StartArgs, config config.AppConfigurer) types.WindowMaximisation {
if startArgs.FilterPath != "" || startArgs.GitArg != appTypes.GitArgNone {
- return SCREEN_HALF
+ return types.SCREEN_HALF
} else {
defaultWindowSize := config.GetUserConfig().Gui.WindowSize
switch defaultWindowSize {
case "half":
- return SCREEN_HALF
+ return types.SCREEN_HALF
case "full":
- return SCREEN_FULL
+ return types.SCREEN_FULL
default:
- return SCREEN_NORMAL
+ return types.SCREEN_NORMAL
}
}
}
diff --git a/pkg/gui/list_context_config.go b/pkg/gui/list_context_config.go
index 4a05a1cd4..d5d7bea35 100644
--- a/pkg/gui/list_context_config.go
+++ b/pkg/gui/list_context_config.go
@@ -21,12 +21,7 @@ func (gui *Gui) filesListContext() *context.WorkingTreeContext {
}
func (gui *Gui) branchesListContext() *context.BranchesContext {
- return context.NewBranchesContext(
- func(startIdx int, length int) [][]string {
- return presentation.GetBranchListDisplayStrings(gui.State.Model.Branches, gui.State.ScreenMode != SCREEN_NORMAL, gui.State.Modes.Diffing.Ref, gui.Tr)
- },
- gui.c,
- )
+ return context.NewBranchesContext(gui.c)
}
func (gui *Gui) remotesListContext() *context.RemotesContext {
@@ -82,7 +77,7 @@ func (gui *Gui) branchCommitsListContext() *context.LocalCommitsContext {
return presentation.GetCommitListDisplayStrings(
gui.Common,
gui.State.Model.Commits,
- gui.State.ScreenMode != SCREEN_NORMAL,
+ gui.State.ScreenMode != types.SCREEN_NORMAL,
gui.helpers.CherryPick.CherryPickedCommitShaSet(),
gui.State.Modes.Diffing.Ref,
gui.c.UserConfig.Gui.TimeFormat,
@@ -112,7 +107,7 @@ func (gui *Gui) subCommitsListContext() *context.SubCommitsContext {
return presentation.GetCommitListDisplayStrings(
gui.Common,
gui.State.Model.SubCommits,
- gui.State.ScreenMode != SCREEN_NORMAL,
+ gui.State.ScreenMode != types.SCREEN_NORMAL,
gui.helpers.CherryPick.CherryPickedCommitShaSet(),
gui.State.Modes.Diffing.Ref,
gui.c.UserConfig.Gui.TimeFormat,
@@ -141,7 +136,7 @@ func (gui *Gui) shouldShowGraph() bool {
case "never":
return false
case "when-maximised":
- return gui.State.ScreenMode != SCREEN_NORMAL
+ return gui.State.ScreenMode != types.SCREEN_NORMAL
}
log.Fatalf("Unknown value for git.log.showGraph: %s. Expected one of: 'always', 'never', 'when-maximised'", value)
@@ -153,7 +148,7 @@ func (gui *Gui) reflogCommitsListContext() *context.ReflogCommitsContext {
func(startIdx int, length int) [][]string {
return presentation.GetReflogCommitListDisplayStrings(
gui.State.Model.FilteredReflogCommits,
- gui.State.ScreenMode != SCREEN_NORMAL,
+ gui.State.ScreenMode != types.SCREEN_NORMAL,
gui.helpers.CherryPick.CherryPickedCommitShaSet(),
gui.State.Modes.Diffing.Ref,
gui.c.UserConfig.Gui.TimeFormat,
diff --git a/pkg/gui/types/common.go b/pkg/gui/types/common.go
index c8be0692e..e1d73bef7 100644
--- a/pkg/gui/types/common.go
+++ b/pkg/gui/types/common.go
@@ -225,6 +225,7 @@ type IRepoStateAccessor interface {
SetStartupStage(stage StartupStage)
GetCurrentPopupOpts() *CreatePopupPanelOpts
SetCurrentPopupOpts(*CreatePopupPanelOpts)
+ GetScreenMode() WindowMaximisation
}
// startup stages so we don't need to load everything at once
@@ -238,3 +239,15 @@ const (
type IFileWatcher interface {
AddFilesToFileWatcher(files []*models.File) error
}
+
+// screen sizing determines how much space your selected window takes up (window
+// as in panel, not your terminal's window). Sometimes you want a bit more space
+// to see the contents of a panel, and this keeps track of how much maximisation
+// you've set
+type WindowMaximisation int
+
+const (
+ SCREEN_NORMAL WindowMaximisation = iota
+ SCREEN_HALF
+ SCREEN_FULL
+)