aboutsummaryrefslogtreecommitdiffstats
path: root/src/vega.h
diff options
context:
space:
mode:
authoreunhhu <[email protected]>2026-09-26 11:54:31 +0100
committereunhhu <[email protected]>2026-09-26 11:54:31 +0100
commit8e2b3ffadcf83dba74d58dbf9ee2c57cef5f1ad5 (patch)
treec99c2c0066af352e9f7487763cf016740467f917 /src/vega.h
parent932df09ea211a83a24210d821dc3d0093ed73561 (diff)
downloadvega-8e2b3ffadcf83dba74d58dbf9ee2c57cef5f1ad5.tar.gz
vega-8e2b3ffadcf83dba74d58dbf9ee2c57cef5f1ad5.zip
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.
Diffstat (limited to 'src/vega.h')
-rw-r--r--src/vega.h6
1 files changed, 4 insertions, 2 deletions
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