MCPcopy Index your code
hub / github.com/docker/docker-agent / visibleCount

Method visibleCount

cmd/root/agent_picker.go:269–277  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

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.
269func (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.
280func (m *agentPickerModel) clampOffset() {

Callers 6

clampOffsetMethod · 0.95
cardRowsMethod · 0.95
cardAtMethod · 0.95
headerTextMethod · 0.95
renderMethod · 0.95
TestAgentPickerWindowingFunction · 0.80

Calls

no outgoing calls

Tested by 1

TestAgentPickerWindowingFunction · 0.64