diff options
| author | adamdottv <[email protected]> | 2025-06-12 06:06:53 -0500 |
|---|---|---|
| committer | adamdottv <[email protected]> | 2025-06-12 16:00:24 -0500 |
| commit | ae339015fc7c96a98c2e4c0a359d5500c7801c15 (patch) | |
| tree | bc2439001ed802ccf565070c8f9ccd5e70ea10b5 /packages/tui/internal/components/util | |
| parent | cce2e4ad754479917fc8f6f24c1421cf19c04573 (diff) | |
| download | opencode-ae339015fc7c96a98c2e4c0a359d5500c7801c15.tar.gz opencode-ae339015fc7c96a98c2e4c0a359d5500c7801c15.zip | |
wip: refactoring tui
Diffstat (limited to 'packages/tui/internal/components/util')
| -rw-r--r-- | packages/tui/internal/components/util/simple-list.go | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/packages/tui/internal/components/util/simple-list.go b/packages/tui/internal/components/util/simple-list.go index d6e27db14..341495613 100644 --- a/packages/tui/internal/components/util/simple-list.go +++ b/packages/tui/internal/components/util/simple-list.go @@ -22,7 +22,7 @@ type SimpleList[T SimpleListItem] interface { GetItems() []T } -type simpleListCmp[T SimpleListItem] struct { +type simpleListComponent[T SimpleListItem] struct { fallbackMsg string items []T selectedIdx int @@ -59,11 +59,11 @@ var simpleListKeys = simpleListKeyMap{ ), } -func (c *simpleListCmp[T]) Init() tea.Cmd { +func (c *simpleListComponent[T]) Init() tea.Cmd { return nil } -func (c *simpleListCmp[T]) Update(msg tea.Msg) (tea.Model, tea.Cmd) { +func (c *simpleListComponent[T]) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch msg := msg.(type) { case tea.KeyMsg: switch { @@ -83,11 +83,11 @@ func (c *simpleListCmp[T]) Update(msg tea.Msg) (tea.Model, tea.Cmd) { return c, nil } -func (c *simpleListCmp[T]) BindingKeys() []key.Binding { +func (c *simpleListComponent[T]) BindingKeys() []key.Binding { return layout.KeyMapToSlice(simpleListKeys) } -func (c *simpleListCmp[T]) GetSelectedItem() (T, int) { +func (c *simpleListComponent[T]) GetSelectedItem() (T, int) { if len(c.items) > 0 { return c.items[c.selectedIdx], c.selectedIdx } @@ -96,20 +96,20 @@ func (c *simpleListCmp[T]) GetSelectedItem() (T, int) { return zero, -1 } -func (c *simpleListCmp[T]) SetItems(items []T) { +func (c *simpleListComponent[T]) SetItems(items []T) { c.selectedIdx = 0 c.items = items } -func (c *simpleListCmp[T]) GetItems() []T { +func (c *simpleListComponent[T]) GetItems() []T { return c.items } -func (c *simpleListCmp[T]) SetMaxWidth(width int) { +func (c *simpleListComponent[T]) SetMaxWidth(width int) { c.maxWidth = width } -func (c *simpleListCmp[T]) View() string { +func (c *simpleListComponent[T]) View() string { t := theme.CurrentTheme() baseStyle := styles.BaseStyle() @@ -149,7 +149,7 @@ func (c *simpleListCmp[T]) View() string { } func NewSimpleList[T SimpleListItem](items []T, maxVisibleItems int, fallbackMsg string, useAlphaNumericKeys bool) SimpleList[T] { - return &simpleListCmp[T]{ + return &simpleListComponent[T]{ fallbackMsg: fallbackMsg, items: items, maxVisibleItems: maxVisibleItems, |
