aboutsummaryrefslogtreecommitdiffstats
path: root/surfaces
diff options
context:
space:
mode:
authoreunhhu <[email protected]>2026-09-30 15:29:20 +0100
committereunhhu <[email protected]>2026-09-30 15:29:20 +0100
commit72ecae6b6eb1365e722bd6d45acae8a5ccb74b23 (patch)
tree3b49bc61da3cee795afdc335bbb149b7df86649e /surfaces
parent8fc6f35b30642f3a8ebbd7f5f47b70195c8ffea1 (diff)
downloadvega-72ecae6b6eb1365e722bd6d45acae8a5ccb74b23.tar.gz
vega-72ecae6b6eb1365e722bd6d45acae8a5ccb74b23.zip
Show a bool as true or false, and make the examples' flags bools
aup and Pure now have a bool (Pure 016): a view or column may be one. vega_text writes it as true or false, as a string's interpolation does, so every surface shows the same words: the CLI, the TUI's cells, speech and the web surface's JSON (a value's text) and page. An app that wants other words picks them with a conditional (if t.done { "done" } else { "" }). The flags of the examples are bools: todo's done and urgent, today's done, the stopwatch's running. vega.when takes the bool as it took the number. bools checks a bool field and a bool column on the CLI, the TUI, speech and the web surface: true and false, never 1 and 0.
Diffstat (limited to 'surfaces')
-rw-r--r--surfaces/screen.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/surfaces/screen.c b/surfaces/screen.c
index f079bd5..51181a5 100644
--- a/surfaces/screen.c
+++ b/surfaces/screen.c
@@ -163,10 +163,13 @@ bool vega_text(PureApp *app, uint32_t view, size_t row, char out[VEGA_TEXT], siz
++evaluations;
*length = 0;
out[0] = 0;
- if (m->view_type[view] == PURE_VIEW_NUM) {
+ if (m->view_type[view] == PURE_VIEW_NUM || m->view_type[view] == PURE_VIEW_BOOL) {
double value;
if (!(column ? pure_app_cell(app, view, row, &value) : pure_app_view(app, view, &value))) return false;
- *length = pure_format_number(value, out);
+ if (m->view_type[view] == PURE_VIEW_BOOL) { /* a bool is written true or false, as a string shows it */
+ *length = value ? 4 : 5;
+ memcpy(out, value ? "true" : "false", *length);
+ } else *length = pure_format_number(value, out);
out[*length] = 0;
return true;
}