Skip to main content

InputModeKind

Trait InputModeKind 

Source
pub trait InputModeKind:
    Sealed
    + Sized
    + 'static {
    type Extras: InputExtras;

    const MULTI_LINE: bool;
    const CODE_EDITOR: bool = false;
Show 19 methods // Provided methods fn drive_highlighter( _highlighter: &Rc<RefCell<Option<Box<dyn InputHighlighter>>>>, _edit: InputEdit, _text: &Rope, _folding: bool, _window: &mut Window, _cx: &mut Context<'_, InputBaseState<Self>>, ) { ... } fn hover_definition_style( _state: &InputBaseState<Self>, _cx: &App, ) -> Option<(Range<usize>, HighlightStyle)> { ... } fn hover_definition_hitbox( _state: &InputBaseState<Self>, _window: &mut Window, _cx: &App, ) -> Option<Hitbox> { ... } fn reset_language_features(_state: &mut InputBaseState<Self>) { ... } fn reset_annotations(_state: &mut InputBaseState<Self>) { ... } fn adjust_annotations( _state: &mut InputBaseState<Self>, _range: &Range<usize>, _new_len: usize, ) { ... } fn refresh_language_features( _state: &mut InputBaseState<Self>, _window: &mut Window, _cx: &mut Context<'_, InputBaseState<Self>>, ) { ... } fn accept_inline_completion( _state: &mut InputBaseState<Self>, _window: &mut Window, _cx: &mut Context<'_, InputBaseState<Self>>, ) -> bool { ... } fn has_inline_completion(_state: &InputBaseState<Self>) -> bool { ... } fn on_click( _state: &mut InputBaseState<Self>, _event: &MouseDownEvent, _offset: usize, _window: &mut Window, _cx: &mut Context<'_, InputBaseState<Self>>, ) -> bool { ... } fn clear_hover_state( _state: &mut InputBaseState<Self>, _cx: &mut Context<'_, InputBaseState<Self>>, ) { ... } fn on_text_typed( _state: &mut InputBaseState<Self>, _range: &Range<usize>, _text: &str, _window: &mut Window, _cx: &mut Context<'_, InputBaseState<Self>>, ) { ... } fn clear_inline_completion( _state: &mut InputBaseState<Self>, _cx: &mut Context<'_, InputBaseState<Self>>, ) { ... } fn hide_context_menu( _state: &mut InputBaseState<Self>, _cx: &mut Context<'_, InputBaseState<Self>>, ) { ... } fn is_context_menu_open(_state: &InputBaseState<Self>, _cx: &App) -> bool { ... } fn handle_context_menu_action( _state: &mut InputBaseState<Self>, _action: Box<dyn Action>, _window: &mut Window, _cx: &mut Context<'_, InputBaseState<Self>>, ) -> bool { ... } fn on_hover_definition( _state: &mut InputBaseState<Self>, _offset: usize, _window: &mut Window, _cx: &mut Context<'_, InputBaseState<Self>>, ) { ... } fn on_mouse_move( _state: &mut InputBaseState<Self>, _offset: usize, _event: &MouseMoveEvent, _window: &mut Window, _cx: &mut Context<'_, InputBaseState<Self>>, ) { ... } fn register_actions( element: Stateful<Div>, _entity: &Entity<InputBaseState<Self>>, _window: &mut Window, ) -> Stateful<Div> { ... }
}
Expand description

Hooks the shared engine calls back into for mode-specific work.

The engine’s render path is generic over the mode, so it cannot name a specific state type. This hook is the seam: each implementation is written for one concrete mode, so inside it Entity<InputBaseState<Self>> is that mode’s own state type. Sealed: the engine branches on a closed set of runtime modes, so the markers are a closed set too. The three above are all of them.

Required Associated Constants§

Source

const MULTI_LINE: bool

Whether this kind of input spans more than one line.

The kind decides this, not the layout: [super::LayoutMode] carries how many rows to show and how to grow, which is a different question from whether the input is a text field or a document. Deriving it from the layout let the two disagree — an auto-growing textarea capped at one row used to report itself as single-line.

Provided Associated Constants§

Source

const CODE_EDITOR: bool = false

Whether this kind of input is a source-code editor.

Required Associated Types§

Source

type Extras: InputExtras

State only this mode needs.

The engine is shared, but its parts are not: a single-line field has no use for an LSP client or a search session, and an editor has no use for number stepping. Keeping those here means a form full of text fields does not carry an editor’s worth of machinery.

Provided Methods§

Source

fn drive_highlighter( _highlighter: &Rc<RefCell<Option<Box<dyn InputHighlighter>>>>, _edit: InputEdit, _text: &Rope, _folding: bool, _window: &mut Window, _cx: &mut Context<'_, InputBaseState<Self>>, )

Drives the syntax highlighter after the text changed.

Only a code editor has one. The engine’s edit path is generic over the mode, so it dispatches here, where Self is concrete and the highlighter can be handed this mode’s own context.

Source

fn hover_definition_style( _state: &InputBaseState<Self>, _cx: &App, ) -> Option<(Range<usize>, HighlightStyle)>

The range highlighted while Cmd-hovering a symbol, with its style.

Source

fn hover_definition_hitbox( _state: &InputBaseState<Self>, _window: &mut Window, _cx: &App, ) -> Option<Hitbox>

The hitbox for Cmd-hover, when the mode supports go-to-definition.

Source

fn reset_language_features(_state: &mut InputBaseState<Self>)

Drops cached language-server results, e.g. after the text is replaced.

Source

fn reset_annotations(_state: &mut InputBaseState<Self>)

Drops decorations and hover state when the text is replaced wholesale.

Source

fn adjust_annotations( _state: &mut InputBaseState<Self>, _range: &Range<usize>, _new_len: usize, )

Slides decoration ranges along with an edit.

Source

fn refresh_language_features( _state: &mut InputBaseState<Self>, _window: &mut Window, _cx: &mut Context<'_, InputBaseState<Self>>, )

Refreshes language-server state after the text changed.

Source

fn accept_inline_completion( _state: &mut InputBaseState<Self>, _window: &mut Window, _cx: &mut Context<'_, InputBaseState<Self>>, ) -> bool

Takes the pending inline completion, when Tab should accept it.

Source

fn has_inline_completion(_state: &InputBaseState<Self>) -> bool

Whether an inline completion is waiting to be accepted.

Source

fn on_click( _state: &mut InputBaseState<Self>, _event: &MouseDownEvent, _offset: usize, _window: &mut Window, _cx: &mut Context<'_, InputBaseState<Self>>, ) -> bool

Reacts to a click, for Cmd-click go-to-definition.

Source

fn clear_hover_state( _state: &mut InputBaseState<Self>, _cx: &mut Context<'_, InputBaseState<Self>>, )

Drops hover state when the pointer leaves or focus moves.

Source

fn on_text_typed( _state: &mut InputBaseState<Self>, _range: &Range<usize>, _text: &str, _window: &mut Window, _cx: &mut Context<'_, InputBaseState<Self>>, )

Offers freshly typed text to the completion engine.

Source

fn clear_inline_completion( _state: &mut InputBaseState<Self>, _cx: &mut Context<'_, InputBaseState<Self>>, )

Drops any inline completion after the text or cursor moved.

Source

fn hide_context_menu( _state: &mut InputBaseState<Self>, _cx: &mut Context<'_, InputBaseState<Self>>, )

Closes any open completion or code-action menu.

Source

fn is_context_menu_open(_state: &InputBaseState<Self>, _cx: &App) -> bool

Whether a completion or code-action menu is currently open.

Source

fn handle_context_menu_action( _state: &mut InputBaseState<Self>, _action: Box<dyn Action>, _window: &mut Window, _cx: &mut Context<'_, InputBaseState<Self>>, ) -> bool

Lets an open menu consume the action first. Returns true when it did.

Source

fn on_hover_definition( _state: &mut InputBaseState<Self>, _offset: usize, _window: &mut Window, _cx: &mut Context<'_, InputBaseState<Self>>, )

Highlights the symbol under the pointer for go-to-definition.

Separate from Self::on_mouse_move: this runs on paths that have no mouse event to hand over, such as opening the context menu.

Source

fn on_mouse_move( _state: &mut InputBaseState<Self>, _offset: usize, _event: &MouseMoveEvent, _window: &mut Window, _cx: &mut Context<'_, InputBaseState<Self>>, )

Reacts to the pointer moving, for the hover popover.

Source

fn register_actions( element: Stateful<Div>, _entity: &Entity<InputBaseState<Self>>, _window: &mut Window, ) -> Stateful<Div>

Registers the actions that only this mode handles.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§