on master help sign in
Support combination of multiple styles at the same time
4021cf8Pavel Aslanov
src/terminal.rs+9−9
@@ -34,17 +34,17 @@ pub fn as_terminal_escaped(
34 let mut style = if !colored {
34 let mut style = if !colored {
35 Style::default()
35 Style::default()
36 } else {
36 } else {
37− let color = to_ansi_color(style.foreground, true_color);
37+ let mut color = Style::from(to_ansi_color(style.foreground, true_color));
38−
39 if style.font_style.contains(FontStyle::BOLD) {
38 if style.font_style.contains(FontStyle::BOLD) {
40− color.bold()
39+ color = color.bold();
40+ }
41− } else if style.font_style.contains(FontStyle::UNDERLINE) {
41+ if style.font_style.contains(FontStyle::UNDERLINE) {
42− color.underline()
42+ color = color.underline();
43+ }
43− } else if italics && style.font_style.contains(FontStyle::ITALIC) {
44+ if italics && style.font_style.contains(FontStyle::ITALIC) {
44− color.italic()
45+ color = color.italic();
45− } else {
46− color.normal()
47 }
46 }
47+ color
48 };
48 };
49
49
50 style.background = background_color.map(|c| to_ansi_color(c, true_color));
50 style.background = background_color.map(|c| to_ansi_color(c, true_color));