import type { RetainedRowChanges, XtermCompatibilityRow } from '../internal/xterm-compatibility.js'; import type { GhosttyBindings } from './bindings.js'; import type { ClipboardPasteRequest, ClipboardPasteResult, ClipboardProtocolOptions, ClipboardWriteRequest, CoreTerminalOptions, Disposable, KeyInput, PointerInput, PointerResult, ProgressState, RenderFrame, SelectionFormatOptions, TerminalBufferRange, TerminalBufferSnapshot, TerminalBufferState, TerminalEventMap, TerminalGeometry, TerminalTheme, ViewportSnapshot } from './types.js'; type Effect = { readonly type: 'input'; readonly data: Uint8Array; } | { readonly type: 'bell' | 'title' | 'cwd'; } | { readonly type: 'notification'; readonly title: string; readonly body: string; } | { readonly type: 'progress'; readonly state: ProgressState; readonly progress: number | null; } | { readonly type: 'clipboardWrite'; readonly request: ClipboardWriteRequest; } | { readonly type: 'error'; readonly error: Error; }; export interface TerminalHost { readonly bindings: GhosttyBindings; readonly callbackIndexes: Readonly<{ writePty: number; bell: number; titleChanged: number; pwdChanged: number; desktopNotification: number; progressReport: number; clipboardRead: number; clipboardWrite: number; mimeReader: number; randomSecure: number; colorScheme: number; }>; unregister(id: number): void; } /** Headless terminal exposing Ghostty VT parsing, input encoding, selection, and snapshots. */ export declare class CoreTerminal implements Disposable { private handle; private readonly inputEncoder; private readonly renderState; private readonly renderReader; private readonly bufferReader; private readonly pointerController; private readonly events; private readonly effects; private currentThemeSource; private currentTheme; private themeAlpha; private disposed; private writing; private revision; private readonly retainedScreens; private _geometry; private readonly host; private clipboardEnabled; private clipboardMaxBytes; private clipboardSnapshotTtlMs; private clipboardSnapshot; private clipboardSnapshotTimer; /** Runtime-unique terminal identifier. */ readonly id: number; constructor(host: TerminalHost, id: number, options?: CoreTerminalOptions); /** Current grid and cell geometry. */ get geometry(): TerminalGeometry; /** Current authored theme. Missing properties inherit from {@link DEFAULT_THEME}. */ get theme(): Readonly; /** Subscribes to a typed headless terminal event. */ on(type: Key, listener: (value: TerminalEventMap[Key]) => void): Disposable; /** Parses terminal output and flushes resulting callbacks. */ write(data: string | Uint8Array): void; /** Applies character-grid and cell-size geometry. */ resize(cols: number, rows: number, cellWidthPx?: number, cellHeightPx?: number): void; /** Resets Ghostty terminal state and invalidates the viewport. */ reset(): void; /** Reads the current incremental render frame. */ render(): RenderFrame; /** * Reports how the active screen's retained rows changed since the previous call for that screen, * so a reader that caches rows by index knows which ones to drop. * * @remarks * Rows keep their index until history is pruned or erased, and output can only change rows that * were in the active area. A tracked reference on the last active row measures how far every * older index moved; Ghostty discards it when its row is pruned, and every older row with it. * Each screen keeps its own reference, so the normal screen is measured across a full-screen app. * @internal */ retainedRowChanges(): RetainedRowChanges; /** Reads retained rows in the packed xterm cell format. @internal */ xtermRows(start: number, end: number): readonly XtermCompatibilityRow[]; /** Makes the next {@link retainedRowChanges} call report a reset for both screens. */ private forgetRetainedRows; /** Reads a complete visible viewport snapshot. */ viewport(): ViewportSnapshot; /** Returns authoritative active-buffer metadata. */ bufferState(): TerminalBufferState; /** Changes the retained scrollback capacity without resetting terminal contents. */ setScrollbackLines(lines: number): void; /** Changes the default cursor shape and blink behavior used by Ghostty. */ setDefaultCursor(style: import('./types.js').CursorStyle, blink: boolean): void; /** Reads a clamped page of active-buffer rows; defaults to the visible viewport. */ readBuffer(range?: TerminalBufferRange): TerminalBufferSnapshot; /** Encodes a physical key input and emits resulting PTY bytes. */ key(input: KeyInput): Uint8Array; /** Encodes composed text input and emits resulting PTY bytes. */ text(data: string | Uint8Array): Uint8Array; /** Encodes pasted content, honoring bracketed-paste mode. */ paste(data: string | Uint8Array): Uint8Array; /** Enables Kitty clipboard paste events and returns an idempotent registration. */ enableClipboard(options?: ClipboardProtocolOptions): Disposable; /** Applies user-initiated MIME data using Kitty paste events when mode 5522 is active. */ pasteClipboard(request: ClipboardPasteRequest): ClipboardPasteResult; /** @internal Replies synchronously to a Ghostty clipboard read callback. */ replyClipboardRead(request: number): void; /** @internal Denies remote clipboard writes and emits the request for auditing. */ replyClipboardWrite(request: number, value: ClipboardWriteRequest): void; /** Encodes a focus transition when focus reporting is enabled. */ focus(focused: boolean): Uint8Array; /** Encodes a pointer action or updates terminal selection. */ pointer(input: PointerInput): PointerResult; /** Applies a wheel gesture as mouse tracking input or viewport scrolling. */ wheel(input: PointerInput, lines: number): void; /** Returns whether an ANSI or DEC terminal mode is enabled. */ isMode(mode: number, ansi?: boolean): boolean; /** Scrolls the viewport by a signed line delta. */ scrollLines(delta: number): void; /** Scrolls to the beginning of the buffer. */ scrollToTop(): void; /** Scrolls to the end of the buffer. */ scrollToBottom(): void; /** Selects all terminal buffer content. */ selectAll(): void; /** Clears the current text selection. */ clearSelection(): void; /** Returns selected content using the requested output format. */ getSelection(options?: SelectionFormatOptions): string; /** Replaces terminal colors and invalidates the render state. */ setTheme(theme: TerminalTheme): Promise; /** Patches the current theme without resetting unspecified properties. */ updateTheme(theme: TerminalTheme): Promise; /** Serializes Ghostty terminal state and geometry. */ snapshot(): Uint8Array; /** Restores a compatible snapshot and its saved geometry. */ restore(snapshot: Uint8Array): void; /** Releases the Ghostty handle and unregisters the terminal from its runtime. */ dispose(): void; /** @internal Called synchronously by the WASM callback router. */ /** @internal */ queueEffect(effect: Effect): void; /** @internal Writes Ghostty's color-scheme callback result. */ writeColorScheme(pointer: number): number; private configure; private disableClipboard; private pasteClipboardEvent; private isUnsafeTextPaste; private setClipboardSnapshot; private clearClipboardSnapshot; private applyTheme; private readonly generatePalette; private rebuildThemeAlpha; private decorateColor; private decorateRows; private decorateFrame; private decorateViewport; private setScalarOption; private applyScrollbackLimit; private setOption; private scroll; private terminalString; private syncGeometry; private emitInput; private flushEffects; private ensureActive; } export {}; //# sourceMappingURL=terminal.d.ts.map