diff options
| author | eunhhu <[email protected]> | 2026-09-26 10:54:12 +0100 |
|---|---|---|
| committer | eunhhu <[email protected]> | 2026-09-26 10:54:12 +0100 |
| commit | b230b70252f09cf3425a8b4b959b3dfd72075b31 (patch) | |
| tree | 6ddae95ead87fa1905e133dbabf0f2d6a595efde /prototypes/connections/module.c | |
| parent | d58e1d29cc3cbd5f1c9b271c0b7e25b9962fad4f (diff) | |
| download | pure-b230b70252f09cf3425a8b4b959b3dfd72075b31.tar.gz pure-b230b70252f09cf3425a8b4b959b3dfd72075b31.zip | |
Let a host point an index at an item
pure_app_point moves an index state to an item, as a user pointing at a
row would: an event with no handler, saved like a key event, joining the
burst when saving is deferred; past the last item it is not_found. A host
learns which index to move from the view that shows it:
pure_module_position gives the state behind a number view that is just
`at.position`. An interface can so turn a click on a list row into its
focus without any code in the app.
Diffstat (limited to 'prototypes/connections/module.c')
| -rw-r--r-- | prototypes/connections/module.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/prototypes/connections/module.c b/prototypes/connections/module.c index ebb746f..5e2b98f 100644 --- a/prototypes/connections/module.c +++ b/prototypes/connections/module.c @@ -522,6 +522,13 @@ int pure_module_view(const PureModule *m, const char *name) { return -1; } +int pure_module_position(const PureModule *m, uint32_t view) { + if (view >= m->views || m->view_type[view] != PURE_VIEW_NUM || m->view_table[view]) return -1; + const PureBlock *block = &m->view_code[view]; + const PureOp *code = &m->code[block->start]; + return block->length == 2 && code[0].op == PURE_OP_INDEX_LOAD && code[1].op == PURE_OP_INDEX_NUM ? (int)code[0].arg : -1; +} + int pure_module_column(const PureModule *m, uint32_t table, const char *name) { for (uint32_t i = 0; i < m->views; ++i) if (m->view_table[i] == table + 1 && !strcmp(m->view_names[i], name)) return (int)i; @@ -1121,6 +1128,19 @@ PureResult pure_app_input(PureApp *app, uint32_t input, PureEdge edge) { return dispatch(app, 1 + 2 * input + (edge == PURE_EDGE_UP), &ev); } +PureResult pure_app_point(PureApp *app, uint32_t state, size_t position) { + const PureModule *m = app->module; + pure_app_finish(app); + if (state >= m->states || m->state_type[state] != PURE_STATE_INDEX) return PURE_INVALID; + if (position >= pure_list_count(app->lists[m->state_ref[state]])) return PURE_NOT_FOUND; + open_burst(app); /* what a failed save returns to */ + app->fault = PURE_FAULT_NONE; + app->fault_pc = UINT32_MAX; + app->values[state] = (double)position; + ++app->events; + return app->deferred ? PURE_OK : pure_app_save(app); +} + PureResult pure_app_text(PureApp *app, uint32_t input, PureSpan text) { pure_app_finish(app); if (input >= app->module->inputs || app->module->input[input].kind != PURE_KIND_TEXT || |
