pub trait InputHighlighter {
// Required methods
fn language(&self) -> SharedString;
fn update(
&mut self,
edit: Option<InputEdit>,
text: &Rope,
folding: bool,
window: &mut Window,
cx: &mut Context<'_, InputBaseState<EditorMode>>,
);
fn styles(
&self,
range: &Range<usize>,
resolver: &dyn HighlightStyleResolver,
) -> Vec<(Range<usize>, HighlightStyle)>;
fn fold_ranges(&self, text: &Rope) -> Vec<FoldRange>;
// Provided methods
fn update_batch(
&mut self,
edits: &[(InputEdit, Rope)],
folding: bool,
window: &mut Window,
cx: &mut Context<'_, InputBaseState<EditorMode>>,
) { ... }
fn fold_ranges_for_edit(
&self,
range: Range<usize>,
text: &Rope,
) -> Vec<FoldRange> { ... }
}Expand description
Parser-independent syntax highlighting seam consumed by the Base editor.
Implementations own parsing, incremental state, and language-specific behavior. Base only asks for styled ranges and fold candidates.
Required Methods§
fn language(&self) -> SharedString
fn update( &mut self, edit: Option<InputEdit>, text: &Rope, folding: bool, window: &mut Window, cx: &mut Context<'_, InputBaseState<EditorMode>>, )
Sourcefn styles(
&self,
range: &Range<usize>,
resolver: &dyn HighlightStyleResolver,
) -> Vec<(Range<usize>, HighlightStyle)>
fn styles( &self, range: &Range<usize>, resolver: &dyn HighlightStyleResolver, ) -> Vec<(Range<usize>, HighlightStyle)>
Return ordered, non-overlapping style runs that fully cover range.
Use HighlightStyle::default for text without a semantic style.
fn fold_ranges(&self, text: &Rope) -> Vec<FoldRange>
Provided Methods§
Sourcefn update_batch(
&mut self,
edits: &[(InputEdit, Rope)],
folding: bool,
window: &mut Window,
cx: &mut Context<'_, InputBaseState<EditorMode>>,
)
fn update_batch( &mut self, edits: &[(InputEdit, Rope)], folding: bool, window: &mut Window, cx: &mut Context<'_, InputBaseState<EditorMode>>, )
Apply several edits made as one change, such as typing with multiple cursors. Each entry is an edit with the text as it stood right after it, in the order the edits were applied.
The default hands each edit to Self::update in turn. Override it to
reparse once for the whole change.
fn fold_ranges_for_edit( &self, range: Range<usize>, text: &Rope, ) -> Vec<FoldRange>
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".