MingaEditor.State.Registers (Minga v0.1.0)

Copy Markdown View Source

Groups register-related fields from EditorState.

Tracks the named register store and the currently selected register (set by "x before an operator).

Each register entry is a {text, type} tuple where type is :charwise or :linewise. Linewise entries (from yy, dd, visual-line yank) paste as new lines; charwise entries paste inline at the cursor.

Summary

Types

A register entry: text content paired with its paste type.

Whether register content should paste as whole lines or inline text.

Register store. Keys are register names

t()

Functions

Gets the entry for the named register name. Returns {text, type} or nil.

Puts text into the named register name with the given type.

Resets the active register selection to unnamed.

Sets the active register to name.

Types

entry()

@type entry() :: {String.t(), reg_type()}

A register entry: text content paired with its paste type.

reg_type()

@type reg_type() :: :charwise | :linewise

Whether register content should paste as whole lines or inline text.

registers()

@type registers() :: %{required(String.t()) => entry()}

Register store. Keys are register names:

  • "" — unnamed (default)
  • "0" — last yank
  • "a""z" — named
  • "+" — system clipboard (virtual; read/write via Minga.Clipboard)
  • "_" — black hole (never stored)

t()

@type t() :: %MingaEditor.State.Registers{active: String.t(), registers: registers()}

Functions

get(registers, name)

@spec get(t(), String.t()) :: entry() | nil

Gets the entry for the named register name. Returns {text, type} or nil.

put(reg, name, text, type \\ :charwise)

@spec put(t(), String.t(), String.t(), reg_type()) :: t()

Puts text into the named register name with the given type.

reset_active(reg)

@spec reset_active(t()) :: t()

Resets the active register selection to unnamed.

set_active(reg, name)

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

Sets the active register to name.