color: add italic to style attributes
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Closes #2841
authored by Tor Shepherd · committed by Andrew Gallant · parent edafb61 · Browse files · 5 files·+18 added−6 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
5 files+18 added−6 removed
- tests:+1 added−1 removed
- other:+17 added−5 removed
Provenance
- Commit
da672f8- Tree
bcdd778- Author
Tor Shepherd <tor.aksel.shepherd@gmail.com>- Committer
Andrew Gallant <jamslam@gmail.com>- Parent
edafb61
5 files changed+18 added−6 removed
modified:crates/core/flags/defs.rs+1 added-1 removed
833 unmodified lines834 provided multiple times. Settings are applied iteratively. Pre-existing color835 labels are limited to one of eight choices: \fBred\fP, \fBblue\fP, \fBgreen\fP,836 \fBcyan\fP, \fBmagenta\fP, \fByellow\fP, \fBwhite\fP and \fBblack\fP. Styles837 are limited to \fBnobold\fP, \fBbold\fP, \fBnointense\fP, \fBintense\fP,838-\fBnounderline\fP or \fBunderline\fP.838+\fBnounderline\fP, \fBunderline\fP, \fBnoitalic\fP or \fBitalic\fP.839 .sp840 The format of the flag is841 \fB{\fP\fItype\fP\fB}:{\fP\fIattribute\fP\fB}:{\fP\fIvalue\fP\fB}\fP.842 \fItype\fP should be one of \fBpath\fP, \fBline\fP, \fBcolumn\fP or6833 unmodified linesmodified:crates/printer/src/color.rs+12 added-2 removed
63 unmodified lines64 ColorError::UnrecognizedStyle(ref name) => write!(65 f,66 "unrecognized style attribute '{}'. Choose from: \67 nobold, bold, nointense, intense, nounderline, \68- underline.",68+ underline, noitalic, italic.",69 name,70 ),71 ColorError::InvalidFormat(ref original) => write!(72 f,47 unmodified lines120 /// decimal number of a hexadecimal number, where the latter is prefixed by121 /// `0x`.122 ///123 /// Valid style instructions are `nobold`, `bold`, `intense`, `nointense`,124-/// `underline`, `nounderline`.124+/// `underline`, `nounderline`, `italic`, `noitalic`.125 ///126 /// ## Example127 ///128 /// The standard way to build a `UserColorSpec` is to parse it from a string.71 unmodified lines200 Intense,201 NoIntense,202 Underline,203 NoUnderline,204+ Italic,205+ NoItalic,206 }207 208 impl ColorSpecs {209 /// Create color specifications from a list of user supplied77 unmodified lines287 }288 Style::NoUnderline => {289 cspec.set_underline(false);290 }291+ Style::Italic => {292+ cspec.set_italic(true);293+ }294+ Style::NoItalic => {295+ cspec.set_italic(false);296+ }297 },298 }299 }300 }76 unmodified lines377 "intense" => Ok(Style::Intense),378 "nointense" => Ok(Style::NoIntense),379 "underline" => Ok(Style::Underline),380 "nounderline" => Ok(Style::NoUnderline),381+ "italic" => Ok(Style::Italic),382+ "noitalic" => Ok(Style::NoItalic),383 _ => Err(ColorError::UnrecognizedStyle(s.to_string())),384 }385 }386 }modified:tests/regression.rs+1 added-1 removed
402 unmodified lines403 let stderr = String::from_utf8_lossy(&output.stderr);404 let expected = "\405 rg: error parsing flag --colors: \406 unrecognized style attribute ''. Choose from: nobold, bold, nointense, \407-intense, nounderline, underline.407+intense, nounderline, underline, noitalic, italic.408 ";409 eqnice!(expected, stderr);410 });411 1008 unmodified linesmodified:CHANGELOG.md+2 added
16 unmodified lines17 Feature enhancements:18 19 * [FEATURE #2708](https://github.com/BurntSushi/ripgrep/pull/2708):20 Completions for the fish shell take ripgrep's config file into account.21+* [FEATURE #2841](https://github.com/BurntSushi/ripgrep/pull/2841):22+ Add `italic` to the list of available style attributes in `--color`.23 24 25 14.1.1 (2024-09-08)26 ===================1709 unmodified linesmodified:FAQ.md+2 added-2 removed
263 unmodified lines264 foreground color, background color, or miscellaneous styling (such as whether265 to bold the output or not).266 * `{value}` is determined by the value of `{attribute}`. If267 `{attribute}` is `style`, then `{value}` should be one of `nobold`,268- `bold`, `nointense`, `intense`, `nounderline` or `underline`. If269- `{attribute}` is `fg` or `bg`, then `{value}` should be a color.268+ `bold`, `nointense`, `intense`, `nounderline`, `underline`, `noitalic` or269+ `italic`. If `{attribute}` is `fg` or `bg`, then `{value}` should be a color.270 271 A color is specified by either one of eight of English names, a single 256-bit272 number or an RGB triple (with over 16 million possible values, or "true273 color").790 unmodified lines