# `MingaEditor.Input`
[🔗](https://github.com/jsmestad/minga/blob/main/lib/minga_editor/input.ex#L1)

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.

# `contribution_source`

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

Source that contributed registry entries.

# `dispatch_handler`

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

Input handler dispatched by the active shell.

# `handler_entry`

```elixir
@type handler_entry() :: {module(), contribution_source(), integer()}
```

# `sourced_handler`

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

Input handler paired with its authoritative contribution source.

# `editing_dispatch_handler`

```elixir
@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?`

```elixir
@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`

```elixir
@spec mod_alt() :: non_neg_integer()
```

Keyboard modifier flag for Alt/Option.

# `mod_ctrl`

```elixir
@spec mod_ctrl() :: non_neg_integer()
```

Keyboard modifier flag for Ctrl.

# `overlay_handlers`

```elixir
@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`

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

Registers an input handler for the surface stack.

# `reset_handlers`

```elixir
@spec reset_handlers() :: :ok
```

Resets the surface handler registry to built-ins only.

# `surface_handler_entries`

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

Returns surface handlers paired with their authoritative contribution sources.

# `surface_handlers`

```elixir
@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`

```elixir
@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`

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

Removes every input handler contributed by a source.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
