aboutsummaryrefslogtreecommitdiffstats
path: root/lib/parse
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2023-03-02 23:49:37 +0100
committerRobin Jarry <robin@jarry.cc>2023-03-08 00:42:42 +0100
commitab8f433e1739f0c823809ddab192693e875d75df (patch)
tree122175e64944a9f32aa833216c3a9633953a7d16 /lib/parse
parent41942bb97df4b806520cae076387a00a7e9f39e1 (diff)
downloadaerc-ab8f433e1739f0c823809ddab192693e875d75df.tar.gz
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 <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
Diffstat (limited to 'lib/parse')
-rw-r--r--lib/parse/ansi.go12
1 files 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)
+ }
}
}