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§
Sourceconst MULTI_LINE: bool
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§
Sourceconst CODE_EDITOR: bool = false
const CODE_EDITOR: bool = false
Whether this kind of input is a source-code editor.
Required Associated Types§
Sourcetype Extras: InputExtras
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§
Sourcefn drive_highlighter(
_highlighter: &Rc<RefCell<Option<Box<dyn InputHighlighter>>>>,
_edit: InputEdit,
_text: &Rope,
_folding: bool,
_window: &mut Window,
_cx: &mut Context<'_, InputBaseState<Self>>,
)
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.
Sourcefn hover_definition_style(
_state: &InputBaseState<Self>,
_cx: &App,
) -> Option<(Range<usize>, HighlightStyle)>
fn hover_definition_style( _state: &InputBaseState<Self>, _cx: &App, ) -> Option<(Range<usize>, HighlightStyle)>
The range highlighted while Cmd-hovering a symbol, with its style.
Sourcefn hover_definition_hitbox(
_state: &InputBaseState<Self>,
_window: &mut Window,
_cx: &App,
) -> Option<Hitbox>
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.
Sourcefn reset_language_features(_state: &mut InputBaseState<Self>)
fn reset_language_features(_state: &mut InputBaseState<Self>)
Drops cached language-server results, e.g. after the text is replaced.
Sourcefn reset_annotations(_state: &mut InputBaseState<Self>)
fn reset_annotations(_state: &mut InputBaseState<Self>)
Drops decorations and hover state when the text is replaced wholesale.
Sourcefn adjust_annotations(
_state: &mut InputBaseState<Self>,
_range: &Range<usize>,
_new_len: usize,
)
fn adjust_annotations( _state: &mut InputBaseState<Self>, _range: &Range<usize>, _new_len: usize, )
Slides decoration ranges along with an edit.
Sourcefn refresh_language_features(
_state: &mut InputBaseState<Self>,
_window: &mut Window,
_cx: &mut Context<'_, InputBaseState<Self>>,
)
fn refresh_language_features( _state: &mut InputBaseState<Self>, _window: &mut Window, _cx: &mut Context<'_, InputBaseState<Self>>, )
Refreshes language-server state after the text changed.
Sourcefn accept_inline_completion(
_state: &mut InputBaseState<Self>,
_window: &mut Window,
_cx: &mut Context<'_, InputBaseState<Self>>,
) -> bool
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.
Sourcefn has_inline_completion(_state: &InputBaseState<Self>) -> bool
fn has_inline_completion(_state: &InputBaseState<Self>) -> bool
Whether an inline completion is waiting to be accepted.
Sourcefn on_click(
_state: &mut InputBaseState<Self>,
_event: &MouseDownEvent,
_offset: usize,
_window: &mut Window,
_cx: &mut Context<'_, InputBaseState<Self>>,
) -> bool
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.
Sourcefn clear_hover_state(
_state: &mut InputBaseState<Self>,
_cx: &mut Context<'_, InputBaseState<Self>>,
)
fn clear_hover_state( _state: &mut InputBaseState<Self>, _cx: &mut Context<'_, InputBaseState<Self>>, )
Drops hover state when the pointer leaves or focus moves.
Sourcefn on_text_typed(
_state: &mut InputBaseState<Self>,
_range: &Range<usize>,
_text: &str,
_window: &mut Window,
_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>>, )
Offers freshly typed text to the completion engine.
Sourcefn clear_inline_completion(
_state: &mut InputBaseState<Self>,
_cx: &mut Context<'_, InputBaseState<Self>>,
)
fn clear_inline_completion( _state: &mut InputBaseState<Self>, _cx: &mut Context<'_, InputBaseState<Self>>, )
Drops any inline completion after the text or cursor moved.
Closes any open completion or code-action menu.
Whether a completion or code-action menu is currently open.
Lets an open menu consume the action first. Returns true when it did.
Sourcefn on_hover_definition(
_state: &mut InputBaseState<Self>,
_offset: usize,
_window: &mut Window,
_cx: &mut Context<'_, InputBaseState<Self>>,
)
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.
Sourcefn on_mouse_move(
_state: &mut InputBaseState<Self>,
_offset: usize,
_event: &MouseMoveEvent,
_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>>, )
Reacts to the pointer moving, for the hover popover.
Sourcefn register_actions(
element: Stateful<Div>,
_entity: &Entity<InputBaseState<Self>>,
_window: &mut Window,
) -> Stateful<Div>
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".