Standardise on 'screen mode' name

We had some conflicting names so we're standardising on screen mode
This commit is contained in:
Jesse Duffield
2025-01-11 14:25:10 +11:00
parent 2c321011db
commit 28d10c26a4
9 changed files with 40 additions and 33 deletions

View File

@@ -217,16 +217,23 @@ func loadUserConfig(configFiles []*ConfigFile, base *UserConfig) (*UserConfig, e
// from one container to another, or changing the type of a key (e.g. from bool
// to an enum).
func migrateUserConfig(path string, content []byte) ([]byte, error) {
changedContent, err := yaml_utils.RenameYamlKey(content, []string{"gui", "skipUnstageLineWarning"},
"skipDiscardChangeWarning")
if err != nil {
return nil, fmt.Errorf("Couldn't migrate config file at `%s`: %s", path, err)
changedContent := content
pathsToReplace := []struct {
oldPath []string
newName string
}{
{[]string{"gui", "skipUnstageLineWarning"}, "skipDiscardChangeWarning"},
{[]string{"keybinding", "universal", "executeCustomCommand"}, "executeShellCommand"},
{[]string{"gui", "windowSize"}, "screenMode"},
}
changedContent, err = yaml_utils.RenameYamlKey(changedContent, []string{"keybinding", "universal", "executeCustomCommand"},
"executeShellCommand")
if err != nil {
return nil, fmt.Errorf("Couldn't migrate config file at `%s`: %s", path, err)
var err error
for _, pathToReplace := range pathsToReplace {
changedContent, err = yaml_utils.RenameYamlKey(changedContent, pathToReplace.oldPath, pathToReplace.newName)
if err != nil {
return nil, fmt.Errorf("Couldn't migrate config file at `%s` for key %s: %s", path, strings.Join(pathToReplace.oldPath, "."), err)
}
}
changedContent, err = changeNullKeybindingsToDisabled(changedContent)

View File

@@ -148,9 +148,9 @@ type GuiConfig struct {
// One of: 'auto' | 'always'
// If 'auto', only split the main window when a file has both staged and unstaged changes
SplitDiff string `yaml:"splitDiff" jsonschema:"enum=auto,enum=always"`
// Default size for focused window. Window size can be changed from within Lazygit with '+' and '_' (but this won't change the default).
// Default size for focused window. Can be changed from within Lazygit with '+' and '_' (but this won't change the default).
// One of: 'normal' (default) | 'half' | 'full'
WindowSize string `yaml:"windowSize" jsonschema:"enum=normal,enum=half,enum=full"`
ScreenMode string `yaml:"screenMode" jsonschema:"enum=normal,enum=half,enum=full"`
// Window border style.
// One of 'rounded' (default) | 'single' | 'double' | 'hidden'
Border string `yaml:"border" jsonschema:"enum=single,enum=double,enum=rounded,enum=hidden"`
@@ -734,7 +734,7 @@ func GetDefaultConfig() *UserConfig {
CommandLogSize: 8,
SplitDiff: "auto",
SkipRewordInEditorWarning: false,
WindowSize: "normal",
ScreenMode: "normal",
Border: "rounded",
AnimateExplosion: true,
PortraitMode: "auto",

View File

@@ -53,7 +53,7 @@ type WindowArrangementArgs struct {
// staged and unstaged changes)
SplitMainPanel bool
// The current screen mode (normal, half, full)
ScreenMode types.WindowMaximisation
ScreenMode types.ScreenMode
// The content shown on the bottom left of the screen when showing a loader
// or toast e.g. 'Rebasing /'
AppStatus string

View File

@@ -12,7 +12,7 @@ type ScreenModeActions struct {
func (self *ScreenModeActions) Next() error {
self.c.State().GetRepoState().SetScreenMode(
nextIntInCycle(
[]types.WindowMaximisation{types.SCREEN_NORMAL, types.SCREEN_HALF, types.SCREEN_FULL},
[]types.ScreenMode{types.SCREEN_NORMAL, types.SCREEN_HALF, types.SCREEN_FULL},
self.c.State().GetRepoState().GetScreenMode(),
),
)
@@ -24,7 +24,7 @@ func (self *ScreenModeActions) Next() error {
func (self *ScreenModeActions) Prev() error {
self.c.State().GetRepoState().SetScreenMode(
prevIntInCycle(
[]types.WindowMaximisation{types.SCREEN_NORMAL, types.SCREEN_HALF, types.SCREEN_FULL},
[]types.ScreenMode{types.SCREEN_NORMAL, types.SCREEN_HALF, types.SCREEN_FULL},
self.c.State().GetRepoState().GetScreenMode(),
),
)
@@ -53,7 +53,7 @@ func (self *ScreenModeActions) rerenderView(view *gocui.View) {
context.HandleRender()
}
func nextIntInCycle(sl []types.WindowMaximisation, current types.WindowMaximisation) types.WindowMaximisation {
func nextIntInCycle(sl []types.ScreenMode, current types.ScreenMode) types.ScreenMode {
for i, val := range sl {
if val == current {
if i == len(sl)-1 {
@@ -65,7 +65,7 @@ func nextIntInCycle(sl []types.WindowMaximisation, current types.WindowMaximisat
return sl[0]
}
func prevIntInCycle(sl []types.WindowMaximisation, current types.WindowMaximisation) types.WindowMaximisation {
func prevIntInCycle(sl []types.ScreenMode, current types.ScreenMode) types.ScreenMode {
for i, val := range sl {
if val == current {
if i > 0 {

View File

@@ -244,7 +244,7 @@ type GuiRepoState struct {
// back in sync with the repo state
ViewsSetup bool
ScreenMode types.WindowMaximisation
ScreenMode types.ScreenMode
CurrentPopupOpts *types.CreatePopupPanelOpts
}
@@ -275,11 +275,11 @@ func (self *GuiRepoState) SetCurrentPopupOpts(value *types.CreatePopupPanelOpts)
self.CurrentPopupOpts = value
}
func (self *GuiRepoState) GetScreenMode() types.WindowMaximisation {
func (self *GuiRepoState) GetScreenMode() types.ScreenMode {
return self.ScreenMode
}
func (self *GuiRepoState) SetScreenMode(value types.WindowMaximisation) {
func (self *GuiRepoState) SetScreenMode(value types.ScreenMode) {
self.ScreenMode = value
}
@@ -580,18 +580,18 @@ func initialWindowViewNameMap(contextTree *context.ContextTree) *utils.ThreadSaf
return result
}
func initialScreenMode(startArgs appTypes.StartArgs, config config.AppConfigurer) types.WindowMaximisation {
func initialScreenMode(startArgs appTypes.StartArgs, config config.AppConfigurer) types.ScreenMode {
if startArgs.ScreenMode != "" {
return getWindowMaximisation(startArgs.ScreenMode)
return parseScreenModeArg(startArgs.ScreenMode)
} else if startArgs.FilterPath != "" || startArgs.GitArg != appTypes.GitArgNone {
return types.SCREEN_HALF
} else {
return getWindowMaximisation(config.GetUserConfig().Gui.WindowSize)
return parseScreenModeArg(config.GetUserConfig().Gui.ScreenMode)
}
}
func getWindowMaximisation(modeString string) types.WindowMaximisation {
switch modeString {
func parseScreenModeArg(screenModeArg string) types.ScreenMode {
switch screenModeArg {
case "half":
return types.SCREEN_HALF
case "full":

View File

@@ -362,8 +362,8 @@ type IRepoStateAccessor interface {
SetStartupStage(stage StartupStage)
GetCurrentPopupOpts() *CreatePopupPanelOpts
SetCurrentPopupOpts(*CreatePopupPanelOpts)
GetScreenMode() WindowMaximisation
SetScreenMode(WindowMaximisation)
GetScreenMode() ScreenMode
SetScreenMode(ScreenMode)
InSearchPrompt() bool
GetSearchState() *SearchState
SetSplitMainPanel(bool)
@@ -382,10 +382,10 @@ const (
// 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
type ScreenMode int
const (
SCREEN_NORMAL WindowMaximisation = iota
SCREEN_NORMAL ScreenMode = iota
SCREEN_HALF
SCREEN_FULL
)