Skip to content

maya

A C++26 TUI framework — a compile-time type-safe DSL, a Yoga flexbox layout engine, reactive signals, an Elm-style runtime, and a SIMD-accelerated cell-diff renderer. Build fast, readable terminal user interfaces with minimal ceremony.

#include <maya/maya.hpp>
using namespace maya;
using namespace maya::dsl;

int main() {
    Signal<int> n{0};
    run(
        [&](const Event& ev) {
            on(ev, '+', [&]{ n.update([](int& x){ ++x; }); });
            return !key(ev, 'q');                 // q quits
        },
        [&]{
            return (v(
                dyn([&]{ return text("Count: " + std::to_string(n.get())); }),
                t<"[+] increment   [q] quit"> | Dim
            ) | pad<1> | border(Rounded)).build();
        }
    );
}

That is a complete, interactive terminal app.

Where to start

This manual goes from "what is a terminal?" to "how maya's renderer works." You don't need prior terminal-UI experience — just C++.

  • New to terminals or TUIs? Begin with Foundations — five short chapters that explain terminals, cells, escape codes, input, and rendering from the ground up, then connect them to maya.
  • Already comfortable in a terminal? Jump straight to Getting Started.

Foundations

A self-contained primer on how every TUI works.

  1. What Is a Terminal? — the grid, the byte stream, emulators vs shells vs TTYs/PTYs.
  2. The Cell Grid — cells, monospace fonts, and the problem of character width.
  3. ANSI Escape Codes — moving the cursor and styling text; 16/256/truecolor.
  4. Keyboard & Mouse Input — raw mode, key bytes, mouse, and paste.
  5. The Rendering Problem — flicker, tearing, and why diffing wins.
  6. How maya Works — the pipeline that ties it all together.

Guide

Reference

Internals

For the curious and for contributors.

Why maya?

  • Impossible states don't compile. The DSL uses C++26 type-state machines, so whole categories of UI bugs become compile errors.
  • Fast by construction. A SIMD cell-diff writes only what changed — typically ~10× fewer bytes than redrawing the frame. Smooth at 60fps, snappy over SSH.
  • Real layout. Yoga flexbox, the same engine behind React Native.
  • Elm-style runtime. Pure update/view functions you can test.
  • Batteries included. A deep widget library, full-screen and inline rendering, mouse, and truecolor with graceful downgrade — and the terminal is always restored cleanly on exit, exceptions, and fatal signals.

moha, a native terminal client for Claude, is built on maya in production. First-class Python bindings live at maya-py.