Minga.Buffer.Selection (Minga v0.1.0)

Copy Markdown View Source

Owns editor selection semantics for document text.

Document stores and mutates the gap buffer. This module decides what a characterwise or linewise selection means, then returns content or a new document from that selection.

Summary

Functions

Builds a characterwise selection between two editor positions.

Clears one line and leaves an empty line behind.

Returns the selected text.

Deletes a selection and places the cursor where that selection began.

Returns the grapheme length of the selected text without constructing a new string.

Returns the joined text for a linewise selection, without a trailing newline.

Builds a linewise selection between two line numbers.

Types

kind()

@type kind() :: :characterwise | :linewise

t()

@type t() :: %Minga.Buffer.Selection{
  cursor: Minga.Buffer.Document.position(),
  kind: kind(),
  span: Minga.Buffer.Span.t()
}

Functions

characterwise(doc, from_pos, to_pos)

Builds a characterwise selection between two editor positions.

clear_line(doc, line)

Clears one line and leaves an empty line behind.

contents(doc, selection)

@spec contents(Minga.Buffer.Document.t(), t()) :: String.t()

Returns the selected text.

delete(doc, selection)

Deletes a selection and places the cursor where that selection began.

length(doc, selection)

@spec length(Minga.Buffer.Document.t(), t()) :: non_neg_integer()

Returns the grapheme length of the selected text without constructing a new string.

line_contents(doc, start_line, end_line)

Returns the joined text for a linewise selection, without a trailing newline.

linewise(doc, start_line, end_line)

Builds a linewise selection between two line numbers.