From ab8f433e1739f0c823809ddab192693e875d75df Mon Sep 17 00:00:00 2001 From: Robin Jarry Date: Thu, 2 Mar 2023 23:49:37 +0100 Subject: templates: allow layered fg & bg color for inline styles If a user style has no fg and/or no bg color defined, use the color from the underlying style. Signed-off-by: Robin Jarry Acked-by: Tim Culverhouse --- lib/parse/ansi.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/parse/ansi.go b/lib/parse/ansi.go index 94f0c4fc..8b448d77 100644 --- a/lib/parse/ansi.go +++ b/lib/parse/ansi.go @@ -242,13 +242,15 @@ func (rb *RuneBuffer) ApplyStyle(style tcell.Style) { // attributes func (rb *RuneBuffer) ApplyAttrs(style tcell.Style) { for _, sr := range rb.buf { - if sr.Style == tcell.StyleDefault { - sr.Style = style - continue - } _, _, srAttrs := sr.Style.Decompose() - _, _, attrs := style.Decompose() + fg, bg, attrs := style.Decompose() sr.Style = sr.Style.Attributes(srAttrs | attrs) + if fg != tcell.ColorDefault { + sr.Style = sr.Style.Foreground(fg) + } + if bg != tcell.ColorDefault { + sr.Style = sr.Style.Background(bg) + } } } -- cgit v1.2.3-54-g00ecf