Implement theme selector in editor example

This commit is contained in:
Héctor Ramón Jiménez 2023-09-18 14:38:54 +02:00
parent 61ef8f3249
commit 8446fe6de5
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
3 changed files with 100 additions and 23 deletions

View file

@ -1,10 +1,9 @@
use crate::Color;
use std::hash::Hash;
use std::ops::Range;
pub trait Highlighter: 'static {
type Settings: Hash;
type Settings: PartialEq + Clone;
type Highlight;
type Iterator<'a>: Iterator<Item = (Range<usize>, Self::Highlight)>
@ -13,6 +12,8 @@ pub trait Highlighter: 'static {
fn new(settings: &Self::Settings) -> Self;
fn update(&mut self, new_settings: &Self::Settings);
fn change_line(&mut self, line: usize);
fn highlight_line(&mut self, line: &str) -> Self::Iterator<'_>;
@ -38,6 +39,8 @@ impl Highlighter for PlainText {
Self
}
fn update(&mut self, _new_settings: &Self::Settings) {}
fn change_line(&mut self, _line: usize) {}
fn highlight_line(&mut self, _line: &str) -> Self::Iterator<'_> {