MingaEditor.MacroRecorder (Minga v0.1.0)

Copy Markdown View Source

Records and replays named keystroke macros.

A pure functional module — no GenServer. The struct is embedded in MingaEditor.State and threaded through the editor's key dispatch.

Macros are stored in named registers (az), separate from text registers. Each register holds a list of key tuples that can be replayed through the editor's handle_key pipeline.

Summary

Types

A key event: {codepoint, modifiers}.

Recording state: {register_name, accumulated_keys} or nil.

t()

Functions

Returns the stored key sequence for a register, or nil.

Returns a fresh macro recorder with no recorded macros.

Appends a key to the active recording. No-op if not recording.

Returns {true, register_name} if recording, or false.

Returns true if currently replaying a macro.

Begins recording into the named register.

Sets the replaying flag.

Finalizes the current recording, storing the key sequence in the register.

Clears the replaying flag.

Types

key()

@type key() :: {non_neg_integer(), non_neg_integer()}

A key event: {codepoint, modifiers}.

recording()

@type recording() :: {String.t(), [key()]} | nil

Recording state: {register_name, accumulated_keys} or nil.

t()

@type t() :: %MingaEditor.MacroRecorder{
  last_register: String.t() | nil,
  recording: recording(),
  registers: %{required(String.t()) => [key()]},
  replaying: boolean()
}

Functions

get_macro(macro_recorder, register)

@spec get_macro(t(), String.t()) :: [key()] | nil

Returns the stored key sequence for a register, or nil.

new()

@spec new() :: t()

Returns a fresh macro recorder with no recorded macros.

record_key(rec, key)

@spec record_key(t(), key()) :: t()

Appends a key to the active recording. No-op if not recording.

recording?(macro_recorder)

@spec recording?(t()) :: {true, String.t()} | false

Returns {true, register_name} if recording, or false.

replaying?(macro_recorder)

@spec replaying?(t()) :: boolean()

Returns true if currently replaying a macro.

start_recording(rec, register)

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

Begins recording into the named register.

start_replay(rec)

@spec start_replay(t()) :: t()

Sets the replaying flag.

stop_recording(rec)

@spec stop_recording(t()) :: t()

Finalizes the current recording, storing the key sequence in the register.

stop_replay(rec)

@spec stop_replay(t()) :: t()

Clears the replaying flag.