EditorCommands class abstract final

A collection of standard editor commands that produce TransactionSpecs.

Each command takes an EditorState and returns a TransactionSpec that can be applied via state.update(spec), or null if the command cannot be executed in the current state (e.g. cursor already at document start).

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

cursorCharLeft(EditorState state) TransactionSpec?
Move the cursor one character to the left. Returns null if the cursor is already at the start of the document.
cursorCharRight(EditorState state) TransactionSpec?
Move the cursor one character to the right. Returns null if the cursor is already at the end of the document.
cursorDocEnd(EditorState state) TransactionSpec
Move the cursor to the end of the document.
cursorDocStart(EditorState state) TransactionSpec
Move the cursor to the start of the document.
cursorLineDown(EditorState state) TransactionSpec?
Move the cursor down one line, preserving column as much as possible. Returns null if the cursor is already on the last line.
cursorLineEnd(EditorState state) TransactionSpec
Move the cursor to the end of the current line.
cursorLineStart(EditorState state) TransactionSpec
Move the cursor to the start of the current line.
cursorLineUp(EditorState state) TransactionSpec?
Move the cursor up one line, preserving column as much as possible. Returns null if the cursor is already on the first line.
cursorWordLeft(EditorState state) TransactionSpec?
Move the cursor to the start of the current word (or end of previous word). Word characters: a-z, A-Z, 0-9, _. Returns null if the cursor is already at the start of the document.
cursorWordRight(EditorState state) TransactionSpec?
Move the cursor to the end of the current word (or start of next word after whitespace). Word characters: a-z, A-Z, 0-9, _. Returns null if the cursor is already at the end of the document.
deleteCharBackward(EditorState state) TransactionSpec?
Delete the character before the cursor, or the selection if non-empty. Returns null if the cursor is at the start of the document with no selection.
deleteCharForward(EditorState state) TransactionSpec?
Delete the character after the cursor, or the selection if non-empty. Returns null if the cursor is at the end of the document with no selection.
deleteLine(EditorState state) TransactionSpec
Delete the line containing the cursor, including its newline. Handles first, last, only, and middle lines.
deleteSelection(EditorState state) TransactionSpec?
Delete the currently selected range. Returns null if the selection is empty (nothing to delete).
deleteWordBackward(EditorState state) TransactionSpec?
Delete from the cursor to the word boundary to the left. Returns null if the cursor is at the start of the document.
deleteWordForward(EditorState state) TransactionSpec?
Delete from the cursor to the word boundary to the right. Returns null if the cursor is at the end of the document.
duplicateLine(EditorState state) TransactionSpec
Insert a copy of the current line after itself. Cursor is placed at the same column on the duplicated line.
insertNewline(EditorState state) TransactionSpec
Insert a newline character at the cursor position.
insertTab(EditorState state) TransactionSpec
Insert two spaces (soft tab) at the cursor position.
insertText(EditorState state, String text) TransactionSpec
Insert text at the cursor, replacing any active selection. The cursor is placed after the inserted text.
moveLineDown(EditorState state) TransactionSpec?
Swap the current line with the line below it. Returns null if the cursor is on the last line.
moveLineUp(EditorState state) TransactionSpec?
Swap the current line with the line above it. Returns null if the cursor is on the first line.
redo(EditorState state) TransactionSpec?
Redo the last undone edit.
selectAll(EditorState state) TransactionSpec
Select the entire document (anchor=0, head=doc.length).
selectCharLeft(EditorState state) TransactionSpec?
Extend the selection one character to the left (keep anchor, move head). Returns null if the head is already at the start of the document.
selectCharRight(EditorState state) TransactionSpec?
Extend the selection one character to the right (keep anchor, move head). Returns null if the head is already at the end of the document.
selectWordLeft(EditorState state) TransactionSpec?
Extend the selection head to the next word boundary to the left. Returns null if the head is already at the start of the document.
selectWordRight(EditorState state) TransactionSpec?
Extend the selection head to the next word boundary to the right. Returns null if the head is already at the end of the document.
undo(EditorState state) TransactionSpec?
Undo the last edit.