/** * SGR mouse protocol (xterm DEC private modes). Mouse tracking and alternate * screen mode (?1049h) are independent terminal capabilities; the full-screen * TUI enables both and tears both down explicitly. * * ?1000h — button press/release tracking (clicks + wheel) * ?1002h — button-event tracking: adds drag (motion while a button is held) * ?1003h — any-event tracking: adds hover (motion with no button) — EXPENSIVE, * one event per cell the cursor crosses; gate behind a setting. * ?1006h — SGR extended coordinates: `ESC [ < b ; x ; y (M|m)`, no 223-col cap. * * Trade-off: with ANY of these on, the terminal reports the wheel to us as * buttons 64/65 instead of scrolling its own scrollback. Shift+wheel (and * users keep access to terminal scrollback — but plain wheel events are owned * by the app while tracking is active. Managed history therefore keeps * button-drag tracking active (click + wheel + held-drag motion) so * drag-select-copy works by default; free hover (1003) remains opt-in. */ /** Click + wheel only (mode 1000). Cheapest; no motion events. */ export declare const MOUSE_CLICK_ON: string; /** Click + wheel + drag (motion while a button is held; mode 1002). */ export declare const MOUSE_DRAG_ON: string; /** Click + wheel + free hover (motion with no button; mode 1003). Expensive. */ export declare const MOUSE_HOVER_ON: string; /** * Disable every tracking mode. Disabling a mode that was never set is a no-op, * so this is safe to send unconditionally on cleanup regardless of which * *_ON sequence (if any) was emitted. */ export declare const MOUSE_OFF: string; export interface MouseTrackingPolicy { /** Full-session pointer mode (`--mouse`, saved setting, or `/mouse on`). */ fullMode: boolean; /** A picker that benefits from temporary click/wheel ownership is visible. */ overlayOpen: boolean; /** * The chat transcript is rendered in a bounded, application-managed * viewport. Its wheel must be reported to the app because native terminal * scrollback cannot move virtualized content. */ managedHistory: boolean; /** * The user explicitly handed the mouse back to the terminal (`/mouse native`). * * This is the ONLY input that can defeat `managedHistory`, and it exists * because nothing else could: with tracking on, the terminal reports the * wheel to us instead of scrolling, which also means it never starts a * native selection — so there was no way to select and copy transcript text * with the mouse at all. Native mode trades in-app wheel scrolling (PgUp/ * PgDn and Ctrl+U/D still page) for that selection. * * It outranks `overlayOpen` too: letting a picker silently re-grab the mouse * would cancel an in-progress drag-selection. */ native?: boolean | undefined; /** Startup terminal capability probe. Undefined keeps legacy callers enabled. */ protocol?: 'none' | 'x10' | 'urxvt' | 'sgr' | undefined; } /** Decide whether the TUI should currently own terminal mouse reports. */ export declare function shouldEnableMouseTracking(policy: MouseTrackingPolicy): boolean; /** * Enter the alternate screen buffer (DECSET 1049). The normal screen is * saved and restored on exit. */ export declare const ALT_SCREEN_ON: string; /** * Exit the alternate screen buffer (DECRST 1049), restoring the normal screen. */ export declare const ALT_SCREEN_OFF: string; export type MouseEventKind = 'press' | 'release' | 'move' | 'wheel'; export type MouseButton = 'left' | 'middle' | 'right' | 'none'; export interface MouseEventInfo { kind: MouseEventKind; button: MouseButton; /** 1-based terminal column (matches the SGR report; column 1 = leftmost). */ x: number; /** 1-based terminal row (column 1 = topmost visible row). */ y: number; /** Wheel direction: +1 = up (away from user), -1 = down, 0 = not a wheel event. */ wheel: number; shift: boolean; /** Alt/Meta modifier. */ meta: boolean; ctrl: boolean; /** True for motion events (button-held drag, or free hover). */ motion: boolean; } /** * Parse a single, whole SGR mouse report into a structured event. Returns null * when `data` is not exactly one report. */ export declare function parseMouseEvent(data: string): MouseEventInfo | null; /** * Scan raw stdin data for ALL SGR mouse reports, in order. A fast wheel scroll * coalesces several reports into one chunk; returns an empty array when the * data contains no report. */ export declare function parseMouseEvents(data: string): MouseEventInfo[]; /** * Longest tail of `data` that is an SGR report the terminal has only partially * delivered, split off so the caller can carry it into the next chunk. * * A report is `ESC [ < b ; x ; y (M|m)` — up to ~18 bytes, and stdin makes no * promise about chunk boundaries. A fast drag or a wheel burst readily splits * one across two `data` events, and {@link parseMouseEvents} (which scans a * single chunk) then matches NEITHER half: the gesture is silently dropped and * the leading half falls through to the key parsers as garbage. * * Only the unambiguous case is held back: a trailing `ESC [ <` with no `M`/`m` * terminator after it. A bare trailing `ESC` or `ESC [` is deliberately NOT * buffered — a lone `ESC` is how the Esc KEY arrives, and swallowing it would * break the Esc ladder outright. * * The carry is capped: past {@link MAX_PARTIAL_MOUSE} bytes the tail cannot be * a real report any more (a malformed or hostile stream), so it is released as * ordinary data rather than accumulating forever. */ export declare function splitTrailingMousePartial(data: string): { consumed: string; pending: string; }; /** * True when `input` (Ink's already-ESC-stripped text) is a leaked mouse report. * The input layer drops these so they never land in the buffer as typed text. */ export declare function isLeakedMouseInput(input: string): boolean; //# sourceMappingURL=mouse.d.ts.map