textui/display.ts

63 lines
1.3 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
/**
2021-07-19 22:48:00 +00:00
* Init the display (will be the first method called)
*/
async init(): Promise<void> {
}
/**
* Restore the display as before *init*
*/
async uninit(): Promise<void> {
}
/**
* Get the current grid size
2021-05-13 22:04:47 +00:00
*/
2021-06-28 18:21:32 +00:00
async getSize(): Promise<BufferSize> {
2021-07-19 22:48:00 +00:00
return { w: 0, h: 0 };
2021-06-28 18:21:32 +00:00
}
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
/**
2021-07-19 22:48:00 +00:00
* Set the cursor visibility
2021-05-11 21:20:33 +00:00
*/
2021-07-19 22:48:00 +00:00
async setCursorVisibility(visible: boolean): Promise<void> {
2021-06-28 18:21:32 +00:00
}
/**
2021-07-19 22:48:00 +00:00
* Flush the display
2021-06-28 18:21:32 +00:00
*/
2021-07-19 22:48:00 +00:00
async flush(): Promise<void> {
2021-06-28 18:21:32 +00:00
}
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
}