Skip to main content

InputExtras

Trait InputExtras 

Source
pub trait InputExtras: Default + 'static {
    // Provided methods
    fn decoration_layers(&self) -> Vec<&[TextDecoration]> { ... }
    fn semantic_token_styles(
        &self,
        _text: &Rope,
        _range: &Range<usize>,
        _resolver: &dyn HighlightStyleResolver,
    ) -> Vec<(Range<usize>, HighlightStyle)> { ... }
    fn document_color_swatches(
        &self,
        _text: &Rope,
        _range: &Range<usize>,
    ) -> Vec<(Range<usize>, Hsla)> { ... }
    fn hover_symbol_range(&self) -> Option<Range<usize>> { ... }
    fn inline_completion_item(&self) -> Option<&InlineCompletionItem> { ... }
    fn context_menu_capabilities(&self) -> (bool, bool) { ... }
}
Expand description

What the renderer may read out of a mode’s extra state.

Kept apart from InputModeKind on purpose. This trait is data: the renderer is generic over the mode, so it cannot name EditorExtras and reach its fields directly, and these are the accessors it goes through instead. Every one of them has an empty answer, which is what a plain input and a textarea give.

InputModeKind is behavior: points where the engine hands control back during an edit. Adding a field an editor renders belongs here and leaves the engine’s callbacks alone.

Provided Methods§

Source

fn decoration_layers(&self) -> Vec<&[TextDecoration]>

Decoration ranges to paint, innermost collection first.

Source

fn semantic_token_styles( &self, _text: &Rope, _range: &Range<usize>, _resolver: &dyn HighlightStyleResolver, ) -> Vec<(Range<usize>, HighlightStyle)>

Semantic-token styles for a visible range, when an LSP supplies them.

Source

fn document_color_swatches( &self, _text: &Rope, _range: &Range<usize>, ) -> Vec<(Range<usize>, Hsla)>

Document colours to paint as swatches, when an LSP supplies them.

Source

fn hover_symbol_range(&self) -> Option<Range<usize>>

The symbol range the hover popover is anchored to.

Source

fn inline_completion_item(&self) -> Option<&InlineCompletionItem>

The inline completion to paint as ghost text.

Source

fn context_menu_capabilities(&self) -> (bool, bool)

What this mode can offer its context menu: go-to-definition, code actions.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl InputExtras for ()

A mode with nothing extra to render.

Implementors§

Source§

impl InputExtras for EditorExtras

What a code editor exposes to the renderer. See crate::input::InputExtras.