From b466603358f8fa5a74551a9819fdd54ad124ef0c Mon Sep 17 00:00:00 2001 From: eunhhu Date: Sat, 26 Sep 2026 17:58:26 +0100 Subject: Give live surfaces a clock and run timers; add a stopwatch The terminal and the web page set the time events see to the wall clock and tick an app's timers on time: each round ticks what is due, draws, then waits for input, a frame or the next tick, and a tick is news to every open page at once. Scripts have no clock: time MS sets the time the next events see and tick TIMER ticks, so an app that uses time replays exactly. A module swap reschedules the timers. examples/stopwatch.aup runs on every surface; the checks drive it by script, on a pseudo-terminal by the clock, and on the web page. --- src/vega.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/vega.h') diff --git a/src/vega.h b/src/vega.h index 47e7e91..f01667b 100644 --- a/src/vega.h +++ b/src/vega.h @@ -36,6 +36,16 @@ typedef struct { } VegaScreen; void vega_screen(VegaScreen *, const PureModule *); + +/* The wall-clock time events see on a live surface: milliseconds since 1970 + * (UTC). Scripts set their own (time MS). */ +double vega_now(void); +/* When each timer input ticks next. run ticks every one due at now (a tick + * sees now) and gives the milliseconds until the next, or -1 without timers; + * ticked says whether any did. Missed ticks are not made up. */ +typedef struct { double next[PURE_MODULE_INPUTS]; } VegaTimers; +void vega_timers_start(VegaTimers *, const PureModule *, double now); +long vega_timers_run(VegaTimers *, PureApp *, double now, bool *ticked); /* What a module seems to mean but does not meet: a list label that is not * text, a _focus view without its table, a column a list never shows, a * second text input. Each finding names the view or input it is about; -- cgit v1.2.3