TextBuffer.h file
TextBuffer: editable UTF-8 text stored as a piece table.
The original text and everything typed since are kept as two append-only stores; the document is a list of pieces referring into them. An edit changes the list, never the bytes, so it costs in proportion to the edit, not the document.
Positions byte offsets into the current text Anchors positions that survive edits made by anyone: carets, selection ends, decoration ends, IME composition Edits transactions: a set of replacements applied and undone together Undo per buffer; adjacent typing and adjacent deletes merge into one step Lines an index of line starts, maintained by every edit
Not thread-safe: use on the thread that updates the document showing it.
Namespaces
- namespace GGUI
Classes
- struct GGUI::TextAnchor
- Handle to an anchor. Only valid with the buffer that created it.
- struct GGUI::TextEdit
- Replace [Start, End) with Text. Start == End inserts; empty Text deletes.
- struct GGUI::TextChange
- Lines affected by a transaction: LinesBefore lines from FirstLine became LinesAfter.
- class GGUI::TextBuffer
- Editable UTF-8 text with anchors, undo, and a line index. See the file description.