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. * * The first color is considered the default background color. */ export type UIPalette = ReadonlyArray>; /** * 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; // 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 resizes // The screen has been cleared before this is called onResize: (size: { w: number; h: number }) => void; // Callback to receive key strokes onKeyStroke: (key: string) => void; // Callback to receive clicks onMouseClick: (loc: { x: number; y: number }) => void; }>; export const UI_CONFIG_DEFAULTS: UIConfig = { ignoreCtrlC: false, hideCursor: true, palette: [], onResize: () => {}, onKeyStroke: () => {}, onMouseClick: () => {}, };