Skip to main content

Module app

Module app 

Source
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.
GridGeom
Geometry of the last-rendered grid, recorded by ui::render so 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_count let the UI page through the dimension’s items with [ / ].

Enums§

CommandKind
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_grid but 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, when Some, 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. None uses the measure’s natural category order. filters restricts which items of a category are shown (presentation only; unlisted categories show all items).
cell_key 🔒
The sorted CoordKey for 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 from filters is 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’s export-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’s import-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’s set).
values_for 🔒
The value map for a measure: CoordKey -> CellValue.

Type Aliases§

Snapshot
Live derived-measure values, keyed by measure then coordinate. Kept in App and refreshed incrementally by the Engine on each committed edit; used to render derived measures instead of a fresh full evaluate().