Expand description
Command Interface Layer
Provides a unified command interface for convenient frontend integration.
§Overview
The Command Interface Layer is the primary entry point for Editor Core, wrapping all underlying components in a unified command pattern. It supports the following types of operations:
- Text Editing: Insert, delete, and replace text
- Cursor Operations: Move cursor and set selection range
- View Management: Set viewport, scroll, and get visible content
- Style Control: Add/remove styles and code folding
§Example
use editor_core::{CommandExecutor, Command, EditCommand};
let mut executor = CommandExecutor::empty(80);
// Insert text
executor.execute(Command::Edit(EditCommand::Insert {
offset: 0,
text: "Hello, World!".to_string(),
})).unwrap();
// Batch execute commands
let commands = vec![
Command::Edit(EditCommand::Insert { offset: 0, text: "Line 1\n".to_string() }),
Command::Edit(EditCommand::Insert { offset: 7, text: "Line 2\n".to_string() }),
];
executor.execute_batch(commands).unwrap();Structs§
- Command
Executor - Command executor
- Editor
Core - Editor Core state
- Position
- Position coordinates (line and column numbers)
- Selection
- Selection range
Enums§
- Command
- Unified command enum
- Command
Error - Command error type
- Command
Result - Command execution result
- Cursor
Command - Cursor & selection commands
- Edit
Command - Text editing commands
- Selection
Direction - Selection direction
- Style
Command - Style and folding commands
- TabKey
Behavior - Controls how a Tab key press is handled by the editor when using
EditCommand::InsertTab. - View
Command - View commands