MingaEditor.Input (Minga v0.1.0)

Copy Markdown View Source

Key input dispatch infrastructure.

The active shell supplies two ordered handler lists:

  1. Overlay handlers — modal UI overlays (picker, completion, conflict prompt) that take priority over everything and run before the active surface.

  2. Surface handlers — scope-specific dispatch (Scoped), global bindings (Ctrl+S, Ctrl+Q), and the mode FSM (vim normal/insert/ visual). These live inside the active surface and are called after overlays pass through.

Summary

Types

Source that contributed registry entries.

Input handler dispatched by the active shell.

Input handler ordering metadata.

Input handler paired with its authoritative contribution source.

Functions

Returns the appropriate bottom-of-stack dispatch handler for the active editing model. Each model owns its own handler module via the Minga.Editing.Model.dispatch_handler/0 callback; adding a new model requires no changes here.

Returns true when the editing model is mid-sequence and should receive the next key before any handler-specific dispatch runs.

Keyboard modifier flag for Alt/Option.

Keyboard modifier flag for Ctrl.

Returns interactive transient handlers in precedence order above the active surface.

Registers an input handler for the surface stack.

Resets the surface handler registry to built-ins only.

Returns surface handlers paired with their authoritative contribution sources.

Returns the editor-level handlers for buffer editing.

Returns the surface handlers for the given editor state.

Removes every input handler contributed by a source.

Types

contribution_source()

@type contribution_source() :: :builtin | :config | {:extension, atom()}

Source that contributed registry entries.

dispatch_handler()

@type dispatch_handler() :: module() | sourced_handler()

Input handler dispatched by the active shell.

handler_entry()

@type handler_entry() :: {module(), contribution_source(), handler_meta()}

handler_meta()

@type handler_meta() :: %{phase: atom(), priority: integer()}

Input handler ordering metadata.

sourced_handler()

@type sourced_handler() :: {module(), contribution_source()}

Input handler paired with its authoritative contribution source.

Functions

editing_dispatch_handler(state)

@spec editing_dispatch_handler(map()) :: module()

Returns the appropriate bottom-of-stack dispatch handler for the active editing model. Each model owns its own handler module via the Minga.Editing.Model.dispatch_handler/0 callback; adding a new model requires no changes here.

key_sequence_pending?(state)

@spec key_sequence_pending?(MingaEditor.State.t()) :: boolean()

Returns true when the editing model is mid-sequence and should receive the next key before any handler-specific dispatch runs.

For vim: leader key sequences, pending g prefix, operator-pending mode, and command-line mode. For CUA: always false (no multi-key sequences). Used by AgentPanel and FileTreeHandler to decide whether to delegate directly to the bottom-of-stack dispatch handler.

mod_alt()

@spec mod_alt() :: non_neg_integer()

Keyboard modifier flag for Alt/Option.

mod_ctrl()

@spec mod_ctrl() :: non_neg_integer()

Keyboard modifier flag for Ctrl.

overlay_handlers()

@spec overlay_handlers() :: [module()]

Returns interactive transient handlers in precedence order above the active surface.

Exclusive modals and completion run first, followed by which-key, focused hover, signature help, and finally operation cancellation. If none consumes the key, the Editor delegates to the active surface.

register_handler(source, module, opts \\ [])

@spec register_handler(contribution_source(), module(), keyword()) :: :ok

Registers an input handler for the surface stack.

reset_handlers()

@spec reset_handlers() :: :ok

Resets the surface handler registry to built-ins only.

surface_handler_entries(state)

@spec surface_handler_entries(map()) :: [sourced_handler()]

Returns surface handlers paired with their authoritative contribution sources.

surface_handlers()

@spec surface_handlers() :: [module()]

Returns the editor-level handlers for buffer editing.

These handle scope-specific dispatch, global bindings, and the editing model's key handler. The last handler in the list is determined by the active editing model: ModeFSM for vim, CUA.Dispatch for CUA.

surface_handlers(state)

@spec surface_handlers(map()) :: [module()]

Returns the surface handlers for the given editor state.

The editing model is read from state.editing_model to determine whether the bottom-of-stack handler is ModeFSM (vim) or CUA.Dispatch.

unregister_source(source)

@spec unregister_source(contribution_source()) :: :ok

Removes every input handler contributed by a source.