Skip to main content

Crate abstracttui

Crate abstracttui 

Source
Expand description

§AbstractTUI

A standalone, reactive, compositor-grade terminal UI engine.

AbstractTUI treats the terminal as a real display device: a layered compositor with damage tracking sits under a fine-grained reactive component model (signals, not virtual-DOM diffing, not full-frame immediate mode). Pixel graphics (kitty / iTerm2 / sixel / unicode mosaic) and software-rasterized 3D (GLB) are first-class citizens of the same scene, themed by a shared design-token system.

Layer map (bottom to top):

  • base — value types: geometry, color, errors
  • term — platform terminal I/O, capability detection
  • input — byte stream -> structured events
  • render — cells, surfaces, compositor, diff, presenter
  • text — measurement, wrapping, shaping helpers
  • anim — clock, tweens, easing, transitions, cell shaders
  • reactive— signals, memos, effects, scopes, scheduler
  • layout — flexbox-style layout solver
  • ui — component/view tree, event routing, focus
  • canvas — sub-cell vector strokes: dots, curves, fills
  • widgets — built-in widget library
  • gfx — bitmaps, mosaic renderers, image protocols
  • three — GLB loading and software 3D rasterization
  • theme — design tokens and theme registry
  • app — application runtime and frame loop
  • boot — AbstractTUI visual identity splash
  • testing — test terminal, VT interpreter, harness utilities

Modules§

anim
Animation engine skeleton: clock, easing, tweens, frame requests.
app
Application runtime: terminal session + input events + reactive scheduler + layout + compositor pipeline, sequenced per the damage contract (docs/design/01-damage-contract.md).
base
Foundational value types shared by every AbstractTUI layer.
boot
AbstractTUI visual identity: the ~2s boot splash (3D mark rendered by three, themed by theme, animated by anim), skippable on any key, auto-skipped when not a TTY or when ABSTRACTTUI_NO_SPLASH is set.
canvas
Sub-cell vector canvas: dots, strokes, curves and partial fills (backlog 0420 — the substrate charts already used privately, promoted to public API for diagram-class extensions and app-side custom traces).
gfx
Pixel graphics: RGBA bitmaps, scaling, dithering; cell-mosaic rendering (half blocks, quadrants, sextants, braille) for universal support; native protocols (kitty graphics, iTerm2 OSC 1337, sixel) when the terminal offers them; PNG decode (miniz_oxide inflate + our own chunk/defilter code).
input
Input pipeline: raw terminal bytes -> structured Events.
layout
Layout: flexbox-style solver over the component tree (direction, grow/shrink/basis, gap, padding, margin, min/max, percent, absolute), with text measurement callbacks. Pure and deterministic: integer cells, largest-remainder rounding (children tile containers exactly), and subtree re-solve for incremental updates.
prelude
Convenience re-exports: use abstracttui::prelude::*; is all an application needs for the common path (REACT’s cycle-8 proposal, approved + executed cycle 9 for RT8-1).
reactive
Fine-grained reactivity: Signal, Memo, Effect, ownership scopes and the frame scheduler. This is the engine’s “React” — but SolidJS style: dependencies tracked at read time, updates propagate to exactly the affected computations, which mark exactly the affected UI regions damaged. No virtual-DOM diffing, no full-frame immediate mode.
render
Rendering core: cells, surfaces, layered compositor, frame diff and ANSI presentation.
term
Terminal kernel: platform I/O, raw mode, alternate screen, resize detection, cross-thread wakeups, and capability detection.
testing
Test rig: an in-memory terminal double capturing the byte stream, plus a small VT interpreter that applies emitted bytes to a model screen — so tests can assert “the bytes we emit produce the frame we intended” (the diff/present correctness property), snapshot frames as text, drive scripted input, and fuzz parsers deterministically.
text
Text measurement and wrapping over extended grapheme clusters.
theme
Themes: semantic design tokens and the AbstractUIC theme family.
three
Software 3D: minimal-but-correct GLB (glTF 2.0 binary) loading — meshes, transforms, base-color materials — and a perspective rasterizer with z-buffer, backface culling and lambert+ambient shading, rendering into RGBA framebuffers presented via gfx (mosaic cells or pixel protocols).
ui
Component model: declarative view tree, mounting, event routing (capture -> target -> bubble), hit testing, focus management, keymaps and shortcuts. Components are plain functions over reactive scopes returning View blueprints; re-render is driven by signals, scoped to the Dyn region that read them.
widgets
Widget library built on ui + layout + theme: visual widgets are DESIGN-owned (block, separator, badge, progress, spinner, logo); behavior-heavy widgets (input, list, table, scroll) are REACT-owned and land in later cycles. Every widget is themable via design tokens and composable like any user component (widgets have no private engine privileges — the proof the component model is enough).