blob: 59126569d68a5dbb138446009adf366fa1514907 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
package src
import (
"fmt"
"github.com/rivo/tview"
)
func (a *app) queuePage() tview.Primitive {
a.playQueueList = tview.NewList().
ShowSecondaryText(false).
SetHighlightFullLine(true)
a.setupKeybindings(a.playQueueList.Box)
a.updatePageQueue()
return a.playQueueList
}
func (a *app) updatePageQueue() {
sel := a.playQueueList.GetCurrentItem()
a.playQueueList.Clear()
for _, song := range a.playQueue.GetSongs() {
ownSong := *song
a.playQueueList.AddItem(fmt.Sprintf("* %s - %s", song.Title, song.Artist), "", 0, func() {
a.playQueue.SkipTo(&ownSong)
a.playQueueList.SetCurrentItem(0)
})
}
if sel < a.playQueueList.GetItemCount() {
a.playQueueList.SetCurrentItem(sel)
} else {
a.playQueueList.SetCurrentItem(a.playQueueList.GetItemCount() - 1)
}
}
|