Expand description
Per-row horizontal projection — the one owner of byte-column ↔
display-cell math on rows with collapsed inline folds, and of the collapsed
block header’s head … tail one-line layout.
Every consumer that needs to place something horizontally — render, caret placement, hit testing, selection, and movement — consults the functions here rather than recomputing the inline-collapse shift, its inverse, the chip-center formula, the caret/glyph boundary predicates, or the header width that feeds a collapsed block’s inline tail. Because each of those facts has exactly one definition, a change to the chip layout or a boundary rule is a one-site edit and every site stays in agreement by construction.
Everything here is in cells and columns — GUI-free. The widget’s only
remaining job is x = origin + cell × advance (and its inverse).
Structs§
- Chip
- One collapsed inline fold’s
…chip on a row, in display cells, as named fields the widget destructures to render and hit-test the chip. - Display
Position - Where a buffer offset renders: its display row plus its horizontal
CaretCell. THE owner of “where does offset O show on screen” — a caret, selection endpoint, squiggle bound, popup anchor, and autoscroll target all read the same value (seeFoldMap::display_position). - Header
Layout - A collapsed block fold’s one-line display layout: the (inline-fold-
aware) header text, the
…placeholder gap, then the fold’s real closing tail —fn main() { … }. The single source for the placeholder render, caret placement on the tail, selection washes, hit-testing, the hover-chip rect, and the preview anchor, so they agree to the pixel by construction. - RowLayout
- A visible buffer row’s horizontal projection: byte column ↔ display cell,
with tab expansion and the horizontal collapse of every root inline fold
on the row. Built per use by
FoldMap::row_layout; holds only the row’s text (aCow— borrowed straight off the backing when the row is stored contiguously, owned only when it spans a chunk boundary) and copies of the row’s folds, so it carries no derived state that could drift out of sync with the document. LikeFoldMap, it is cheap to rebuild and never stored. - Tail
Glyph - One visible glyph of a collapsed block’s inline closing tail, resolved to the display cell it occupies on the header row.
Enums§
- Caret
Cell - Where a caret at some byte column renders horizontally: a whole display
cell, or — for a column hidden inside a collapsed inline fold — the center
of that fold’s
…chip. The chip center is the only fractional cell in the system; fencing it in this enum keepsf32out of the inverse maps. - Header
Hit - Which region of a collapsed block header’s display line a cell falls in.
Constants§
- FOLD_
PLACEHOLDER_ CELLS - Display cells between a collapsed block header’s end and its inline closing
tail — the
…placeholder gap. - INLINE_
CHIP_ CELLS - Display cells a collapsed inline fold’s
…chip occupies. The chip starts one cell past the opening bracket; the interior collapses to this.
Functions§
- gap_
hides_ caret - Whether caret offset
offis strictly inside the collapsed gap of the pair(open, close). THE caret-boundary rule:open+1andcloseare landable; strictly between them hides. (Its off-by-one sibling isgap_hides_glyph— a glyph atopen+1hides even though the caret slot there is landable. The two variants exist as exactly these two functions.) - gap_
hides_ glyph - Whether the glyph at offset
offis hidden by the collapsed pair(open, close): everything strictly between the brackets. - gap_
left_ edge - The caret slot just after a pair’s opening bracket — the LEFT landable edge
of a collapsed inline gap. The one place
open + 1is written. - pair_
has_ interior - Whether a bracket pair
(open, close)has a non-empty interior — the one foldability rule: there must be something between the brackets to hide. Shared by the document’s foldable-pair enumeration and the fold map’s inline/block resolution. - tail_
start_ col - Byte column where a line’s visible content starts (its leading whitespace
length) — where a collapsed block’s closing tail begins on its last row.
The one
trim_startrule, shared by movement and the widget. - virtual_
cell - Round a fractional display cell to the nearest cell boundary, floored at 0
— the quantization for a column (box) selection’s virtual corner cells,
which may lie past any line’s content and so can’t resolve through
RowLayout::hityet. The same round-half-up rulehitapplies over real content, so a box edge and a click at the same pixel agree on the boundary.