Expand description
A text buffer for a text editor.
Implements a Unicode-aware, layout-aware text buffer for terminals. It’s based on a gap buffer. It has no line cache and instead relies on the performance of the ucd module for fast text navigation.
If the project ever outgrows a basic gap buffer (e.g. to add time travel) an ideal, alternative architecture would be a piece table with immutable trees. The tree nodes can be allocated on the same arena allocator as the added chunks, making lifetime management fairly easy. The algorithm is described here:
- https://cdacamar.github.io/data%20structures/algorithms/benchmarking/text%20editors/c++/editor-data-structures/
- https://github.com/cdacamar/fredbuf
The downside is that text navigation & search takes a performance hit due to small chunks. The solution to the former is to keep line caches, which further complicates the architecture. There’s no solution for the latter. However, there’s a chance that the performance will still be sufficient.
Structs§
- GapBuffer
- Most people know how
Vec<T>works: It has some spare capacity at the end, so that pushing into it doesn’t reallocate every single time. A gap buffer is the same thing, but the spare capacity can be anywhere in the buffer. This variant is optimized for large buffers and uses virtual memory. - Render
Result - The result of a call to
TextBuffer::render(). - Search
Options - Options for a search operation.
- Text
Buffer - A text buffer for a text editor.
- Text
Buffer Statistics - Stores statistics about the whole document.
Enums§
- Bom
- Cursor
Movement - Char- or word-wise navigation? Your choice.
Type Aliases§
- RcText
Buffer - A
TextBufferinside anRc. - Text
Buffer Cell - A
TextBufferwith inner mutability.