A minimal, blazing-fast code editor built entirely from scratch in C++ and Qt. No Electron. No bloat. Just pure engineering.
Core features
Custom QPainter loop draws only visible lines. No layout engine. No DOM. Sub-millisecond frame times even on large files.
Cursor tracked as (row, col) and converted to pixels only at paint time. Eliminating an entire class of rendering bugs.
Hand-written tokenizer with no regex overhead. Identifies keywords, types, strings, and comments in a single O(n) pass.
Open and save any file instantly with Qt's native file dialogs. Reads directly into the line buffer — no intermediate copies.
Rendered with a fixed 50px offset. Current line highlighted. Gutter background separated with a subtle 0.5px border.
On Enter, the editor copies the leading whitespace from the current line. Keeps your indentation intact across the session.
Architecture
Each layer has a single responsibility. The buffer owns the data. The renderer owns the pixels. They never talk directly — only through the cursor.
std::vector<std::string> — one string per line. Insert, delete, split, merge.
O(1) line accessStruct { int row; int col }. Logical position only — pixels are derived, never stored.
decoupled from renderQPainter in paintEvent. Draws only the visible viewport window, token by token.
viewport cullingkeyPressEvent routes chars to buffer, arrows to cursor, and calls update() once per event.
single repaint/eventSingle-pass lexer classifies tokens into keyword, type, string, comment, or plain text.
O(n) per lineBuild roadmap
Tech decisions
Rope trees are powerful but overkill. For files under 20k lines, vector<string> is faster to implement and reason about — and finishes in the time budget.
Tracking cursor in (row, col) and converting to pixels at render time eliminates an entire class of drift bugs when the font changes or the viewport scrolls.
Only draw lines between startRow and endRow based on scrollY. A 10,000-line file runs at the same FPS as a 10-line file.
QFont initialized with a fixed monospace font at startup. Variable-width fonts break all cursor math — this constraint is non-negotiable.
Open source
Clone the repo, study the code, build on it. Valence is a proof that systems software doesn't need frameworks.