visibleCount returns the number of cards shown at once: all of them when they fit (or before the first WindowSizeMsg), otherwise as many as fit the terminal height, at least one. The panel is centred within the terminal, so the bound is the terminal height minus the panel's non-card rows; fit can ex
()
| 267 | // so the bound is the terminal height minus the panel's non-card rows; fit |
| 268 | // can exceed the number of cards on tall terminals and is clamped. |
| 269 | func (m *agentPickerModel) visibleCount() int { |
| 270 | n := len(m.choices) |
| 271 | if m.height <= 0 { |
| 272 | return n |
| 273 | } |
| 274 | stride := agentPickerCardHeight + agentPickerCardGap |
| 275 | fit := (m.height - agentPickerPanelOverhead + agentPickerCardGap) / stride |
| 276 | return min(n, max(fit, 1)) |
| 277 | } |
| 278 | |
| 279 | // clampOffset keeps the visible window within bounds and the cursor inside it. |
| 280 | func (m *agentPickerModel) clampOffset() { |
no outgoing calls