From 4021cf812828d59e17459570631954ec27e43434 Mon Sep 17 00:00:00 2001 From: Pavel Aslanov Date: Wed, 4 Mar 2020 12:05:10 +0000 Subject: [PATCH] Support combination of multiple styles at the same time Old version of the code did not allowed for `bold italic` or `bold underline` styles --- src/terminal.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/terminal.rs b/src/terminal.rs index 4f7c1d67..8c3766c5 100644 --- a/src/terminal.rs +++ b/src/terminal.rs @@ -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));