Minga.Buffer.CursorContext (Minga v0.1.0)

Copy Markdown View Source

Coherent buffer metadata for cursor-local operations.

Cursor columns use Minga's internal UTF-8 byte offsets. grapheme_column records the corresponding grapheme offset explicitly so callers never need to treat a byte offset as a String.slice/3 index.

Summary

Functions

Builds a coherent cursor-local snapshot from buffer-owned state.

Returns the internal byte-indexed cursor position.

Returns the text between a same-line byte position and the cursor.

Types

t()

@type t() :: %Minga.Buffer.CursorContext{
  byte_column: non_neg_integer(),
  file_path: String.t() | nil,
  filetype: atom(),
  grapheme_column: non_neg_integer(),
  line: non_neg_integer(),
  line_prefix: String.t(),
  line_text: String.t(),
  version: non_neg_integer()
}

Functions

new(document, version, file_path, filetype)

@spec new(Minga.Buffer.Document.t(), non_neg_integer(), String.t() | nil, atom()) ::
  t()

Builds a coherent cursor-local snapshot from buffer-owned state.

position(cursor_context)

@spec position(t()) :: Minga.Buffer.Document.position()

Returns the internal byte-indexed cursor position.

text_since(cursor_context, arg)

@spec text_since(t(), Minga.Buffer.Document.position()) :: String.t() | nil

Returns the text between a same-line byte position and the cursor.