ScrollInput
lib/scroll/scroll_input.march — Controls whose value a cell reads.
import ScrollInput
let model = ScrollInput.select("Model", ["Weekly naive", "Chronos-2 Small"], "Chronos-2 Small")
let last_lead = ScrollInput.slider("Last lead (hours)", 1, 24, 24)Each call shows a control in the cell's output and returns the control's current value (the default until someone changes it). Changing the control re-runs this cell and the cells that use what it defines, and nothing else, so data loaded earlier is not loaded again.
The notebook keeps the values in a JSON file, {"<label>": <value>, ...}, named by SCROLL_INPUTS in the REPL's environment; outside Scroll every call returns its default. A control's label is its key, so two controls in one notebook need different labels.
Each call prints one __SCROLL_BLOB__ block of type application/vnd.scroll.input+json: {"label":"Model","kind":"select","options":["a","b"],"value":"b"} (slider adds min/max/step, number adds step).
Functions
A checkbox. Returns whether it is ticked.
The sentinel block that displays a control (for tests and composition).
The MIME type the notebook renders as a control.
A number field. Returns the entered number.
A drop-down of options. Returns the chosen option, or default when nothing valid is stored.
A slider over the integers min..max (inclusive). Returns the chosen value.
The stored value for label, if the notebook has one.
A one-line text field. Returns the entered text.