1
0
mirror of https://github.com/BurntSushi/ripgrep.git synced 2025-08-04 21:52:54 +02:00

color: add italic to style attributes

Closes #2841
This commit is contained in:
Tor Shepherd
2024-06-21 15:11:25 -04:00
committed by Andrew Gallant
parent aebab44e3e
commit ff8afcf8aa
5 changed files with 18 additions and 6 deletions

View File

@ -18,6 +18,8 @@ Feature enhancements:
* [FEATURE #2708](https://github.com/BurntSushi/ripgrep/pull/2708):
Completions for the fish shell take ripgrep's config file into account.
* [FEATURE #2841](https://github.com/BurntSushi/ripgrep/pull/2841):
Add `italic` to the list of available style attributes in `--color`.
14.1.1 (2024-09-08)

4
FAQ.md
View File

@ -265,8 +265,8 @@ The `--colors` flag is a bit more complicated. The general format is:
to bold the output or not).
* `{value}` is determined by the value of `{attribute}`. If
`{attribute}` is `style`, then `{value}` should be one of `nobold`,
`bold`, `nointense`, `intense`, `nounderline` or `underline`. If
`{attribute}` is `fg` or `bg`, then `{value}` should be a color.
`bold`, `nointense`, `intense`, `nounderline`, `underline`, `noitalic` or
`italic`. If `{attribute}` is `fg` or `bg`, then `{value}` should be a color.
A color is specified by either one of eight of English names, a single 256-bit
number or an RGB triple (with over 16 million possible values, or "true

View File

@ -835,7 +835,7 @@ provided multiple times. Settings are applied iteratively. Pre-existing color
labels are limited to one of eight choices: \fBred\fP, \fBblue\fP, \fBgreen\fP,
\fBcyan\fP, \fBmagenta\fP, \fByellow\fP, \fBwhite\fP and \fBblack\fP. Styles
are limited to \fBnobold\fP, \fBbold\fP, \fBnointense\fP, \fBintense\fP,
\fBnounderline\fP or \fBunderline\fP.
\fBnounderline\fP, \fBunderline\fP, \fBnoitalic\fP or \fBitalic\fP.
.sp
The format of the flag is
\fB{\fP\fItype\fP\fB}:{\fP\fIattribute\fP\fB}:{\fP\fIvalue\fP\fB}\fP.

View File

@ -65,7 +65,7 @@ impl std::fmt::Display for ColorError {
f,
"unrecognized style attribute '{}'. Choose from: \
nobold, bold, nointense, intense, nounderline, \
underline.",
underline, noitalic, italic.",
name,
),
ColorError::InvalidFormat(ref original) => write!(
@ -121,7 +121,7 @@ pub struct ColorSpecs {
/// `0x`.
///
/// Valid style instructions are `nobold`, `bold`, `intense`, `nointense`,
/// `underline`, `nounderline`.
/// `underline`, `nounderline`, `italic`, `noitalic`.
///
/// ## Example
///
@ -201,6 +201,8 @@ enum Style {
NoIntense,
Underline,
NoUnderline,
Italic,
NoItalic,
}
impl ColorSpecs {
@ -286,6 +288,12 @@ impl SpecValue {
Style::NoUnderline => {
cspec.set_underline(false);
}
Style::Italic => {
cspec.set_italic(true);
}
Style::NoItalic => {
cspec.set_italic(false);
}
},
}
}
@ -370,6 +378,8 @@ impl std::str::FromStr for Style {
"nointense" => Ok(Style::NoIntense),
"underline" => Ok(Style::Underline),
"nounderline" => Ok(Style::NoUnderline),
"italic" => Ok(Style::Italic),
"noitalic" => Ok(Style::NoItalic),
_ => Err(ColorError::UnrecognizedStyle(s.to_string())),
}
}

View File

@ -404,7 +404,7 @@ rgtest!(r428_unrecognized_style, |dir: Dir, mut cmd: TestCommand| {
let expected = "\
rg: error parsing flag --colors: \
unrecognized style attribute ''. Choose from: nobold, bold, nointense, \
intense, nounderline, underline.
intense, nounderline, underline, noitalic, italic.
";
eqnice!(expected, stderr);
});