/** * The one-line text box the dashboard uses to ask for a name. * * Pure on purpose, like the key dispatcher next to it: typing, deleting and * confirming are decided here, so the behaviour can be tested without a * terminal. The dashboard only draws the result. * * Everything works on a CHUNK rather than a single key, because that is what a * terminal delivers: typing at speed, or pasting, arrives as one blob holding * several keystrokes. Acting on only the first byte of a chunk is how a hand * rolled text box ends up impossible to confirm. */ export type PromptStatus = 'editing' | 'submit' | 'cancel'; /** What the box is being used for, which decides what submitting it does. */ export type PromptKind = 'add' | 'rename'; export interface PromptState { kind: PromptKind; /** The question shown to the operator. */ label: string; text: string; status: PromptStatus; /** Set when the typed value is not usable, shown under the box. */ error?: string; } export declare function openPrompt(kind: PromptKind, label: string, text?: string): PromptState; /** * Apply a chunk of keypresses. * * Enter confirms, Escape and Ctrl-C cancel, Ctrl-U clears the line, Backspace and * Delete remove a character. Everything is applied in the order it arrived, so a * chunk mixing editing and text behaves the same as typing it slowly. Control * bytes and escape sequences (arrow keys and the like) are skipped rather than * typed in as junk. */ export declare function promptKey(state: PromptState, key: string, byte0?: number): PromptState; /** Put the prompt back into editing with a reason, after a rejected value. */ export declare function rejectPrompt(state: PromptState, error: string): PromptState;