summaryrefslogtreecommitdiffstats
path: root/pkg/gui/arrangement.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-05-18 22:21:36 +1000
committerJesse Duffield <jessedduffield@gmail.com>2020-08-13 21:50:23 +1000
commit1fd35f3824404aa67454b033287fb84e44eb0adc (patch)
tree9fdb2fed74db6ad011ca5f74abc699920ce5da30 /pkg/gui/arrangement.go
parente73937c2bd5c10ba7389392784a1e90af57cc490 (diff)
centralise logic for information section
WIP
Diffstat (limited to 'pkg/gui/arrangement.go')
-rw-r--r--pkg/gui/arrangement.go54
1 files changed, 50 insertions, 4 deletions
diff --git a/pkg/gui/arrangement.go b/pkg/gui/arrangement.go
index 589bf6c3c..8a209358b 100644
--- a/pkg/gui/arrangement.go
+++ b/pkg/gui/arrangement.go
@@ -1,5 +1,9 @@
package gui
+import (
+ "github.com/jesseduffield/lazygit/pkg/utils"
+)
+
func (gui *Gui) mainSectionChildren() []*box {
currentViewName := gui.currentViewName()
@@ -61,7 +65,49 @@ func (gui *Gui) getMidSectionWeights() (int, int) {
return sideSectionWeight, mainSectionWeight
}
-func (gui *Gui) getViewDimensions() map[string]dimensions {
+func (gui *Gui) infoSectionChildren(informationStr string, appStatus string) []*box {
+ if gui.State.Searching.isSearching {
+ return []*box{
+ {
+ viewName: "searchPrefix",
+ size: len(SEARCH_PREFIX),
+ },
+ {
+ viewName: "search",
+ weight: 1,
+ },
+ }
+ }
+
+ result := []*box{}
+
+ if len(appStatus) > 0 {
+ result = append(result,
+ &box{
+ viewName: "appStatus",
+ size: len(appStatus) + len(INFO_SECTION_PADDING),
+ },
+ )
+ }
+
+ result = append(result,
+ []*box{
+ {
+ viewName: "options",
+ weight: 1,
+ },
+ {
+ viewName: "information",
+ // unlike appStatus, informationStr has various colors so we need to decolorise before taking the length
+ size: len(INFO_SECTION_PADDING) + len(utils.Decolorise(informationStr)),
+ },
+ }...,
+ )
+
+ return result
+}
+
+func (gui *Gui) getViewDimensions(informationStr string, appStatus string) map[string]dimensions {
width, height := gui.g.Size()
sideSectionWeight, mainSectionWeight := gui.getMidSectionWeights()
@@ -98,10 +144,10 @@ func (gui *Gui) getViewDimensions() map[string]dimensions {
},
},
},
- // TODO: actually handle options here. Currently we're just hard-coding it to be set on the bottom row in our layout function given that we need some custom logic to have it share space with other views on that row.
{
- viewName: "options",
- size: 1,
+ direction: COLUMN,
+ size: 1,
+ children: gui.infoSectionChildren(informationStr, appStatus),
},
},
}