class Cursor
- Cursor
- Reference
- Object
Overview
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.
Included Modules
- Comparable(Cursor)
Direct Known Subclasses
Defined in:
aspis/cursor.crConstructors
Instance Method Summary
-
#<=>(other : Cursor)
Compares this cursor and other cursor by indices.
-
#==(other : self)
Two cursors are equal when their indices are equal.
- #acquire
-
#at_document_end?
Returns whether this cursor is located after the last character in the document.
-
#at_document_start?
Returns whether this cursor is located before the first character in the document.
-
#at_first_line?
Returns whether this cursor is located at the first line in the document.
-
#at_last_line?
Returns whether this cursor is located at the last line in the document.
-
#at_line_end?
Returns whether this cursor is located at the end of its line.
-
#at_line_start?
Returns whether this cursor is located at the beginning of its line.
-
#attract(other : Cursor, settings = SeekSettings.new)
Moves ("teleports") other cursor to this cursor.
-
#color
Returns the color of this cursor.
-
#column
Returns the column (offset from line start) of this cursor.
-
#coords
Returns the point coordinates of this cursor in the document.
-
#copy
Returns a shallow copy of this cursor.
-
#each_line(upto other : Cursor, &)
Yields
Line
s starting from this cursor's line up to other's line. -
#hash(hasher)
Two cursors are equal when their indices are equal.
-
#home?
Returns whether this cursor's column is its preferred home column.
-
#ins(string : String)
Inserts string before this cursor.
-
#line
Returns the
Line
of this cursor. -
#minmax(other : Cursor)
Returns a tuple with this and other cursor sorted in ascending order (minimum to maximum, aka leftmost to rightmost).
-
#motions : Stream(Motion)
Returns a stream which yields
Motion
objects whenever this cursor moves. -
#move(delta : Int, settings = SeekSettings.new)
Increments this cursor's index by delta.
-
#partially_visible?(*, upto other : Cursor)
Returns whether the range starting from this cursor, and up to other cursor, is partially or completely visible.
-
#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.
-
#present(window)
Presents this cursor on window.
- #release
-
#scroll_to_view
Asks the document to scroll this cursor to view.
-
#seek(other : Cursor, settings = SeekSettings.new)
Moves ("teleports") this cursor to other cursor.
-
#seek(index : Int, settings = SeekSettings.new)
Moves this cursor to index.
-
#seek_column(column : Int, settings = SeekSettings.new)
Moves this cursor to the given column.
-
#seek_line_end(settings = SeekSettings.new)
Moves this cursor to the end of its line.
-
#seek_line_start(settings = SeekSettings.new)
Moves this cursor to the beginning of its line.
-
#size
Returns a float vector that is the width, height of this cursor's rectangle.
-
#span(*, upto other : Cursor)
Builds and returns a
Span
starting from this cursor up to other cursor (based on indices of both). -
#span(*, from start : Int)
Builds and returns a
Span
starting from start up to this cursor. -
#visible?
Returns whether this cursor is visible in the document.
-
#ymove(delta : Int, settings = SeekSettings.new(home: false))
Increments this cursor's line number by delta.
Constructor Detail
Instance Method Detail
Returns whether this cursor is located after the last character in the document.
Returns whether this cursor is located before the first character in the document.
Moves ("teleports") other cursor to this cursor.
See #seek
to learn what settings are.
Returns the column (offset from line start) of this cursor. Columns are counted starting from zero!
Yields Line
s starting from this cursor's line up to
other's line.
Returns a tuple with this and other cursor sorted in ascending order (minimum to maximum, aka leftmost to rightmost).
Returns a stream which yields Motion
objects whenever
this cursor moves.
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.
Returns whether the range starting from this cursor, and up to other cursor, is partially or completely visible.
Returns whether the range starting from the given start index, and up to this cursor, is partially or completely visible.
Moves ("teleports") this cursor to other cursor.
See #seek
to learn what settings are.
Moves this cursor to index.
settings specify how this method should seek index.
See SeekSettings
for the available settings.
Returns self.
Moves this cursor to the given column.
See #seek
to learn what settings are.
Moves this cursor to the end of its line.
See #seek
to learn what settings are.
Moves this cursor to the beginning of its line.
See #seek
to learn what settings are.
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.
Builds and returns a Span
starting from start up to
this cursor. Order matters! This cursor's index must be
greater than start.
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.