From 23162f7a344c661936d6ca804ac38650b3688be6 Mon Sep 17 00:00:00 2001 From: Dmitry Maluka Date: Sun, 18 Oct 2020 02:53:08 +0200 Subject: [PATCH] Add tabbar.active color group (#1831) Added tabbar.active color group for displaying the name of the active tab in the tabbar with different colors. If tabbar.active is not defined in the colorscheme, the active tab name is displayed with the same colors as inactive ones. Ref #1646 --- internal/display/tabwindow.go | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/internal/display/tabwindow.go b/internal/display/tabwindow.go index 6263586d..70694504 100644 --- a/internal/display/tabwindow.go +++ b/internal/display/tabwindow.go @@ -98,8 +98,16 @@ func (w *TabWindow) Display() { if style, ok := config.Colorscheme["tabbar"]; ok { tabBarStyle = style } + tabBarActiveStyle := tabBarStyle + if style, ok := config.Colorscheme["tabbar.active"]; ok { + tabBarActiveStyle = style + } - draw := func(r rune, n int) { + draw := func(r rune, n int, active bool) { + style := tabBarStyle + if active { + style = tabBarActiveStyle + } for i := 0; i < n; i++ { rw := runewidth.RuneWidth(r) for j := 0; j < rw; j++ { @@ -114,7 +122,7 @@ func (w *TabWindow) Display() { } else if x == 0 && w.hscroll > 0 { screen.SetContent(0, w.Y, '<', nil, tabBarStyle) } else if x >= 0 && x < w.Width { - screen.SetContent(x, w.Y, c, nil, tabBarStyle) + screen.SetContent(x, w.Y, c, nil, style) } x++ } @@ -123,21 +131,21 @@ func (w *TabWindow) Display() { for i, n := range w.Names { if i == w.active { - draw('[', 1) + draw('[', 1, true) } else { - draw(' ', 1) + draw(' ', 1, false) } for _, c := range n { - draw(c, 1) + draw(c, 1, i == w.active) } if i == len(w.Names)-1 { done = true } if i == w.active { - draw(']', 1) - draw(' ', 2) + draw(']', 1, true) + draw(' ', 2, true) } else { - draw(' ', 3) + draw(' ', 3, false) } if x >= w.Width { break @@ -145,6 +153,6 @@ func (w *TabWindow) Display() { } if x < w.Width { - draw(' ', w.Width-x) + draw(' ', w.Width-x, false) } }