Be aware: This project is a work in progress and may contain bugs or incomplete features.
A terminal emulator built from the ground up using MLX42 for hardware-accelerated rendering and FreeType for crisp font typography. It is based on the Warp terminal's innovative block-based UI design, which organizes command history into discrete, inspectable blocks rather than a continuous stream of text.
Unlike traditional terminals that treat output as a flat stream of text, Terminal-UI uses a custom-built UI layout engine to organize command history into discrete, inspectable blocks, complete with execution timing, Git branch detection, and context-aware styling.
- Block-Based Architecture: Every command and its output is encapsulated in a UI "Div," making history easier to scan.
- Custom UI Engine: Includes a lightweight layout system (Elements, Divs, Text) with Flexbox-inspired logic (Columns/Rows/Gaps).
- Performance Metrics: Automatically tracks and displays how long each command took to execute.
- Context Awareness: Displays the current working directory (CWD) and active Git branch for every command block.
- Hardware Accelerated: Uses MLX42 (OpenGL based) for smooth scrolling and rendering.
- UTF-8 Support: Full support for multi-byte character rendering.
- Error Highlighting: Basic heuristic detection to highlight command blocks containing errors.
Before building, ensure you have the following dependencies installed:
- Compiler: A C++17 compatible compiler (Clang/GCC).
- Build Tools:
make,cmake, andpkg-config. - Graphics: GLFW (required by MLX42).
- Fonts: FreeType 2.
- System: Linux or macOS.
git clone --recursive git@github.com:qvanderlaan/cpp-terminal.git
cd cpp-terminalmake./terminal- Typing: Standard character input.
- Enter: Execute the current command.
- Backspace: Delete characters.
- Mouse Wheel: Scroll through command history.
- Auto-Scroll: The terminal automatically snaps to the bottom when you type or execute a command.
The project is divided into four main modules:
- Core: Handles the
FontRenderer(FreeType abstraction) and the mainRendererwhich interfaces with the MLX42 framebuffer. - UI: A custom DOM-like hierarchy.
Element: Base class for layout and drawing.Div: Container with support for vertical/horizontal stacking and gaps.TextElement: Handles text wrapping and rendering.
- Terminal Engine: Manages the
Pty(Pseudoterminal) communication, ANSI escape code stripping, and command block state. - Hooks: The bridge between MLX42 events (keys, scroll, resize) and the application state.
This project is licensed under the MIT License - see the LICENSE file for details.