Components / Developer tools
Query builder
A filter built from conditions joined by all or any, in groups that nest.
Functions: cui_query_builder, cui_query_match

Usage
static cui_query_node nodes[32]; /* node 0, the outer group, is made for you */
static int count;
if (cui_query_builder(ui, "filter", fields, field_count, nodes, &count, 32)) {
for (int i = 0; i < issue_count; i++)
issues[i].shown = cui_query_match(fields, field_count, nodes, count, issue_values(i));
}
Conditions joined by all or any, in groups you can nest (three deep by default, max_depth). The nodes are a flat array in order, each with its depth, so they are easy to save. A rule picks a field, an operator that fits the field's type, and a value: a text field, a number, a choice from the field's list, or nothing for a yes or no field. cui_query_text writes the query as a sentence, and cui_query_match tests a record whose values you pass as text. On a phone each rule's value moves to its own line.
Keyboard
- Tab moves through the controls of each rule. Left and Right switch between All and Any, Up and Down change a focused select, Space opens it, and the remove buttons take Enter or Space.
Options of cui_query_builder
| Option | Type | Default | Description |
|---|---|---|---|
.width | cui_size | Width: CUI_FILL, CUI_FIT, CUI_PX(n) or CUI_PCT(n); unset uses the component's own. | |
.max_depth | int | 3 | how deep groups may nest, default 3 |
.read_only | bool | Shows the value but does not let it be edited. |
cui_query_field
| Field | Type | Description |
|---|---|---|
name | const char * | shown in the field select and in the text cui_query_text writes |
type | cui_query_type | One of CUI_QUERY_TEXT, CUI_QUERY_NUMBER, CUI_QUERY_CHOICE or CUI_QUERY_BOOL. |
choices | const char *const * | CUI_QUERY_CHOICE: the values to pick from |
choice_count | int | number of choices |
cui_query_type: CUI_QUERY_TEXT, CUI_QUERY_NUMBER, CUI_QUERY_CHOICE, CUI_QUERY_BOOL
cui_query_node
| Field | Type | Description |
|---|---|---|
depth | int | 0 for the outer group |
group | bool | a group of the nodes after it that are one level deeper; otherwise a rule |
any | bool | group: any rule (or) instead of all (and) |
field | int | rule: index into the fields |
op | int | rule: see cui_query_op_name |
value | char[64] | rule: the text, number or choice compared with |
Related
- Text field: A single-line field that edits text in a buffer you own, with a label, an icon, a hint and an error. The search field is a variant.
- Schedule picker: A cron schedule edited through plain choices instead of the expression, with the next runs listed.
- Pipeline: A CI or CD run: each stage is a column of its jobs with their status and duration, and connectors run between the stages.
- Keymap: A keyboard with the shortcuts on it.