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

Structured minibuffer data for the GUI frontend.

Extracts the current minibuffer state (mode, prompt, input, context,
completion candidates) from editor state for encoding as the `0x7F
gui_minibuffer` protocol opcode.

The TUI continues to render the cell-grid minibuffer via
`MingaEditor.Renderer.Minibuffer`. This module serves the native
SwiftUI minibuffer only.

# `candidate`

```elixir
@type candidate() :: %{
  label: String.t(),
  description: String.t(),
  match_score: non_neg_integer(),
  match_positions: [non_neg_integer()],
  annotation: String.t()
}
```

A completion candidate for the minibuffer.

# `t`

```elixir
@type t() :: %MingaEditor.MinibufferData{
  candidates: [candidate()],
  context: String.t(),
  cursor_pos: non_neg_integer(),
  input: String.t(),
  mode: non_neg_integer(),
  prompt: String.t(),
  selected_index: non_neg_integer(),
  total_candidates: non_neg_integer(),
  visible: boolean()
}
```

Structured minibuffer data for GUI encoding.

# `clamp_index`

```elixir
@spec clamp_index(integer(), non_neg_integer()) :: non_neg_integer()
```

Clamps a candidate index to the valid range for a candidate list.

Wraps around in both directions so arrow navigation cycles through
candidates. Returns 0 for empty lists.

# `complete_ex_command`

```elixir
@spec complete_ex_command(String.t()) :: {[candidate()], non_neg_integer()}
```

Generates completion candidates for an ex command input string.

Queries the command registry and fuzzy-matches against the input.
Returns up to `@max_candidates` results sorted by match quality.

# `from_state`

```elixir
@spec from_state(MingaEditor.State.t()) :: t()
```

Extracts structured minibuffer data from the current editor state.

Returns a `t()` struct ready for protocol encoding via
`MingaEditor.Frontend.Protocol.GUI.encode_gui_minibuffer/1`.

---

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