class

Cursor

Inherits Comparable < Reference < Object

Represents a cursor in the editor. Appearance is managed here too.

Cursor is not yet self-sufficient. You must use Selection to have complete editing capabilities.

Constructors

new(document : Document, index : Int32, home_column : Int32 = 0)
Source

Instance methods

<=>(other : Cursor)

Compares this cursor and other cursor by indices.

Source
==(other : self)

Two cursors are equal when their indices are equal.

acquire
Source
at_document_end?

Returns whether this cursor is located after the last character in the document.

Source
at_document_start?

Returns whether this cursor is located before the first character in the document.

Source
at_first_line?

Returns whether this cursor is located at the first line in the document.

Source
at_last_line?

Returns whether this cursor is located at the last line in the document.

Source
at_line_end?

Returns whether this cursor is located at the end of its line.

Source
at_line_start?

Returns whether this cursor is located at the beginning of its line.

Source
attract(other : Cursor, settings = SeekSettings.new)

Moves ("teleports") other cursor to this cursor.

See seek to learn what settings are.

Source
color

Returns the color of this cursor.

Source
column

Returns the column (offset from line start) of this cursor. Columns are counted starting from zero!

Source
coords

Returns the point coordinates of this cursor in the document.

Source
copy

Returns a shallow copy of this cursor.

Source
each_line(upto other : Cursor, &)

Yields Lines starting from this cursor's line up to other's line.

Source
hash(hasher)

Two cursors are equal when their indices are equal.

home?

Returns whether this cursor's column is its preferred home column.

Source
ins(string : String)

Inserts string before this cursor.

Source
line

Returns the Line of this cursor.

Source
minmax(other : Cursor)

Returns a tuple with this and other cursor sorted in ascending order (minimum to maximum, aka leftmost to rightmost).

Source
motions

Returns a stream which yields Motion objects whenever this cursor moves.

Source
move(delta : Int, settings = SeekSettings.new)

Increments this cursor's index by delta.

That is, if delta is negative, this cursor will move that many characters to the left; if it is positive, this cursor will move that many characters to the right.

If delta is zero, simply refreshes this cursor's X, Y position in document.

See seek to learn what settings are.

Returns self.

Source
partially_visible?(*, upto other : Cursor)

Returns whether the range starting from this cursor, and up to other cursor, is partially or completely visible.

Source
partially_visible?(*, from start : Int)

Returns whether the range starting from the given start index, and up to this cursor, is partially or completely visible.

Source
present(window)

Presents this cursor on window.

Source
release
Source
scroll_to_view

Asks the document to scroll this cursor to view.

Source
seek(other : Cursor, settings = SeekSettings.new)

Moves ("teleports") this cursor to other cursor.

See seek to learn what settings are.

Source
seek(index : Int, settings = SeekSettings.new)

Moves this cursor to index.

settings specify how this method should seek index. See SeekSettings for the available settings.

Returns self.

Source
seek_column(column : Int, settings = SeekSettings.new)

Moves this cursor to the given column.

See seek to learn what settings are.

Source
seek_line_end(settings = SeekSettings.new)

Moves this cursor to the end of its line.

See seek to learn what settings are.

Source
seek_line_start(settings = SeekSettings.new)

Moves this cursor to the beginning of its line.

See seek to learn what settings are.

Source
size

Returns a float vector that is the width, height of this cursor's rectangle.

Source
span(*, upto other : Cursor)

Builds and returns a Span starting from this cursor up to other cursor (based on indices of both). Order matters! This cursor's index must be smaller than that of other.

Source
span(*, from start : Int)

Builds and returns a Span starting from start up to this cursor. Order matters! This cursor's index must be greater than start.

Source
visible?

Returns whether this cursor is visible in the document.

Source
ymove(delta : Int, settings = SeekSettings.new(home: false))

Increments this cursor's line number by delta.

That is, if delta is negative, this cursor will move that many lines up; if it is positive, this cursor will move that many lines down.

If unable to move because the cursor is already at the top or bottom line of the document, moves to the first or last character in the document, respectively.

See seek to learn what settings are.

Returns self.

Source

Nested types