Expand description
Editor State Interface
Provides a complete state query interface for the editor, used for frontend rendering and state synchronization.
§Overview
The state interface layer exposes the editor’s internal state to the frontend in a structured, immutable manner. It supports:
- State Queries: Retrieve document, cursor, viewport, and other state information
- Version Tracking: Track state changes through version numbers
- Change Notifications: Subscribe to state change events
- Viewport Management: Obtain rendering data for visible regions
§Example
use editor_core::{EditorStateManager, StateChangeType};
let mut manager = EditorStateManager::new("Hello, World!", 80);
// Query document state
let doc_state = manager.get_document_state();
println!("Line count: {}", doc_state.line_count);
// Subscribe to state changes
manager.subscribe(|change| {
println!("State changed: {:?}", change.change_type);
});
// Modify document and mark changes
manager.editor_mut().piece_table.insert(0, "New: ");
manager.mark_modified(StateChangeType::DocumentModified);Structs§
- Cursor
State - Cursor state
- Document
State - Document state
- Editor
State - Complete editor state snapshot
- Editor
State Manager - Editor state manager
- Folding
State - Folding state
- State
Change - State change record
- Style
State - Style state
- Undo
Redo State - Undo/redo stack state
- Viewport
State - Viewport state
Enums§
- State
Change Type - State change type
Type Aliases§
- State
Change Callback - State change callback function type