diff options
| author | Paul Oliver <contact@pauloliver.dev> | 2026-05-04 23:33:08 +0200 |
|---|---|---|
| committer | Paul Oliver <contact@pauloliver.dev> | 2026-05-24 23:46:55 +0200 |
| commit | 522e11c8086b7d8ab76b9be07c1861f35ed2327f (patch) | |
| tree | 48c61dd69cf817fce674c073d051de8a01a7f0ad /core | |
| parent | 6cecf64dbb488949a67eb080bf27d06f51533f40 (diff) | |
Adds prototype for the data client UI
Diffstat (limited to 'core')
| -rw-r--r-- | core/logger.c | 25 | ||||
| -rw-r--r-- | core/tui.c | 14 |
2 files changed, 31 insertions, 8 deletions
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 <assert.h> #include <stdarg.h> +#include <stdbool.h> #include <stddef.h> #include <stdio.h> #include <time.h> @@ -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); } } @@ -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); } |
