From 653965ef5908a240f6038609e17bc8fa27640203 Mon Sep 17 00:00:00 2001 From: adamdottv <2363879+adamdottv@users.noreply.github.com> Date: Thu, 12 Jun 2025 16:00:20 -0500 Subject: wip: refactoring tui --- packages/tui/internal/components/util/simple-list.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'packages/tui/internal/components/util') diff --git a/packages/tui/internal/components/util/simple-list.go b/packages/tui/internal/components/util/simple-list.go index 341495613..fcffe5b96 100644 --- a/packages/tui/internal/components/util/simple-list.go +++ b/packages/tui/internal/components/util/simple-list.go @@ -20,6 +20,7 @@ type SimpleList[T SimpleListItem] interface { GetSelectedItem() (item T, idx int) SetItems(items []T) GetItems() []T + SetSelectedIndex(idx int) } type simpleListComponent[T SimpleListItem] struct { @@ -109,6 +110,12 @@ func (c *simpleListComponent[T]) SetMaxWidth(width int) { c.maxWidth = width } +func (c *simpleListComponent[T]) SetSelectedIndex(idx int) { + if idx >= 0 && idx < len(c.items) { + c.selectedIdx = idx + } +} + func (c *simpleListComponent[T]) View() string { t := theme.CurrentTheme() baseStyle := styles.BaseStyle() -- cgit v1.2.3