pub struct Editor { /* private fields */ }Expand description
The editor state machine. Ties together buffer, selection, and history. This is the primary public API for kode-core.
Implementations§
Source§impl Editor
impl Editor
pub fn buffer(&self) -> &Buffer
pub fn text(&self) -> String
pub fn selection(&self) -> Selection
pub fn cursor(&self) -> Position
pub fn version(&self) -> u64
pub fn is_dirty(&self) -> bool
pub fn can_undo(&self) -> bool
pub fn can_redo(&self) -> bool
pub fn mark_clean(&mut self)
Sourcepub fn selected_text(&self) -> String
pub fn selected_text(&self) -> String
Get the selected text, or empty string if cursor only.
Sourcepub fn insert(&mut self, text: &str)
pub fn insert(&mut self, text: &str)
Insert text at the cursor. If there’s a selection, replace it.
Sourcepub fn delete_forward(&mut self)
pub fn delete_forward(&mut self)
Delete the character after the cursor (forward delete).
Sourcepub fn delete_selection(&mut self)
pub fn delete_selection(&mut self)
Delete the current selection. No-op if cursor only.
Sourcepub fn insert_newline(&mut self)
pub fn insert_newline(&mut self)
Insert a newline at the cursor.
Sourcepub fn apply_transaction(&mut self, tx: Transaction)
pub fn apply_transaction(&mut self, tx: Transaction)
Apply a pre-built transaction atomically. All steps are applied and a single history entry is created for undo.
Steps must contain sequential offsets: each step’s offset is relative to the buffer state after all previous steps have been applied.
Sourcepub fn set_cursor(&mut self, pos: Position)
pub fn set_cursor(&mut self, pos: Position)
Set the cursor to a position, collapsing any selection.
Sourcepub fn set_selection(&mut self, anchor: Position, head: Position)
pub fn set_selection(&mut self, anchor: Position, head: Position)
Set a selection range.
Sourcepub fn extend_selection(&mut self, head: Position)
pub fn extend_selection(&mut self, head: Position)
Extend the selection to a new head position (shift+arrow behavior).
Sourcepub fn select_all(&mut self)
pub fn select_all(&mut self)
Select all text.
Sourcepub fn move_right(&mut self)
pub fn move_right(&mut self)
Move cursor right by one character.
Sourcepub fn move_to_line_start(&mut self)
pub fn move_to_line_start(&mut self)
Move cursor to start of current line.
Sourcepub fn move_to_line_end(&mut self)
pub fn move_to_line_end(&mut self)
Move cursor to end of current line.
Sourcepub fn move_to_start(&mut self)
pub fn move_to_start(&mut self)
Move cursor to start of document.
Sourcepub fn move_to_end(&mut self)
pub fn move_to_end(&mut self)
Move cursor to end of document.
Sourcepub fn move_word_left(&mut self)
pub fn move_word_left(&mut self)
Move cursor left to the start of the previous word.
Sourcepub fn move_word_right(&mut self)
pub fn move_word_right(&mut self)
Move cursor right to the end of the next word.
Sourcepub fn extend_selection_left(&mut self)
pub fn extend_selection_left(&mut self)
Extend selection one character left (Shift+Left).
Sourcepub fn extend_selection_right(&mut self)
pub fn extend_selection_right(&mut self)
Extend selection one character right (Shift+Right).
Sourcepub fn extend_selection_up(&mut self)
pub fn extend_selection_up(&mut self)
Extend selection up one line (Shift+Up).
Sourcepub fn extend_selection_down(&mut self)
pub fn extend_selection_down(&mut self)
Extend selection down one line (Shift+Down).
Sourcepub fn extend_selection_word_left(&mut self)
pub fn extend_selection_word_left(&mut self)
Extend selection to word boundary left (Shift+Ctrl+Left).
Sourcepub fn extend_selection_word_right(&mut self)
pub fn extend_selection_word_right(&mut self)
Extend selection to word boundary right (Shift+Ctrl+Right).
Sourcepub fn extend_selection_to_line_start(&mut self)
pub fn extend_selection_to_line_start(&mut self)
Extend selection to line start (Shift+Home).
Sourcepub fn extend_selection_to_line_end(&mut self)
pub fn extend_selection_to_line_end(&mut self)
Extend selection to line end (Shift+End).
Sourcepub fn extend_selection_to_start(&mut self)
pub fn extend_selection_to_start(&mut self)
Extend selection to document start (Ctrl+Shift+Home).
Sourcepub fn extend_selection_to_end(&mut self)
pub fn extend_selection_to_end(&mut self)
Extend selection to document end (Ctrl+Shift+End).
Sourcepub fn select_word(&mut self)
pub fn select_word(&mut self)
Select the word at the cursor (double-click behavior).
Sourcepub fn select_line(&mut self)
pub fn select_line(&mut self)
Select the entire current line (triple-click behavior).
Sourcepub fn delete_word_back(&mut self)
pub fn delete_word_back(&mut self)
Delete from cursor to start of previous word (Ctrl+Backspace).
Sourcepub fn delete_word_forward(&mut self)
pub fn delete_word_forward(&mut self)
Delete from cursor to end of next word (Ctrl+Delete).
Sourcepub fn outdent(&mut self)
pub fn outdent(&mut self)
Remove one level of indentation (2 spaces) from the current or selected lines.
Sourcepub fn duplicate_lines(&mut self)
pub fn duplicate_lines(&mut self)
Duplicate the current line or all selected lines (Ctrl+D).
Sourcepub fn word_start_before_cursor(&self) -> Position
pub fn word_start_before_cursor(&self) -> Position
Get the position at the start of the word before/at the cursor. Used by the autocomplete system to determine the prefix to replace.