@teaui/core
Version:
A high-level terminal UI library for Node
38 lines (37 loc) • 1.38 kB
TypeScript
import { View } from '../View.js';
import { type HotKeyDef, type KeyEvent } from '../events/index.js';
export declare class FocusManager {
#private;
/**
* If the previous focus-view is not mounted, we can clear out the current
* focus-view and focus the first that registers.
*
* If the previous focus-view is mounted but does not request focus, we can't know
* that until _after_ the first render. In that case, after render, 'needsRerender'
* selects the first focus-view and triggers a re-render.
*/
reset(isRootView: boolean): void;
trigger(event: KeyEvent): void;
triggerPaste(text: string): void;
/**
* Returns whether the current view has focus.
*/
registerFocus(view: View, isDefault: boolean): boolean;
get currentFocusView(): View | undefined;
get hotKeyViews(): [View, HotKeyDef][];
registerHotKey(view: View, key: HotKeyDef): void;
/**
* Registers a fallback keyboard listener. When no hotkey matches and no view
* has focus, key events are sent to the last (innermost) registered listener.
*/
registerKeyboard(view: View): void;
requestFocus(view: View): boolean;
unfocus(): void;
determineFocus(): boolean;
/**
* @return boolean Whether the focus changed
*/
commit(): boolean;
prevFocus(): void;
nextFocus(): void;
}