Skip to content
This repository was archived by the owner on Oct 13, 2021. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion list.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type List struct {
items []string
selected int
pos int
style string

onItemActivated func(*List)
onSelectionChanged func(*List)
Expand All @@ -20,13 +21,14 @@ type List struct {
func NewList() *List {
return &List{
selected: -1,
style: "list.item",
}
}

// Draw draws the list.
func (l *List) Draw(p *Painter) {
for i, item := range l.items {
style := "list.item"
style := l.style
if i == l.selected-l.pos {
style += ".selected"
}
Expand All @@ -37,6 +39,10 @@ func (l *List) Draw(p *Painter) {
}
}

func (l *List) SetStyle(style string) {
l.style = style
}

// SizeHint returns the recommended size for the list.
func (l *List) SizeHint() image.Point {
var width int
Expand Down