import { type AutocompleteProvider } from "../autocomplete"; import type { SymbolTheme } from "../symbols"; import { type Component, type Focusable } from "../tui"; import { type SelectListTheme } from "./select-list"; export interface EditorTheme { borderColor: (str: string) => string; selectList: SelectListTheme; symbols: SymbolTheme; editorPaddingX?: number; /** Style function for inline hint/ghost text (dim text after cursor) */ hintStyle?: (text: string) => string; } export interface EditorTopBorder { /** The status content (already styled) */ content: string; /** Visible width of the content */ width: number; } export type EditorBorderStyle = "round" | "sharp"; interface HistoryEntry { prompt: string; } interface HistoryStorage { add(prompt: string, cwd?: string): Promise; getRecent(limit: number, cwd?: string): HistoryEntry[]; } /** Test-only performance counters for advisory baseline tests. */ export declare const __editorPerfCounters: { layoutTextInvocations: number; layoutLogicalLinesProcessed: number; visibleWidthMeasurements: number; reset(): void; }; export declare class Editor implements Component, Focusable { #private; /** Focusable interface - set by TUI when focus changes */ focused: boolean; /** When set, replaces the normal cursor glyph at end-of-text with this ANSI-styled string. */ cursorOverride: string | undefined; /** Display width of the cursorOverride glyph (needed because override may contain ANSI escapes). */ cursorOverrideWidth: number | undefined; borderColor: (str: string) => string; onAutocompleteUpdate?: () => void; onSubmit?: (text: string) => void; onAltEnter?: (text: string) => void; onChange?: (text: string) => void; onUndo?: (text: string) => void; onAutocompleteCancel?: () => void; onTabDeclined?: (text: string) => void; /** * Called before Tab opens/applies autocomplete. Return true to consume Tab * for app-level behavior (for example, queueing a draft while a turn runs). */ onTab?: (text: string) => boolean | undefined; disableSubmit: boolean; constructor(theme: EditorTheme); dispose(): void; setAutocompleteProvider(provider: AutocompleteProvider | undefined): void; getAutocompleteProvider(): AutocompleteProvider | undefined; /** Whether the autocomplete dropdown is currently open. */ isAutocompleteOpen(): boolean; /** * Set custom content for the top border (e.g., status line). * Pass undefined to use the default plain border. */ setTopBorder(content: EditorTopBorder | undefined): void; /** * Show or hide the editor border chrome. */ setBorderVisible(borderVisible: boolean): void; setBorderStyle(borderStyle: EditorBorderStyle): void; setClosedBorderBox(closedBorderBox: boolean): void; setPromptGutter(promptGutter: string | undefined): void; setInputPrefix(inputPrefix: string | undefined): void; setPlaceholder(placeholder: string | undefined): void; /** * Get the available width for top border content given a total terminal width. * Accounts for right gutter, border characters, and horizontal padding when visible. */ getTopBorderAvailableWidth(terminalWidth: number): number; /** * Use the real terminal cursor instead of rendering a cursor glyph. */ setUseTerminalCursor(useTerminalCursor: boolean): void; getUseTerminalCursor(): boolean; setMaxHeight(maxHeight: number | undefined): void; setPaddingX(paddingX: number): void; setRightGutterWidth(width: number): void; getAutocompleteMaxVisible(): number; setAutocompleteMaxVisible(maxVisible: number): void; setHistoryStorage(storage: HistoryStorage): void; setHistoryStorageLoader(loader: (() => Promise) | undefined): void; /** * Add a prompt to history for up/down arrow navigation. * Called after successful submission. */ addToHistory(text: string): void; invalidate(): void; render(width: number): string[]; handleInput(data: string): void; /** Test-only seam: current wrap-cache entry count (memory-bound assertions). */ get wrappedLineCacheSize(): number; getText(): string; /** * Get text with paste markers expanded to their actual content. * Use this when you need the full content (e.g., for external editor). */ getExpandedText(): string; getLines(): string[]; getCursor(): { line: number; col: number; }; moveToLineStart(): void; moveToLineEnd(): void; moveToMessageStart(): void; moveToMessageEnd(): void; /** * Undo the last meaningful edit while ignoring transient text that is still present at the cursor. * Used for command-like autocomplete actions whose typed trigger should not count as the edit being undone. */ undoPastTransientText(transientText: string): void; setText(text: string): void; /** Insert text at the current cursor position */ insertText(text: string): void; /** * Delete an exact text run immediately before the cursor as one edit. * Returns false without changing the document when the text is not present. */ deleteTextBeforeCursor(text: string): boolean; /** * Delete a same-line text range containing the cursor as one edit. * Returns false without changing the document when the range is invalid. */ deleteTextRangeAroundCursor(startCol: number, endCol: number): boolean; isShowingAutocomplete(): boolean; } export {};