wip: refactoring tui

This commit is contained in:
adamdottv 2025-06-12 16:00:20 -05:00
commit 653965ef59
No known key found for this signature in database
GPG key ID: 9CB48779AF150E75
14 changed files with 491 additions and 1391 deletions

View file

@ -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()