Skip to content

qvanderlaan/cpp-terminal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C++ Terminal

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.

Features

  • 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.

Prerequisites

Before building, ensure you have the following dependencies installed:

  • Compiler: A C++17 compatible compiler (Clang/GCC).
  • Build Tools: make, cmake, and pkg-config.
  • Graphics: GLFW (required by MLX42).
  • Fonts: FreeType 2.
  • System: Linux or macOS.

Getting Started

1. Clone the repository

git clone --recursive git@github.com:qvanderlaan/cpp-terminal.git
cd cpp-terminal

2. Build

make

3. Run

./terminal

Controls

  • 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.

Architecture

The project is divided into four main modules:

  1. Core: Handles the FontRenderer (FreeType abstraction) and the main Renderer which interfaces with the MLX42 framebuffer.
  2. 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.
  3. Terminal Engine: Manages the Pty (Pseudoterminal) communication, ANSI escape code stripping, and command block state.
  4. Hooks: The bridge between MLX42 events (keys, scroll, resize) and the application state.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

C++ terminal emulator with block-based UI, custom layout engine, and hardware-accelerated rendering.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors