I Use a Gap Buffer, Bitch.
← back to blogI got tired of waiting for my editor to load, and I got tired of remembering which mode I was in. So I wrote my own.
FUCK VIM.
And Honeymoon doesn’t run a Lisp interpreter that eats 4GB of RAM on startup. It is a minimal, Emacs-inspired terminal text editor written in C++20.
It is fast.
Features
- Visual Mode
Ctrl-Spaceto mark. Move.Ctrl-Wto cut. Just like Emacs, but without the pinky pain. (Okay, maybe some pinky pain.)
Architecture
The code is split into three namespaces:
-
honeymoon::kernelCore editor logic. -
honeymoon::driverRaw mode, TTY I/O, screen rendering. -
honeymoon::memA templated gap buffer implementation.
The Gap Buffer
Instead of a simple string or a rope (which can be complex), Honeymoon uses a Gap Buffer. This is a dynamic array with a “gap” (a sequence of unused entries) that moves with the cursor. This makes insertions and deletions at the cursor position extremely efficient—O(1) in most cases—without the overhead of shifting the entire document.
// Simplified concept
['H', 'e', 'l', 'l', 'o', _, _, _, _, 'W', 'o', 'r', 'l', 'd']
^ Gap starts here
Build
You need a C++20 compiler and make.
- Linux: you’re fine.
- Windows: WSL or sm.
make
./honeymoon filename.txt
Controls
If you know Vim, I’m sorry.
Internals
For a deeper dive into the technical details (ANSI, custom drivers, etc.), check out the full internals documentation: mooofin.github.io/honeymoon/index.html