Skip to main content

InputHighlighter

Trait InputHighlighter 

Source
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 method
    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§

Source

fn language(&self) -> SharedString

Source

fn update( &mut self, edit: Option<InputEdit>, text: &Rope, folding: bool, window: &mut Window, cx: &mut Context<'_, InputBaseState<EditorMode>>, )

Source

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.

Source

fn fold_ranges(&self, text: &Rope) -> Vec<FoldRange>

Provided Methods§

Source

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".

Implementors§