/** * The dashboard's terminal (operator-console/AC-1, operator-console/AC-4, * operator-console/AC-7, operator-console/AC-13, operator-console/AC-19, * operator-console/AC-25). * * Draws on the alternate screen, reads raw keys, and writes only what changed: a * frame rewrites the rows whose text differs, a spinner tick rewrites just the * spinner cells, and nothing clears the screen except a resize or coming back from * a shell. Whatever ends the process — `q`, an uncaught error, a signal from outside * — the terminal gets its modes, cursor and normal screen back. * * Writes go through the `write` taken when the terminal was made, not through * `process.stdout.write` at call time: a command's quiet capture replaces that while * it runs, and must not swallow the dashboard's own drawing (design §3.4). * * @module */ import { type Key } from 'node:readline'; import type { KeyName, Screen, Size } from './model.js'; /** What restores the terminal: the normal screen, a visible cursor, no colour left on. */ export declare const RESTORE = "\u001B[0m\u001B[?25h\u001B[?1049l"; export interface Terminal { /** Alternate screen, hidden cursor, raw keys, resize and restore handlers. */ open(): void; /** Write only the rows whose text changed since the last frame. */ draw(s: Screen): void; /** Write only the spinner cells, with `glyph`. */ tick(s: Screen, glyph: string): void; /** Clear and draw everything: after a resize, or coming back from a shell. */ repaint(s: Screen): void; /** Leave the alternate screen and raw mode while `run` runs, then come back. */ suspend(run: () => Promise): Promise; /** Give the terminal back. Safe to call more than once. */ close(): void; size(): Size; onKey(h: (k: KeyName) => void): void; onResize(h: () => void): void; } /** The process around the terminal; faked in tests. */ export interface TermIO { write(text: string): void; /** For the `exit` handler, where nothing asynchronous runs any more. */ writeSync(text: string): void; size(): Size; /** Raw keypresses until the returned function is called, which restores the mode. */ readKeys(h: (s: string | undefined, key: Key | undefined) => void): () => void; onResize(h: () => void): () => void; on(event: string, h: (...args: unknown[]) => void): void; off(event: string, h: (...args: unknown[]) => void): void; exit(code: number): void; error(text: string): void; } /** One keypress as a `KeyName`, or null for one the dashboard does not use (Alt chords). */ export declare function keyName(s: string | undefined, key: Key | undefined): KeyName | null; export declare function createTerminal(io: TermIO): Terminal; /** This process's terminal. Takes `process.stdout.write` now, before any capture can replace it. */ export declare function processTermIO(): TermIO; //# sourceMappingURL=screen.d.ts.map