pub trait Highlighter: 'static {
    type Settings: PartialEq + Clone;
    type Highlight;
    type Iterator<'a>: Iterator<Item = (Range<usize>, Self::Highlight)>
       where Self: 'a;

    // Required methods
    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<'_>;
    fn current_line(&self) -> usize;
}
Available on crate feature advanced only.
Expand description

A type capable of highlighting text.

A Highlighter highlights lines in sequence. When a line changes, it must be notified and the lines after the changed one must be fed again to the Highlighter.

Required Associated Types§

source

type Settings: PartialEq + Clone

The settings to configure the Highlighter.

source

type Highlight

The output of the Highlighter.

source

type Iterator<'a>: Iterator<Item = (Range<usize>, Self::Highlight)> where Self: 'a

The highlight iterator type.

Required Methods§

source

fn new(settings: &Self::Settings) -> Self

Creates a new Highlighter from its Self::Settings.

source

fn update(&mut self, new_settings: &Self::Settings)

Updates the Highlighter with some new Self::Settings.

source

fn change_line(&mut self, line: usize)

Notifies the Highlighter that the line at the given index has changed.

source

fn highlight_line(&mut self, line: &str) -> Self::Iterator<'_>

Highlights the given line.

If a line changed prior to this, the first line provided here will be the line that changed.

source

fn current_line(&self) -> usize

Returns the current line of the Highlighter.

If change_line has been called, this will normally be the least index that changed.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Highlighter for Highlighter

§

type Settings = Settings

§

type Highlight = Highlight

§

type Iterator<'a> = Box<dyn Iterator<Item = (Range<usize>, <Highlighter as Highlighter>::Highlight)> + 'a>

source§

fn new(settings: &<Highlighter as Highlighter>::Settings) -> Highlighter

source§

fn update(&mut self, new_settings: &<Highlighter as Highlighter>::Settings)

source§

fn change_line(&mut self, line: usize)

source§

fn highlight_line( &mut self, line: &str ) -> <Highlighter as Highlighter>::Iterator<'_>

source§

fn current_line(&self) -> usize

Implementors§