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
replacementand 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.
- History
Limits - Limits apply to retained undo and redo entries together.
- Inline
Style - Paragraph
- An immutable paragraph. Its text and formatting can be shared by history.
- Position
- A caret position.
byteis a UTF-8 offset at an extended grapheme boundary. - Search
Options - 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.
- Style
Patch - Only supplied attributes change.
Some(None)clears a foreground color.
Enums§
- Error
- Fragment
Error - A malformed or unsupported native rich-text fragment.
- Movement
- Paragraph
Kind