Skip to content

Commit 91cb1ff

Browse files
Standardise on 'screen mode' naming convention (#4142)
We had some conflicting names: screen-mode, window-size, and window-maximisation. I think panel-size sounds good. - **PR Description** - **Please check if the PR fulfills these requirements** * [x] Cheatsheets are up-to-date (run `go generate ./...`) * [x] Code has been formatted (see [here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#code-formatting)) * [x] Tests have been added/updated (see [here](https://github.com/jesseduffield/lazygit/blob/master/pkg/integration/README.md) for the integration test guide) * [x] Text is internationalised (see [here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#internationalisation)) * [ ] If a new UserConfig entry was added, make sure it can be hot-reloaded (see [here](https://github.com/jesseduffield/lazygit/blob/master/docs/dev/Codebase_Guide.md#using-userconfig)) * [x] Docs have been updated if necessary * [x] You've read through your own file changes for silly mistakes etc <!-- Be sure to name your PR with an imperative e.g. 'Add worktrees view' see https://github.com/jesseduffield/lazygit/releases/tag/v0.40.0 for examples -->
2 parents 2c32101 + 28d10c2 commit 91cb1ff

File tree

9 files changed

+40
-33
lines changed

9 files changed

+40
-33
lines changed

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ Undo uses the reflog which is specific to commits and branches so we can't undo
200200

201201
### Commit graph
202202

203-
When viewing the commit graph in an enlarged window (use `+` and `_` to cycle window sizes), the commit graph is shown. Colours correspond to the commit authors, and as you navigate down the graph, the parent commits of the selected commit are highlighted.
203+
When viewing the commit graph in an enlarged window (use `+` and `_` to cycle screen modes), the commit graph is shown. Colours correspond to the commit authors, and as you navigate down the graph, the parent commits of the selected commit are highlighted.
204204

205205
![commit_graph](../assets/demo/commit_graph-compressed.gif)
206206

Diff for: docs/Config.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,9 @@ gui:
219219
# If 'auto', only split the main window when a file has both staged and unstaged changes
220220
splitDiff: auto
221221

222-
# Default size for focused window. Window size can be changed from within Lazygit with '+' and '_' (but this won't change the default).
222+
# Default size for focused window. Can be changed from within Lazygit with '+' and '_' (but this won't change the default).
223223
# One of: 'normal' (default) | 'half' | 'full'
224-
windowSize: normal
224+
screenMode: normal
225225

226226
# Window border style.
227227
# One of 'rounded' (default) | 'single' | 'double' | 'hidden'

Diff for: pkg/config/app_config.go

+15-8
Original file line numberDiff line numberDiff line change
@@ -217,16 +217,23 @@ func loadUserConfig(configFiles []*ConfigFile, base *UserConfig) (*UserConfig, e
217217
// from one container to another, or changing the type of a key (e.g. from bool
218218
// to an enum).
219219
func migrateUserConfig(path string, content []byte) ([]byte, error) {
220-
changedContent, err := yaml_utils.RenameYamlKey(content, []string{"gui", "skipUnstageLineWarning"},
221-
"skipDiscardChangeWarning")
222-
if err != nil {
223-
return nil, fmt.Errorf("Couldn't migrate config file at `%s`: %s", path, err)
220+
changedContent := content
221+
222+
pathsToReplace := []struct {
223+
oldPath []string
224+
newName string
225+
}{
226+
{[]string{"gui", "skipUnstageLineWarning"}, "skipDiscardChangeWarning"},
227+
{[]string{"keybinding", "universal", "executeCustomCommand"}, "executeShellCommand"},
228+
{[]string{"gui", "windowSize"}, "screenMode"},
224229
}
225230

226-
changedContent, err = yaml_utils.RenameYamlKey(changedContent, []string{"keybinding", "universal", "executeCustomCommand"},
227-
"executeShellCommand")
228-
if err != nil {
229-
return nil, fmt.Errorf("Couldn't migrate config file at `%s`: %s", path, err)
231+
var err error
232+
for _, pathToReplace := range pathsToReplace {
233+
changedContent, err = yaml_utils.RenameYamlKey(changedContent, pathToReplace.oldPath, pathToReplace.newName)
234+
if err != nil {
235+
return nil, fmt.Errorf("Couldn't migrate config file at `%s` for key %s: %s", path, strings.Join(pathToReplace.oldPath, "."), err)
236+
}
230237
}
231238

232239
changedContent, err = changeNullKeybindingsToDisabled(changedContent)

Diff for: pkg/config/user_config.go

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

Diff for: pkg/gui/controllers/helpers/window_arrangement_helper.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ type WindowArrangementArgs struct {
5353
// staged and unstaged changes)
5454
SplitMainPanel bool
5555
// The current screen mode (normal, half, full)
56-
ScreenMode types.WindowMaximisation
56+
ScreenMode types.ScreenMode
5757
// The content shown on the bottom left of the screen when showing a loader
5858
// or toast e.g. 'Rebasing /'
5959
AppStatus string

Diff for: pkg/gui/controllers/screen_mode_actions.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ type ScreenModeActions struct {
1212
func (self *ScreenModeActions) Next() error {
1313
self.c.State().GetRepoState().SetScreenMode(
1414
nextIntInCycle(
15-
[]types.WindowMaximisation{types.SCREEN_NORMAL, types.SCREEN_HALF, types.SCREEN_FULL},
15+
[]types.ScreenMode{types.SCREEN_NORMAL, types.SCREEN_HALF, types.SCREEN_FULL},
1616
self.c.State().GetRepoState().GetScreenMode(),
1717
),
1818
)
@@ -24,7 +24,7 @@ func (self *ScreenModeActions) Next() error {
2424
func (self *ScreenModeActions) Prev() error {
2525
self.c.State().GetRepoState().SetScreenMode(
2626
prevIntInCycle(
27-
[]types.WindowMaximisation{types.SCREEN_NORMAL, types.SCREEN_HALF, types.SCREEN_FULL},
27+
[]types.ScreenMode{types.SCREEN_NORMAL, types.SCREEN_HALF, types.SCREEN_FULL},
2828
self.c.State().GetRepoState().GetScreenMode(),
2929
),
3030
)
@@ -53,7 +53,7 @@ func (self *ScreenModeActions) rerenderView(view *gocui.View) {
5353
context.HandleRender()
5454
}
5555

56-
func nextIntInCycle(sl []types.WindowMaximisation, current types.WindowMaximisation) types.WindowMaximisation {
56+
func nextIntInCycle(sl []types.ScreenMode, current types.ScreenMode) types.ScreenMode {
5757
for i, val := range sl {
5858
if val == current {
5959
if i == len(sl)-1 {
@@ -65,7 +65,7 @@ func nextIntInCycle(sl []types.WindowMaximisation, current types.WindowMaximisat
6565
return sl[0]
6666
}
6767

68-
func prevIntInCycle(sl []types.WindowMaximisation, current types.WindowMaximisation) types.WindowMaximisation {
68+
func prevIntInCycle(sl []types.ScreenMode, current types.ScreenMode) types.ScreenMode {
6969
for i, val := range sl {
7070
if val == current {
7171
if i > 0 {

Diff for: pkg/gui/gui.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ type GuiRepoState struct {
244244
// back in sync with the repo state
245245
ViewsSetup bool
246246

247-
ScreenMode types.WindowMaximisation
247+
ScreenMode types.ScreenMode
248248

249249
CurrentPopupOpts *types.CreatePopupPanelOpts
250250
}
@@ -275,11 +275,11 @@ func (self *GuiRepoState) SetCurrentPopupOpts(value *types.CreatePopupPanelOpts)
275275
self.CurrentPopupOpts = value
276276
}
277277

278-
func (self *GuiRepoState) GetScreenMode() types.WindowMaximisation {
278+
func (self *GuiRepoState) GetScreenMode() types.ScreenMode {
279279
return self.ScreenMode
280280
}
281281

282-
func (self *GuiRepoState) SetScreenMode(value types.WindowMaximisation) {
282+
func (self *GuiRepoState) SetScreenMode(value types.ScreenMode) {
283283
self.ScreenMode = value
284284
}
285285

@@ -580,18 +580,18 @@ func initialWindowViewNameMap(contextTree *context.ContextTree) *utils.ThreadSaf
580580
return result
581581
}
582582

583-
func initialScreenMode(startArgs appTypes.StartArgs, config config.AppConfigurer) types.WindowMaximisation {
583+
func initialScreenMode(startArgs appTypes.StartArgs, config config.AppConfigurer) types.ScreenMode {
584584
if startArgs.ScreenMode != "" {
585-
return getWindowMaximisation(startArgs.ScreenMode)
585+
return parseScreenModeArg(startArgs.ScreenMode)
586586
} else if startArgs.FilterPath != "" || startArgs.GitArg != appTypes.GitArgNone {
587587
return types.SCREEN_HALF
588588
} else {
589-
return getWindowMaximisation(config.GetUserConfig().Gui.WindowSize)
589+
return parseScreenModeArg(config.GetUserConfig().Gui.ScreenMode)
590590
}
591591
}
592592

593-
func getWindowMaximisation(modeString string) types.WindowMaximisation {
594-
switch modeString {
593+
func parseScreenModeArg(screenModeArg string) types.ScreenMode {
594+
switch screenModeArg {
595595
case "half":
596596
return types.SCREEN_HALF
597597
case "full":

Diff for: pkg/gui/types/common.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,8 @@ type IRepoStateAccessor interface {
362362
SetStartupStage(stage StartupStage)
363363
GetCurrentPopupOpts() *CreatePopupPanelOpts
364364
SetCurrentPopupOpts(*CreatePopupPanelOpts)
365-
GetScreenMode() WindowMaximisation
366-
SetScreenMode(WindowMaximisation)
365+
GetScreenMode() ScreenMode
366+
SetScreenMode(ScreenMode)
367367
InSearchPrompt() bool
368368
GetSearchState() *SearchState
369369
SetSplitMainPanel(bool)
@@ -382,10 +382,10 @@ const (
382382
// as in panel, not your terminal's window). Sometimes you want a bit more space
383383
// to see the contents of a panel, and this keeps track of how much maximisation
384384
// you've set
385-
type WindowMaximisation int
385+
type ScreenMode int
386386

387387
const (
388-
SCREEN_NORMAL WindowMaximisation = iota
388+
SCREEN_NORMAL ScreenMode = iota
389389
SCREEN_HALF
390390
SCREEN_FULL
391391
)

Diff for: schema/config.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -388,14 +388,14 @@
388388
"description": "Whether to split the main window when viewing file changes.\nOne of: 'auto' | 'always'\nIf 'auto', only split the main window when a file has both staged and unstaged changes",
389389
"default": "auto"
390390
},
391-
"windowSize": {
391+
"screenMode": {
392392
"type": "string",
393393
"enum": [
394394
"normal",
395395
"half",
396396
"full"
397397
],
398-
"description": "Default size for focused window. Window size can be changed from within Lazygit with '+' and '_' (but this won't change the default).\nOne of: 'normal' (default) | 'half' | 'full'",
398+
"description": "Default size for focused window. Can be changed from within Lazygit with '+' and '_' (but this won't change the default).\nOne of: 'normal' (default) | 'half' | 'full'",
399399
"default": "normal"
400400
},
401401
"border": {

0 commit comments

Comments
 (0)