aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ui/table.go
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2023-01-31 14:08:59 +0100
committerRobin Jarry <robin@jarry.cc>2023-02-20 14:48:42 +0100
commit191876182a91659bbeab0c7b5c4ef61ebe636f76 (patch)
tree1536b9d7112b7a1bde59ebbdbaa8ce342e184dad /lib/ui/table.go
parent5efa357e107b1a7fe4bfcf186c94fbd274b96acd (diff)
downloadaerc-191876182a91659bbeab0c7b5c4ef61ebe636f76.tar.gz
ui/table: allow zero width columns
When a column uses WIDTH_FIT and its contents are empty, the column is not rendered at all, neither is its separator. This can cause display artifacts (interruption of background color, etc.). Make sure to differentiate between zero-width columns and columns that overflow screen width. Fixes: 012be0192c88 ("ui: add reusable table widget") Acked-by: Tim Culverhouse <tim@timculverhouse.com> Signed-off-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'lib/ui/table.go')
-rw-r--r--lib/ui/table.go11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/ui/table.go b/lib/ui/table.go
index 13bec12d..89b59c23 100644
--- a/lib/ui/table.go
+++ b/lib/ui/table.go
@@ -138,14 +138,17 @@ func (t *Table) computeWidths() {
remain := t.Width
for c := range t.Columns {
col := &t.Columns[c]
- if col.Width == 0 && autoWidth > 0 {
+ if col.Def.Flags.Has(config.WIDTH_AUTO) && autoWidth > 0 {
col.Width = autoWidth
if nonFixed >= 2*autoWidth {
nonFixed -= autoWidth
}
}
- // limit width to avoid overflow
- if col.Width > remain {
+ if remain == 0 {
+ // column is outside of screen
+ col.Width = -1
+ } else if col.Width > remain {
+ // limit width to avoid overflow
col.Width = remain
}
remain -= col.Width
@@ -198,7 +201,7 @@ func (t *Table) Draw(ctx *Context) {
continue
}
for c, col := range t.Columns {
- if col.Width == 0 {
+ if col.Width == -1 {
// column overflows screen width
continue
}