/** * TUI Diff Renderer * * Renders unified diffs in a beautiful terminal UI with: * - Header with file path and statistics * - Toolbar with action buttons * - Line numbers (old and new) * - Color coding (green for added, red for removed) * - Footer with keyboard shortcuts * - Scrolling support for long diffs * - Light and dark theme support */ import { ChalkInstance } from 'chalk'; import { ParsedDiff, Hunk, DiffLine } from '../diff-engine.js'; import { PendingChange } from '../state-manager.js'; /** * Theme configuration for light and dark terminals */ export interface TUITheme { name: 'light' | 'dark'; headerBg: ChalkInstance; headerText: ChalkInstance; headerPath: ChalkInstance; toolbarBg: ChalkInstance; toolbarText: ChalkInstance; toolbarActive: ChalkInstance; addedLine: ChalkInstance; addedLineBg: ChalkInstance; deletedLine: ChalkInstance; deletedLineBg: ChalkInstance; unchangedLine: ChalkInstance; lineNumber: ChalkInstance; lineNumberActive: ChalkInstance; hunkHeader: ChalkInstance; hunkHeaderBg: ChalkInstance; separator: ChalkInstance; footerBg: ChalkInstance; footerText: ChalkInstance; footerShortcut: ChalkInstance; statsAdded: ChalkInstance; statsDeleted: ChalkInstance; statsModified: ChalkInstance; } /** * Predefined themes for the TUI renderer */ export declare const THEMES: Record<'light' | 'dark', TUITheme>; /** * Configuration options for TUIRenderer */ export interface TUIRendererConfig { theme: 'light' | 'dark' | TUITheme; lineNumbers: boolean; showToolbar: boolean; showFooter: boolean; contextLines: number; maxLineLength: number; scrollOffset: number; } /** * Action button definition for toolbar */ export interface ActionButton { key: string; label: string; shortcut: string; active?: boolean; destructive?: boolean; } /** * Bulk action button definition for bulk operations toolbar */ export interface BulkActionButton extends ActionButton { action: 'acceptAll' | 'rejectAll' | 'acceptFile' | 'rejectFile' | 'acceptHunk' | 'rejectHunk'; } /** * Stats display for showing change statistics */ export interface StatsDisplay { accepted: number; rejected: number; pending: number; total: number; percentageComplete: number; } /** * Render statistics for a diff */ export interface DiffStats { additions: number; deletions: number; changes: number; fileStatus: 'added' | 'modified' | 'deleted' | 'renamed' | 'unchanged'; } /** * TUIRenderer - Terminal UI Diff Renderer * * Renders diffs in a beautiful terminal interface with full scrolling support, * line numbers, color coding, and customizable themes. */ export declare class TUIRenderer { private config; private theme; private terminalWidth; private terminalHeight; private scrollPosition; private actionButtons; private bulkActionButtons; private pendingChange; private currentHunkIndex; private confirmationDialog; private onBulkActionCallback?; constructor(config?: Partial); /** * Set the pending change for bulk actions */ setPendingChange(change: PendingChange | null): void; /** * Get the current pending change */ getPendingChange(): PendingChange | null; /** * Set current hunk index for hunk-level actions */ setCurrentHunkIndex(index: number): void; /** * Get current hunk index */ getCurrentHunkIndex(): number; /** * Set callback for bulk actions */ setOnBulkActionCallback(callback: (action: string, hunkIndex?: number) => void): void; /** * Resolve theme from string or object */ private resolveTheme; /** * Get terminal width */ private getTerminalWidth; /** * Get terminal height */ private getTerminalHeight; /** * Get default action buttons */ private getDefaultActionButtons; /** * Get default bulk action buttons */ private getDefaultBulkActionButtons; /** * Set bulk action buttons */ setBulkActionButtons(buttons: BulkActionButton[]): void; /** * Get bulk action buttons */ getBulkActionButtons(): BulkActionButton[]; /** * Update configuration */ setConfig(config: Partial): void; /** * Set action buttons */ setActionButtons(buttons: ActionButton[]): void; /** * Calculate diff statistics */ calculateStats(diff: ParsedDiff): DiffStats; /** * Get change statistics from pending change */ getChangeStats(): StatsDisplay | null; /** * Render the complete diff view */ render(diff: ParsedDiff): string; /** * Render header with file path and stats */ renderHeader(diff: ParsedDiff, stats?: DiffStats): string; /** * Get status icon */ private getStatusIcon; /** * Get status color */ private getStatusColor; /** * Render toolbar with action buttons */ renderToolbar(): string; /** * Render bulk actions toolbar */ renderBulkToolbar(): string; /** * Render statistics display */ renderStatsDisplay(): string; /** * Render separator line */ renderSeparator(): string; /** * Render diff content with hunks and lines */ renderDiffContent(diff: ParsedDiff): string[]; /** * Render hunk header */ renderHunkHeader(hunk: Hunk): string; /** * Render a single diff line with line numbers */ renderDiffLine(line: DiffLine, _index: number): string; /** * Get prefix character for line type */ private getLinePrefix; /** * Get visible content lines based on scroll position */ private getVisibleContentLines; /** * Get available height for content area */ private getAvailableContentHeight; /** * Render footer with keyboard shortcuts and scroll info */ renderFooter(totalLines: number): string; /** * Get scroll position info string */ private getScrollInfo; /** * Scroll up by specified lines */ scrollUp(lines?: number): void; /** * Scroll down by specified lines */ scrollDown(totalLines: number, lines?: number): void; /** * Scroll to top */ scrollToTop(): void; /** * Scroll to bottom */ scrollToBottom(totalLines: number): void; /** * Page up */ pageUp(): void; /** * Page down */ pageDown(totalLines: number): void; /** * Handle keyboard input */ handleInput(key: string, totalLines: number): { action?: string; handled: boolean; }; /** * Handle bulk action */ private handleBulkAction; /** * Show confirmation dialog for destructive actions */ private showConfirmationDialog; /** * Handle confirmation dialog input */ private handleConfirmationInput; /** * Render confirmation dialog */ renderConfirmationDialog(): string; private confirmationDialogHunkIndex?; /** * Render a simple diff string (for quick display) */ renderSimple(diff: ParsedDiff): string; /** * Clear terminal and render */ clearAndRender(diff: ParsedDiff): void; /** * Strip ANSI codes from string */ private stripAnsi; /** * Get current scroll position */ getScrollPosition(): number; /** * Get current theme */ getTheme(): TUITheme; /** * Get current configuration */ getConfig(): TUIRendererConfig; } export default TUIRenderer; //# sourceMappingURL=tui-renderer.d.ts.map