Minga.Mode.CommandState (Minga v0.1.0)

Copy Markdown View Source

FSM state for Command (:) mode.

Owns the command-line input without the leading :, its grapheme cursor position, completion selection, and the standard count/leader fields.

Summary

Functions

Deletes the grapheme before the cursor and resets completion selection.

Inserts text at the cursor and resets completion selection.

Moves the completion selection; the presenter wraps it to the candidate count.

Moves the cursor by one grapheme within the command input.

Creates command input with the cursor at its end.

Replaces command input, moves the cursor to its end, and resets completion selection.

Types

t()

@type t() :: %Minga.Mode.CommandState{
  candidate_index: integer(),
  count: non_neg_integer() | nil,
  cursor: non_neg_integer(),
  input: String.t(),
  leader_keys: [String.t()],
  leader_node: Minga.Keymap.Bindings.node_t() | nil
}

Functions

backspace(state)

@spec backspace(t()) :: t()

Deletes the grapheme before the cursor and resets completion selection.

insert_text(state, text)

@spec insert_text(t(), String.t()) :: t()

Inserts text at the cursor and resets completion selection.

move_candidate(state, delta)

@spec move_candidate(t(), integer()) :: t()

Moves the completion selection; the presenter wraps it to the candidate count.

move_cursor(state, atom)

@spec move_cursor(t(), :left | :right) :: t()

Moves the cursor by one grapheme within the command input.

new(input \\ "")

@spec new(String.t()) :: t()

Creates command input with the cursor at its end.

replace_input(state, input)

@spec replace_input(t(), String.t()) :: t()

Replaces command input, moves the cursor to its end, and resets completion selection.