iced_core/text/
highlighter.rs1use crate::Color;
3use crate::font;
4
5pub trait Highlighter<Input, Theme = crate::Theme> {
8 fn id(&self) -> &str;
10
11 fn highlight(&self, input: Input, theme: &Theme) -> Style;
13}
14
15#[derive(Debug, Clone, Copy, PartialEq, Default)]
17pub struct Style {
18 pub color: Option<Color>,
20 pub style: Option<font::Style>,
22}
23
24impl<T, Input, Theme> Highlighter<Input, Theme> for T
25where
26 T: Fn(Input, &Theme) -> Style,
27{
28 fn id(&self) -> &str {
29 std::any::type_name_of_val(self) }
31
32 fn highlight(&self, input: Input, theme: &Theme) -> Style {
33 (self)(input, theme)
34 }
35}