pub fn compute_updates_modal_scroll_for_selection(
entry_line_starts: &[u16],
total_lines: u16,
content_rect: Option<(u16, u16, u16, u16)>,
selected: usize,
total_items: usize,
_current_scroll: u16,
) -> u16Expand description
What: Compute updates-modal scroll offset that vertically centers the selected entry.
Inputs:
entry_line_starts: Mapping from entry index to first rendered line in wrapped output.total_lines: Total rendered line count across wrapped updates rows.content_rect: Optional updates content rectangle tuple(x, y, width, height).selected: Selected entry index.total_items: Number of entries in the updates list._current_scroll: Reserved for callers; scroll is derived from selection and geometry only.
Output:
- Returns the clamped scroll offset as
u16.
Details:
- Derives
visible_linesfromcontent_rectheight and falls back to1when absent. - Uses rendered-line mapping to support wrapped rows consistently.
- Centers the first rendered line of the selected entry (
⌊visible_lines / 2⌋rows above it) when possible; clamps to[0, max_scroll]near list ends so the list never overscrolls.