/** * Keyboard input parser - converts terminal input to key events * * Uses the termio tokenizer for escape sequence boundary detection, * then interprets sequences as keypresses. */ import { Buffer } from 'buffer'; import { type Tokenizer } from '../termio/tokenize.js'; /** DECRPM status values (response to DECRQM) */ export declare const DECRPM_STATUS: { readonly NOT_RECOGNIZED: 0; readonly SET: 1; readonly RESET: 2; readonly PERMANENTLY_SET: 3; readonly PERMANENTLY_RESET: 4; }; /** * A response sequence received from the terminal (not a keypress). * Emitted in answer to queries like DECRQM, DA1, OSC 11, etc. */ export type TerminalResponse = /** DECRPM: answer to DECRQM (request DEC private mode status) */ { type: 'decrpm'; mode: number; status: number; } /** DA1: primary device attributes (used as a universal sentinel) */ | { type: 'da1'; params: number[]; } /** DA2: secondary device attributes (terminal version info) */ | { type: 'da2'; params: number[]; } /** Kitty keyboard protocol: current flags (answer to CSI ? u) */ | { type: 'kittyKeyboard'; flags: number; } /** DSR: cursor position report (answer to CSI 6 n) */ | { type: 'cursorPosition'; row: number; col: number; } /** OSC response: generic operating-system-command reply (e.g. OSC 11 bg color) */ | { type: 'osc'; code: number; data: string; } /** XTVERSION: terminal name/version string (answer to CSI > 0 q). * Example values: "xterm.js(5.5.0)", "ghostty 1.2.0", "iTerm2 3.6". */ | { type: 'xtversion'; name: string; }; export type KeyParseState = { mode: 'NORMAL' | 'IN_PASTE'; incomplete: string; pasteBuffer: string; _tokenizer?: Tokenizer; }; export declare const INITIAL_STATE: KeyParseState; export declare function parseMultipleKeypresses(prevState: KeyParseState, input?: Buffer | string | null): [ParsedInput[], KeyParseState]; export declare const nonAlphanumericKeys: string[]; export type ParsedKey = { kind: 'key'; fn: boolean; name: string | undefined; ctrl: boolean; meta: boolean; shift: boolean; option: boolean; super: boolean; sequence: string | undefined; raw: string | undefined; code?: string; isPasted: boolean; }; export type ParsedResponse = { kind: 'response'; sequence: string; response: TerminalResponse; }; export type ParsedMouse = { kind: 'mouse'; button: number; action: 'press' | 'release'; col: number; row: number; sequence: string; }; export type ParsedInput = ParsedKey | ParsedMouse | ParsedResponse; //# sourceMappingURL=parse-keypress.d.ts.map