textui/display.ts

51 lines
1.1 KiB
TypeScript
Raw Normal View History

2021-05-13 22:04:47 +00:00
import { BufferLocation, BufferSize, Char, Color } from "./base.ts";
2021-05-11 21:20:33 +00:00
/**
* Display protocol, to allow the UI to draw things on "screen"
*/
2021-06-28 18:21:32 +00:00
export class Display {
2021-05-13 22:04:47 +00:00
/**
* Get the displayable grid size
*/
2021-06-28 18:21:32 +00:00
async getSize(): Promise<BufferSize> {
return { w: 1, h: 1 };
}
2021-05-13 22:04:47 +00:00
2021-05-11 21:20:33 +00:00
/**
* 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.
*/
2021-06-28 18:21:32 +00:00
async setupPalette(colors: readonly Color[]): Promise<readonly Color[]> {
return [];
}
2021-05-11 21:20:33 +00:00
/**
* Clear the whole screen
*/
2021-06-28 18:21:32 +00:00
async clear(): Promise<void> {
}
/**
* Set the cursor visibility
*/
async setCursorVisibility(visible: boolean): Promise<void> {
}
2021-05-13 22:04:47 +00:00
/**
* Draw a single character on screen
*/
2021-06-28 18:21:32 +00:00
async setChar(at: BufferLocation, char: Char): Promise<void> {
}
/**
* Get the keys pressed since last call
*/
async getKeyStrokes(): Promise<string[]> {
return [];
}
2021-05-11 21:20:33 +00:00
}