A C++ text editor built from scratch with OpenGL rendering, targeting 60+ fps with GB-sized files.
- Rope Data Structure - AVL-balanced tree (256-512 byte nodes) with O(log n) operations
- X11/OpenGL Platform - Direct X11 window management with OpenGL 3.3 context
- FreeType Font Rendering - Dynamic glyph atlas with subpixel antialiasing
- Instanced Rendering - Single draw call for up to 100k glyphs per frame
- Text Editing - Insert/delete operations using the rope structure
- File I/O - Load and save text files
- Header-only architecture for fast compilation
- Unity build support (compiles in ~1 second)
- Comprehensive rope unit tests (all passing)
- Subpixel AA with gamma correction
- HiDPI display support
- LRU glyph atlas caching
# Install dependencies (Ubuntu/Debian)
sudo apt-get install -y libfreetype-dev libglew-dev libx11-dev
# Build
make unity
# Run
./zed [filename]zed/
├── Makefile # Unity build system
├── src/
│ ├── main.cpp # Entry point
│ ├── platform.h # X11 window + OpenGL context (180 lines)
│ ├── rope.h # AVL-balanced rope (407 lines)
│ ├── font.h # FreeType + glyph atlas (229 lines)
│ ├── renderer.h # Instanced text rendering (352 lines)
│ ├── shaders.h # GLSL shaders (109 lines)
│ ├── editor.h # Editor state + logic (126 lines)
│ └── config.h # Configuration system (92 lines)
├── tests/
│ └── rope_test.cpp # Rope unit tests (all passing!)
└── assets/
├── default_config.json
└── default_theme.json
Fully Functional:
- Window creation and event handling
- Text rendering with beautiful subpixel AA
- Rope-based text buffer
- Character insertion
- File loading
- Keyboard input
Working On:
- Cursor rendering and navigation
- Backspace/Delete handling
- Text selection
- Undo/redo system
- File saving
- Compilation: ~1 second unity build
- Binary Size: 311KB
- Target: 60+ fps with GB files
- Rope Operations: O(log n) insert/delete/lookup
# Run rope tests
make testAll rope tests passing:
- Creation and initialization
- Insert operations
- Delete operations
- Character access
- Large file handling (1000+ lines)
- AVL-balanced binary tree
- Small nodes (256-512 bytes) for cache efficiency
- Automatic rebalancing on insert/delete
- Supports arbitrary file sizes
- Text → Rope structure
- Rope → Character sequence
- Characters → Glyph lookups (FreeType)
- Glyphs → Atlas packing (LRU eviction)
- Atlas coords → Instance data
- Single
glDrawArraysInstanced()call
- Vertex: Orthographic projection + instance transform
- Fragment: RGB subpixel AA + gamma correction
- Configurable theme colors
Edit assets/default_config.json:
{
"font": {
"path": "/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf",
"size": 14
},
"theme": {
"background": "#1e1e1e",
"foreground": "#d4d4d4",
"cursor": "#00ff00",
"selection": "#264f78"
}
}- Rope data structure
- Text rendering
- File loading
- Character insertion
- Cursor rendering
- Arrow key navigation
- Backspace/Delete
- File saving
- Undo/redo
- Multi-cursor editing
- Search (find)
- Command palette
- Theme system
- Replace (search & replace)
- Syntax highlighting (background thread)
- Line numbers
- Minimap
- Rope over Gap Buffer - O(log n) ops, essential for multi-cursor and huge files
- Header-only - Fast compilation, easy to understand
- OpenGL 3.3 - Balance of performance and compatibility
- No text shaping - Simpler pipeline, Latin text only (for now)
- Subpixel AA - Highest quality rendering
- X11 direct - Full control, no framework overhead
- ASCII only (no UTF-8 yet)
- No syntax highlighting yet
- No line numbers
- Limited keybindings
- Linux only (X11)
See SPEC.md for complete technical specification including:
- Detailed architecture
- Performance targets
- Threading model
- Memory management
- Risk mitigation
# Unity build (fast)
make unity
# Regular build
make
# Clean
make clean
# Run tests
make test
# Run editor
./zed SPEC.mdBuilt from scratch as an educational project demonstrating:
- High-performance text rendering
- Advanced data structures (AVL rope)
- OpenGL instanced rendering
- Modern C++ architecture
Status: MVP in active development - core systems fully functional!