textui/config.ts

40 lines
1.1 KiB
TypeScript

import { Color } from "./base.ts";
/**
* Color palette requirements.
*
* The array represents the "ideal" colors desired by the application.
* When drawing things, *bg* and *fg* color information should be an index
* in this palette.
*
* For each palette index, a single color can be requested, or an
* array of accepted alternatives, with decreasing priority.
*/
export type UIPalette = ReadonlyArray<Color | ReadonlyArray<Color>>;
/**
* Configuration of the UI
*/
export type UIConfig = Readonly<{
// Set the automatic loop interval on init
// If left undefined, a call to ui.loop() will be required after init
loopInterval?: number;
// Set if anything is rendered at all
renderingEnabled: boolean;
// Ignore the ctrl+c key combo to quit the UI
ignoreCtrlC: boolean;
// Initially hide the cursor
hideCursor: boolean;
// Palette of colors that will be used by the UI
palette: UIPalette;
// Callback to receive key strokes
onKeyStroke: (key: string) => void;
}>;
export const UI_CONFIG_DEFAULTS: UIConfig = {
renderingEnabled: true,
ignoreCtrlC: false,
hideCursor: true,
palette: [],
onKeyStroke: () => {},
};