Expand description
Scroll position, expressed as a row rather than a pixel.
The single most load-bearing design decision in the engine. A raw pixel scroll value is only meaningful relative to a particular set of row heights, and every interesting thing that happens to a chat buffer changes those heights: a resize re-wraps, a zoom rescales, an image finishes decoding and a 16-pixel placeholder becomes 240 pixels, a history batch prepends 50 rows above the viewport, a scrollback trim drops rows off the top.
Anchoring to (row, offset within it) makes all of those free.
Compare xtext, which hand-patches each case separately:
gtk_xtext_insert_indent_before (xtext.c:5720) bumps pagetop_line,
last_pixel_pos, old_value and the adjustment by the inserted
row’s subline count to approximate “don’t jump”; the trim path does
the mirror-image decrement; and a font change just accepts the jump.
It is also what makes estimated heights (crate::index) tolerable:
when an estimate is replaced by a real measurement the total height
changes, so the scrollbar thumb moves — but the anchored row does
not, so the text the user is reading stays put. Thumb drift is
survivable; content jumping is not.
Structs§
- Anchor
Resolver - Resolves anchors against a live index. Stateless — the buffer calls these as associated functions.
- Scroll
Anchor - The viewport’s position.
Enums§
- Gravity
- What the viewport is pinned to.