feat(tui): add windowed, keyboard-navigable SelectList component#1074
Merged
Conversation
Adds a reusable single-select list to the tui package: - RenderSelectListWindowed: renders at most maxVisible options at once, scrolling to keep the cursor in view, with a "Showing X–Y of N" footer so the height stays fixed regardless of option count. RenderSelectList keeps its existing render-all behaviour. - SelectList: a stateful component owning the cursor and windowing. It handles up/down (k/j), pgup/pgdown, home/g and end/G with clamping via HandleKey, exposes Cursor/Selected/View, and Shortcuts that surface the PgUp/PgDn hint only when the list is windowed. Lets callers drop in a fixed-height option picker without reimplementing cursor and paging logic.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a reusable single-select list component to
internal/tui, so fixed-height option pickers don't have to reimplement cursor and paging logic.What's included
RenderSelectListWindowed— renders at mostmaxVisibleoptions at once, scrolling to keep the cursor in view, with aShowing X–Y of Nfooter so the card height stays fixed regardless of option count.RenderSelectListkeeps its existing render-all behaviour (delegates withmaxVisible = 0).SelectList— a stateful component that owns the cursor and windowing:HandleKey(key) boolhandles↑/↓(k/j),pgup/pgdown,home/g,end/Gwith clamping; returnsfalsefor keys it doesn't own (enter, esc) so the caller acts on them.Cursor(),Selected() (SelectOption, bool),View().Shortcuts()surfaces thePgUp/PgDnhint only when the list is windowed.Notes
tuipackage only — no consumer changes. Theproject upgradewizard will adopt it in a separate PR.Selected, and the conditional paging shortcut.Testing
go build ./internal/tui/...go test ./internal/tui/...golangci-lint run ./internal/tui/...— 0 issues