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.
BlockSnapshot
All layout-relevant data for one block, captured atomically.
CellFormat
Cell-level formatting.
CellSnapshot
Snapshot of one table cell including its block content.
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.
FlowSnapshot
Consistent snapshot of the entire document flow, captured in a single lock acquisition.
FrameFormat
Frame formatting. All fields are optional.
FrameSnapshot
Snapshot of a sub-frame and its contents.
HtmlImportResult
Result of an HTML import (set_html).
ListInfo
List membership and marker information for a block.
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.
TableCellRef
Reference to a table cell that contains a block.
TableFormat
Table-level formatting.
TableSnapshot
Consistent snapshot of a table’s structure and all cell content.
TextBlock
A lightweight, read-only handle to a single block (paragraph).
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.”
TextFrame
A read-only handle to a frame in the document.
TextList
A read-only handle to a list in the document.
TextTable
A read-only handle to a table in the document.
TextTableCell
A read-only handle to a single cell within a table.

Enums§

Alignment
CellVerticalAlignment
Vertical alignment within a table cell.
CharVerticalAlignment
DocumentEvent
Events emitted by a TextDocument.
FlowElement
An element in the document’s visual flow.
FlowElementSnapshot
Snapshot of one flow element.
FormatChangeKind
What kind of formatting changed.
FragmentContent
A contiguous run of content with uniform formatting within a block.
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