Skip to main content

Crate improv_tui

Crate improv_tui 

Source
Expand description

improv-tui: a VisiCalc-style pivot grid over an Improv model.

Usage: improv-tui <model.db | postgres://…?model=NAME>

The binary is a thin shell: run owns the real terminal (raw mode, alt screen, panic hook) and feeds crossterm events into event_loop, which is generic over the ratatui backend and the event source so tests can drive it with a TestBackend and a scripted Vec<Event>.

ModulesΒ§

app πŸ”’
App state and the pure pivot-grid logic (terminal-free, unit-tested).
complete πŸ”’
Formula-edit assistance, terminal-free: Tab completion of the identifier before the caret, and the ghost text of the parameters still to type.
diagnose πŸ”’
Located formula errors, terminal-free: the span of text a [ParseError] is about, its message, and a hint for the common cases (a misspelled name, the wrong number of arguments, an unclosed ().
edit πŸ”’
The edit line for a cell value or a formula: its text and a caret.
fnhelp πŸ”’
Function help overlay state (? / F1): a search line over the built-in functions, the ranked results, and the selection in them. Pure state, terminal-free; ui draws it and main feeds it keys.
ui πŸ”’
Rendering: a status box (title, prompt/message, pages, filters, key help) sized to its content, over the pivot grid as a table.

FunctionsΒ§

event_loop πŸ”’
Draw, then handle one event, until the app quits or events runs dry.
filter_row_under_cursor πŸ”’
Toggle the visibility of the row item under the cursor within its (row) category. Repeated β€˜f’ on different rows narrows the row axis to a subset.
handle_event πŸ”’
Dispatch one terminal event by mode (edit / command prompt / normal).
help_key πŸ”’
Keys while the function help overlay is open: type to search, move the selection, Enter inserts NAME( into an edit in progress, Esc closes.
line_key πŸ”’
Line-editing keys for the command prompt (the cell edit has a caret: edit::LineEdit::key).
load πŸ”’
Open the model at path and build the app state.
main πŸ”’
normal_key πŸ”’
Key handling in normal (navigation) mode.
restore πŸ”’
Undo terminal setup. Safe to call multiple times.
revert πŸ”’
Reload the model from path, dropping this session’s unsaved edits. The way out of a save conflict: the quit autosave refuses to clobber another writer, so revert, pick up their changes, and redo yours. On failure the session is untouched.
run πŸ”’
Enter the alt screen, run the loop, and always restore the terminal β€” even on error or panic β€” then autosave.
save πŸ”’
Autosave the (possibly edited) model back to path on clean exit; edits are held in memory during the session.
save_current_view πŸ”’
Save the current layout as a generated β€œview N” name and persist to path. (Inline text entry is intentionally omitted; the view can be renamed via a future dialog. Documented simplification.)