# `Minga.Mode.State`
[🔗](https://github.com/jsmestad/minga/blob/main/lib/minga/mode/state.ex#L1)

Base FSM state for the editor's modal system.

Carries the shared fields used across all modes: the accumulated count
prefix, leader-key sequence state, and a `pending` tagged union for
single-key completion operations. Normal mode uses this struct directly;
other modes define their own structs that include these fields plus
mode-specific context.

## Pending operations

The `pending` field is a tagged union encoding the mutually exclusive
single-key operations (find-char, replace, mark, register, macro
record/replay). At most one can be active at a time, and the type
system enforces this: `pending` is either a tagged value or `nil`.

## Describe-key mode

The `describe_key` field holds state for the describe-key meta-mode,
which intercepts all input to walk the keymap trie and report bindings.
When `nil`, describe-key is inactive. When set, it contains the current
trie node and accumulated key sequence.

# `find_direction`

```elixir
@type find_direction() :: :f | :F | :t | :T
```

Pending find-char direction.

# `normal_bindings_map`

```elixir
@type normal_bindings_map() :: %{
  required(Minga.Keymap.Bindings.key()) =&gt; {atom(), String.t()}
}
```

Single-key normal bindings map: key => {command, description}.

# `pending`

```elixir
@type pending() ::
  {:find, find_direction()}
  | :replace
  | {:mark, pending_mark_kind()}
  | :register
  | :macro_register
  | :macro_replay
  | nil
```

A single-key completion operation waiting for the next keystroke.

At most one can be active at a time. `nil` means no pending operation.

# `pending_mark_kind`

```elixir
@type pending_mark_kind() :: :set | :jump_line | :jump_exact
```

Pending mark operation kind.

# `t`

```elixir
@type t() :: %Minga.Mode.State{
  count: non_neg_integer() | nil,
  describe_key: Minga.Mode.DescribeKey.t() | nil,
  filetype: atom(),
  leader_keys: [String.t()],
  leader_node: Minga.Keymap.Bindings.node_t() | nil,
  leader_trie: Minga.Keymap.Bindings.node_t() | nil,
  mode_trie: Minga.Keymap.Bindings.node_t() | nil,
  normal_bindings: normal_bindings_map(),
  pending: pending(),
  prefix_keys: [String.t()],
  prefix_node: Minga.Keymap.Bindings.node_t() | nil
}
```

---

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