aboutsummaryrefslogtreecommitdiff
path: root/data/client.c
diff options
context:
space:
mode:
authorPaul Oliver <contact@pauloliver.dev>2026-05-04 22:14:52 +0200
committerPaul Oliver <contact@pauloliver.dev>2026-05-04 22:14:52 +0200
commitaa6d8c2e6f9635d36819cb8325cdc93d325ce3d6 (patch)
treece8dd8655515482bf0664207300aade43e55fdac /data/client.c
parent8401fde7b1d10dc4c1ce9117c1eda7a21067778b (diff)
Adds basic scaffolding for data server and client
Diffstat (limited to 'data/client.c')
-rw-r--r--data/client.c80
1 files changed, 77 insertions, 3 deletions
diff --git a/data/client.c b/data/client.c
index 7af411f..02c7687 100644
--- a/data/client.c
+++ b/data/client.c
@@ -1,6 +1,80 @@
-#include <stdio.h>
+#include <assert.h>
+#include <curses.h>
+#include <locale.h>
+#include <stdlib.h>
+#include <time.h>
+#include <unistd.h>
+
+#include "logger.c"
+#include "tui.c"
+
+#define CTRL(x) (x & 0x1f)
+
+enum {
+ PAIR_HEADER = 1,
+};
+
+// Globals
+bool g_exit;
+
+void ui_print(void) {
+ int l = 1;
+
+ tui_line(false, l++, PAIR_HEADER, A_BOLD, "SALIS DATA CLIENT");
+}
+
+void ev_handle(void) {
+ int ev = getch();
+
+ switch (ev) {
+ case CTRL('c'):
+ g_exit = true;
+ break;
+ case KEY_RESIZE:
+ clear();
+ tui_line_buff_resize();
+ default:
+ break;
+ }
+}
+
+void init(void) {
+ log_info("Initializing salis data client");
+
+ setlocale(LC_ALL, "");
+
+ initscr();
+ raw();
+ noecho();
+ curs_set(0);
+ keypad(stdscr, TRUE);
+
+ start_color();
+ init_color(COLOR_BLACK, 0, 0, 0);
+
+ init_pair(PAIR_NORMAL, COLOR_WHITE, COLOR_BLACK);
+ init_pair(PAIR_HEADER, COLOR_BLUE, COLOR_BLACK);
+
+ tui_line_buff_resize();
+}
+
+void exec(void) {
+ while (!g_exit) {
+ ui_print();
+ ev_handle();
+ }
+}
+
+void quit(void) {
+ tui_line_buff_free();
+ endwin();
+ log_info("Shutting down salis data client");
+}
+
+int main(void) {
+ init();
+ exec();
+ quit();
-int main() {
- printf("hello client\n");
return 0;
}