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
@type kind() :: :characterwise | :linewise
@type t() :: %Minga.Buffer.Selection{ cursor: Minga.Buffer.Document.position(), kind: kind(), span: Minga.Buffer.Span.t() }
Functions
@spec characterwise( Minga.Buffer.Document.t(), Minga.Buffer.Document.position(), Minga.Buffer.Document.position() ) :: t()
Builds a characterwise selection between two editor positions.
@spec clear_line(Minga.Buffer.Document.t(), non_neg_integer()) :: {String.t(), Minga.Buffer.Document.t()}
Clears one line and leaves an empty line behind.
@spec contents(Minga.Buffer.Document.t(), t()) :: String.t()
Returns the selected text.
@spec delete(Minga.Buffer.Document.t(), t()) :: Minga.Buffer.Document.t()
Deletes a selection and places the cursor where that selection began.
@spec length(Minga.Buffer.Document.t(), t()) :: non_neg_integer()
Returns the grapheme length of the selected text without constructing a new string.
@spec line_contents(Minga.Buffer.Document.t(), non_neg_integer(), non_neg_integer()) :: String.t()
Returns the joined text for a linewise selection, without a trailing newline.
@spec linewise(Minga.Buffer.Document.t(), non_neg_integer(), non_neg_integer()) :: t()
Builds a linewise selection between two line numbers.