Rendering Pipeline
TUIX renders through native buffers. Each object has a buffer, builders fill pixel data, the compositor resolves visibility and layering, and the renderer emits terminal output.
Pipeline Stages
- Read and route input snapshots.
- Resolve terminal size, object modifiers, parent layout, viewport offsets, and explicit layout overrides.
- Call builder resize/layout/event/content callbacks as needed.
- Composite root and child buffers using z-index, parent traversal, viewport clipping, and modal rules.
- Generate the hitmap used for mouse picking.
- Render terminal-visible diffs.
Geometry Resolution
Basic geometry starts from width_mod, height_mod, margin_top_mod, and margin_left_mod. Layout parents can then override child rectangles by writing layout rects or grid placement data. Scroll containers and viewport widgets contribute offsets and clipping in content space.
Pixel Ownership
v0.5 hardens pixel ownership with TuixBuffer.pixels_owned and safer handling for builder-returned temporary buffers. Builders can keep persistent pixel buffers or return temporary pixels that the core copies into owned storage.
Viewport-Aware Compositing
Viewport widgets expose offset, insets, and content size callbacks. The compositor uses those values to clip child buffers and make hitmap picking match the visible content, including scrolled children.
Hitmap Picking
A frame-local hitmap maps terminal cells back to topmost visible buffer UIDs. Input routing uses it before builder dispatch so mouse clicks follow actual painter order and viewport clipping.
Diff Stability
The text and halfblock renderers compare terminal-visible ANSI color output rather than unstable intermediate color values. This reduces unnecessary redraws when equivalent colors pass through different internal paths.