Skip to content

Commit

Permalink
Standardise panel size naming
Browse files Browse the repository at this point in the history
We had some conflicting names: screen-mode, window-size, and
window-maximisation. I think panel-size sounds good.
  • Loading branch information
jesseduffield committed Jan 7, 2025
1 parent 2d193cb commit 0d45df0
Show file tree
Hide file tree
Showing 38 changed files with 221 additions and 215 deletions.
8 changes: 4 additions & 4 deletions docs/Config.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ gui:
# - 'flexible': (default) split the window horizontally if the window is wide enough, otherwise split vertically
mainPanelSplitMode: flexible

# How the window is split when in half screen mode (i.e. after hitting '+' once).
# How the window is split when in half panel-size mode (i.e. after hitting '+' once).
# Possible values:
# - 'left': split the window horizontally (side panel on the left, main view on the right)
# - 'top': split the window vertically (side panel on top, main view below)
Expand Down Expand Up @@ -221,7 +221,7 @@ gui:

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

# Window border style.
# One of 'rounded' (default) | 'single' | 'double' | 'hidden'
Expand Down Expand Up @@ -532,8 +532,8 @@ keybinding:
createPatchOptionsMenu: <c-p>
nextTab: ']'
prevTab: '['
nextScreenMode: +
prevScreenMode: _
nextPanelSize: +
prevPanelSize: _
undo: z
redo: <c-z>
filteringMenu: <c-s>
Expand Down
4 changes: 2 additions & 2 deletions docs/keybindings/Keybindings_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ _Legend: `<c-b>` means ctrl+b, `<a-b>` means alt+b, `B` means shift+b_
| `` <c-p> `` | View custom patch options | |
| `` m `` | View merge/rebase options | View options to abort/continue/skip the current merge/rebase. |
| `` R `` | Refresh | Refresh the git state (i.e. run `git status`, `git branch`, etc in background to update the contents of panels). This does not run `git fetch`. |
| `` + `` | Next screen mode (normal/half/fullscreen) | |
| `` _ `` | Prev screen mode | |
| `` + `` | Next panel size (normal/half/fullscreen) | |
| `` _ `` | Prev panel size | |
| `` ? `` | Open keybindings menu | |
| `` <c-s> `` | View filter options | View options for filtering the commit log, so that only commits matching the filter are shown. |
| `` W `` | View diffing options | View options relating to diffing two refs e.g. diffing against selected ref, entering ref to diff against, and reversing the diff direction. |
Expand Down
10 changes: 5 additions & 5 deletions pkg/app/entry_point.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type cliArgs struct {
WorkTree string
GitDir string
CustomConfigFile string
ScreenMode string
PanelSize string
PrintVersionInfo bool
Debug bool
TailLogs bool
Expand Down Expand Up @@ -165,7 +165,7 @@ func Start(buildInfo *BuildInfo, integrationTest integrationTypes.IntegrationTes

parsedGitArg := parseGitArg(cliArgs.GitArg)

Run(appConfig, common, appTypes.NewStartArgs(cliArgs.FilterPath, parsedGitArg, cliArgs.ScreenMode, integrationTest))
Run(appConfig, common, appTypes.NewStartArgs(cliArgs.FilterPath, parsedGitArg, cliArgs.PanelSize, integrationTest))
}

func parseCliArgsAndEnvVars() *cliArgs {
Expand Down Expand Up @@ -210,8 +210,8 @@ func parseCliArgsAndEnvVars() *cliArgs {
customConfigFile := ""
flaggy.String(&customConfigFile, "ucf", "use-config-file", "Comma separated list to custom config file(s)")

screenMode := ""
flaggy.String(&screenMode, "sm", "screen-mode", "The initial screen-mode, which determines the size of the focused panel. Valid options: 'normal' (default), 'half', 'full'")
PanelSize := ""
flaggy.String(&PanelSize, "ps", "panel-size", "The initial size of the focused panel. Valid options: 'normal' (default), 'half', 'full'")

flaggy.Parse()

Expand All @@ -233,7 +233,7 @@ func parseCliArgsAndEnvVars() *cliArgs {
WorkTree: workTree,
GitDir: gitDir,
CustomConfigFile: customConfigFile,
ScreenMode: screenMode,
PanelSize: PanelSize,
}
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/app/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ type StartArgs struct {
IntegrationTest integrationTypes.IntegrationTest
// FilterPath determines which path we're going to filter on so that we only see commits from that file.
FilterPath string
// ScreenMode determines the initial Screen Mode (normal, half or full) to use
ScreenMode string
// PanelSize determines the initial panel size (normal, half or full) to use
PanelSize string
}

type GitArg string
Expand All @@ -26,11 +26,11 @@ const (
GitArgStash GitArg = "stash"
)

func NewStartArgs(filterPath string, gitArg GitArg, screenMode string, test integrationTypes.IntegrationTest) StartArgs {
func NewStartArgs(filterPath string, gitArg GitArg, PanelSize string, test integrationTypes.IntegrationTest) StartArgs {
return StartArgs{
FilterPath: filterPath,
GitArg: gitArg,
ScreenMode: screenMode,
PanelSize: PanelSize,
IntegrationTest: test,
}
}
29 changes: 19 additions & 10 deletions pkg/config/app_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,16 +217,25 @@ 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, 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)
changedContent := content

pathsToReplace := []struct {
oldPath []string
newName string
}{
{[]string{"gui", "skipUnstageLineWarning"}, "skipDiscardChangeWarning"},
{[]string{"keybinding", "universal", "executeCustomCommand"}, "executeShellCommand"},
{[]string{"gui", "windowSize"}, "panelSize"},
{[]string{"keybinding", "nextScreenMode"}, "nextPanelSize"},
{[]string{"keybinding", "prevScreenMode"}, "prevPanelSize"},
}

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)
Expand Down
14 changes: 7 additions & 7 deletions pkg/config/user_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ type GuiConfig struct {
// - 'vertical': split the window vertically
// - 'flexible': (default) split the window horizontally if the window is wide enough, otherwise split vertically
MainPanelSplitMode string `yaml:"mainPanelSplitMode" jsonschema:"enum=horizontal,enum=flexible,enum=vertical"`
// How the window is split when in half screen mode (i.e. after hitting '+' once).
// How the window is split when in half panel-size mode (i.e. after hitting '+' once).
// Possible values:
// - 'left': split the window horizontally (side panel on the left, main view on the right)
// - 'top': split the window vertically (side panel on top, main view below)
Expand Down Expand Up @@ -150,7 +150,7 @@ type GuiConfig struct {
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).
// One of: 'normal' (default) | 'half' | 'full'
WindowSize string `yaml:"windowSize" jsonschema:"enum=normal,enum=half,enum=full"`
PanelSize string `yaml:"panelSize" 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"`
Expand Down Expand Up @@ -410,8 +410,8 @@ type KeybindingUniversalConfig struct {
CreatePatchOptionsMenu string `yaml:"createPatchOptionsMenu"`
NextTab string `yaml:"nextTab"`
PrevTab string `yaml:"prevTab"`
NextScreenMode string `yaml:"nextScreenMode"`
PrevScreenMode string `yaml:"prevScreenMode"`
NextPanelSize string `yaml:"nextPanelSize"`
PrevPanelSize string `yaml:"prevPanelSize"`
Undo string `yaml:"undo"`
Redo string `yaml:"redo"`
FilteringMenu string `yaml:"filteringMenu"`
Expand Down Expand Up @@ -734,7 +734,7 @@ func GetDefaultConfig() *UserConfig {
CommandLogSize: 8,
SplitDiff: "auto",
SkipRewordInEditorWarning: false,
WindowSize: "normal",
PanelSize: "normal",
Border: "rounded",
AnimateExplosion: true,
PortraitMode: "auto",
Expand Down Expand Up @@ -855,8 +855,8 @@ func GetDefaultConfig() *UserConfig {
CreatePatchOptionsMenu: "<c-p>",
NextTab: "]",
PrevTab: "[",
NextScreenMode: "+",
PrevScreenMode: "_",
NextPanelSize: "+",
PrevPanelSize: "_",
Undo: "z",
Redo: "<c-z>",
FilteringMenu: "<c-s>",
Expand Down
2 changes: 1 addition & 1 deletion pkg/gui/context/branches_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func NewBranchesContext(c *ContextCommon) *BranchesContext {
return presentation.GetBranchListDisplayStrings(
viewModel.GetItems(),
c.State().GetItemOperation,
c.State().GetRepoState().GetScreenMode() != types.SCREEN_NORMAL,
c.State().GetRepoState().GetPanelSize() != types.PANEL_SIZE_NORMAL,
c.Modes().Diffing.Ref,
c.Views().Branches.InnerWidth(),
c.Tr,
Expand Down
6 changes: 3 additions & 3 deletions pkg/gui/context/local_commits_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func NewLocalCommitsContext(c *ContextCommon) *LocalCommitsContext {
c.Model().Branches,
c.Model().CheckedOutBranch,
hasRebaseUpdateRefsConfig,
c.State().GetRepoState().GetScreenMode() != types.SCREEN_NORMAL,
c.State().GetRepoState().GetPanelSize() != types.PANEL_SIZE_NORMAL,
c.Modes().CherryPicking.SelectedHashSet(),
c.Modes().Diffing.Ref,
c.Modes().MarkedBaseCommit.GetHash(),
Expand All @@ -77,7 +77,7 @@ func NewLocalCommitsContext(c *ContextCommon) *LocalCommitsContext {
Key: LOCAL_COMMITS_CONTEXT_KEY,
Kind: types.SIDE_CONTEXT,
Focusable: true,
NeedsRerenderOnWidthChange: types.NEEDS_RERENDER_ON_WIDTH_CHANGE_WHEN_SCREEN_MODE_CHANGES,
NeedsRerenderOnWidthChange: types.NEEDS_RERENDER_ON_WIDTH_CHANGE_WHEN_PANEL_SIZE_CHANGES,
NeedsRerenderOnHeightChange: true,
})),
ListRenderer: ListRenderer{
Expand Down Expand Up @@ -215,7 +215,7 @@ func shouldShowGraph(c *ContextCommon) bool {
case "never":
return false
case "when-maximised":
return c.State().GetRepoState().GetScreenMode() != types.SCREEN_NORMAL
return c.State().GetRepoState().GetPanelSize() != types.PANEL_SIZE_NORMAL
}

log.Fatalf("Unknown value for git.log.showGraph: %s. Expected one of: 'always', 'never', 'when-maximised'", value)
Expand Down
4 changes: 2 additions & 2 deletions pkg/gui/context/reflog_commits_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func NewReflogCommitsContext(c *ContextCommon) *ReflogCommitsContext {
getDisplayStrings := func(_ int, _ int) [][]string {
return presentation.GetReflogCommitListDisplayStrings(
viewModel.GetItems(),
c.State().GetRepoState().GetScreenMode() != types.SCREEN_NORMAL,
c.State().GetRepoState().GetPanelSize() != types.PANEL_SIZE_NORMAL,
c.Modes().CherryPicking.SelectedHashSet(),
c.Modes().Diffing.Ref,
time.Now(),
Expand All @@ -48,7 +48,7 @@ func NewReflogCommitsContext(c *ContextCommon) *ReflogCommitsContext {
Key: REFLOG_COMMITS_CONTEXT_KEY,
Kind: types.SIDE_CONTEXT,
Focusable: true,
NeedsRerenderOnWidthChange: types.NEEDS_RERENDER_ON_WIDTH_CHANGE_WHEN_SCREEN_MODE_CHANGES,
NeedsRerenderOnWidthChange: types.NEEDS_RERENDER_ON_WIDTH_CHANGE_WHEN_PANEL_SIZE_CHANGES,
})),
ListRenderer: ListRenderer{
list: viewModel,
Expand Down
6 changes: 3 additions & 3 deletions pkg/gui/context/sub_commits_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func NewSubCommitsContext(

getDisplayStrings := func(startIdx int, endIdx int) [][]string {
// This can happen if a sub-commits view is asked to be rerendered while
// it is invisible; for example when switching screen modes, which
// it is invisible; for example when switching panel size, which
// rerenders all views.
if viewModel.GetRef() == nil {
return [][]string{}
Expand All @@ -64,7 +64,7 @@ func NewSubCommitsContext(
branches,
viewModel.GetRef().RefName(),
hasRebaseUpdateRefsConfig,
c.State().GetRepoState().GetScreenMode() != types.SCREEN_NORMAL,
c.State().GetRepoState().GetPanelSize() != types.PANEL_SIZE_NORMAL,
c.Modes().CherryPicking.SelectedHashSet(),
c.Modes().Diffing.Ref,
"",
Expand Down Expand Up @@ -121,7 +121,7 @@ func NewSubCommitsContext(
Kind: types.SIDE_CONTEXT,
Focusable: true,
Transient: true,
NeedsRerenderOnWidthChange: types.NEEDS_RERENDER_ON_WIDTH_CHANGE_WHEN_SCREEN_MODE_CHANGES,
NeedsRerenderOnWidthChange: types.NEEDS_RERENDER_ON_WIDTH_CHANGE_WHEN_PANEL_SIZE_CHANGES,
NeedsRerenderOnHeightChange: true,
})),
ListRenderer: ListRenderer{
Expand Down
4 changes: 2 additions & 2 deletions pkg/gui/controllers/filtering_menu_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ func (self *FilteringMenuAction) setFiltering() error {
self.c.Modes().Filtering.SetSelectedCommitHash(self.c.Contexts().LocalCommits.GetSelectedCommitHash())

repoState := self.c.State().GetRepoState()
if repoState.GetScreenMode() == types.SCREEN_NORMAL {
repoState.SetScreenMode(types.SCREEN_HALF)
if repoState.GetPanelSize() == types.PANEL_SIZE_NORMAL {
repoState.SetPanelSize(types.PANEL_SIZE_HALF)
}

self.c.Context().Push(self.c.Contexts().LocalCommits)
Expand Down
20 changes: 10 additions & 10 deletions pkg/gui/controllers/global_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ func (self *GlobalController) GetKeybindings(opts types.KeybindingsOpts) []*type
Tooltip: self.c.Tr.RefreshTooltip,
},
{
Key: opts.GetKey(opts.Config.Universal.NextScreenMode),
Handler: self.nextScreenMode,
Description: self.c.Tr.NextScreenMode,
Key: opts.GetKey(opts.Config.Universal.NextPanelSize),
Handler: self.nextPanelSize,
Description: self.c.Tr.NextPanelSize,
},
{
Key: opts.GetKey(opts.Config.Universal.PrevScreenMode),
Handler: self.prevScreenMode,
Description: self.c.Tr.PrevScreenMode,
Key: opts.GetKey(opts.Config.Universal.PrevPanelSize),
Handler: self.prevPanelSize,
Description: self.c.Tr.PrevPanelSize,
},
{
ViewName: "",
Expand Down Expand Up @@ -145,12 +145,12 @@ func (self *GlobalController) refresh() error {
return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC})
}

func (self *GlobalController) nextScreenMode() error {
return (&ScreenModeActions{c: self.c}).Next()
func (self *GlobalController) nextPanelSize() error {
return (&PanelSizeActions{c: self.c}).Next()
}

func (self *GlobalController) prevScreenMode() error {
return (&ScreenModeActions{c: self.c}).Prev()
func (self *GlobalController) prevPanelSize() error {
return (&PanelSizeActions{c: self.c}).Prev()
}

func (self *GlobalController) createOptionsMenu() error {
Expand Down
4 changes: 2 additions & 2 deletions pkg/gui/controllers/helpers/mode_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ func (self *ModeHelper) ExitFilterMode() error {
func (self *ModeHelper) ClearFiltering() error {
selectedCommitHash := self.c.Contexts().LocalCommits.GetSelectedCommitHash()
self.c.Modes().Filtering.Reset()
if self.c.State().GetRepoState().GetScreenMode() == types.SCREEN_HALF {
self.c.State().GetRepoState().SetScreenMode(types.SCREEN_NORMAL)
if self.c.State().GetRepoState().GetPanelSize() == types.PANEL_SIZE_HALF {
self.c.State().GetRepoState().SetPanelSize(types.PANEL_SIZE_NORMAL)
}

return self.c.Refresh(types.RefreshOptions{
Expand Down
Loading

0 comments on commit 0d45df0

Please sign in to comment.