aboutsummaryrefslogtreecommitdiffstats
path: root/src/vega.h
diff options
context:
space:
mode:
authoreunhhu <[email protected]>2026-09-26 11:08:29 +0100
committereunhhu <[email protected]>2026-09-26 11:08:29 +0100
commit0054ea8452a811f2745d72ce4b7764ea158f1d5f (patch)
tree62fef2445feedd1a8f679ee7255944b80dc0dc88 /src/vega.h
parentf6be15d01ac184f070e1bb34af12689f68eb9140 (diff)
downloadvega-0054ea8452a811f2745d72ce4b7764ea158f1d5f.tar.gz
vega-0054ea8452a811f2745d72ce4b7764ea158f1d5f.zip
Add a web surface: the same spec as a page
vega web MODULE serves the screen to a browser (127.0.0.1 unless given --listen): one dependency-free page draws the title, fields, lists as listboxes and tables, with tones as colors and the focus highlighted. It asks for the screen as JSON with the rows it can show per list or table, so only those cells are evaluated, scrolled like the TUI around the focus. Keys go as KeyboardEvent.code, which is Pure's key naming already; typed text commits with Enter; a click or the wheel moves the focus through pure_app_point; an event stream tells every open page of each change. Scrolling, key presses and text commits are now shared helpers. The checks drive it against the model (1,200 random steps: title, field, rows, focus, the window of items with badges and tones), check a table's columns and cells, post at random to every example, and in headless Chromium over the DevTools protocol press keys, click a row and type Korean text into the page itself.
Diffstat (limited to 'src/vega.h')
-rw-r--r--src/vega.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/vega.h b/src/vega.h
index 80e3f7d..98ed410 100644
--- a/src/vega.h
+++ b/src/vega.h
@@ -51,6 +51,15 @@ size_t vega_focus(PureApp *, const VegaPart *);
/* Focus a row, as a user pointing at it (a click); false when the part's
* focus is not a plain index position or the row is not there. */
bool vega_point(PureApp *, const VegaPart *, size_t row);
+/* The first row to show of `rows` when `visible` fit: the least scrolling
+ * from first that keeps the focused row in view. */
+size_t vega_scroll(size_t first, size_t focus, size_t visible, size_t rows);
+/* The key input answering a key name (Pure's names, as KeyboardEvent.code
+ * spells them), or -1; press sends its press and release. */
+int vega_key_input(const PureModule *, const char *key);
+bool vega_press(PureApp *, const char *key);
+/* Commit text to the screen's text input. */
+bool vega_commit(PureApp *, const VegaScreen *, const char *text, size_t length);
VegaTone vega_tone(PureApp *, const VegaPart *, size_t row);
/* Values evaluated so far, for checking that surfaces stay lazy. */
unsigned long vega_evaluations(void);
@@ -68,6 +77,9 @@ unsigned vega_text_width(const char *text, size_t length);
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);
/* 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