Skip to content

Commit

Permalink
Add config setting for splitting window vertically in half screen mode
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanhaller committed Nov 26, 2023
1 parent d8059d7 commit 95c1376
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 6 additions & 0 deletions pkg/config/user_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,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"`
// How the window is split when in half screen mode (i.e. after hitting '+' once).
// Possible values:
// - 'horizontal': split the window horizontally (side panel on the left, main view on the right)
// - 'vertical': split the window vertically (side panel on top, main view below)
HalfScreenSplitMode string `yaml:"halfScreenSplitMode"`
// One of 'auto' (default) | 'en' | 'zh-CN' | 'zh-TW' | 'pl' | 'nl' | 'ja' | 'ko' | 'ru'
Language string `yaml:"language"`
// Format used when displaying time e.g. commit time.
Expand Down Expand Up @@ -589,6 +594,7 @@ func GetDefaultConfig() *UserConfig {
SidePanelWidth: 0.3333,
ExpandFocusedSidePanel: false,
MainPanelSplitMode: "flexible",
HalfScreenSplitMode: "horizontal",
Language: "auto",
TimeFormat: "02 Jan 06",
ShortTimeFormat: time.Kitchen,
Expand Down
10 changes: 9 additions & 1 deletion pkg/gui/controllers/helpers/window_arrangement_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ func NewWindowArrangementHelper(
const INFO_SECTION_PADDING = " "

func (self *WindowArrangementHelper) shouldUsePortraitMode(width, height int) bool {
if self.c.State().GetRepoState().GetScreenMode() == types.SCREEN_HALF {
return self.c.UserConfig.Gui.HalfScreenSplitMode == "vertical"
}

switch self.c.UserConfig.Gui.PortraitMode {
case "never":
return false
Expand Down Expand Up @@ -174,7 +178,11 @@ func (self *WindowArrangementHelper) getMidSectionWeights() (int, int) {
}
} else {
if screenMode == types.SCREEN_HALF {
mainSectionWeight = 1
if self.c.UserConfig.Gui.HalfScreenSplitMode == "vertical" {
mainSectionWeight = 2
} else {
mainSectionWeight = 1
}
} else if screenMode == types.SCREEN_FULL {
mainSectionWeight = 0
}
Expand Down

0 comments on commit 95c1376

Please sign in to comment.