The shared field chrome parts — everything a formula-backed field paints, extracted so each
chrome (the plain-DOM FormulaInput here, the MUI FormulaField in studio-mui) is only its
kit-specific field + adornments around the same headless hook + these parts. The presentation
pieces themselves (paren matching, the eval-run band, the "input expected" marker) live in the
shared formulaPresentation module — the SAME code the cell editor (SheetCellInput) renders, so
a formula reads identically in a field and in the grid by construction.
Fields are ALWAYS colored (the Excel-online model) — with one exception: while ANOTHER input is
the reference-mode bus producer (another field picking, a cell-formula edit), this field stands
down to plain text. Every field shares one picker palette and only the producer's ranges are on
the grid, so the active editor must own the highlight language alone — a bystander painted in the
same colors reads as linked to the pick when it isn't.
The overlay itself is the formula editor's trick: the input's own glyphs go transparent and an
identically-measured overlay paints each span — TOKENS with the editor's syntax palette in
'formula' grammar (references by picker index via tokenColor, parens by nesting depth, orphan
closes red, the caret's/hovered pair emphasized), comma-SEGMENTS by picker index in 'reference'
grammar (segment i = picker range i = its on-grid rectangle's color). The overlay copies the
input's measured box + computed text styles, so it tracks any host styling (a MUI TextField
variant, a --sxl-*-themed plain input) without duplicating it. Hovering an evaluable span shows
its value in the shared eval bubble (portaled to body — a transformed/overflow-clipped dialog
ancestor can't trap or offset it) and bands the run being evaluated. While ENGAGED, a 'formula'
field whose last character expects an operand shows the trailing "input expected" marker
(Sheets-style).
The shared field chrome parts — everything a formula-backed field paints, extracted so each chrome (the plain-DOM
FormulaInputhere, the MUIFormulaFieldinstudio-mui) is only its kit-specific field + adornments around the same headless hook + these parts. The presentation pieces themselves (paren matching, the eval-run band, the "input expected" marker) live in the sharedformulaPresentationmodule — the SAME code the cell editor (SheetCellInput) renders, so a formula reads identically in a field and in the grid by construction.Fields are ALWAYS colored (the Excel-online model) — with one exception: while ANOTHER input is the reference-mode bus producer (another field picking, a cell-formula edit), this field stands down to plain text. Every field shares one picker palette and only the producer's ranges are on the grid, so the active editor must own the highlight language alone — a bystander painted in the same colors reads as linked to the pick when it isn't.
The overlay itself is the formula editor's trick: the input's own glyphs go transparent and an identically-measured overlay paints each span — TOKENS with the editor's syntax palette in
'formula'grammar (references by picker index viatokenColor, parens by nesting depth, orphan closes red, the caret's/hovered pair emphasized), comma-SEGMENTS by picker index in'reference'grammar (segment i = picker range i = its on-grid rectangle's color). The overlay copies the input's measured box + computed text styles, so it tracks any host styling (a MUI TextField variant, a--sxl-*-themed plain input) without duplicating it. Hovering an evaluable span shows its value in the shared eval bubble (portaled to body — a transformed/overflow-clipped dialog ancestor can't trap or offset it) and bands the run being evaluated. While ENGAGED, a'formula'field whose last character expects an operand shows the trailing "input expected" marker (Sheets-style).