Skip to content

Commit c76471c

Browse files
committed
fixup! Layout the bottom line view using spacer views
1 parent c4928a2 commit c76471c

File tree

5 files changed

+9
-21
lines changed

5 files changed

+9
-21
lines changed

pkg/gui/context/context.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ const (
3838
LIMIT_CONTEXT_KEY types.ContextKey = "limit"
3939
STATUS_SPACER1_CONTEXT_KEY types.ContextKey = "statusSpacer1"
4040
STATUS_SPACER2_CONTEXT_KEY types.ContextKey = "statusSpacer2"
41-
STATUS_SPACER3_CONTEXT_KEY types.ContextKey = "statusSpacer3"
42-
STATUS_SPACER4_CONTEXT_KEY types.ContextKey = "statusSpacer4"
4341

4442
MENU_CONTEXT_KEY types.ContextKey = "menu"
4543
CONFIRMATION_CONTEXT_KEY types.ContextKey = "confirmation"
@@ -121,8 +119,6 @@ type ContextTree struct {
121119
Limit types.Context
122120
StatusSpacer1 types.Context
123121
StatusSpacer2 types.Context
124-
StatusSpacer3 types.Context
125-
StatusSpacer4 types.Context
126122
}
127123

128124
// the order of this decides which context is initially at the top of its window
@@ -166,8 +162,6 @@ func (self *ContextTree) Flatten() []types.Context {
166162
self.Limit,
167163
self.StatusSpacer1,
168164
self.StatusSpacer2,
169-
self.StatusSpacer3,
170-
self.StatusSpacer4,
171165
}
172166
}
173167

pkg/gui/context/setup.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,5 @@ func NewContextTree(c *ContextCommon) *ContextTree {
145145
Limit: NewDisplayContext(LIMIT_CONTEXT_KEY, c.Views().Limit, "limit"),
146146
StatusSpacer1: NewDisplayContext(STATUS_SPACER1_CONTEXT_KEY, c.Views().StatusSpacer1, "statusSpacer1"),
147147
StatusSpacer2: NewDisplayContext(STATUS_SPACER2_CONTEXT_KEY, c.Views().StatusSpacer2, "statusSpacer2"),
148-
StatusSpacer3: NewDisplayContext(STATUS_SPACER3_CONTEXT_KEY, c.Views().StatusSpacer3, "statusSpacer3"),
149-
StatusSpacer4: NewDisplayContext(STATUS_SPACER4_CONTEXT_KEY, c.Views().StatusSpacer4, "statusSpacer4"),
150148
}
151149
}

pkg/gui/controllers/helpers/window_arrangement_helper.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,8 @@ func infoSectionChildren(args WindowArrangementArgs) []*boxlayout.Box {
266266

267267
statusSpacerPrefix := "statusSpacer"
268268
spacerBoxIndex := 0
269-
maxSpacerBoxIndex := 4 // See pkg/gui/types/views.go
270-
// Returns a box with size 1 to be used as padding before, between, or after views
269+
maxSpacerBoxIndex := 2 // See pkg/gui/types/views.go
270+
// Returns a box with size 1 to be used as padding between views
271271
spacerBox := func() *boxlayout.Box {
272272
spacerBoxIndex++
273273

@@ -278,7 +278,7 @@ func infoSectionChildren(args WindowArrangementArgs) []*boxlayout.Box {
278278
return &boxlayout.Box{Window: fmt.Sprintf("%s%d", statusSpacerPrefix, spacerBoxIndex), Size: 1}
279279
}
280280

281-
// Returns a box with weight 1 to be used as flexible padding before, between, or after views
281+
// Returns a box with weight 1 to be used as flexible padding between views
282282
flexibleSpacerBox := func() *boxlayout.Box {
283283
spacerBoxIndex++
284284

@@ -327,9 +327,11 @@ func infoSectionChildren(args WindowArrangementArgs) []*boxlayout.Box {
327327

328328
if len(result) == 2 && result[0].Window == "appStatus" {
329329
// Only status and information are showing; need to insert a flexible
330-
// spacer after the 1-width spacer between the two, so that information
331-
// is right-aligned
332-
330+
// spacer between the two, so that information is right-aligned. Note
331+
// that the call to insertSpacerBoxes below will still insert a 1-char
332+
// spacer in addition (right after the flexible one); this is needed for
333+
// the case that there's not enough room, to ensure there's always at
334+
// least one space.
333335
result = slices.Insert(result, 1, flexibleSpacerBox())
334336
} else if len(result) == 1 {
335337
if result[0].Window == "information" {

pkg/gui/types/views.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ type Views struct {
3636
SearchPrefix *gocui.View
3737
StatusSpacer1 *gocui.View
3838
StatusSpacer2 *gocui.View
39-
StatusSpacer3 *gocui.View
40-
StatusSpacer4 *gocui.View
4139
Limit *gocui.View
4240
Suggestions *gocui.View
4341
Tooltip *gocui.View

pkg/gui/views.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,9 @@ func (gui *Gui) orderedViewNameMappings() []viewNameMapping {
5555
{viewPtr: &gui.Views.Search, name: "search"},
5656
// this view shows either the "Search:" prompt when searching, or the "Filter:" prompt when filtering
5757
{viewPtr: &gui.Views.SearchPrefix, name: "searchPrefix"},
58-
// these views all contain one space, and are used as spacers before, between, and after the various views in the bottom line
58+
// these views contain one space, and are used as spacers between the various views in the bottom line
5959
{viewPtr: &gui.Views.StatusSpacer1, name: "statusSpacer1"},
6060
{viewPtr: &gui.Views.StatusSpacer2, name: "statusSpacer2"},
61-
{viewPtr: &gui.Views.StatusSpacer3, name: "statusSpacer3"},
62-
{viewPtr: &gui.Views.StatusSpacer4, name: "statusSpacer4"},
6361

6462
// popups.
6563
{viewPtr: &gui.Views.CommitMessage, name: "commitMessage"},
@@ -105,8 +103,6 @@ func (gui *Gui) createAllViews() error {
105103

106104
gui.Views.StatusSpacer1.Frame = false
107105
gui.Views.StatusSpacer2.Frame = false
108-
gui.Views.StatusSpacer3.Frame = false
109-
gui.Views.StatusSpacer4.Frame = false
110106

111107
gui.Views.Search.BgColor = gocui.ColorDefault
112108
gui.Views.Search.FgColor = gocui.ColorCyan

0 commit comments

Comments
 (0)