import type { Terminal } from "../../core/types.js"; import type { RendererCapabilities } from "../capabilities.js"; import type { TerminalGraphicsCapabilities, TerminalGraphicsDetectionInput } from "../terminal-graphics.js"; import type { ThemePalette } from "../../core/ansi-palette.js"; export type CliOutput = Readonly<{ write: (chunk: string) => unknown; isTTY?: boolean; fd?: number; columns?: number; rows?: number; on?: (event: "resize", listener: () => void) => unknown; off?: (event: "resize", listener: () => void) => unknown; }>; export type StdoutRenderer = Readonly<{ capabilities: RendererCapabilities; graphicsCapabilities?: TerminalGraphicsCapabilities; render: () => void; /** * Force an immediate full repaint of the renderer's rows, bypassing frame * throttling. For `anchor: "bottom"` (REPL bar) callers this re-anchors the * bar and re-establishes the scroll region after the terminal resized or * after native output was written above the bar. */ forceRender: () => void; dispose: () => void; /** Move terminal cursor to specified cell position for IME input */ setCursor: (x: number, y: number) => void; /** Show or hide the terminal cursor */ showCursor: (visible: boolean) => void; /** Update default background without recreating the renderer. */ updateTheme?: (next: Readonly<{ defaultBg?: string | null; palette?: ThemePalette | null; }>) => void; }>; export type StdoutColorMode = "auto" | "truecolor" | "ansi256" | "ansi16" | "ansi8"; export type DirtyRowPatchMode = "auto" | "row" | "span"; export type { ThemePalette } from "../../core/ansi-palette.js"; export type StdoutRendererOptions = Readonly<{ output?: CliOutput; clear?: boolean; hideCursor?: boolean; altScreen?: boolean; /** * How the TUI buffer is anchored on the terminal screen. * * - `"top"` (default): buffer row 0 maps to screen row 1 — the renderer owns * the whole terminal screen (full-screen TUIs). * - `"bottom"`: the buffer is pinned to the bottom `rows` of the terminal * screen (a REPL-style prompt bar). Everything above the buffer is native * terminal output owned by the caller (scrollback, right-click paste, * native scrolling) — the renderer only ever writes to its own pinned rows * and never clears or repaints the area above. * * In bottom mode the renderer: * - initially scrolls existing terminal contents upward to reserve the bar * rows and one fresh native-output row without overwriting prior history; * - repaints the full (small) buffer every frame, so an externally scrolled * screen can never leave stale bar rows behind; * - never emits buffer scroll operations that would disturb the caller's * scroll region above the bar; * - skips the whole-screen clear even when `clear` is true; * - establishes a scroll region that excludes the bar (`ESC[1;r`) * so output written by the caller scrolls natively above the bar, and * restores it on dispose. */ anchor?: "top" | "bottom"; /** * Rows of blank space reserved between the native output region and the * pinned bar in `anchor: "bottom"` mode. The bar stays at the very bottom; * the scroll region the renderer establishes shrinks by `barGap` rows so * caller output scrolls above a persistent blank gap. Default 0. */ barGap?: number; /** * Live provider of the terminal screen height in rows (cells). Used only for * `anchor: "bottom"` to compute the bar's pinned offset. Falls back to * `output.rows` and then `process.stdout.rows` when omitted. */ screenRows?: () => number; /** Fallback background color when a cell has no explicit bg. `null` = terminal default. */ defaultBg?: string | null; /** Optional ANSI-name palette used when emitting ansi256/truecolor sequences. */ palette?: ThemePalette | null; /** Track TTY resize events and call terminal.resize(). */ trackResize?: boolean; /** Color mode for ANSI output. */ colorMode?: StdoutColorMode; /** * Dirty-row stdout patch strategy. * * - "auto": prefer span patching, with conservative row fallback on * terminals that are sensitive to fragmented cursor-addressed writes. * - "row": repaint each dirty row. * - "span": force row-internal span/contiguous patching where possible. * This skips terminal-sensitive conservative row fallback and is intended * as an escape hatch when the caller wants maximum partial-row patching. * Safety expansion for wide glyphs and stale-tail handling still applies. * * Env fallback when this option is not provided: * VUE_TUI_DIRTY_ROW_PATCH_MODE, DIMCODE_TUI_DIRTY_ROW_RENDER_MODE, * or DIMCODE_TUI_DIRTY_ROW_PATCH_MODE. */ dirtyRowPatchMode?: DirtyRowPatchMode; /** * Max changed-cell coverage to patch in auto mode on conservative TTYs. * Larger dirty rows fall back to full-row repaint. * * Env fallback when this option is not provided: * VUE_TUI_DIRTY_SPAN_MAX_CELLS or DIMCODE_TUI_DIRTY_SPAN_MAX_CELLS. */ dirtySpanConservativeMaxCells?: number; /** * Alias for dirtyRowPatchMode. * * - true => "span" * - false => "row" * - "auto" => "auto" * * When both are provided, dirtyRowPatchMode wins. * * @deprecated Use dirtyRowPatchMode instead. */ columnDiff?: boolean | "auto"; /** Optional function to get IME cursor position, included in render output atomically. */ getImeAnchor?: () => { cellX: number; cellY: number; } | null; /** Use DEC 2026 synchronized output mode. */ useSyncOutput?: boolean; terminalGraphics?: false | TerminalGraphicsCapabilities | TerminalGraphicsDetectionInput; allowFileUrls?: boolean; profileFileWriter?: { appendFileSync?: (path: string, data: string) => void; }; }>; export declare function createStdoutRenderer(terminal: Terminal, options?: StdoutRendererOptions): StdoutRenderer;