From 373493be85f9bace92dd03e5595e43ad5dc59c9b Mon Sep 17 00:00:00 2001 From: Rob Warner Date: Thu, 12 Sep 2019 17:10:42 -0400 Subject: feat: Add support for italic styles (#354) (#358) --- src/config.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/config.rs') diff --git a/src/config.rs b/src/config.rs index fc23a327e..d54767a65 100644 --- a/src/config.rs +++ b/src/config.rs @@ -174,6 +174,7 @@ impl Config for Table { - 'bg:' (specifies that the color read should be a background color) - 'underline' - 'bold' + - 'italic' - '' (see the parse_color_string doc for valid color strings) */ fn parse_style_string(style_string: &str) -> Option { @@ -201,6 +202,7 @@ fn parse_style_string(style_string: &str) -> Option { match token.as_str() { "underline" => style = style.underline(), "bold" => style = style.bold(), + "italic" => style = style.italic(), "dimmed" => style = style.dimmed(), "none" => return Some(ansi_term::Style::new()), // Overrides other toks @@ -339,16 +341,21 @@ mod tests { fn table_get_styles_simple() { let mut table = toml::value::Table::new(); - // Test for a bold underline green module (with SiLlY cApS) + // Test for a bold italic underline green module (with SiLlY cApS) table.insert( String::from("mystyle"), - toml::value::Value::String(String::from("bOlD uNdErLiNe GrEeN")), + toml::value::Value::String(String::from("bOlD ItAlIc uNdErLiNe GrEeN")), ); assert!(table.get_as_ansi_style("mystyle").unwrap().is_bold); + assert!(table.get_as_ansi_style("mystyle").unwrap().is_italic); assert!(table.get_as_ansi_style("mystyle").unwrap().is_underline); assert_eq!( table.get_as_ansi_style("mystyle").unwrap(), - ansi_term::Style::new().bold().underline().fg(Color::Green) + ansi_term::Style::new() + .bold() + .italic() + .underline() + .fg(Color::Green) ); // Test a "plain" style with no formatting -- cgit v1.2.3