The Cursor
class represents the little blinking line identifying
where text can be inserted.
Cursors belong to TextEditors and have some metadata attached in the form of a DisplayMarker.
Calls your callback
when the cursor has been moved.
Argument | Description |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Cursor that triggered the event |
Return values |
---|
Returns a Disposable on which |
Calls your callback
when the cursor is destroyed
Argument | Description |
---|---|
|
Return values |
---|
Returns a Disposable on which |
Moves a cursor to a given screen position.
Argument | Description |
---|---|
|
Array of two numbers: the screen row, and the screen column. |
|
optional
Object with the following keys: |
|
A Boolean which, if |
Moves a cursor to a given buffer position.
Argument | Description |
---|---|
|
Array of two numbers: the buffer row, and the buffer column. |
|
optional
Object with the following keys: |
|
Boolean indicating whether to autoscroll to the new position. Defaults to |
Return values |
---|
Returns the current buffer position as an Array. |
Return values |
---|
Returns the cursor’s current screen row. |
Return values |
---|
Returns the cursor’s current screen column. |
Retrieves the cursor’s current buffer row.
Return values |
---|
Returns the cursor’s current buffer column. |
Return values |
---|
Returns the cursor’s current buffer row of text excluding its line ending. |
Return values |
---|
Returns whether the cursor is at the start of a line. |
Return values |
---|
Returns whether the cursor is on the line return character. |
Identifies if the cursor is surrounded by whitespace.
“Surrounded” here means that the character directly before and after the cursor are both whitespace.
Return values |
---|
Returns a Boolean. |
This method returns false if the character before or after the cursor is whitespace.
Return values |
---|
Returns whether the cursor is currently between a word and non-word
character. The non-word characters are defined by the
|
Returns a Boolean. |
Argument | Description |
---|---|
|
optional |
|
A RegExp indicating what constitutes a “word” (default: ::wordRegExp). |
Return values |
---|
Returns whether this cursor is between a word’s start and end. |
Returns a Boolean |
Return values |
---|
Returns the indentation level of the current line. |
Retrieves the scope descriptor for the cursor’s current position.
Return values |
---|
Returns a ScopeDescriptor |
Retrieves the syntax tree scope descriptor for the cursor’s current position.
Return values |
---|
Returns a ScopeDescriptor |
Return values |
---|
Returns true if this cursor has no non-whitespace characters before its current position. |
Identifies if this cursor is the last in the TextEditor.
“Last” is defined as the most recently added cursor.
Return values |
---|
Returns a Boolean. |
Moves the cursor to the top of the buffer.
Moves the cursor to the bottom of the buffer.
Moves the cursor to the beginning of the line.
Moves the cursor to the beginning of the buffer line.
Moves the cursor to the beginning of the first character in the line.
Moves the cursor to the end of the line.
Moves the cursor to the end of the buffer line.
Moves the cursor to the beginning of the word.
Moves the cursor to the end of the word.
Moves the cursor to the beginning of the next word.
Moves the cursor to the previous word boundary.
Moves the cursor to the next word boundary.
Moves the cursor to the previous subword boundary.
Moves the cursor to the next subword boundary.
Moves the cursor to the beginning of the buffer line, skipping all whitespace.
Moves the cursor to the beginning of the next paragraph
Moves the cursor to the beginning of the previous paragraph
Argument | Description |
---|---|
|
optional
Object with the following keys: |
|
A RegExp indicating what constitutes a “word” (default: ::wordRegExp) |
Return values |
---|
Returns buffer position of previous word boundary. It might be on the current word, or the previous word. |
Argument | Description |
---|---|
|
optional
Object with the following keys: |
|
A RegExp indicating what constitutes a “word” (default: ::wordRegExp) |
Return values |
---|
Returns buffer position of the next word boundary. It might be on the current word, or the previous word. |
Retrieves the buffer position of where the current word starts.
Argument | Description |
---|---|
|
optional
An Object with the following keys: |
|
A RegExp indicating what constitutes a “word” (default: ::wordRegExp). |
|
A Boolean indicating whether to include non-word characters in the default word regex. Has no effect if wordRegex is set. |
|
A Boolean indicating whether the beginning of the previous word can be returned. |
Return values |
---|
Returns a Range. |
Retrieves the buffer position of where the current word ends.
Argument | Description |
---|---|
|
optional
Object with the following keys: |
|
A RegExp indicating what constitutes a “word” (default: ::wordRegExp) |
|
A Boolean indicating whether to include non-word characters in the default word regex. Has no effect if wordRegex is set. |
Return values |
---|
Returns a Range. |
Retrieves the buffer position of where the next word starts.
Argument | Description |
---|---|
|
optional |
|
A RegExp indicating what constitutes a “word” (default: ::wordRegExp). |
Return values |
---|
Returns a Range |
Argument | Description |
---|---|
|
optional |
|
A RegExp indicating what constitutes a “word” (default: ::wordRegExp). |
Return values |
---|
Returns the buffer Range occupied by the word located under the cursor. |
Retrieves the range for the current paragraph.
A paragraph is defined as a block of text surrounded by empty lines or comments.
Return values |
---|
Returns a Range. |
Return values |
---|
Returns the characters preceding the cursor in the current word. |
Compare this cursor’s buffer position to another cursor’s buffer position.
See Point::compare for more details.
Argument | Description |
---|---|
|
Cursor to compare against |
Deselects the current selection.