Skip to main content

Crate text_document

Crate text_document 

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

BlockFormat
Block (paragraph) formatting. All fields are optional.
BlockInfo
Info about a block at a given position.
DocumentFragment
A piece of rich text that can be inserted into a TextDocument.
DocumentStats
Document-level statistics. O(1) cached.
DocxExportResult
Result of a DOCX export (to_docx).
FindMatch
A single search match.
FindOptions
Options for find / find_all / replace operations.
FrameFormat
Frame formatting. All fields are optional.
HtmlImportResult
Result of an HTML import (set_html).
MarkdownImportResult
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.
TextCursor
A cursor into a TextDocument.
TextDocument
A rich text document.
TextFormat
Character/text formatting. All fields are optional: None means “not set — inherit from the block’s default or the document’s default.”

Enums§

Alignment
CharVerticalAlignment
DocumentEvent
Events emitted by a TextDocument.
FramePosition
InlineContent
ListStyle
MarkerType
MoveMode
Controls whether a movement collapses or extends the selection.
MoveOperation
Semantic cursor movement operations.
ResourceType
SelectionType
Quick-select a region around the cursor.
TextDirection
UnderlineStyle
WrapMode

Type Aliases§

Result