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

Prompt UI: open, key handling, and close.

Manages a single-line text input prompt in the minibuffer area. Extensions
use this for collecting free-form text input (capture titles, rename targets,
search queries). All functions are pure `state -> state` transformations.

Prompts and pickers are mutually exclusive: opening a prompt closes any
active picker, and vice versa.

## Usage

    # Open a prompt
    state = PromptUI.open(state, MyCapturePrompt)
    state = PromptUI.open(state, MyCapturePrompt, default: "pre-filled")

    # Keys are routed here when prompt is active
    {state, action} = PromptUI.handle_key(state, key, mods)

# `action`

```elixir
@type action() :: nil
```

Optional action the GenServer should dispatch after handle_key.

# `state`

```elixir
@type state() :: MingaEditor.State.t()
```

Internal editor state.

# `close`

```elixir
@spec close(state()) :: state()
```

Closes the prompt without calling any handler callback.

# `handle_key`

```elixir
@spec handle_key(state(), non_neg_integer(), non_neg_integer()) :: {state(), action()}
```

Handles a key event while the prompt is active.

Returns `{state, action}` where action is always nil (prompts don't
produce deferred actions like the picker does).

# `open`

```elixir
@spec open(state(), module(), keyword()) :: state()
```

Opens a text input prompt with the given handler module.

Closes any active picker first. An optional `:default` value pre-fills
the input field. An optional `:context` map is stored for the handler
to read.

## Options

- `:default` — pre-filled text (default: `""`)
- `:context` — arbitrary map passed through to the handler (default: `nil`)

# `open?`

```elixir
@spec open?(state()) :: boolean()
```

Returns true if a prompt is currently open.

# `render`

```elixir
@spec render(state(), MingaEditor.Viewport.t()) ::
  {[MingaEditor.DisplayList.draw()],
   {non_neg_integer(), non_neg_integer()} | nil}
```

Renders the prompt overlay into draw commands and a cursor position.

Returns `{draws, cursor}` where draws is a list of display list
draw commands and cursor is a `%Cursor{}` for the input position.
Returns `{[], nil}` when no prompt is active.

# `render_data`

```elixir
@spec render_data(state()) :: {String.t(), String.t(), non_neg_integer()}
```

Returns the label and current text for rendering.

Returns `{label, text, cursor_col}` where cursor_col is the column
within the text (not including the label width).

---

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