Skip to main content

apply_highlight

Function apply_highlight 

Source
pub fn apply_highlight(
    spans: &[Span],
    ranges: &[(usize, usize)],
    highlight_style: Style,
) -> Vec<Span>
Expand description

Apply highlighting to spans using grapheme-index ranges.

Ranges are expressed as half-open intervals (start, end) in grapheme indices over the concatenated plain text (spans_plain_text).

Highlighting is applied by overlaying the provided highlight_style onto the base span style:

  • fg / bg fields from highlight_style replace the base fields when they are Some.
  • dim, bold, italic, underline, blink, inverse, and strike are ORed with the base flags.

Invalid ranges (where start >= end) are ignored.