From b739323dfd13b177971250ed6f0ce0c58877c0e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Tue, 14 Mar 2017 16:56:22 +0100 Subject: Add experimental raw vt100 UI backend The intention of this is not to slowly reimplement curses but to provide a minimal working terminal UI backend which can also be used for debugging, fuzzing and in environments where curses is not available. Currently no attempt is made to optimize terminal output. The amount of flickering will depend on the smartness of your terminal emulator. --- ui.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'ui.h') diff --git a/ui.h b/ui.h index 41ef975..ee434fc 100644 --- a/ui.h +++ b/ui.h @@ -50,12 +50,27 @@ enum UiStyle { UI_STYLE_MAX, }; +#if CONFIG_CURSES typedef uint64_t CellAttr; typedef short CellColor; static inline bool cell_color_equal(CellColor c1, CellColor c2) { return c1 == c2; } +#else +typedef uint8_t CellAttr; +typedef struct { + uint8_t r, g, b; + uint8_t index; +} CellColor; + +static inline bool cell_color_equal(CellColor c1, CellColor c2) { + if (c1.index != (uint8_t)-1 || c2.index != (uint8_t)-1) + return c1.index == c2.index; + return c1.r == c2.r && c1.g == c2.g && c1.b == c2.b; +} + +#endif typedef struct { CellAttr attr; -- cgit v1.2.3