pub struct CommandExecutor { /* private fields */ }Expand description
Command executor
CommandExecutor is the main interface for the editor, responsible for:
- Execute various editor commands
- Maintain command history
- Handle errors and exceptions
- Ensure editor state consistency
§Command Types
EditCommand- Text insertion, deletion, replacementCursorCommand- Cursor movement, selection operationsViewCommand- Viewport management and scroll controlStyleCommand- Style and folding management
§Example
use editor_core::{CommandExecutor, Command, EditCommand, CursorCommand, Position};
let mut executor = CommandExecutor::empty(80);
// Insert text
executor.execute(Command::Edit(EditCommand::Insert {
offset: 0,
text: "fn main() {}".to_string(),
})).unwrap();
// Move cursor
executor.execute(Command::Cursor(CursorCommand::MoveTo {
line: 0,
column: 3,
})).unwrap();
assert_eq!(executor.editor().cursor_position(), Position::new(0, 3));Implementations§
Source§impl CommandExecutor
impl CommandExecutor
Sourcepub fn execute(
&mut self,
command: Command,
) -> Result<CommandResult, CommandError>
pub fn execute( &mut self, command: Command, ) -> Result<CommandResult, CommandError>
Execute command
Sourcepub fn execute_batch(
&mut self,
commands: Vec<Command>,
) -> Result<Vec<CommandResult>, CommandError>
pub fn execute_batch( &mut self, commands: Vec<Command>, ) -> Result<Vec<CommandResult>, CommandError>
Batch execute commands (transactional)
Sourcepub fn get_command_history(&self) -> &[Command]
pub fn get_command_history(&self) -> &[Command]
Get command history
Sourcepub fn undo_depth(&self) -> usize
pub fn undo_depth(&self) -> usize
Undo stack depth (counted by undo steps; grouped undo may pop multiple steps at once)
Sourcepub fn redo_depth(&self) -> usize
pub fn redo_depth(&self) -> usize
Redo stack depth (counted by undo steps)
Sourcepub fn current_change_group(&self) -> Option<usize>
pub fn current_change_group(&self) -> Option<usize>
Currently open undo group ID (for insert coalescing only)
Sourcepub fn mark_clean(&mut self)
pub fn mark_clean(&mut self)
Mark current state as clean point (call after saving file)
Sourcepub fn editor(&self) -> &EditorCore
pub fn editor(&self) -> &EditorCore
Get a reference to the Editor Core
Sourcepub fn editor_mut(&mut self) -> &mut EditorCore
pub fn editor_mut(&mut self) -> &mut EditorCore
Get a mutable reference to the Editor Core
Auto Trait Implementations§
impl Freeze for CommandExecutor
impl RefUnwindSafe for CommandExecutor
impl Send for CommandExecutor
impl Sync for CommandExecutor
impl Unpin for CommandExecutor
impl UnwindSafe for CommandExecutor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more