diff options
author | Nisheet Sinvhal <nisheet1.sinvhal@gmail.com> | 2018-11-04 22:38:33 +0530 |
---|---|---|
committer | David Peter <sharkdp@users.noreply.github.com> | 2018-11-04 19:40:05 +0100 |
commit | 18d1a3b97337b60e9e3c38694560271384545f2e (patch) | |
tree | 6aa3570a77b39247975b30fdb9085ca3dc7603f0 | |
parent | dc10246bd229ba0aa4bcd732b2b6409496764163 (diff) |
Changed italics to use-italic-text in config
Better placing of italics in help and also added long_help for it
-rw-r--r-- | src/app.rs | 4 | ||||
-rw-r--r-- | src/clap_app.rs | 22 | ||||
-rw-r--r-- | src/printer.rs | 6 | ||||
-rw-r--r-- | src/terminal.rs | 2 |
4 files changed, 17 insertions, 17 deletions
@@ -77,7 +77,7 @@ pub struct Config<'a> { /// Command to start the pager pub pager: Option<&'a str>, - pub italics: bool, + pub use_italic_text: bool, } fn is_truecolor_terminal() -> bool { @@ -260,7 +260,7 @@ impl App { output_components, syntax_mapping, pager: self.matches.value_of("pager"), - italics: match self.matches.value_of("italic-text") { + use_italic_text: match self.matches.value_of("italic-text") { Some("always") => true, _ => false, }, diff --git a/src/clap_app.rs b/src/clap_app.rs index 8ed8ef82..2999a6be 100644 --- a/src/clap_app.rs +++ b/src/clap_app.rs @@ -203,6 +203,17 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> { ), ) .arg( + Arg::with_name("italic-text") + .long("italic-text") + .takes_value(true) + .value_name("when") + .possible_values(&["always", "never"]) + .default_value("never") + .hide_default_value(true) + .help("Use italics in output (always, *never*)") + .long_help("Specify when to use ANSI sequences for italic text in the output. Possible values: always, *never*."), + ) + .arg( Arg::with_name("decorations") .long("decorations") .overrides_with("decorations") @@ -320,17 +331,6 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> { .hidden(true) .help("Show path to the configuration file."), ) - .arg( - Arg::with_name("italic-text") - .long("italic-text") - .takes_value(true) - .multiple(false) - .value_name("always|*never*") - .possible_values(&["always", "never"]) - .default_value("never") - .hide_default_value(true) - .help("Use italics in output (always, *never*)"), - ) .subcommand( SubCommand::with_name("cache") .about("Modify the syntax-definition and theme cache") diff --git a/src/printer.rs b/src/printer.rs index 0c372187..1fc0343e 100644 --- a/src/printer.rs +++ b/src/printer.rs @@ -305,7 +305,7 @@ impl<'a> Printer for InteractivePrinter<'a> { if self.config.output_wrap == OutputWrap::None { let true_color = self.config.true_color; let colored_output = self.config.colored_output; - let italics = self.config.italics; + let italics = self.config.use_italic_text; for &(style, region) in regions.iter() { let text = &*self.preprocess(region, &mut cursor_total); @@ -368,7 +368,7 @@ impl<'a> Printer for InteractivePrinter<'a> { ), self.config.true_color, self.config.colored_output, - self.config.italics + self.config.use_italic_text ) )?; break; @@ -408,7 +408,7 @@ impl<'a> Printer for InteractivePrinter<'a> { ), self.config.true_color, self.config.colored_output, - self.config.italics + self.config.use_italic_text ), panel_wrap.clone().unwrap() )?; diff --git a/src/terminal.rs b/src/terminal.rs index 630ac48f..eeb15cbd 100644 --- a/src/terminal.rs +++ b/src/terminal.rs @@ -29,7 +29,7 @@ pub fn as_terminal_escaped( color.bold() } else if style.font_style.contains(FontStyle::UNDERLINE) { color.underline() - } else if style.font_style.contains(FontStyle::ITALIC) && italics { + } else if italics && style.font_style.contains(FontStyle::ITALIC) { color.italic() } else { color.normal() |