@teaui/core
Version:
A high-level terminal UI library for Node
73 lines (72 loc) • 2.75 kB
TypeScript
import type { BlessedProgram } from './sys';
import type { SGRTerminal } from './terminal';
import type { Rect, Point } from './geometry';
import { View } from './View';
import type { HotKeyDef, KeyEvent, MouseEventListenerName, SystemEvent, SystemMouseEvent } from './events';
import { Window } from './components/Window';
type ViewConstructor<T extends View> = (program: BlessedProgram) => T | Promise<T>;
export interface ScreenOptions {
quitChar?: 'c' | 'q' | '' | undefined | false;
}
export declare class Screen {
#private;
rootView: View;
/**
* A helper function that puts the terminal into a "known good" state. I use this
* during debugging, if the app crashes and I need to get the terminal CLI working
* again.
*/
static reset(): void;
static start(): Promise<[Screen, BlessedProgram, Window]>;
static start<T extends View>(viewConstructor: T | ViewConstructor<T>, opts?: Partial<ScreenOptions>): Promise<[Screen, BlessedProgram, T]>;
constructor(program: SGRTerminal, rootView: View);
onExit(callback: () => void): void;
/**
* Called from Screen.start(). Don't call this yourself unless you wanted
* to construct your own 'program' (using blessed). I recommend starting with a
* copy of the implementation of Screen.start.
*/
start(): void;
/**
* Puts the screen back in normal terminal mode, restores the normal buffer
*/
stop(): void;
/**
* Stops (putting the screen back in normal mode and buffer) and exits by emitting
* process.exit(0)
*/
exit(): void;
trigger(event: SystemEvent): void;
/**
* Requests a modal. A modal will be created if:
* (a) no modal is already displayed
* or
* (b) a modal is requesting a nested modal
*/
requestModal(parent: View, modal: View, onClose: () => void, rect: Rect): boolean;
/**
* @return boolean Whether the current view has focus
*/
registerFocus(view: View): boolean;
registerHotKey(view: View, key: HotKeyDef): void;
requestFocus(view: View): boolean;
nextFocus(): void;
prevFocus(): void;
triggerKeyboard(event: KeyEvent): void;
/**
* @see MouseManager.registerMouse
*/
registerMouse(view: View, offset: Point, point: Point, eventNames: MouseEventListenerName[]): void;
checkMouse(view: View, x: number, y: number): void;
triggerMouse(systemEvent: SystemMouseEvent): void;
registerTick(view: View): void;
triggerTick(dt: number): void;
preRender(view: View): void;
/**
* @return boolean Whether or not to rerender the view due to focus or mouse change
*/
commit(): boolean;
needsRender(): void;
render(): void;
}
export {};