Expand description
§text-document
A rich text document model for Rust.
Provides a TextDocument as the main entry point and TextCursor for
cursor-based editing, inspired by Qt’s QTextDocument/QTextCursor API.
use text_document::{TextDocument, MoveMode, MoveOperation};
let doc = TextDocument::new();
doc.set_plain_text("Hello world").unwrap();
let cursor = doc.cursor();
cursor.move_position(MoveOperation::EndOfWord, MoveMode::KeepAnchor, 1);
cursor.insert_text("Goodbye").unwrap(); // replaces "Hello"
// Multiple cursors on the same document
let c1 = doc.cursor();
let c2 = doc.cursor_at(5);
c1.insert_text("A").unwrap();
// c2's position is automatically adjusted
doc.undo().unwrap();Structs§
- Block
Format - Block (paragraph) formatting. All fields are optional.
- Block
Info - Info about a block at a given position.
- Document
Fragment - A piece of rich text that can be inserted into a
TextDocument. - Document
Stats - Document-level statistics. O(1) cached.
- Docx
Export Result - Result of a DOCX export (
to_docx). - Find
Match - A single search match.
- Find
Options - Options for find / find_all / replace operations.
- Frame
Format - Frame formatting. All fields are optional.
- Html
Import Result - Result of an HTML import (
set_html). - Markdown
Import Result - Result of a Markdown import (
set_markdown). - Operation
- A handle to a running long operation (Markdown/HTML import, DOCX export).
- Subscription
- Handle to a document event subscription.
- Text
Cursor - A cursor into a
TextDocument. - Text
Document - A rich text document.
- Text
Format - Character/text formatting. All fields are optional:
Nonemeans “not set — inherit from the block’s default or the document’s default.”
Enums§
- Alignment
- Char
Vertical Alignment - Document
Event - Events emitted by a
TextDocument. - Frame
Position - Inline
Content - List
Style - Marker
Type - Move
Mode - Controls whether a movement collapses or extends the selection.
- Move
Operation - Semantic cursor movement operations.
- Resource
Type - Selection
Type - Quick-select a region around the cursor.
- Text
Direction - Underline
Style - Wrap
Mode