Fix colors using blend

This commit is contained in:
Dheepak Krishnamurthy 2021-02-14 19:02:16 -07:00
parent 62c9e2f02c
commit 374f90a348

View file

@ -5,13 +5,20 @@ use std::str;
use tui::style::{Color, Modifier, Style}; use tui::style::{Color, Modifier, Style};
pub fn blend(style: Style, c: TColor) -> Style { pub fn blend(style: Style, c: TColor) -> Style {
let mut style = style.fg(c.fg); let mut style = style;
if style.fg.is_none() || c.fg != Color::Reset {
style = style.fg(c.fg);
}
if style.bg.is_none() || c.bg != Color::Reset { if style.bg.is_none() || c.bg != Color::Reset {
style = style.bg(c.bg); style = style.bg(c.bg);
} }
for modifier in c.modifiers {
style = style.add_modifier(modifier); for m in c.modifiers {
style = style.add_modifier(m);
} }
style style
} }