4 tea "charm.land/bubbletea/v2"
5 "github.com/charmbracelet/crush/internal/tui/components/core/layout"
6 "github.com/charmbracelet/crush/internal/tui/util"
9type Group[T Item] struct {
13type GroupedList[T Item] interface {
18 SetGroups([]Group[T]) tea.Cmd
23 SelectItemAbove() tea.Cmd
24 SelectItemBelow() tea.Cmd
25 SetSelected(string) tea.Cmd
28type groupedList[T Item] struct {
33func NewGroupedList[T Item](groups []Group[T], opts ...ListOption) GroupedList[T] {
35 confOptions: &confOptions{
36 direction: DirectionForward,
37 keyMap: DefaultKeyMap(),
41 indexMap: make(map[string]int),
42 renderedItems: make(map[string]renderedItem),
44 for _, opt := range opts {
48 return &groupedList[T]{
53func (g *groupedList[T]) Init() tea.Cmd {
58func (l *groupedList[T]) Update(msg tea.Msg) (util.Model, tea.Cmd) {
59 u, cmd := l.list.Update(msg)
60 l.list = u.(*list[Item])
64func (g *groupedList[T]) SelectedItem() *T {
65 item := g.list.SelectedItem()
70 c, ok := any(dRef).(T)
77func (g *groupedList[T]) convertItems() {
79 for _, g := range g.groups {
80 items = append(items, g.Section)
81 for _, g := range g.Items {
82 items = append(items, g)
88func (g *groupedList[T]) SetGroups(groups []Group[T]) tea.Cmd {
91 return g.SetItems(g.items)
94func (g *groupedList[T]) Groups() []Group[T] {
98func (g *groupedList[T]) Items() []Item {
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list