diff options
| author | Sean Kurtz <seankurtz75@gmail.com> | 2026-11-25 21:47:13 -0600 |
|---|---|---|
| committer | Sean Kurtz <seankurtz75@gmail.com> | 2026-11-25 21:47:13 -0600 |
| commit | a31dca8186343f5ec7c46a8807c60453addc94e3 (patch) | |
| tree | 1e43953607ca68596d2d24d3292e1a1bf0a968a8 | |
| parent | 5ac81f8a746bfd01cf20860ba3c3d57a970d0ac0 (diff) | |
| download | ztop-a31dca8186343f5ec7c46a8807c60453addc94e3.tar.gz | |
tui: let update reach the app, so quit works
| -rw-r--r-- | .clangd | 2 | ||||
| -rw-r--r-- | src/ztop.c | 7 | ||||
| -rw-r--r-- | tui/tui.c | 2 | ||||
| -rw-r--r-- | tui/tui.h | 4 |
4 files changed, 7 insertions, 8 deletions
@@ -2,7 +2,7 @@ # tree builds on z/OS with make and on Linux for the portable tests, so the # flags are repeated here for the editor. CompileFlags: - Add: [-Itui, -std=c23, -D_XOPEN_SOURCE=500, -D_POSIX_C_SOURCE=200112L, + Add: [-Itui, -D_XOPEN_SOURCE=500, -D_POSIX_C_SOURCE=200112L, -Wall, -Wextra, -Wshadow, -Wpedantic] Diagnostics: UnusedIncludes: Strict @@ -267,7 +267,6 @@ struct app { int collect_ms; bool paused; bool help; - bool quit; int tab; int sub; struct tui_table storage; @@ -578,8 +577,8 @@ static void usage(FILE *f) { " -h this text\n"); } -static bool update(void *model, const struct tui_msg *m) { - struct app *a = model; +static bool update(struct tui_app *app, const struct tui_msg *m) { + struct app *a = app->model; int rows, height; if (a->help) { @@ -599,7 +598,7 @@ static bool update(void *model, const struct tui_msg *m) { return false; if (m->key == 'q' || m->key == TUI_KEY_ESC || m->key == 0x03) { - a->quit = true; + app->quit = true; return false; } if (m->key == '?') { @@ -624,7 +624,7 @@ void tui_run(struct tui *t, struct tui_app *app) { m.type = TUI_MSG_KEY; m.key = k; } - if (app->update(app->model, &m)) { + if (app->update(app, &m)) { app->view(app->model, t); tui_flush(t); } @@ -65,7 +65,7 @@ enum { TUI_KEY_DEL, TUI_KEY_RESIZE, TUI_KEY_TAB, - TUI_KEY_BACKTAB + TUI_KEY_BACKTAB, }; #define TUI_MAX_W 500 @@ -121,7 +121,7 @@ struct tui_app { void *model; /** Handle a message. Returns true when the screen must be redrawn. * Set @c quit to leave the loop. */ - bool (*update)(void *model, const struct tui_msg *m); + bool (*update)(struct tui_app *app, const struct tui_msg *m); /** Draw the model into the buffer. */ void (*view)(void *model, struct tui *t); int tick_ms; /**< 0 = no tick messages */ |
