pi-tui
Pi TUI
Component-based architecture (TUI/Container/Box/Text/TruncatedText/Input/Editor/Markdown/Loader/CancellableLoader/SelectList/SettingsList/Spacer/Image), overlay system, IME support, autocomplete, Kitty keyboard protocol. Differential rendering TUI framework.
Install: npm install @earendil-works/pi-tui
Use Cases
Use when building terminal UIs, interactive CLI apps, TUI editors, terminal select lists/settings panels, terminal Markdown rendering, or inline terminal images.
Core Concepts
Component Interface — All components implement render(width): string[] (each line ≤ width), handleInput?(data), invalidate?(). Each line auto-appends SGR+OSC reset; styles do not carry across lines.
Focusable Interface — Components needing IME implement a focused: boolean property and insert CURSOR_MARKER before the cursor in render. Containers with Input/Editor children must propagate focus state (otherwise IME candidate window mispositions). Hardware cursor hidden by default; enable with PI_HARDWARE_CURSOR=1.
Differential Rendering — Three strategies: first render outputs all lines, width change clears and redraws, incremental only updates changed lines. CSI 2026 synchronized output prevents flicker.