From 6edfbfa8ce3760b7d0ee91bb6be768b296a50574 Mon Sep 17 00:00:00 2001 From: Koni Marti Date: Sun, 17 Apr 2022 01:03:49 +0200 Subject: aerc: use contextual ui styleset for tabs/compose Use contextual ui styleset for tabs and compose widgets. If no account is selected, use default styleset as fallback. Fixes: https://todo.sr.ht/~rjarry/aerc/3 Signed-off-by: Koni Marti Acked-by: Robin Jarry --- lib/ui/tab.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/ui/tab.go b/lib/ui/tab.go index 07f61998..a67bdabc 100644 --- a/lib/ui/tab.go +++ b/lib/ui/tab.go @@ -31,6 +31,7 @@ type Tab struct { invalid bool pinned bool indexBeforePin int + uiConf *config.UIConfig } type TabStrip Tabs @@ -47,10 +48,11 @@ func NewTabs(uiConf *config.UIConfig) *Tabs { return tabs } -func (tabs *Tabs) Add(content Drawable, name string) *Tab { +func (tabs *Tabs) Add(content Drawable, name string, uiConf *config.UIConfig) *Tab { tab := &Tab{ Content: content, Name: name, + uiConf: uiConf, } tabs.Tabs = append(tabs.Tabs, tab) tabs.TabStrip.Invalidate() @@ -283,9 +285,13 @@ func (tabs *Tabs) removeHistory(index int) { func (strip *TabStrip) Draw(ctx *Context) { x := 0 for i, tab := range strip.Tabs { - style := strip.uiConfig.GetStyle(config.STYLE_TAB) + uiConfig := strip.uiConfig + if tab.uiConf != nil { + uiConfig = tab.uiConf + } + style := uiConfig.GetStyle(config.STYLE_TAB) if strip.Selected == i { - style = strip.uiConfig.GetStyleSelected(config.STYLE_TAB) + style = uiConfig.GetStyleSelected(config.STYLE_TAB) } tabWidth := 32 if ctx.Width()-x < tabWidth { @@ -293,7 +299,7 @@ func (strip *TabStrip) Draw(ctx *Context) { } name := tab.Name if tab.pinned { - name = strip.uiConfig.PinnedTabMarker + name + name = uiConfig.PinnedTabMarker + name } trunc := runewidth.Truncate(name, tabWidth, "…") x += ctx.Printf(x, 0, style, " %s ", trunc) -- cgit