class Cursor

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

Direct Known Subclasses

Defined in:

aspis/cursor.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(document : Document, index : Int32, home_column : Int32 = 0) #

[View source]

Instance Method Detail

def <=>(other : Cursor) #

Compares this cursor and other cursor by indices.


[View source]
def ==(other : self) #

Two cursors are equal when their indices are equal.


def acquire #

[View source]
def at_document_end? #

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


[View source]
def at_document_start? #

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


[View source]
def at_first_line? #

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


[View source]
def at_last_line? #

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


[View source]
def at_line_end? #

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


[View source]
def at_line_start? #

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


[View source]
def attract(other : Cursor, settings = SeekSettings.new) #

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

See #seek to learn what settings are.


[View source]
def color #

Returns the color of this cursor.


[View source]
def column #

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


[View source]
def coords #

Returns the point coordinates of this cursor in the document.


[View source]
def copy #

Returns a shallow copy of this cursor.


[View source]
def each_line(upto other : Cursor, &) #

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


[View source]
def hash(hasher) #

Two cursors are equal when their indices are equal.


def home? #

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


[View source]
def ins(string : String) #

Inserts string before this cursor.


[View source]
def line #

Returns the Line of this cursor.


[View source]
def minmax(other : Cursor) #

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


[View source]
def motions : Stream(Motion) #

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


[View source]
def 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.


[View source]
def partially_visible?(*, upto other : Cursor) #

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


[View source]
def 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.


[View source]
def present(window) #

Presents this cursor on window.


[View source]
def release #

[View source]
def scroll_to_view #

Asks the document to scroll this cursor to view.


[View source]
def seek(other : Cursor, settings = SeekSettings.new) #

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

See #seek to learn what settings are.


[View source]
def 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.


[View source]
def seek_column(column : Int, settings = SeekSettings.new) #

Moves this cursor to the given column.

See #seek to learn what settings are.


[View source]
def seek_line_end(settings = SeekSettings.new) #

Moves this cursor to the end of its line.

See #seek to learn what settings are.


[View source]
def seek_line_start(settings = SeekSettings.new) #

Moves this cursor to the beginning of its line.

See #seek to learn what settings are.


[View source]
def size #

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


[View source]
def 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.


[View source]
def 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.


[View source]
def visible? #

Returns whether this cursor is visible in the document.


[View source]
def 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.


[View source]