aboutsummaryrefslogtreecommitdiff
path: root/ui.h
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2017-03-14 16:56:22 +0100
committerMarc André Tanner <mat@brain-dump.org>2017-03-14 19:04:21 +0100
commitb739323dfd13b177971250ed6f0ce0c58877c0e8 (patch)
tree0a1f3055cbb26eaac96715af0c59cd8bdb5bbc5c /ui.h
parent9bcf2667e7e239873597b7ec2172206a9af18071 (diff)
downloadvis-b739323dfd13b177971250ed6f0ce0c58877c0e8.tar.gz
vis-b739323dfd13b177971250ed6f0ce0c58877c0e8.tar.xz
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.
Diffstat (limited to 'ui.h')
-rw-r--r--ui.h15
1 files changed, 15 insertions, 0 deletions
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;