pub trait SyntaxHighlighter: Send + Sync {
// Required method
fn highlight_block(&self, text: &str, ctx: &mut HighlightContext);
}Expand description
A user-implemented syntax highlighter that applies visual-only formatting.
Inspired by Qt’s QSyntaxHighlighter. Implement this trait and attach it
to a document via TextDocument::set_syntax_highlighter.
The highlighter is called once per block when the document content changes.
Use HighlightContext::set_format to apply highlight spans. Use
HighlightContext::set_current_block_state and
HighlightContext::previous_block_state for multi-block constructs
(e.g., multiline comments).
Required Methods§
Sourcefn highlight_block(&self, text: &str, ctx: &mut HighlightContext)
fn highlight_block(&self, text: &str, ctx: &mut HighlightContext)
Called for each block that needs re-highlighting.