aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJeffas <dev@jeffas.io>2019-07-26 09:46:15 +0100
committerDrew DeVault <sir@cmpwn.com>2019-07-26 15:12:24 -0400
commit7a3765a36bfa1c54f8bc77c761a741d5529addcf (patch)
tree6814f1ddd4aab9384c2fddaf91bb7dca081ba3ec /lib
parentcded067bc3919a77b17feedd877e4590e7c95f4a (diff)
Fix tabstrip over-drawing when not enough space
Tabstrip didn't take into account the width of the context. Now, it just shows as many tabs as can fit and truncates the last one if necessary. In future it probably would be best to ensure that the selected tab is rendered on the screen.
Diffstat (limited to 'lib')
-rw-r--r--lib/ui/tab.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/ui/tab.go b/lib/ui/tab.go
index b6e7bd5..90c7ce9 100644
--- a/lib/ui/tab.go
+++ b/lib/ui/tab.go
@@ -167,8 +167,15 @@ func (strip *TabStrip) Draw(ctx *Context) {
if strip.Selected == i {
style = tcell.StyleDefault
}
- trunc := runewidth.Truncate(tab.Name, 32, "…")
+ tabWidth := 32
+ if ctx.Width()-x < tabWidth {
+ tabWidth = ctx.Width() - x - 2
+ }
+ trunc := runewidth.Truncate(tab.Name, tabWidth, "…")
x += ctx.Printf(x, 0, style, " %s ", trunc)
+ if x >= ctx.Width() {
+ break
+ }
}
style := tcell.StyleDefault.Reverse(true)
ctx.Fill(x, 0, ctx.Width()-x, 1, ' ', style)