1,001 B
1,001 B
title | date | draft | description | tags | categories | series | favorite | disable_feed | |||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Gap Buffer | 2024-07-06T21:27:19+01:00 | false | As featured in GNU Emacs |
|
|
|
false | false |
The Gap Buffer is a popular data structure for text editors to represent files and editable buffers. The most famous of them probably being emacs.
What does it do?
A Gap Buffer is simply a list of characters, similar to a normal string, but with the added twist of splitting it into two side: the prefix and suffix, on either side of the cursor. In between them, a gap is left to allow for quick insertion at the cursor.
Moving the cursor moves the gap around the buffer, the prefix and suffix getting shorter/longer as required.