Expand description
App state and the pure pivot-grid logic (terminal-free, unit-tested).
A measure is a tensor over N categories. We render the first two categories
as the row/column axes; any remaining categories are “pages” pinned to their
first item (v1: fixed, shown on a status line). Values come from the model’s
input cells (input measures) or from engine::evaluate (derived measures),
both keyed by CoordKey = Vec<(u32, u32)>.
Structs§
- App
- The whole application state.
- Grid
- One rendered pivot grid for a single measure.
- Grid
Geom - Geometry of the last-rendered grid, recorded by
ui::renderso mouse clicks (screen col/row) can be mapped back to a grid cell. - PageDim
- An extra dimension not on the row/column axes, pinned to one item (a
“page”).
item_index/item_countlet the UI page through the dimension’s items with[/].
Enums§
- Command
Kind - Which CSV command is active in the command-prompt (
self.command). Mirrors the cell-edit buffer (self.edit) but for a full command line instead of a single value, and covers the two storage_csv entry points.
Constants§
- NO_CELL 🔒
- Status shown when the cursor is not on a real cell (empty/filtered axis).
Functions§
- build_
grid - Build the pivot grid for
measure. Uses the measure’s first two categories as the row/column axes and pins the rest to their first item. - build_
grid_ paged - Like
build_gridbut pins each extra (page) dimension to the item at the given index (clamped).page_idx[i]selects the item for the i-th extra dimension (categories beyond the first two); a missing/short entry defaults to 0. Enables paging through a 3+ dimensional measure. - build_
grid_ pivoted - The most general grid builder.
axis_order, whenSome, is a permutation of the measure’s categories that sets which category is on rows (first), columns (second), and pages (rest) — this is how the UI pivots without touching formulas.Noneuses the measure’s natural category order.filtersrestricts which items of a category are shown (presentation only; unlisted categories show all items). - cell_
key 🔒 - The sorted
CoordKeyfor the cell at[row][col]given the axes/pages. Shared by grid fill and cursor->coordinate mapping so they can’t drift. - items_
of 🔒 - Item names for a category, in the category’s declared item order, keeping
only items that pass
filters(a category absent fromfiltersis unfiltered). Presentation-only: it hides items, it never touches data. - measure_
order - Measures sorted for stable cycling: derived first, then by id.
- parse_
export_ line - Parse an
export-csv>prompt line into(target-path, measure-id, delimiter). Mirrors the CLI’sexport-csv <db> <target.csv> <measure-id> [--tsv], minus<db>. - parse_
formula_ text - Parse formula text as the symbolic DSL (
Price * Quantity), else as controlled English (Price times Quantity, what the status line shows). If both fail, the DSL’s error: it carries the position. - parse_
import_ line - Parse an
import-csv>prompt line into an [ImportSpec]. Mirrors the CLI’simport-csv <db> <file.csv> <measure-id> <measure-name> <value-col> <dim-col:cat-id:cat-name> [...] [--tsv] [--no-header]syntax, minus the leading<db>(the TUI’s already-open model plays that role). Whitespace- separated, like the CLI’s own argv; no quoting support (a filename with a space isn’t representable, matching the CLI’s own simplicity). - parse_
typed - Parse an edit buffer as a
vt-typed value (mirrors the CLI’sset). - values_
for 🔒 - The value map for a measure:
CoordKey -> CellValue.
Type Aliases§
- Snapshot
- Live derived-measure values, keyed by measure then coordinate. Kept in
Appand refreshed incrementally by theEngineon each committed edit; used to render derived measures instead of a fresh fullevaluate().