Minga.Buffer.Cursor (Minga v0.1.0)

Copy Markdown View Source

Moves the document cursor while preserving valid editor caret positions.

Summary

Functions

Returns whether a byte column is an exact editor caret boundary in a line.

Clamps a byte column to the nearest preceding editor caret boundary in a line.

Moves the cursor one move in the requested direction.

Returns the character immediately after a caret.

Places the cursor at the nearest valid caret position for the requested editor position.

Splits the character immediately before a caret from the preceding text.

Types

direction()

@type direction() :: :left | :right | :up | :down

Functions

caret_boundary?(line_text, column)

@spec caret_boundary?(String.t(), non_neg_integer()) :: boolean()

Returns whether a byte column is an exact editor caret boundary in a line.

caret_column(line_text, target_column)

@spec caret_column(String.t(), non_neg_integer()) :: non_neg_integer()

Clamps a byte column to the nearest preceding editor caret boundary in a line.

move(doc, atom)

Moves the cursor one move in the requested direction.

next_character(text)

@spec next_character(String.t()) :: {String.t(), String.t()} | nil

Returns the character immediately after a caret.

place(doc, arg)

Places the cursor at the nearest valid caret position for the requested editor position.

previous_character(text)

@spec previous_character(String.t()) :: {String.t(), String.t()}

Splits the character immediately before a caret from the preceding text.