export interface Size { cols: number; rows: number; } export interface Rect { row: number; col: number; width: number; height: number; } export interface Style { fg?: string; bg?: string; bold?: boolean; dim?: boolean; reverse?: boolean; } export interface Span { text: string; style?: Style; } /** An SGR fg/bg parameter is digits and semicolons only (e.g. '32', '1;36', '236'). * Guards styleSpan against a non-numeric value (a color name) producing a broken * escape sequence. */ export declare function isSgrParams(v: string): boolean; /** Style one chunk of text. Hue (fg/bg) is gated on `color`; bold/dim/reverse * are not. After the styled text we return to `lineBase` (not a bare reset) so a * row-level background/dim persists across spans instead of bleeding or being * cleared. */ export declare function styleSpan(text: string, style: Style | undefined, color: boolean, lineBase: string): string; /** Assemble styled spans into one line clipped to `width` visible cols. When * `fill`, pad the remainder with spaces (under `lineBase`) so a cursor-row * background spans the full width. Always RESET-terminated so no color bleeds * into the next line. */ export declare function assemble(spans: Span[], width: number, color: boolean, lineBase: string, fill: boolean): string; /** Truncate to `max` visible cols (plain text, no ANSI). */ export declare function clip(text: string, max: number): string; export interface ColorCaps { /** Any hue (fg/bg color) allowed. */ color: boolean; /** 256-color bg allowed — drives the subtle cursor-row background. */ color256: boolean; } /** Detect color capability. Honors `NO_COLOR` and `TERM=dumb`, and only emits * hue when stdout is a TTY. `color256` additionally requires a 256/truecolor * terminal (for the cursor-row background; otherwise we fall back to reverse). */ export declare function detectColorCaps(stream?: { isTTY?: boolean; }, env?: NodeJS.ProcessEnv): ColorCaps; /** One pre-styled list row (the view styles its own spans; `list` windows + the * cursor highlight are the host's job). An optional `right` group is flush-right * on the row (e.g. a timestamp) via spansRight; the left `spans` are clipped to * leave room for it, and the cursor-row highlight merges over both. */ export interface ListItemRow { spans: Span[]; right?: Span[]; /** Optional continuation lines drawn under `spans` as part of the SAME item * (e.g. a wrapped subtitle). They share the item's cursor highlight and the * item still counts as one cursor position; the list windows by screen rows. */ lines?: Span[][]; } /** Adjusted scroll the view stores back so the cursor stays visible. */ export interface ListResult { scroll: number; } export interface Draw { readonly size: Size; readonly caps: ColorCaps; /** Styled spans at an absolute cell, clipped to maxWidth (default → edge). */ spans(row: number, col: number, spans: Span[], maxWidth?: number): void; /** Flush-right span placement (mirror of `spans`): the group's last visible * cell lands just before `rightCol` (i.e. start col = rightCol − visibleWidth, * rightCol exclusive). If the group exceeds `maxWidth` (default → the room left * of rightCol) the LEFT end is clipped with a leading `…`. */ spansRight(row: number, rightCol: number, spans: Span[], maxWidth?: number): void; /** Convenience single span. */ text(row: number, col: number, text: string, style?: Style): void; /** Dim horizontal rule across [fromCol,toCol) (default full width). */ hline(row: number, fromCol?: number, toCol?: number, ch?: string): void; /** Dim vertical rule down column `col` across [fromRow,toRow) (default full * height). `ch` defaults to `│`; pass `|` as the ASCII fallback. */ vline(col: number, fromRow?: number, toRow?: number, ch?: string): void; /** Single-line box border around rect (optional title in the top edge). */ box(rect: Rect, title?: string): void; /** Split a rect into N columns by weights. */ columns(rect: Rect, weights: number[]): Rect[]; /** Scrollable list within rect: windows `items` to fit height, highlights the * cursor row (256-bg or reverse fallback, like browse). Returns adjusted * scroll so the cursor stays visible — the view stores it in state. */ list(rect: Rect, items: ListItemRow[], cursor: number, scroll: number): ListResult; } /** A live Draw plus the host-side serializer. */ export interface DrawHandle { draw: Draw; /** Serialize the buffer to a full repaint frame (home + per-line clear + clear * below) — identical framing to browse's renderFrame. */ frame(): string; } /** Create a screen-sized cell buffer + the absolute-cell Draw API over it. */ export declare function createDraw(size: Size, caps: ColorCaps): DrawHandle;