|
| 1 | +# Screen Modes |
| 2 | + |
| 3 | +Rezi apps can present in two terminal screen modes, selected at app creation: |
| 4 | + |
| 5 | +| Mode | Surface | Fits | |
| 6 | +| --- | --- | --- | |
| 7 | +| `"alt"` (default) | Full-screen on the alternate screen buffer | Dashboards, editors, full-screen TUIs | |
| 8 | +| `"inline"` | A bounded region on the primary screen | Status UIs, progress displays, REPLs, agent-style CLIs | |
| 9 | + |
| 10 | +In **alt mode** the app owns the whole terminal and the prior screen is |
| 11 | +restored on exit — the classic full-screen TUI experience. |
| 12 | + |
| 13 | +In **inline mode** the app renders a region of `inlineRows` rows at the |
| 14 | +current scroll position, the way tools like Ink-based CLIs present: |
| 15 | + |
| 16 | +- Terminal **scrollback stays visible above the region** while the app runs. |
| 17 | +- The region scrolls naturally with the session as it claims rows. |
| 18 | +- On exit, the **final frame remains in scrollback** and the shell prompt is |
| 19 | + restored on a fresh line below it. |
| 20 | +- Repaints use relative cursor motion only — the engine never clears the |
| 21 | + screen or addresses absolute rows, so content above the app is never |
| 22 | + touched. |
| 23 | + |
| 24 | +## Enabling inline mode |
| 25 | + |
| 26 | +```ts |
| 27 | +import { createNodeApp } from "@rezi-ui/node"; |
| 28 | + |
| 29 | +const app = createNodeApp({ |
| 30 | + initialState: {}, |
| 31 | + config: { |
| 32 | + screen: { mode: "inline", inlineRows: 9 }, |
| 33 | + }, |
| 34 | +}); |
| 35 | +``` |
| 36 | + |
| 37 | +`screen.inlineRows` (1..1024) is required in inline mode and rejected in alt |
| 38 | +mode. The effective viewport is clamped to the live terminal height and |
| 39 | +re-clamped on terminal resize. |
| 40 | + |
| 41 | +See [`examples/inline-status`](https://github.com/RtlZeroMemory/Rezi/tree/main/examples/inline-status) |
| 42 | +for a complete runnable app (spinner + progress bar + quit keys). |
| 43 | + |
| 44 | +## Layout and sizing |
| 45 | + |
| 46 | +The app's layout viewport in inline mode is `terminal columns x inlineRows`; |
| 47 | +resize events report that viewport, so layout, wrapping, and responsive |
| 48 | +breakpoints work unchanged. |
| 49 | + |
| 50 | +Size `inlineRows` to your content's height. Remember that container chrome |
| 51 | +consumes rows: `ui.panel(...)` adds two border rows plus padding, and stack |
| 52 | +gaps add one row per gap. The `examples/inline-status` panel (one status row, |
| 53 | +a progress bar, and a caption) needs 9 rows. |
| 54 | + |
| 55 | +## Behavior notes |
| 56 | + |
| 57 | +- **Capability fallback**: protocol images (kitty / sixel / iTerm2) require |
| 58 | + absolute screen coordinates, so inline mode renders `ui.image(...)` through |
| 59 | + the sub-cell blitter path instead. `ui.canvas(...)` blitters are unaffected. |
| 60 | + Backend capability snapshots reflect this (`supportsScrollRegion` and image |
| 61 | + protocol support read as unavailable). |
| 62 | +- **Terminal resize**: the engine re-anchors and repaints the region. As with |
| 63 | + every inline-style CLI, the terminal's own reflow of *pre-resize scrollback* |
| 64 | + can leave artifacts above the region; the app's region itself repaints |
| 65 | + cleanly. |
| 66 | +- **Exiting**: prefer the repo's standard pattern of `await app.run()` |
| 67 | + followed by `process.exit(0)` when the app holds timers or other live |
| 68 | + handles (see `examples/gallery`). |
| 69 | + |
| 70 | +## Naming note: `screen.mode` vs `executionMode` |
| 71 | + |
| 72 | +These are independent options that compose freely: |
| 73 | + |
| 74 | +- `screen.mode: "alt" | "inline"` — what the app looks like in the terminal |
| 75 | + (this page). |
| 76 | +- `executionMode: "auto" | "worker" | "inline"` — where the native engine |
| 77 | + runs (worker thread vs main thread); see |
| 78 | + [Worker model](../backend/worker-model.md). |
| 79 | + |
| 80 | +An inline-screen app can run on the worker path, and a full-screen app can |
| 81 | +run on the inline execution path. |
| 82 | + |
| 83 | +## Under the hood |
| 84 | + |
| 85 | +Inline mode is implemented by the Zireael engine (v1.4.0+, engine ABI 1.3.0) |
| 86 | +as a first-class screen mode: relative-motion emission (CR/CUU/CUD/CHA), LF |
| 87 | +row claims that scroll the region as one unit, and a scrollback-safe erase |
| 88 | +baseline. The Node backend forwards `screen` as native config keys |
| 89 | +(`plat.screenMode`, `inlineRows`); raw `nativeConfig` passthrough of those |
| 90 | +keys is also accepted, with the high-level `screen` option taking precedence. |
0 commit comments