Support combination of multiple styles at the same time

Old version of the code did not allowed for `bold italic` or `bold underline` styles
This commit is contained in:
Pavel Aslanov 2020-03-04 12:05:10 +00:00 committed by David Peter
parent 7155f76963
commit 4021cf8128

View File

@ -34,17 +34,17 @@ pub fn as_terminal_escaped(
let mut style = if !colored {
Style::default()
} else {
let color = to_ansi_color(style.foreground, true_color);
let mut color = Style::from(to_ansi_color(style.foreground, true_color));
if style.font_style.contains(FontStyle::BOLD) {
color.bold()
} else if style.font_style.contains(FontStyle::UNDERLINE) {
color.underline()
} else if italics && style.font_style.contains(FontStyle::ITALIC) {
color.italic()
} else {
color.normal()
color = color.bold();
}
if style.font_style.contains(FontStyle::UNDERLINE) {
color = color.underline();
}
if italics && style.font_style.contains(FontStyle::ITALIC) {
color = color.italic();
}
color
};
style.background = background_color.map(|c| to_ansi_color(c, true_color));