Changed italics to use-italic-text in config

Better placing of italics in help and also added long_help for it
This commit is contained in:
Nisheet Sinvhal 2018-11-04 22:38:33 +05:30 committed by David Peter
parent dc10246bd2
commit 18d1a3b973
4 changed files with 17 additions and 17 deletions

View File

@ -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,
},

View File

@ -202,6 +202,17 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
Possible values: *auto*, never, always.",
),
)
.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")
@ -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")

View File

@ -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()
)?;

View File

@ -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()