From 35b72420adebf7118f92e6d07109f4f0bfe204a7 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Wed, 12 Aug 2020 22:06:37 +1000 Subject: [PATCH] support accordian mode i.e. expanding focused side panels --- docs/Config.md | 1 + pkg/config/app_config.go | 1 + pkg/gui/arrangement.go | 32 ++++++++++++++++---------------- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/docs/Config.md b/docs/Config.md index 9de38d3ba..14da960ec 100644 --- a/docs/Config.md +++ b/docs/Config.md @@ -14,6 +14,7 @@ Default path for the config file: scrollHeight: 2 # how many lines you scroll by scrollPastBottom: true # enable scrolling past the bottom sidePanelWidth: 0.3333 # number from 0 to 1 + expandFocusedSidePanel: false theme: lightTheme: false # For terminals with a light background activeBorderColor: diff --git a/pkg/config/app_config.go b/pkg/config/app_config.go index 7ae670d4d..668bc3477 100644 --- a/pkg/config/app_config.go +++ b/pkg/config/app_config.go @@ -246,6 +246,7 @@ func GetDefaultConfig() []byte { skipUnstageLineWarning: false skipStashWarning: true sidePanelWidth: 0.3333 + expandFocusedSidePanel: false theme: lightTheme: false activeBorderColor: diff --git a/pkg/gui/arrangement.go b/pkg/gui/arrangement.go index bc7f674d1..aeb6ce59d 100644 --- a/pkg/gui/arrangement.go +++ b/pkg/gui/arrangement.go @@ -181,27 +181,27 @@ func (gui *Gui) sidePanelChildren(width int, height int) []*box { fullHeightBox("stash"), } } else if height >= 28 { + accordianMode := gui.Config.GetUserConfig().GetBool("gui.expandFocusedSidePanel") + accordianBox := func(defaultBox *box) *box { + if accordianMode && defaultBox.viewName == currentCyclableViewName { + return &box{ + viewName: defaultBox.viewName, + weight: 2, + } + } + + return defaultBox + } + return []*box{ { viewName: "status", size: 3, }, - { - viewName: "files", - weight: 1, - }, - { - viewName: "branches", - weight: 1, - }, - { - viewName: "commits", - weight: 1, - }, - { - viewName: "stash", - size: 3, - }, + accordianBox(&box{viewName: "files", weight: 1}), + accordianBox(&box{viewName: "branches", weight: 1}), + accordianBox(&box{viewName: "commits", weight: 1}), + accordianBox(&box{viewName: "stash", size: 3}), } } else { squashedHeight := 1