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.
- Block
Snapshot - All layout-relevant data for one block, captured atomically.
- Cell
Format - Cell-level formatting.
- Cell
Range - A rectangular range of cells within a single table (inclusive bounds).
- Cell
Snapshot - Snapshot of one table cell including its block content.
- Color
- An RGBA color value. Each component is 0–255.
- Djot
Export Options - Selects which optional block attributes the djot exporter emits as
{key=value}block attributes. A disabled attribute is omitted from the output even when the model carries a value for it. - Djot
Import Options - Selects which optional block attributes the djot importer applies to the document model. An attribute present in the source but disabled here is parsed and discarded, exactly like an unrepresentable construct.
- 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.
- Flow
Snapshot - Consistent snapshot of the entire document flow, captured in a single lock acquisition.
- Frame
Format - Frame formatting. All fields are optional.
- Frame
Ref - Reference to the frame that immediately encloses the cursor’s block.
depthis the nesting level (1 for a direct child of the root).is_blockquoteis true ifffmt_is_blockquoteisSome(true). - Frame
Snapshot - Snapshot of a sub-frame and its contents.
- Highlight
Context - Context passed to
SyntaxHighlighter::highlight_block. - Highlight
Format - Formatting applied by a syntax highlighter to a text range.
- Highlight
Span - A single highlight span within a block.
- Html
Import Result - Result of an HTML import (
set_html). - List
Format - List formatting. All fields are optional:
Nonemeans “not set — don’t change this property.” - List
Info - List membership and marker information for a block.
- Markdown
Import Result - Result of a Markdown import (
set_markdown). - Operation
- A handle to a running long operation (Markdown/HTML import, DOCX export).
- Paint
Highlight Span - A resolved paint-only highlight span for one character range of a block.
- Subscription
- Handle to a document event subscription.
- Table
Cell Context - Snapshot-friendly reference to a table cell (plain IDs, no live handles).
- Table
Cell Ref - Reference to a table cell that contains a block.
- Table
Format - Table-level formatting.
- Table
Snapshot - Consistent snapshot of a table’s structure and all cell content.
- Text
Block - A lightweight, read-only handle to a single block (paragraph).
- 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.” - Text
Frame - A read-only handle to a frame in the document.
- Text
List - A read-only handle to a list in the document.
- Text
Table - A read-only handle to a table in the document.
- Text
Table Cell - A read-only handle to a single cell within a table.
Enums§
- Alignment
- Cell
Vertical Alignment - Vertical alignment within a table cell.
- Char
Vertical Alignment - Document
Error - Errors returned by the public
text-documentAPI. - Document
Event - Events emitted by a
TextDocument. - Flow
Element - An element in the document’s visual flow.
- Flow
Element Snapshot - Snapshot of one flow element.
- Format
Change Kind - What kind of formatting changed.
- Fragment
Content - A contiguous run of content with uniform formatting within a block.
- Frame
Position - Inline
Content - Content type for an inline segment: text, image, or empty.
- List
Style - Marker
Type - Move
Mode - Controls whether a movement collapses or extends the selection.
- Move
Operation - Semantic cursor movement operations.
- Resource
Type - Selection
Kind - Describes what kind of selection the cursor currently has.
- Selection
Type - Quick-select a region around the cursor.
- Text
Direction - Underline
Style - Wrap
Mode
Traits§
- Syntax
Highlighter - A user-implemented syntax highlighter that applies visual-only formatting.
Type Aliases§
- Result
- Result alias used throughout the public API.