Expand description
Optional vertical scrollbar helpers, gated behind the scrollbar feature.
Two pieces, both pure and panel-agnostic (they work for a
MultiSelectPanel, a
SelectablePanel, or any home-grown scrollable
content):
scroll_for_track_rowmaps a clicked/dragged terminal row within a scrollbar track to a scroll offset, so a click or drag anywhere in the track jumps/scrolls proportionally — the way a native scrollbar behaves.render_scrollbardraws a ratatuiScrollbarinto a track column, sizing and positioning the thumb fromtotal/capacity/startand no-op-ing when everything already fits.
Panels that own their scroll offset (MultiSelectPanel) expose thin
convenience wrappers ([MultiSelectPanel::scroll_to_track_row] and
[MultiSelectPanel::render_scrollbar]) that plumb their own geometry into
these functions; callers that keep scroll externally can use the free
functions directly.
Structs§
- Scrollbar
Style - Visual styling for
render_scrollbar. Start fromScrollbarStyle::default(a right-hand vertical bar with a│track and a solid█thumb, both unstyled) and override what you want — most callers only settrack_style/thumb_styleto their theme’s dim/accent colours.
Functions§
- render_
scrollbar - Render a vertical scrollbar into
area, sizing the thumb fromtotalcontent rows, the visiblecapacity(rows that fit at once) and the currentstartscroll offset. A no-op when the area is empty or the content already fits (total <= capacity), so callers can call it unconditionally. - scroll_
for_ track_ row - Map a clicked/dragged terminal
rowwithin a vertical scrollbartrackto a scroll offset in0..=max_scroll, clamped to the track’s own bounds (so a click above the track reads as the top and below it as the bottom). Returns0when there’s nothing to scroll (an empty track ormax_scroll == 0).