Minga.Buffer.Position (Minga v0.1.0)

Copy Markdown View Source

Resolves editor positions into concrete places in document text.

A position is still stored as {line, column} for the rest of the editor, but this module owns the translation between that editor-facing coordinate and the document's internal text point.

Summary

Types

An absolute point in the document text.

t()

A zero-indexed editor position.

Functions

Returns the point immediately after the character at point.

Returns the on-screen column for an editor position.

Returns the editor position at a document point.

Returns the position of the last selectable character on a line.

Returns the document point for an editor position.

Returns the document point for an editor position against an existing line index.

Types

point()

@type point() :: non_neg_integer()

An absolute point in the document text.

t()

@type t() :: {line :: non_neg_integer(), column :: non_neg_integer()}

A zero-indexed editor position.

Functions

after_character_at(text, point)

@spec after_character_at(String.t(), point()) :: point()

Returns the point immediately after the character at point.

display_column(doc, arg)

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

Returns the on-screen column for an editor position.

from_point(doc, point)

@spec from_point(Minga.Buffer.Document.t(), point()) :: t()

Returns the editor position at a document point.

last_character_on_line(text)

@spec last_character_on_line(String.t()) :: non_neg_integer()

Returns the position of the last selectable character on a line.

point_for(doc, arg)

@spec point_for(Minga.Buffer.Document.t(), t()) :: point()

Returns the document point for an editor position.

point_in(line_starts, line, column, text_size)

Returns the document point for an editor position against an existing line index.