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§

CommandExecutor
Command executor
EditorCore
Editor Core state
Position
Position coordinates (line and column numbers)
Selection
Selection range

Enums§

Command
Unified command enum
CommandError
Command error type
CommandResult
Command execution result
CursorCommand
Cursor & selection commands
EditCommand
Text editing commands
SelectionDirection
Selection direction
StyleCommand
Style and folding commands
TabKeyBehavior
Controls how a Tab key press is handled by the editor when using EditCommand::InsertTab.
ViewCommand
View commands