Module buffer

Module buffer 

Source
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:

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.
RenderResult
The result of a call to TextBuffer::render().
SearchOptions
Options for a search operation.
TextBuffer
A text buffer for a text editor.
TextBufferStatistics
Stores statistics about the whole document.

Enums§

Bom
CursorMovement
Char- or word-wise navigation? Your choice.

Type Aliases§

RcTextBuffer
A TextBuffer inside an Rc.
TextBufferCell
A TextBuffer with inner mutability.