diff options
| author | eunhhu <[email protected]> | 2026-09-26 11:28:13 +0100 |
|---|---|---|
| committer | eunhhu <[email protected]> | 2026-09-26 11:28:13 +0100 |
| commit | ee0791397be3dc6d5b56611b505a312f1d8350a0 (patch) | |
| tree | 6fd4400c27731d053b096c527eda683cc93eb0e2 /prototypes/connections/module.h | |
| parent | cd3fcb9873e23c2d07bd4e9d02d2111c96959440 (diff) | |
| download | pure-ee0791397be3dc6d5b56611b505a312f1d8350a0.tar.gz pure-ee0791397be3dc6d5b56611b505a312f1d8350a0.zip | |
Filter a table's rows
A table view can now carry a filter: its list goes in the byte after the
view's type (list + 1) and its code range is a block run as a column of
the list, leaving one number; the table has a row for each item the block
keeps, in the list's order. Columns read the item (ROW is the item's
position, not the row's). The filter runs once per item after a change of
the app's states, counted by a new number that never goes back (events,
points, a failed save's undo, a module replacement), and its rows serve
every cell until the next change.
pure_app_row_item and pure_app_item_row turn a table's rows into items
and back, so a host shows a focus (an index names an item) on the row it
is in and points at the item a clicked row shows. pure_app_rows now takes
a mutable app.
The checks cover rows, cells, the mapping both ways as items leave and
come back, six refusals, and 20,000 damaged filter modules.
Diffstat (limited to 'prototypes/connections/module.h')
| -rw-r--r-- | prototypes/connections/module.h | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/prototypes/connections/module.h b/prototypes/connections/module.h index 6938350..b57e11f 100644 --- a/prototypes/connections/module.h +++ b/prototypes/connections/module.h @@ -54,8 +54,9 @@ typedef enum { /* A cursor that stays before text inserted at it (a mark); other cursors go * after it (a caret). */ enum { PURE_CURSOR_STAYS = 1 }; -/* A table view has one row per item of a list; its columns are number or - * text views evaluated for one row at a time. */ +/* A table view has one row per item of a list, or per item its filter + * keeps; its columns are number or text views evaluated for one row at a + * time. */ typedef enum { PURE_VIEW_NUM = 0, PURE_VIEW_TEXT = 1, PURE_VIEW_TABLE = 2 } PureViewType; typedef enum { PURE_UNIT_CHAR = 0, PURE_UNIT_LINE = 1 } PureUnit; typedef enum { PURE_EDGE_DOWN, PURE_EDGE_UP } PureEdge; @@ -181,6 +182,9 @@ typedef struct { PureFault fault; uint32_t fault_pc; uint64_t ticks, events; + uint64_t changes; /* counts every change of states, never back: what a filter's rows are fresh for */ + struct PureRows { uint32_t table; uint64_t changes; size_t *items, count, capacity; } *rows; /* a filtered table's items */ + unsigned row_tables; /* Current message or text event, kept until pure_app_finish. */ void *document; PureSpan payload; @@ -220,9 +224,13 @@ void pure_app_finish(PureApp *); bool pure_app_view(PureApp *, uint32_t view, double *out); /* A text view, lent in order until the next view evaluation. */ PureResult pure_app_view_text(PureApp *, uint32_t view, bool (*visit)(void *, PureSpan), void *context); -/* The rows of a table view (its list's items), or 0 for another view. A - * host evaluates only the cells it shows. */ -size_t pure_app_rows(const PureApp *, uint32_t table); +/* The rows of a table view (its list's items, or those its filter keeps), + * or 0 for another view. A host evaluates only the cells it shows. */ +size_t pure_app_rows(PureApp *, uint32_t table); +/* The item a row of a table shows, and the row that shows an item (false: + * its filter leaves the item out). Without a filter both are the identity. */ +bool pure_app_row_item(PureApp *, uint32_t table, size_t row, size_t *item); +bool pure_app_item_row(PureApp *, uint32_t table, size_t item, size_t *row); bool pure_app_cell(PureApp *, uint32_t column, size_t row, double *out); PureResult pure_app_cell_text(PureApp *, uint32_t column, size_t row, bool (*visit)(void *, PureSpan), void *context); /* Switch to another verified module. States keep their value by name (text |
