/** * Drawing for the diff view: pure functions from parsed diffs to lines of a given width, so they * can be tested without a terminal. Colours come from the theme's diff tokens; the tint behind * added and removed lines is a mix of that colour into the panel shade. * * Everything that comes from a diff (file contents, paths, hunk headings) goes through `clean` * first: a file can hold escape sequences, and they must never reach the terminal. */ import type { Theme } from "@earendil-works/pi-coding-agent"; import type { FileDiff } from "./git-diff.ts"; /** * Replace control characters (escape sequences, C1 controls, bidi overrides) and expand tabs. A * carriage return at the very end is dropped first: it is the second half of a CRLF line ending, * not content, and would otherwise show as a dot on every line of a Windows-style file. */ export declare function clean(s: string): string; /** One row of the right pane. */ export interface BodyRow { kind: "hunk" | "add" | "del" | "ctx" | "note" | "blank"; text: string; oldNo?: number; newNo?: number; } /** The rows of a file's diff pane, and where each hunk starts. */ export interface Body { rows: BodyRow[]; hunkStarts: number[]; /** Widest line number, for the gutter. */ numWidth: number; } export declare function buildBody(file: FileDiff): Body; /** Index of the hunk whose rows contain `row`, or the first hunk if `row` is above all of them. */ export declare function hunkAt(body: Body, row: number): number; export interface Palette { text: string; addFg: string; delFg: string; ctxFg: string; dim: string; muted: string; accent: string; warn: string; addBg: string; delBg: string; panel: string; element: string; selected: string; reset: string; } /** The theme's diff colours plus a tint of each, mixed into the panel shade for the whole line. */ export declare function paletteFor(theme: Theme): Palette; /** Pad or cut plain text to exactly `w` columns. */ export declare const cell: (text: string, w: number) => string; /** * One row of the diff pane at `width` columns, with a line-number gutter. Added and removed lines * are tinted across the full width. `shift` scrolls long lines sideways. */ export declare function renderBodyRow(row: BodyRow, width: number, pal: Palette, numW: number, shift?: number, mark?: "current" | "other"): string; /** Path cut from the left so the file name stays visible. */ export declare function cutLeft(text: string, width: number): string; /** "+12 -3", "bin", or "" for a file with nothing to count, plain text for measuring. */ export declare function statsText(file: FileDiff): string; /** * One row of the file list: a marker, git's two-letter code, the path (directory muted, name * bright), and +N -M on the right. The selected row is painted on the theme's selection colour. */ export declare function renderFileRow(file: FileDiff, width: number, pal: Palette, selected: boolean, focused?: boolean): string;