Draft Highlighter API

This commit is contained in:
Héctor Ramón Jiménez 2023-09-17 15:29:14 +02:00
parent 723111bb0d
commit 76dc82e8e8
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
10 changed files with 218 additions and 19 deletions

View file

@ -1,5 +1,6 @@
//! Change the appearance of a text editor.
use iced_core::{Background, BorderRadius, Color};
use crate::core::text::highlighter;
use crate::core::{self, Background, BorderRadius, Color};
/// The appearance of a text input.
#[derive(Debug, Clone, Copy)]
@ -45,3 +46,16 @@ pub trait StyleSheet {
/// Produces the style of a disabled text input.
fn disabled(&self, style: &Self::Style) -> Appearance;
}
pub trait Highlight<Font = core::Font, Theme = crate::Theme> {
fn format(&self, theme: &Theme) -> highlighter::Format<Font>;
}
impl<Font, Theme> Highlight<Font, Theme> for () {
fn format(&self, _theme: &Theme) -> highlighter::Format<Font> {
highlighter::Format {
color: None,
font: None,
}
}
}