aboutsummaryrefslogtreecommitdiff
path: root/client/ui.h
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2022-05-29 16:27:29 +0200
committerlonkaars <loek@pipeframe.xyz>2022-05-29 16:27:29 +0200
commit3b2c2cf6b2af9e76b343a5a8fc8e9245f240690d (patch)
treef257a9a03b8205f55301901d00c5865f8b179607 /client/ui.h
parentf466856892d94f5b42bf2369cae0fd73dd468dfa (diff)
serial parsing working on client
Diffstat (limited to 'client/ui.h')
-rw-r--r--client/ui.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/client/ui.h b/client/ui.h
new file mode 100644
index 0000000..433d610
--- /dev/null
+++ b/client/ui.h
@@ -0,0 +1,58 @@
+#pragma once
+
+#include <stdint.h>
+
+#include "../shared/bool.h"
+
+typedef struct {
+ unsigned int width;
+ unsigned int height;
+ unsigned int cursor_pos;
+} w2_s_ui_tty_canvas;
+
+typedef enum {
+ W2_UI_COL_BLK,
+ W2_UI_COL_RED,
+ W2_UI_COL_GRN,
+ W2_UI_COL_YEL,
+ W2_UI_COL_BLU,
+ W2_UI_COL_MAG,
+ W2_UI_COL_CYN,
+ W2_UI_COL_WHT,
+ W2_UI_COL_RST,
+} w2_e_colors;
+
+typedef enum {
+ W2_UI_ALIGN_LEFT,
+ W2_UI_ALIGN_CENTER,
+ W2_UI_ALIGN_RIGHT,
+} w2_e_alignment;
+
+extern bool g_w2_ui_enable_color;
+extern w2_s_ui_tty_canvas g_w2_ui_canvas;
+
+/** update terminal props */
+void w2_ui_update();
+/** clear screen */
+void w2_ui_clear();
+/** draw complete ui */
+void w2_ui_paint();
+/** draw status bar */
+void w2_ui_paint_statusbar();
+/** update and paint */
+void w2_ui_main();
+
+/** echo ansi color code for foreground color */
+void w2_ui_set_fg(w2_e_colors color);
+/** echo ansi color code for background color */
+void w2_ui_set_bg(w2_e_colors color);
+
+/** align `text` `align` with `text` buffer length `length` */
+void w2_ui_align(char* text, w2_e_alignment align, unsigned int length);
+
+/**
+ * trim spaces from `top` and overlay on top of `bottom`
+ * both strings should be at least `length` long
+ */
+void w2_ui_overlay(char* bottom, char* top, unsigned int length);
+