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.
- What Is a Terminal? — the grid, the byte stream, emulators vs shells vs TTYs/PTYs.
- The Cell Grid — cells, monospace fonts, and the problem of character width.
- ANSI Escape Codes — moving the cursor and styling text; 16/256/truecolor.
- Keyboard & Mouse Input — raw mode, key bytes, mouse, and paste.
- The Rendering Problem — flicker, tearing, and why diffing wins.
- How maya Works — the pipeline that ties it all together.
Guide¶
- Introduction — philosophy and a tour.
- Getting Started — install, build, your first UI and app.
- The Compile-Time DSL — elements and the type-state builder.
- Styling — colors, attributes, modifiers.
- Layout — Yoga flexbox: rows, columns, grow/shrink, alignment.
- Runtime Content — dynamic views and the Program (MVU) architecture.
- Event Handling — keys, mouse, paste, resize.
- Signals & Reactivity — reactive state.
- Rendering Modes — full-screen vs inline, the diff, synchronized output.
- Canvas API — the cell grid up close.
- Widget Reference — charts, tables, scroll views, markdown, agent UI.
- Examples Walkthrough — real programs, explained.
Reference¶
- API Reference — every public symbol.
- Glossary — every term in one place.
Internals¶
For the curious and for contributors.
- Render-path roadmap
- Inline-mode redraw paths
- Inline autogrow & the ghosting trap
- The Witness Chain
- Scrollback corruption audit
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/viewfunctions 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.