summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSean Kurtz <seankurtz75@gmail.com>2026-11-25 21:47:13 -0600
committerSean Kurtz <seankurtz75@gmail.com>2026-11-25 21:47:13 -0600
commita31dca8186343f5ec7c46a8807c60453addc94e3 (patch)
tree1e43953607ca68596d2d24d3292e1a1bf0a968a8
parent5ac81f8a746bfd01cf20860ba3c3d57a970d0ac0 (diff)
downloadztop-a31dca8186343f5ec7c46a8807c60453addc94e3.tar.gz
tui: let update reach the app, so quit works
-rw-r--r--.clangd2
-rw-r--r--src/ztop.c7
-rw-r--r--tui/tui.c2
-rw-r--r--tui/tui.h4
4 files changed, 7 insertions, 8 deletions
diff --git a/.clangd b/.clangd
index b573ef3..42ecec2 100644
--- a/.clangd
+++ b/.clangd
@@ -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
diff --git a/src/ztop.c b/src/ztop.c
index 4c9e45a..1d32e6d 100644
--- a/src/ztop.c
+++ b/src/ztop.c
@@ -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 == '?') {
diff --git a/tui/tui.c b/tui/tui.c
index 62878d4..34bd7f0 100644
--- a/tui/tui.c
+++ b/tui/tui.c
@@ -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);
}
diff --git a/tui/tui.h b/tui/tui.h
index 6d3c491..9046620 100644
--- a/tui/tui.h
+++ b/tui/tui.h
@@ -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 */