diff options
author | Sean E. Russell <ser@ser1.net> | 2020-02-18 12:18:34 -0600 |
---|---|---|
committer | Sean E. Russell <ser@ser1.net> | 2020-02-18 12:18:34 -0600 |
commit | a197638e1f1292f3f01b17a0f4419d0180810927 (patch) | |
tree | 115d5d4b17c87ae6319cc3c9ac6be8e9efe43130 /layout | |
parent | 6c9e51470e6fef4282d22f419ac2deaf8435195d (diff) |
Fixes a layout bug; rolls back gopsutil dep update
Diffstat (limited to 'layout')
-rw-r--r-- | layout/layout.go | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/layout/layout.go b/layout/layout.go index c78bb67..3214b97 100644 --- a/layout/layout.go +++ b/layout/layout.go @@ -86,13 +86,28 @@ func processRow(c gotop.Config, numRows int, rowDefs [][]widgetRule) (ui.GridIte columns = append(columns, make([]interface{}, 0)) } colHeights := make([]int, numCols) - for _, rds := range processing { - for _, rd := range rds { + for i, row := range processing { + // A definition may fill up the columns before all rows are consumed, + // e.g. wid1/2 wid2/2. This block checks for that and, if it occurs, + // prepends the remaining rows to the "remainder" return value. + full := true + for _, ch := range colHeights { + if ch <= maxHeight { + full = false + break + } + } + if full { + rowDefs = append(processing[i:], rowDefs...) + break + } + // Not all rows have been consumed, so go ahead and place the row's widgets in columns + for _, wid := range row { for j, ch := range colHeights { - if ch+rd.Height <= maxHeight { - widget := makeWidget(c, rd) - columns[j] = append(columns[j], ui.NewRow(float64(rd.Height)/float64(maxHeight), widget)) - colHeights[j] += rd.Height + if ch+wid.Height <= maxHeight { + widget := makeWidget(c, wid) + columns[j] = append(columns[j], ui.NewRow(float64(wid.Height)/float64(maxHeight), widget)) + colHeights[j] += wid.Height break } } |