Use default color if Text span part is Reset

This commit is contained in:
veeso
2021-04-03 17:27:43 +02:00
parent 37da49f4f8
commit f8a448f5e9
2 changed files with 14 additions and 5 deletions

View File

@@ -30,7 +30,7 @@ use super::{Canvas, Component, InputEvent, Msg, Payload, Props, PropsBuilder};
// ext
use tui::{
layout::Rect,
style::Style,
style::{Color, Style},
text::{Span, Spans, Text as TuiText},
widgets::Paragraph,
};
@@ -64,12 +64,21 @@ impl Component for Text {
Some(rows) => rows
.iter()
.map(|x| {
// Keep line color, or use default
let fg: Color = match x.fg {
Color::Reset => self.props.foreground,
_ => x.fg,
};
let bg: Color = match x.bg {
Color::Reset => self.props.background,
_ => x.bg,
};
Span::styled(
x.content.clone(),
Style::default()
.add_modifier(x.get_modifiers())
.fg(x.fg)
.bg(x.bg),
.fg(fg)
.bg(bg),
)
})
.collect(),