From 8e2b3ffadcf83dba74d58dbf9ee2c57cef5f1ad5 Mon Sep 17 00:00:00 2001 From: eunhhu Date: Sat, 26 Sep 2026 11:54:31 +0100 Subject: Swap a running app's module: --watch and the swap command vega tui|web MODULE --watch replaces the running app's module when its file is written again (aup watch writes it); states keep their values by name through pure_app_replace and every web page hears of it. The file is compared by the digest of its bytes, at most five times a second, so a module of the same size written within the same second is not missed; a module that does not load leaves the app as it was and is not tried again. Modules alternate between two slots so a failed load never touches the running one. Scripts get swap MODULE; whether a module runs frames is now a property of the screen. --- src/vega.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/vega.h') diff --git a/src/vega.h b/src/vega.h index 59a663e..47e7e91 100644 --- a/src/vega.h +++ b/src/vega.h @@ -30,6 +30,7 @@ typedef struct { const PureModule *module; int title; /* text view, or -1 */ int prompt; /* the first text input, or -1 */ + bool ticks; /* it handles frames: a surface runs them, about 60 a second */ VegaPart parts[VEGA_PARTS]; unsigned count; } VegaScreen; @@ -82,8 +83,9 @@ void vega_print(FILE *, PureApp *, const VegaScreen *, bool color); /* NUI: the screen as sentences (all), or only the focused item of the first list. */ void vega_say(FILE *, PureApp *, const VegaScreen *, bool all); /* GUI: the screen as a web page on listen:port (0: any free port, printed as - * {"port":N}); runs until SIGINT or SIGTERM. */ -int vega_web(PureApp *, const VegaScreen *, const char *listen, unsigned port); + * {"port":N}); runs until SIGINT or SIGTERM. reload, when given, is asked + * a few times a second whether the module was replaced (the screen with it). */ +int vega_web(PureApp *, const VegaScreen *, const char *listen, unsigned port, bool (*reload)(void)); /* TUI: a grid of cells, redrawn from the app on every change. first keeps each * list's scroll between frames; the focused row stays visible. shown is what -- cgit v1.2.3