mirror of
https://github.com/sharkdp/bat.git
synced 2025-02-20 20:08:58 +00:00
italics enable|disable working
This commit is contained in:
parent
d702d6740c
commit
e90308e1f8
@ -324,10 +324,12 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
|
||||
Arg::with_name("enable-italics")
|
||||
.long("enable-italics")
|
||||
.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)")
|
||||
.help("Use italics in output (always, *never*)")
|
||||
)
|
||||
.subcommand(
|
||||
SubCommand::with_name("cache")
|
||||
|
@ -305,13 +305,14 @@ 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;
|
||||
|
||||
for &(style, region) in regions.iter() {
|
||||
let text = &*self.preprocess(region, &mut cursor_total);
|
||||
write!(
|
||||
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.colored_output,
|
||||
self.config.italics
|
||||
)
|
||||
)?;
|
||||
break;
|
||||
@ -406,6 +408,7 @@ impl<'a> Printer for InteractivePrinter<'a> {
|
||||
),
|
||||
self.config.true_color,
|
||||
self.config.colored_output,
|
||||
self.config.italics
|
||||
),
|
||||
panel_wrap.clone().unwrap()
|
||||
)?;
|
||||
|
@ -18,6 +18,7 @@ pub fn as_terminal_escaped(
|
||||
text: &str,
|
||||
true_color: bool,
|
||||
colored: bool,
|
||||
italics: bool,
|
||||
) -> String {
|
||||
let style = if !colored {
|
||||
Style::default()
|
||||
@ -28,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) {
|
||||
} else if style.font_style.contains(FontStyle::ITALIC) && italics {
|
||||
color.italic()
|
||||
} else {
|
||||
color.normal()
|
||||
|
Loading…
x
Reference in New Issue
Block a user