Skip to main content

Highlighter

Trait Highlighter 

pub trait Highlighter {
    // Required method
    fn spans(&self, line: &str, carry: u64) -> LineSpans;
}
Expand description

A pluggable, per-line source tokenizer. The CodeEditor owns rendering, caret, and selection; a Highlighter owns only the language lexing — mapping a line of source to coloured Spans. SyntaxHighlighter covers every language with a grammar; hand it (or a wrapper that adds app-specific spans) to CodeEditor::with_highlighter.

Required Methods§

fn spans(&self, line: &str, carry: u64) -> LineSpans

line never contains \n. carry is the HlState the previous line left (0 for the first line); the returned LineSpans::carry is what the following line begins with. Byte ranges in the returned spans are relative to line.

Implementors§