import { EventEmitter } from 'eventemitter3'; import type { Abortable } from 'node:events'; import type * as readline from 'node:readline'; interface InterfaceEvents { close: []; line: [input: string]; pause: []; resume: []; SIGCONT: []; SIGINT: []; SIGTSTP: []; history: [history: string[]]; } export declare class Interface extends EventEmitter implements readline.Interface { readonly input: NodeJS.ReadableStream; readonly output?: NodeJS.WritableStream | undefined; readonly terminal: boolean; readonly line: string; protected _cursor: number; get cursor(): number; private _buffer; private _closed; private _paused; private _prompt; private _history; private _historyIndex; private _currentLine; constructor(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream | undefined, completer?: readline.Completer | readline.AsyncCompleter, terminal?: boolean); private _onData; /** * Closes the interface and removes all event listeners */ close(): void; /** * Pauses the input stream */ pause(): this; /** * Resumes the input stream */ resume(): this; /** * Sets the prompt text */ setPrompt(prompt: string): void; /** * Gets the current prompt text */ getPrompt(): string; /** * Displays the prompt to the user */ prompt(preserveCursor?: boolean): void; /** * Writes data to the interface and handles key events */ write(data: string | Buffer, key?: readline.Key): void; private _renderLine; /** * Asks the user for input with a specified prompt */ question(query: string, callback: (answer: string) => void): void; question(query: string, options: Abortable, callback: (answer: string) => void): void; /** * Gets the current cursor position */ getCursorPos(): { rows: number; cols: number; }; /** * Prepends a listener for the specified event */ prependListener(event: keyof InterfaceEvents, listener: (...args: any[]) => void): this; /** * Prepends a one-time listener for the specified event */ prependOnceListener(event: keyof InterfaceEvents, listener: (...args: any[]) => void): this; /** * Sets the maximum number of listeners */ setMaxListeners(): this; /** * Gets the maximum number of listeners */ getMaxListeners(): number; [Symbol.asyncIterator](): AsyncIteratorObject; [Symbol.dispose](): void; [Symbol.asyncDispose](): Promise; rawListeners(event: keyof InterfaceEvents): ((...args: any[]) => void)[]; } /** * Creates a readline interface * @param input The readable stream to read from * @param output The writable stream to write to * @param completer The completer function * @param terminal Whether to use terminal features * @returns A readline interface */ export declare function createInterface(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: readline.Completer | readline.AsyncCompleter, terminal?: boolean): Interface; /** * Creates a readline interface from options * @param options The options for the interface * @returns A readline interface */ export declare function createInterface(options: readline.ReadLineOptions): Interface; /** * Clear the current line in the terminal * @param stream The stream to clear the line on * @param dir The direction to clear: -1 for left, 1 for right, 0 for entire line */ export declare function clearLine(stream: NodeJS.WritableStream, dir: number): boolean; /** * Clear the screen down from the current position * @param stream The stream to clear the screen on */ export declare function clearScreenDown(stream: NodeJS.WritableStream): boolean; /** * Move the cursor in the terminal * @param stream The stream to move the cursor on * @param dx The number of characters to move horizontally * @param dy The number of lines to move vertically */ export declare function moveCursor(stream: NodeJS.WritableStream, dx: number, dy: number): boolean; /** * The `readline.emitKeypressEvents()` method causes the given Readable stream to begin emitting `'keypress'` events corresponding to received input. * * Optionally, interface specifies a `readline.Interface` instance for which autocompletion is disabled when copy-pasted input is detected. * * If the `stream` is a TTY, then it must be in raw mode. * * This is automatically called by any readline instance on its `input` if the `input` is a terminal. Closing the `readline` instance does not stop the `input` from emitting `'keypress'` events. */ export declare function emitKeypressEvents(stream: NodeJS.ReadableStream, readlineInterface?: Interface | readline.Interface): void; export {};