Skip to main content

Module commands

Module commands 

Source
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§

AutoPair
A single auto-pair entry (opening + closing delimiter).
AutoPairsConfig
Auto-pairs configuration used by EditCommand::TypeChar, and optionally by delete-like commands (pair deletion).
CommandExecutor
Command executor
EditorCore
Editor Core state
Position
Position coordinates (line and column numbers)
Selection
Selection range
TextEditSpec
A simple document text edit (character offsets, half-open).
UndoHistorySelectionSet
Persisted selection set state captured alongside undo/redo steps.
UndoHistorySnapshot
A persistable snapshot of the undo/redo history for a single document.
UndoHistoryStep
A single undo/redo step in a persisted history snapshot.
UndoHistoryTextEdit
A single persisted text edit in an undo/redo step.
WordBoundaryConfig
Word boundary configuration used by editor-friendly “word” operations (selection expansion, double-click selection, etc.).

Enums§

Command
Unified command enum
CommandError
Command error type
CommandResult
Command execution result
CursorCommand
Cursor & selection commands
EditCommand
Text editing commands
ExpandSelectionDirection
Selection expansion direction for CursorCommand::ExpandSelectionBy.
ExpandSelectionUnit
Selection expansion unit for CursorCommand::ExpandSelectionBy.
SelectionDirection
Selection direction
StyleCommand
Style and folding commands
TabKeyBehavior
Controls how a Tab key press is handled by the editor when using EditCommand::InsertTab.
UndoHistoryRestoreError
Errors produced when restoring undo history snapshots.
ViewCommand
View commands