italics enable|disable working

pull/400/head
Nisheet Sinvhal 6 years ago committed by David Peter
parent d702d6740c
commit e90308e1f8

@ -324,10 +324,12 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
Arg::with_name("enable-italics") Arg::with_name("enable-italics")
.long("enable-italics") .long("enable-italics")
.takes_value(true) .takes_value(true)
.multiple(false)
.value_name("always|*never*")
.possible_values(&["always", "never"]) .possible_values(&["always", "never"])
.default_value("never") .default_value("never")
.hide_default_value(true) .hide_default_value(true)
.help("Use italics in output (always, *never)") .help("Use italics in output (always, *never*)")
) )
.subcommand( .subcommand(
SubCommand::with_name("cache") SubCommand::with_name("cache")

@ -305,13 +305,14 @@ impl<'a> Printer for InteractivePrinter<'a> {
if self.config.output_wrap == OutputWrap::None { if self.config.output_wrap == OutputWrap::None {
let true_color = self.config.true_color; let true_color = self.config.true_color;
let colored_output = self.config.colored_output; let colored_output = self.config.colored_output;
let italics = self.config.italics;
for &(style, region) in regions.iter() { for &(style, region) in regions.iter() {
let text = &*self.preprocess(region, &mut cursor_total); let text = &*self.preprocess(region, &mut cursor_total);
write!( write!(
handle, handle,
"{}", "{}",
as_terminal_escaped(style, &*text, true_color, colored_output,) as_terminal_escaped(style, &*text, true_color, colored_output, italics,)
)?; )?;
} }
@ -367,6 +368,7 @@ impl<'a> Printer for InteractivePrinter<'a> {
), ),
self.config.true_color, self.config.true_color,
self.config.colored_output, self.config.colored_output,
self.config.italics
) )
)?; )?;
break; break;
@ -406,6 +408,7 @@ impl<'a> Printer for InteractivePrinter<'a> {
), ),
self.config.true_color, self.config.true_color,
self.config.colored_output, self.config.colored_output,
self.config.italics
), ),
panel_wrap.clone().unwrap() panel_wrap.clone().unwrap()
)?; )?;

@ -18,6 +18,7 @@ pub fn as_terminal_escaped(
text: &str, text: &str,
true_color: bool, true_color: bool,
colored: bool, colored: bool,
italics: bool,
) -> String { ) -> String {
let style = if !colored { let style = if !colored {
Style::default() Style::default()
@ -28,7 +29,7 @@ pub fn as_terminal_escaped(
color.bold() color.bold()
} else if style.font_style.contains(FontStyle::UNDERLINE) { } else if style.font_style.contains(FontStyle::UNDERLINE) {
color.underline() color.underline()
} else if style.font_style.contains(FontStyle::ITALIC) { } else if style.font_style.contains(FontStyle::ITALIC) && italics {
color.italic() color.italic()
} else { } else {
color.normal() color.normal()

Loading…
Cancel
Save