pub fn highlight_substring(
text: &str,
query: &str,
base_style: Style,
highlight_style: Style,
) -> Line<'static>Expand description
Highlight substring matches in text (case-insensitive)
Returns a Line with matching portions styled using highlight_style.
Non-matching portions use the base_style.
§Example
ⓘ
use tui_dispatch_components::style::{highlight_substring, Style, Color, Modifier};
let base = Style::default();
let highlight = Style::default().fg(Color::Yellow).add_modifier(Modifier::BOLD);
let line = highlight_substring("Hello World", "wor", base, highlight);
// Results in: "Hello " (base) + "Wor" (highlight) + "ld" (base)§Notes
- Matching is case-insensitive
- Only works with ASCII text; non-ASCII returns the text with base style
- Empty query returns the text with base style