Skip to content
Myr

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

5 files+18 added−6 removed

modified:crates/core/flags/defs.rs+1 added-1 removed
833 unmodified lines
834provided multiple times. Settings are applied iteratively. Pre-existing color835labels 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. Styles837are 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.sp840The 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 or
6833 unmodified lines
modified:crates/printer/src/color.rs+12 added-2 removed
63 unmodified lines
64 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 lines
120/// 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 lines
200 Intense,201 NoIntense,202 Underline,203 NoUnderline,204 Italic,205 NoItalic,206}207208impl ColorSpecs {209 /// Create color specifications from a list of user supplied
77 unmodified lines
287 }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 lines
377 "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 lines
403 let stderr = String::from_utf8_lossy(&output.stderr);404 let expected = "\405rg: error parsing flag --colors: \406unrecognized style attribute ''. Choose from: nobold, bold, nointense, \407intense, nounderline, underline.407intense, nounderline, underline, noitalic, italic.408";409 eqnice!(expected, stderr);410});411
1008 unmodified lines
modified:CHANGELOG.md+2 added
16 unmodified lines
17Feature enhancements:1819* [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`.23242514.1.1 (2024-09-08)26===================
1709 unmodified lines
modified:FAQ.md+2 added-2 removed
263 unmodified lines
264 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.270271A color is specified by either one of eight of English names, a single 256-bit272number or an RGB triple (with over 16 million possible values, or "true273color").
790 unmodified lines