ERBSLAND COLOR TERM

A Unicode-aware, cross-platform terminal library for modern C++

Language C++
License Apache 2.0

Erbsland Color Term is a compact C++20 library for building terminal applications that need more than plain text output.

It brings together colorful screen rendering, Unicode-aware text handling, keyboard input, geometry helpers, and drawing utilities in one focused package. The goal is to provide a practical foundation for terminal dashboards, tools, and small games that behave consistently across Linux, macOS, and Windows.

#include <erbsland/cterm/Terminal.hpp>

using namespace erbsland::cterm;

auto main() -> int {
    auto terminal = Terminal{{80, 25}};
    terminal.initializeScreen();

    terminal.printLine(fg::BrightGreen, "Hello terminal.");

    terminal.restoreScreen();
    return 0;
}

Key Features

Erbsland Color Term focuses on areas of terminal development that often become fragile when implemented from scratch:

  • One consistent API for Linux, macOS, and Windows, covering terminal output, screen handling, and keyboard input.
  • Correct layout for full-width and zero-width Unicode sequences, including mixed-width text and combining characters.
  • Buffer-based rendering for full-screen terminal applications with resize-aware updates.
  • Frame, rectangle, line, and geometry helpers for building structured terminal layouts.
  • Automatic handling of frame intersections so borders combine cleanly.
  • Integrated text wrapping, alignment, color sequences, and bitmap-font support.
  • A lightweight static-library design that integrates cleanly into modern CMake-based C++20 projects.

Portable Full-Screen Rendering

The retro-plasma demo shows the library in a dynamic scenario: a full-screen terminal animation driven by a continuously updated buffer, timed redraws, keyboard input, and palette changes.

This kind of workload is where portability often becomes complicated. Here, the same library interface covers screen updates, resize handling, and interactive input, allowing the application code to focus on the visual effect rather than platform-specific terminal behavior.

Consistent Results Across Platforms

The screenshots show the same retro-plasma demo running on Windows and macOS. Achieving consistent behavior across platforms is one of the core goals of the library.

With a single user-facing implementation, the library handles terminal-specific differences internally. For terminal tools and TUIs, this often matters more than feature count: it reduces conditional code, prevents platform drift, and helps applications behave predictably on different systems.

Unicode Layout That Holds Together

Terminal layouts often break when full-width East Asian text, combining marks, or other zero-width characters appear. Erbsland Color Term accounts for these display widths directly, helping wrapped, centered, and panel-based layouts remain stable.

The text-gallery demo demonstrates this by combining framed panels, wrapped text, animated titles, and styled prompts on a single screen without the character-width glitches that frequently occur in terminal interfaces.

Frames That Combine Cleanly

The library also provides carefully designed drawing primitives. With the frame and rectangle utilities, structured terminal interfaces can be created quickly, and intersecting borders are resolved automatically so the result remains visually coherent.

The frame-weaver demo highlights this behavior. It draws frames of different sizes, colors, and line styles while the library selects suitable intersection characters for each overlap.

Requirements

The technical requirements are intentionally modest:

  • A C++ compiler with support for C++20 or later.
  • A C++ standard library with C++20 support.
  • CMake 3.28 or newer.

The recommended integration approach is straightforward: add the repository to your project and include it using add_subdirectory(...) in CMake.

Build a Small Terminal App

The documentation walks through building a small terminal dashboard step by step. It introduces direct output, buffered rendering, layout helpers, fonts, input handling, and resize-aware redraws.

Sources and License

The complete source code for Erbsland Color Term is available on GitHub.

The documentation is published at color-term.erbsland.dev. The project is released under the Apache License 2.0.