mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-12 12:55:47 +02:00
Add ability to force portrait mode
A new gui config flag 'portraitMode':<string> is added to influence when LazyGit stacks its UI components on top of one another. The accepted values are 'auto', 'always', 'never'. 'auto': enter portrait mode when terminal becomes narrow enough 'always': always use portrait mode unconditional of the terminal dimensions 'never': never use portraid mode Signed-off-by: Louis DeLosSantos <louis.delos@gmail.com>
This commit is contained in:
parent
4f3127ccb8
commit
9c72d8a2b0
3 changed files with 17 additions and 2 deletions
|
@ -85,6 +85,7 @@ gui:
|
||||||
skipRewordInEditorWarning: false # for skipping the confirmation before launching the reword editor
|
skipRewordInEditorWarning: false # for skipping the confirmation before launching the reword editor
|
||||||
border: 'rounded' # one of 'single' | 'double' | 'rounded' | 'hidden'
|
border: 'rounded' # one of 'single' | 'double' | 'rounded' | 'hidden'
|
||||||
animateExplosion: true # shows an explosion animation when nuking the working tree
|
animateExplosion: true # shows an explosion animation when nuking the working tree
|
||||||
|
portraitMode: 'auto' # one of 'auto' | 'never' | 'always'
|
||||||
git:
|
git:
|
||||||
paging:
|
paging:
|
||||||
colorArg: always
|
colorArg: always
|
||||||
|
|
|
@ -130,6 +130,9 @@ type GuiConfig struct {
|
||||||
Border string `yaml:"border"`
|
Border string `yaml:"border"`
|
||||||
// If true, show a seriously epic explosion animation when nuking the working tree.
|
// If true, show a seriously epic explosion animation when nuking the working tree.
|
||||||
AnimateExplosion bool `yaml:"animateExplosion"`
|
AnimateExplosion bool `yaml:"animateExplosion"`
|
||||||
|
// Whether to stack UI components on top of each other.
|
||||||
|
// One of 'auto' (default) | 'always' | 'never'
|
||||||
|
PortraitMode string `yaml:"portraitMode"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ThemeConfig struct {
|
type ThemeConfig struct {
|
||||||
|
@ -619,6 +622,7 @@ func GetDefaultConfig() *UserConfig {
|
||||||
SkipRewordInEditorWarning: false,
|
SkipRewordInEditorWarning: false,
|
||||||
Border: "rounded",
|
Border: "rounded",
|
||||||
AnimateExplosion: true,
|
AnimateExplosion: true,
|
||||||
|
PortraitMode: "auto",
|
||||||
},
|
},
|
||||||
Git: GitConfig{
|
Git: GitConfig{
|
||||||
Paging: PagingConfig{
|
Paging: PagingConfig{
|
||||||
|
|
|
@ -34,14 +34,24 @@ func NewWindowArrangementHelper(
|
||||||
|
|
||||||
const INFO_SECTION_PADDING = " "
|
const INFO_SECTION_PADDING = " "
|
||||||
|
|
||||||
|
func (self *WindowArrangementHelper) shouldUsePortraitMode(width, height int) bool {
|
||||||
|
switch self.c.UserConfig.Gui.PortraitMode {
|
||||||
|
case "never":
|
||||||
|
return false
|
||||||
|
case "always":
|
||||||
|
return true
|
||||||
|
default: // "auto" or any garbage values in PortraitMode value
|
||||||
|
return width <= 84 && height > 45
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (self *WindowArrangementHelper) GetWindowDimensions(informationStr string, appStatus string) map[string]boxlayout.Dimensions {
|
func (self *WindowArrangementHelper) GetWindowDimensions(informationStr string, appStatus string) map[string]boxlayout.Dimensions {
|
||||||
width, height := self.c.GocuiGui().Size()
|
width, height := self.c.GocuiGui().Size()
|
||||||
|
|
||||||
sideSectionWeight, mainSectionWeight := self.getMidSectionWeights()
|
sideSectionWeight, mainSectionWeight := self.getMidSectionWeights()
|
||||||
|
|
||||||
sidePanelsDirection := boxlayout.COLUMN
|
sidePanelsDirection := boxlayout.COLUMN
|
||||||
portraitMode := width <= 84 && height > 45
|
if self.shouldUsePortraitMode(width, height) {
|
||||||
if portraitMode {
|
|
||||||
sidePanelsDirection = boxlayout.ROW
|
sidePanelsDirection = boxlayout.ROW
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue