-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
2,977 additions
and
34 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package listv | ||
|
||
import ( | ||
"io" | ||
|
||
"github.com/charmbracelet/bubbles/list" | ||
tea "github.com/charmbracelet/bubbletea" | ||
"github.com/charmbracelet/lipgloss" | ||
) | ||
|
||
type listItemDelegate struct { | ||
itemStyle lipgloss.Style | ||
selectedItemStyle lipgloss.Style | ||
selectedItemPrefix string | ||
} | ||
|
||
func (d *listItemDelegate) Height() int { return 1 } | ||
func (d *listItemDelegate) Spacing() int { return 0 } | ||
func (d *listItemDelegate) Update(msg tea.Msg, m *list.Model) tea.Cmd { return nil } | ||
func (d *listItemDelegate) Render(w io.Writer, m list.Model, index int, item list.Item) { | ||
i, ok := item.(ListItem) | ||
if !ok { | ||
return | ||
} | ||
|
||
if index == m.Index() { | ||
_, _ = io.WriteString(w, d.selectedItemStyle.MaxWidth(m.Width()).Render(d.selectedItemPrefix+i.Title())) | ||
return | ||
} | ||
_, _ = io.WriteString(w, d.itemStyle.MaxWidth(m.Width()).Render(i.Title())) | ||
} | ||
|
||
func NewSimpleListItemDelegate(itemStyle lipgloss.Style, selectedItemPrefix string, selectedItemStyle lipgloss.Style) list.ItemDelegate { | ||
return &listItemDelegate{ | ||
itemStyle: itemStyle, | ||
selectedItemStyle: selectedItemStyle, | ||
selectedItemPrefix: selectedItemPrefix, | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package listv | ||
|
||
type ListItem interface { | ||
Id() string | ||
Title() string | ||
FilterValue() string | ||
} | ||
|
||
var _ ListItem = &simpleListItem{} | ||
|
||
type simpleListItem struct { | ||
id string | ||
title string | ||
filterValue string | ||
} | ||
|
||
func (s *simpleListItem) Id() string { | ||
return s.id | ||
} | ||
|
||
func (s *simpleListItem) Title() string { | ||
return s.title | ||
} | ||
|
||
func (s *simpleListItem) FilterValue() string { | ||
return s.filterValue | ||
} | ||
|
||
func NewSimpleListItem(id, title, filterValue string) ListItem { | ||
return &simpleListItem{id: id, title: title, filterValue: filterValue} | ||
} |
Oops, something went wrong.