textui/display.ts

50 lines
1.1 KiB
TypeScript

import { BufferLocation, BufferSize, Char, Color } from "./base.ts";
/**
* Display protocol, to allow the UI to draw things on "screen"
*/
export class Display {
/**
* Get the displayable grid size
*/
async getSize(): Promise<BufferSize> {
return { w: 1, h: 1 };
}
/**
* Setup the palette for color display
*
* If the display supports the whole RGB range, it may return the array as-is.
* If the display only supports a limited palette, it may return only supported colors.
*
* From this call forward, colors will be received by numbered index in the returned array.
*/
async setupPalette(colors: readonly Color[]): Promise<readonly Color[]> {
return [];
}
/**
* Clear the whole screen
*/
async clear(): Promise<void> {
}
/**
* Set the cursor visibility
*/
async setCursorVisibility(visible: boolean): Promise<void> {
}
/**
* Draw a single character on screen
*/
async setChar(at: BufferLocation, char: Char): Promise<void> {
}
/**
* Get the keys pressed since last call
*/
async getKeyStrokes(): Promise<string[]> {
return [];
}
}