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.
CellRange
A rectangular range of cells within a single table (inclusive bounds).
CellSnapshot
Snapshot of one table cell including its block content.
Color
An RGBA color value. Each component is 0–255.
DjotExportOptions
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.
DjotImportOptions
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.
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.
FrameRef
Reference to the frame that immediately encloses the cursor’s block. depth is the nesting level (1 for a direct child of the root). is_blockquote is true iff fmt_is_blockquote is Some(true).
FrameSnapshot
Snapshot of a sub-frame and its contents.
HighlightContext
Context passed to SyntaxHighlighter::highlight_block.
HighlightFormat
Formatting applied by a syntax highlighter to a text range.
HighlightSpan
A single highlight span within a block.
HtmlImportResult
Result of an HTML import (set_html).
ListFormat
List formatting. All fields are optional: None means “not set — don’t change this property.”
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).
PaintHighlightSpan
A resolved paint-only highlight span for one character range of a block.
Subscription
Handle to a document event subscription.
TableCellContext
Snapshot-friendly reference to a table cell (plain IDs, no live handles).
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
DocumentError
Errors returned by the public text-document API.
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
Content type for an inline segment: text, image, or empty.
ListStyle
MarkerType
MoveMode
Controls whether a movement collapses or extends the selection.
MoveOperation
Semantic cursor movement operations.
ResourceType
SelectionKind
Describes what kind of selection the cursor currently has.
SelectionType
Quick-select a region around the cursor.
TextDirection
UnderlineStyle
WrapMode

Traits§

SyntaxHighlighter
A user-implemented syntax highlighter that applies visual-only formatting.

Type Aliases§

Result
Result alias used throughout the public API.