Expand description
Text storage and editing with styled segments.
This module provides rope-backed text buffers for efficient editing of large documents.
§Grapheme Pool Policy
This module’s public API uses &str for text content, keeping grapheme pool
details internal. Multi-codepoint grapheme clusters (emoji, ZWJ sequences) are
handled transparently during rendering using crate::GraphemeId::placeholder for
width-aware layout without pool allocation. Users needing direct grapheme pool
access should use crate::GraphemePool and crate::GraphemeId from the crate root.
Key types:
TextBuffer: Styled text storage with syntax highlighting supportEditBuffer: Editable buffer with cursor movement and undo/redoEditorView: Visual rendering with line numbers and selectionTextBufferView: Viewport configuration with wrapping modes
§Examples
§Basic Text Buffer
use opentui_rust::TextBuffer;
let buffer = TextBuffer::with_text("Hello, world!");
assert_eq!(buffer.len_chars(), 13);
assert_eq!(buffer.len_lines(), 1);§Editable Buffer with Undo
use opentui_rust::EditBuffer;
let mut editor = EditBuffer::new();
editor.insert("Hello");
editor.commit(); // Create undo checkpoint
editor.insert(" World");
editor.commit();
assert_eq!(editor.text(), "Hello World");
// Undo the last insert
editor.undo();
assert_eq!(editor.text(), "Hello");
// Redo brings it back
editor.redo();
assert_eq!(editor.text(), "Hello World");Structs§
- Edit
Buffer - Text buffer with editing operations, cursor, and undo/redo.
- Editor
View - Editor view wrapping an EditBuffer with visual rendering.
- Line
Info - Cached line layout information for wrapped text.
- Local
Selection - Local (viewport) selection based on screen coordinates.
- Rope
Wrapper - Wrapper around ropey::Rope with convenience methods.
- Selection
- Selection range.
- Styled
Segment - A segment of text with associated style.
- Text
Buffer - Text buffer with styled segments and highlights.
- Text
Buffer View - View into a text buffer with viewport and rendering options.
- Text
Measure - Measurement result for a given viewport size.
- Viewport
- Viewport configuration.
- Visual
Cursor - Visual cursor information in wrapped view.
Enums§
- Wrap
Mode - Text wrapping mode.