Files
mail/attachments.go

46 lines
829 B
Go
Raw Permalink Normal View History

2023-06-13 23:31:19 -04:00
package main
import (
"io"
"path/filepath"
"charm.land/bubbles/v2/list"
tea "charm.land/bubbletea/v2"
2023-06-13 23:31:19 -04:00
)
type attachment string
func (a attachment) FilterValue() string {
return string(a)
}
type attachmentDelegate struct {
focused bool
}
func (d attachmentDelegate) Height() int {
return 1
}
func (d attachmentDelegate) Spacing() int {
return 0
}
func (d attachmentDelegate) Render(w io.Writer, m list.Model, index int, item list.Item) {
path := filepath.Base(item.(attachment).FilterValue())
style := textStyle
if m.Index() == index && d.focused {
style = activeTextStyle
}
if m.Index() == index {
_, _ = w.Write([]byte(style.Render("• " + path)))
} else {
_, _ = w.Write([]byte(style.Render(" " + path)))
}
}
2023-07-31 10:32:02 -04:00
func (d attachmentDelegate) Update(_ tea.Msg, _ *list.Model) tea.Cmd {
2023-06-13 23:31:19 -04:00
return nil
}