From 522e11c8086b7d8ab76b9be07c1861f35ed2327f Mon Sep 17 00:00:00 2001 From: Paul Oliver Date: Mon, 4 May 2026 23:33:08 +0200 Subject: Adds prototype for the data client UI --- core/logger.c | 25 ++++++++++++++++++------- core/tui.c | 14 +++++++++++++- 2 files changed, 31 insertions(+), 8 deletions(-) (limited to 'core') diff --git a/core/logger.c b/core/logger.c index f665908..880c231 100644 --- a/core/logger.c +++ b/core/logger.c @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -25,20 +26,30 @@ void log_msg_to_buff(char *out, int size, enum LogLevel level, bool colored, con long msec = ts.tv_nsec / 1000000; struct tm tm = *localtime(&ts.tv_sec); pid_t pid = getpid(); - char *level_str = NULL; + switch (level) { - case LOG_INFO: level_str = "INFO"; break; - case LOG_WARN: level_str = "WARN"; break; - default: assert(false); + case LOG_INFO: + level_str = "INFO"; + break; + case LOG_WARN: + level_str = "WARN"; + break; + default: + assert(false); } char *color_code = NULL; if (colored) { switch (level) { - case LOG_INFO: color_code = "\033[1;32m"; break; - case LOG_WARN: color_code = "\033[1;33m"; break; - default: assert(false); + case LOG_INFO: + color_code = "\033[1;32m"; + break; + case LOG_WARN: + color_code = "\033[1;33m"; + break; + default: + assert(false); } } diff --git a/core/tui.c b/core/tui.c index 6c27ff5..4fc2ce4 100644 --- a/core/tui.c +++ b/core/tui.c @@ -1,3 +1,6 @@ +#define PANE_WIDTH 27 +#define PANE_AND_MARGIN_WIDTH (PANE_WIDTH + 2) + enum { PAIR_NORMAL = 0, }; @@ -70,17 +73,26 @@ void tui_field(int line, int col, int color, int attr, const char *format, ...) void tui_str_field(int l, const char *label, const char *value) { assert(label); + assert(strlen(label) <= 4); assert(value); - tui_line(false, l, PAIR_NORMAL, A_NORMAL, "%s : %18s", label, value); + tui_line(false, l, PAIR_NORMAL, A_NORMAL, "%-4s : %18s", label, value); } void tui_ulx_field(int l, const char *label, uint64_t value) { assert(label); + assert(strlen(label) <= 4); tui_line(false, l, PAIR_NORMAL, A_NORMAL, "%-4s : %#18lx", label, value); } +void tui_uld_field(int l, const char *label, uint64_t value) { + assert(label); + assert(strlen(label) <= 4); + tui_line(false, l, PAIR_NORMAL, A_NORMAL, "%-4s : %#18ld", label, value); +} + void tui_float_field(int l, const char *label, float value) { assert(label); + assert(strlen(label) <= 4); tui_line(false, l, PAIR_NORMAL, A_NORMAL, "%-4s : %18.1f", label, value); } -- cgit v1.3