Skip to main content

Module row_layout

Module row_layout 

Source
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.
DisplayPosition
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 (see FoldMap::display_position).
HeaderLayout
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 (a Cow — 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. Like FoldMap, it is cheap to rebuild and never stored.
TailGlyph
One visible glyph of a collapsed block’s inline closing tail, resolved to the display cell it occupies on the header row.

Enums§

CaretCell
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 keeps f32 out of the inverse maps.
HeaderHit
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 off is strictly inside the collapsed gap of the pair (open, close). THE caret-boundary rule: open+1 and close are landable; strictly between them hides. (Its off-by-one sibling is gap_hides_glyph — a glyph at open+1 hides 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 off is 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 + 1 is 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_start rule, 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::hit yet. The same round-half-up rule hit applies over real content, so a box edge and a click at the same pixel agree on the boundary.