$ show rockorager/libvaxis
libvaxis is a terminal user interface (TUI) library for Zig that provides both low-level terminal manipulation and a high-level declarative widget system (vxfw). The library does not rely on terminfo; instead it dynamically queries terminal capabilities via escape sequences, supporting modern features such as RGB color, kitty keyboard and graphics protocols, hyperlinks (OSC 8), bracketed paste, mouse shapes, system clipboard, notifications, synchronized output, and Unicode Core. The architecture comprises an event-driven loop (generic over event type) that reads from a platform-specific TTY abstraction, a state-machine parser for input sequences, double-buffered screen rendering with diff-based updates, and a widget tree with constraint-based layout, focus management, and event propagation (capture/target/bubble phases). Low-level components include the TTY abstraction (Posix, Windows, test stub), input parser, screen buffer, window sub-region handling, and image transmission via the kitty graphics protocol. The high-level vxfw framework offers composable widgets such as Button, TextInput, ListView, SplitView, Border, FlexRow/Column, ScrollView, Spinner, and more. Widgets receive draw context with min/max constraints and an arena allocator per frame, returning surfaces that may contain child surfaces. The library also includes an embedded terminal emulator widget (Terminal) that runs a child process in a PTY and renders its output as a virtual terminal. A stable C API is provided via `vaxis.h`, exposing parsing, screen manipulation, and runtime management without requiring Zig compilation. Cross-platform support covers macOS, Windows, Linux and BSD/Unix systems. The library is built with Zig 0.16.0 and depends on `zigimg` for image decoding and `uucode` for Unicode property data, both fetched as build dependencies.
The LLM identified 3 files worth highlighting for reuse:
Implements a bounded, thread-safe queue using atomic operations and a condition variable for blocking. Provides push/tryPush/pop/tryPop methods and is generic over element type and capacity. Used internally to decouple the TTY reading thread from the event loop, enabling efficient producer-consumer communication. The implementation is minimal and self-contained, suitable for extraction into any Zig project requiring a thread-safe event queue.
Provides a fixed-size associative cache for grapheme width data computed from Unicode properties. Avoids recalculating display widths for repeated graphemes across frames, reducing per-frame allocations and latency. The cache is independent of the rest of Vaxis and can be reused in any Zig application that needs efficient grapheme width lookups for terminal or text-rendering purposes.
Exposes functions to compute the display width of Unicode text, handling combining characters, emoji sequences, zero-width joiners (ZWJ), and regional indicator pairs. Uses the `uucode` library for Unicode property data. The module is self-contained and could be extracted as a standalone Zig utility for text layout calculations in any project that needs accurate terminal-width-aware text formatting.