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§
- Auto
Pair - A single auto-pair entry (opening + closing delimiter).
- Auto
Pairs Config - Auto-pairs configuration used by
EditCommand::TypeChar, and optionally by delete-like commands (pair deletion). - Command
Executor - Command executor
- Editor
Core - Editor Core state
- Position
- Position coordinates (line and column numbers)
- Selection
- Selection range
- Text
Edit Spec - A simple document text edit (character offsets, half-open).
- Undo
History Selection Set - Persisted selection set state captured alongside undo/redo steps.
- Undo
History Snapshot - A persistable snapshot of the undo/redo history for a single document.
- Undo
History Step - A single undo/redo step in a persisted history snapshot.
- Undo
History Text Edit - A single persisted text edit in an undo/redo step.
- Word
Boundary Config - Word boundary configuration used by editor-friendly “word” operations (selection expansion, double-click selection, etc.).
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
- Expand
Selection Direction - Selection expansion direction for
CursorCommand::ExpandSelectionBy. - Expand
Selection Unit - Selection expansion unit for
CursorCommand::ExpandSelectionBy. - 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. - Undo
History Restore Error - Errors produced when restoring undo history snapshots.
- View
Command - View commands