/** * Diff view — side-by-side ≥ 100 cols, unified otherwise. * * Implements the "Diff rendering: side-by-side ≥ 100 cols, unified otherwise, * AAA contrast" deliverable from WS10. This component takes a pre-computed * line diff (additions / deletions / context) and lays it out for a given * terminal width. Hunk parsing is the caller's job — the existing edit-format * renderers in `coding-agent/src/core/edit-formats/` (WS8 territory) will * produce these line-tagged inputs. */ import type { Component } from "../tui.js"; export type DiffLineKind = "context" | "add" | "del" | "header" | "hunk"; export interface DiffLine { kind: DiffLineKind; text: string; oldLine?: number; newLine?: number; } export interface DiffViewTheme { add: (text: string) => string; del: (text: string) => string; context: (text: string) => string; header: (text: string) => string; hunk: (text: string) => string; gutterAdd: (text: string) => string; gutterDel: (text: string) => string; gutterContext: (text: string) => string; separator: (text: string) => string; } /** Threshold below which we render unified rather than side-by-side. */ export declare const SIDE_BY_SIDE_MIN_WIDTH = 100; export type DiffLayout = "unified" | "side-by-side"; export declare function pickLayout(width: number): DiffLayout; export interface DiffViewOptions { lines: DiffLine[]; theme?: DiffViewTheme; /** Force a specific layout. Default: width-based per `pickLayout`. */ forceLayout?: DiffLayout; /** Show line-number gutter. */ showLineNumbers?: boolean; } export declare class DiffView implements Component { private lines; private theme; private forceLayout?; private showLineNumbers; constructor(options: DiffViewOptions); setLines(lines: DiffLine[]): void; invalidate(): void; render(width: number): string[]; private renderUnified; private renderSideBySide; private formatHalf; private formatGutter; } interface DiffPair { kind: DiffLineKind; text: string; left?: DiffLine; right?: DiffLine; } /** * Pair up consecutive del/add runs for side-by-side layout. Within a hunk: * * [del A, del B, add C, add D, ctx X] * * becomes: * * [del A | add C, del B | add D, ctx X | ctx X] * * Mismatched lengths are padded with empty halves. */ export declare function pairUpHunks(lines: DiffLine[]): DiffPair[]; export {}; //# sourceMappingURL=DiffView.d.ts.map