/** * Rebindable keys: a small set of high-frequency actions, and the rules for * applying a user's overrides without breaking the defaults. * * The TUI dispatches on raw byte sequences (`\x1b[5~` for PageUp, `\x1b` for * Esc), which is fine until someone's terminal sends something else for a key, * or their hands want the action elsewhere. Only actions are rebindable — never * arbitrary bytes — so a typo cannot invent a key that does nothing, and a key * that two actions claim is refused rather than silently winning by order. * @module dsh-ssh-tui/keymap */ /** The actions a user may move. */ export type KeyAction = 'pageUp' | 'pageDown' | 'toggleCard' | 'copy' | 'cancel'; /** Every action, in the order reports list them. */ export declare const KEY_ACTIONS: readonly KeyAction[]; /** The key each action answers to out of the box. */ export declare const DEFAULT_KEYMAP: Readonly>; /** * The bytes one key name stands for, or undefined when the name means nothing. * * Accepts the named keys above, `ctrl+`, and a single character. * @param name - the name from the config or the default table. * @returns the sequence, or undefined for an unknown name. */ export declare function keySequence(name: string): string | undefined; /** What a config's `keys` section asked for, and what was wrong with it. */ export interface ResolvedKeymap { /** Sequence to action, for the keys that survived. */ sequences: Map; /** Names the config used that no action has. */ unknownActions: string[]; /** Keys the config asked for that are not keys this TUI knows. */ unknownKeys: string[]; /** Keys two actions claim; the first (default order) keeps it. */ conflicts: Array<{ key: string; actions: KeyAction[]; }>; /** * Actions the config actually moved. Only these are dispatched through the * keymap, so a key the user did not touch keeps the handling it always had — * Enter in the input box still submits, Esc still closes a dialog. */ overridden: Set; /** * Sequences that used to be a default and are now unclaimed. Pressing one * does nothing instead of falling through to the old hard-coded branch. */ suppressed: Set; } /** * Apply a user's overrides to the defaults. * * Order matters and is deliberate: the defaults are laid down first, then the * overrides in {@link KEY_ACTIONS} order. A key that ends up claimed twice is * removed from the map and reported, so neither action surprises the other — * the user is told, and pressing that key does nothing rather than the wrong * thing. An action whose override is unusable keeps its default. * @param overrides - the config's `keys` section, action to key name. * @returns the keymap, plus what to tell the user about it. */ export declare function resolveKeymap(overrides?: Readonly>): ResolvedKeymap; /** * One line describing what was wrong with a config's keys, or undefined when * there is nothing to say. Silent acceptance is how a user ends up pressing a * key that does nothing and blaming the TUI. */ export declare function keymapReport(resolved: ResolvedKeymap): string | undefined;