diff options
author | Stefan Haller <stefan@haller-berlin.de> | 2023-11-26 13:11:50 +0100 |
---|---|---|
committer | Stefan Haller <stefan@haller-berlin.de> | 2024-01-09 15:45:26 +0100 |
commit | d70dd5123dfca5248ab9f2396307c46eff96bcb4 (patch) | |
tree | 5bb529272ecf770ca18c299a975426cb26aa525d /pkg | |
parent | 15da70214086a1485e2a6d1d2f792fec80755ce5 (diff) |
Add config setting for side panel location (left or top) in half screen mode
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/config/user_config.go | 6 | ||||
-rw-r--r-- | pkg/gui/controllers/helpers/window_arrangement_helper.go | 10 | ||||
-rw-r--r-- | pkg/gui/controllers/helpers/window_arrangement_helper_test.go | 64 |
3 files changed, 79 insertions, 1 deletions
diff --git a/pkg/config/user_config.go b/pkg/config/user_config.go index 2392d49cf..ffc27eb88 100644 --- a/pkg/config/user_config.go +++ b/pkg/config/user_config.go @@ -84,6 +84,11 @@ 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). + // 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) + EnlargedSideViewLocation string `yaml:"enlargedSideViewLocation"` // One of 'auto' (default) | 'en' | 'zh-CN' | 'zh-TW' | 'pl' | 'nl' | 'ja' | 'ko' | 'ru' Language string `yaml:"language" jsonschema:"enum=auto,enum=en,enum=zh-TW,enum=zh-CN,enum=pl,enum=nl,enum=ja,enum=ko,enum=ru"` // Format used when displaying time e.g. commit time. @@ -604,6 +609,7 @@ func GetDefaultConfig() *UserConfig { SidePanelWidth: 0.3333, ExpandFocusedSidePanel: false, MainPanelSplitMode: "flexible", + EnlargedSideViewLocation: "left", Language: "auto", TimeFormat: "02 Jan 06", ShortTimeFormat: time.Kitchen, diff --git a/pkg/gui/controllers/helpers/window_arrangement_helper.go b/pkg/gui/controllers/helpers/window_arrangement_helper.go index 0d9b119e3..8615769dc 100644 --- a/pkg/gui/controllers/helpers/window_arrangement_helper.go +++ b/pkg/gui/controllers/helpers/window_arrangement_helper.go @@ -107,6 +107,10 @@ func (self *WindowArrangementHelper) GetWindowDimensions(informationStr string, } func shouldUsePortraitMode(args WindowArrangementArgs) bool { + if args.ScreenMode == types.SCREEN_HALF { + return args.UserConfig.Gui.EnlargedSideViewLocation == "top" + } + switch args.UserConfig.Gui.PortraitMode { case "never": return false @@ -241,7 +245,11 @@ func getMidSectionWeights(args WindowArrangementArgs) (int, int) { } } else { if args.ScreenMode == types.SCREEN_HALF { - mainSectionWeight = 1 + if args.UserConfig.Gui.EnlargedSideViewLocation == "top" { + mainSectionWeight = 2 + } else { + mainSectionWeight = 1 + } } else if args.ScreenMode == types.SCREEN_FULL { mainSectionWeight = 0 } diff --git a/pkg/gui/controllers/helpers/window_arrangement_helper_test.go b/pkg/gui/controllers/helpers/window_arrangement_helper_test.go index 4e299ec2e..9c455ff33 100644 --- a/pkg/gui/controllers/helpers/window_arrangement_helper_test.go +++ b/pkg/gui/controllers/helpers/window_arrangement_helper_test.go @@ -122,6 +122,70 @@ func TestGetWindowDimensions(t *testing.T) { `, }, { + name: "half screen mode, enlargedSideViewLocation left", + mutateArgs: func(args *WindowArrangementArgs) { + args.Height = 20 // smaller height because we don't more here + args.ScreenMode = types.SCREEN_HALF + args.UserConfig.Gui.EnlargedSideViewLocation = "left" + }, + expected: ` + ╭status──────────────────────────────╮╭main───────────────────────────────╮ + │ ││ │ + │ ││ │ + │ ││ │ + │ ││ │ + │ ││ │ + │ ││ │ + │ ││ │ + │ ││ │ + │ ││ │ + │ ││ │ + │ ││ │ + │ ││ │ + │ ││ │ + │ ││ │ + │ ││ │ + │ ││ │ + │ ││ │ + ╰────────────────────────────────────╯╰───────────────────────────────────╯ + <options──────────────────────────────────────────────────────>A<B────────> + A: statusSpacer1 + B: information + `, + }, + { + name: "half screen mode, enlargedSideViewLocation top", + mutateArgs: func(args *WindowArrangementArgs) { + args.Height = 20 // smaller height because we don't more here + args.ScreenMode = types.SCREEN_HALF + args.UserConfig.Gui.EnlargedSideViewLocation = "top" + }, + expected: ` + ╭status───────────────────────────────────────────────────────────────────╮ + │ │ + │ │ + │ │ + │ │ + │ │ + ╰─────────────────────────────────────────────────────────────────────────╯ + ╭main─────────────────────────────────────────────────────────────────────╮ + │ │ + │ │ + │ │ + │ │ + │ │ + │ │ + │ │ + │ │ + │ │ + │ │ + ╰─────────────────────────────────────────────────────────────────────────╯ + <options──────────────────────────────────────────────────────>A<B────────> + A: statusSpacer1 + B: information + `, + }, + { name: "search mode", mutateArgs: func(args *WindowArrangementArgs) { args.InSearchPrompt = true |