Skip to main content

Crate textloom

Crate textloom 

Source
Expand description

Native rich-text editing, independent of any window system or renderer.

Positions use paragraph indices and UTF-8 byte offsets at grapheme boundaries. GUI integrations are opt-in; the default build depends only on Unicode segmentation.

use textloom::{Editor, Position, Selection, StylePatch};
let mut editor = Editor::from_text("Hello Rust");
editor.set_selection(Selection::new(Position::new(0, 0), Position::new(0, 5)))?;
editor.apply_style(StylePatch { bold: Some(true), ..Default::default() })?;
assert!(editor.document().paragraph(0).unwrap().spans()[0].style.bold);
assert!(editor.undo());

Modules§

accessibility
Borrowed semantics for custom GUI adapters, with an optional AccessKit tree.
adapter
GUI adapters keep platform events and rendering outside the editing core.

Structs§

Color
Unpremultiplied sRGBA color.
Composition
Native IME preedit. It is rendered over replacement and never stored in the document.
Document
A document always contains at least one paragraph.
Editor
A document, directional selection, bounded history, and transient IME state.
Fragment
An immutable piece of a rich-text document, suitable for a clipboard.
HistoryLimits
Limits apply to retained undo and redo entries together.
InlineStyle
Paragraph
An immutable paragraph. Its text and formatting can be shared by history.
Position
A caret position. byte is a UTF-8 offset at an extended grapheme boundary.
SearchOptions
Options for explicit document searches.
Selection
A directional selection: the anchor stays fixed while the focus moves.
Span
A run of equally formatted text, measured in UTF-8 bytes within a paragraph.
StylePatch
Only supplied attributes change. Some(None) clears a foreground color.

Enums§

Error
FragmentError
A malformed or unsupported native rich-text fragment.
Movement
ParagraphKind