mirror of
https://github.com/aditya-K2/gspt.git
synced 2026-01-09 22:08:04 -05:00
Embed tview.Table in some structs
This commit is contained in:
40
ui/app.go
40
ui/app.go
@@ -115,36 +115,36 @@ func NewApplication() *tview.Application {
|
|||||||
root = NewRoot()
|
root = NewRoot()
|
||||||
coverArt = newCoverArt()
|
coverArt = newCoverArt()
|
||||||
Main = NewInteractiveView()
|
Main = NewInteractiveView()
|
||||||
Main.Table.SetBorder(true)
|
Main.SetBorder(true)
|
||||||
|
|
||||||
progressBar := NewProgressBar().SetProgressFunc(progressFunc)
|
progressBar := NewProgressBar().SetProgressFunc(progressFunc)
|
||||||
searchbar := NewSearchBar()
|
searchbar := NewSearchBar()
|
||||||
navMenu := NewNavMenu([]navItem{
|
navMenu := NewNavMenu([]navItem{
|
||||||
{"Albums", NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
{"Albums", NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||||
SetCurrentView(albumsView)
|
SetCurrentView(albumsView)
|
||||||
App.SetFocus(Main.Table)
|
App.SetFocus(Main)
|
||||||
return nil
|
return nil
|
||||||
}, nil)},
|
}, nil)},
|
||||||
{"Artists", NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
{"Artists", NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||||
SetCurrentView(artistsView)
|
SetCurrentView(artistsView)
|
||||||
App.SetFocus(Main.Table)
|
App.SetFocus(Main)
|
||||||
return nil
|
return nil
|
||||||
}, nil)},
|
}, nil)},
|
||||||
{"Liked Songs", NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
{"Liked Songs", NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||||
SetCurrentView(likedSongsView)
|
SetCurrentView(likedSongsView)
|
||||||
App.SetFocus(Main.Table)
|
App.SetFocus(Main)
|
||||||
return nil
|
return nil
|
||||||
}, nil)},
|
}, nil)},
|
||||||
{"Recently Played", NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
{"Recently Played", NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||||
recentlyPlayedView.RefreshState()
|
recentlyPlayedView.RefreshState()
|
||||||
SetCurrentView(recentlyPlayedView)
|
SetCurrentView(recentlyPlayedView)
|
||||||
App.SetFocus(Main.Table)
|
App.SetFocus(Main)
|
||||||
return nil
|
return nil
|
||||||
}, nil)},
|
}, nil)},
|
||||||
})
|
})
|
||||||
playlistNav := NewPlaylistNav()
|
playlistNav := NewPlaylistNav()
|
||||||
|
|
||||||
root.AfterContextClose(func() { App.SetFocus(Main.Table) })
|
root.AfterContextClose(func() { App.SetFocus(Main) })
|
||||||
|
|
||||||
// Define Actions
|
// Define Actions
|
||||||
openCurrentArtist := func() {
|
openCurrentArtist := func() {
|
||||||
@@ -152,7 +152,7 @@ func NewApplication() *tview.Application {
|
|||||||
if len(state.Item.Artists) != 0 {
|
if len(state.Item.Artists) != 0 {
|
||||||
artistView.SetArtist(&state.Item.Artists[0].ID)
|
artistView.SetArtist(&state.Item.Artists[0].ID)
|
||||||
SetCurrentView(artistView)
|
SetCurrentView(artistView)
|
||||||
App.SetFocus(Main.Table)
|
App.SetFocus(Main)
|
||||||
} else {
|
} else {
|
||||||
SendNotification("No Artist Found!")
|
SendNotification("No Artist Found!")
|
||||||
}
|
}
|
||||||
@@ -162,7 +162,7 @@ func NewApplication() *tview.Application {
|
|||||||
if state != nil && state.Item != nil {
|
if state != nil && state.Item != nil {
|
||||||
albumView.SetAlbum(state.Item.Album.Name, &state.Item.Album.ID)
|
albumView.SetAlbum(state.Item.Album.Name, &state.Item.Album.ID)
|
||||||
SetCurrentView(albumView)
|
SetCurrentView(albumView)
|
||||||
App.SetFocus(Main.Table)
|
App.SetFocus(Main)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
globalActions := map[string]*Action{
|
globalActions := map[string]*Action{
|
||||||
@@ -181,15 +181,15 @@ func NewApplication() *tview.Application {
|
|||||||
return nil
|
return nil
|
||||||
}, nil),
|
}, nil),
|
||||||
"focus_nav": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
"focus_nav": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||||
App.SetFocus(navMenu.Table)
|
App.SetFocus(navMenu)
|
||||||
return nil
|
return nil
|
||||||
}, nil),
|
}, nil),
|
||||||
"focus_playlists": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
"focus_playlists": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||||
App.SetFocus(playlistNav.Table)
|
App.SetFocus(playlistNav)
|
||||||
return nil
|
return nil
|
||||||
}, nil),
|
}, nil),
|
||||||
"focus_main_view": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
"focus_main_view": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||||
App.SetFocus(Main.Table)
|
App.SetFocus(Main)
|
||||||
return nil
|
return nil
|
||||||
}, nil),
|
}, nil),
|
||||||
"open_current_track_album": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
"open_current_track_album": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||||
@@ -225,7 +225,7 @@ func NewApplication() *tview.Application {
|
|||||||
}
|
}
|
||||||
playlistView.SetPlaylist(&p.SimplePlaylist)
|
playlistView.SetPlaylist(&p.SimplePlaylist)
|
||||||
SetCurrentView(playlistView)
|
SetCurrentView(playlistView)
|
||||||
App.SetFocus(Main.Table)
|
App.SetFocus(Main)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
@@ -254,10 +254,10 @@ func NewApplication() *tview.Application {
|
|||||||
"play_entry": NewAction(playlistNav.PlaySelectEntry,
|
"play_entry": NewAction(playlistNav.PlaySelectEntry,
|
||||||
progressBar),
|
progressBar),
|
||||||
"open_entry": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
"open_entry": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||||
r, _ := playlistNav.Table.GetSelection()
|
r, _ := playlistNav.GetSelection()
|
||||||
playlistView.SetPlaylist(&(*playlistNav.Playlists)[r])
|
playlistView.SetPlaylist(&(*playlistNav.Playlists)[r])
|
||||||
SetCurrentView(playlistView)
|
SetCurrentView(playlistView)
|
||||||
App.SetFocus(Main.Table)
|
App.SetFocus(Main)
|
||||||
return nil
|
return nil
|
||||||
}, nil),
|
}, nil),
|
||||||
}))
|
}))
|
||||||
@@ -372,9 +372,9 @@ func NewApplication() *tview.Application {
|
|||||||
|
|
||||||
// Map Actions
|
// Map Actions
|
||||||
playlistNav.SetMappings(mappings["playlist_nav"])
|
playlistNav.SetMappings(mappings["playlist_nav"])
|
||||||
playlistNav.Table.SetInputCapture(playlistNav.ExternalInputCapture())
|
playlistNav.SetInputCapture(playlistNav.ExternalInputCapture())
|
||||||
navMenu.SetMappings(mappings["nav_menu"])
|
navMenu.SetMappings(mappings["nav_menu"])
|
||||||
navMenu.Table.SetInputCapture(navMenu.ExternalInputCapture())
|
navMenu.SetInputCapture(navMenu.ExternalInputCapture())
|
||||||
playlistView.SetMappings(mappings["playlist_view"])
|
playlistView.SetMappings(mappings["playlist_view"])
|
||||||
recentlyPlayedView.SetMappings(mappings["recently_played_view"])
|
recentlyPlayedView.SetMappings(mappings["recently_played_view"])
|
||||||
topTracksView.SetMappings(mappings["top_tracks_view"])
|
topTracksView.SetMappings(mappings["top_tracks_view"])
|
||||||
@@ -387,8 +387,8 @@ func NewApplication() *tview.Application {
|
|||||||
|
|
||||||
// Set up UI
|
// Set up UI
|
||||||
navFlex := tview.NewFlex().SetDirection(tview.FlexRow).
|
navFlex := tview.NewFlex().SetDirection(tview.FlexRow).
|
||||||
AddItem(navMenu.Table, 6, 3, false).
|
AddItem(navMenu, 6, 3, false).
|
||||||
AddItem(playlistNav.Table, 0, 6, false)
|
AddItem(playlistNav, 0, 6, false)
|
||||||
|
|
||||||
if !config.Config.HideImage {
|
if !config.Config.HideImage {
|
||||||
navFlex.AddItem(coverArt, 9, 3, false)
|
navFlex.AddItem(coverArt, 9, 3, false)
|
||||||
@@ -397,7 +397,7 @@ func NewApplication() *tview.Application {
|
|||||||
// mid
|
// mid
|
||||||
mFlex := tview.NewFlex().
|
mFlex := tview.NewFlex().
|
||||||
AddItem(navFlex, 17, 1, false).
|
AddItem(navFlex, 17, 1, false).
|
||||||
AddItem(Main.Table, 0, 4, false)
|
AddItem(Main, 0, 4, false)
|
||||||
|
|
||||||
// mid + top
|
// mid + top
|
||||||
tFlex := tview.NewFlex().SetDirection(tview.FlexRow).
|
tFlex := tview.NewFlex().SetDirection(tview.FlexRow).
|
||||||
@@ -409,7 +409,7 @@ func NewApplication() *tview.Application {
|
|||||||
AddItem(progressBar, 5, 1, false)
|
AddItem(progressBar, 5, 1, false)
|
||||||
|
|
||||||
root.Primitive("Main", mainFlex)
|
root.Primitive("Main", mainFlex)
|
||||||
App.SetRoot(root.Root, true).SetFocus(Main.Table)
|
App.SetRoot(root.Root, true).SetFocus(Main)
|
||||||
|
|
||||||
// Start Routines
|
// Start Routines
|
||||||
InitNotifier()
|
InitNotifier()
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ type interactiveView struct {
|
|||||||
visual bool
|
visual bool
|
||||||
vrange *_range
|
vrange *_range
|
||||||
baseSel int
|
baseSel int
|
||||||
Table *tview.Table
|
*tview.Table
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewInteractiveView() *interactiveView {
|
func NewInteractiveView() *interactiveView {
|
||||||
|
|||||||
14
ui/nav.go
14
ui/nav.go
@@ -13,7 +13,7 @@ type navItem struct {
|
|||||||
|
|
||||||
type NavMenu struct {
|
type NavMenu struct {
|
||||||
*defView
|
*defView
|
||||||
Table *tview.Table
|
*tview.Table
|
||||||
m []navItem
|
m []navItem
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ func (n *NavMenu) SelectEntry(e *tcell.EventKey) *tcell.EventKey {
|
|||||||
|
|
||||||
type PlaylistNav struct {
|
type PlaylistNav struct {
|
||||||
*defView
|
*defView
|
||||||
Table *tview.Table
|
*tview.Table
|
||||||
Playlists *spt.UserPlaylists
|
Playlists *spt.UserPlaylists
|
||||||
c chan bool
|
c chan bool
|
||||||
done func(error)
|
done func(error)
|
||||||
@@ -63,13 +63,6 @@ func NewPlaylistNav() *PlaylistNav {
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
T.SetDrawFunc(func(s tcell.Screen, x, y, w, h int) (int, int, int, int) {
|
T.SetDrawFunc(func(s tcell.Screen, x, y, w, h int) (int, int, int, int) {
|
||||||
v.Draw()
|
|
||||||
return T.GetInnerRect()
|
|
||||||
})
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *PlaylistNav) Draw() {
|
|
||||||
if v.Playlists == nil {
|
if v.Playlists == nil {
|
||||||
v.RefreshState()
|
v.RefreshState()
|
||||||
}
|
}
|
||||||
@@ -77,6 +70,9 @@ func (v *PlaylistNav) Draw() {
|
|||||||
v.Table.SetCell(k, 0,
|
v.Table.SetCell(k, 0,
|
||||||
GetCell(p.Name, PlaylistNavStyle))
|
GetCell(p.Name, PlaylistNavStyle))
|
||||||
}
|
}
|
||||||
|
return T.GetInnerRect()
|
||||||
|
})
|
||||||
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *PlaylistNav) PlaySelectEntry(e *tcell.EventKey) *tcell.EventKey {
|
func (v *PlaylistNav) PlaySelectEntry(e *tcell.EventKey) *tcell.EventKey {
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ func notify(n *notification) {
|
|||||||
n.position = npos
|
n.position = npos
|
||||||
root.Root.AddPage(currentTime, n, false, true)
|
root.Root.AddPage(currentTime, n, false, true)
|
||||||
App.Draw()
|
App.Draw()
|
||||||
App.SetFocus(Main.Table)
|
App.SetFocus(Main)
|
||||||
if n.msg != nil {
|
if n.msg != nil {
|
||||||
n.text = <-n.msg
|
n.text = <-n.msg
|
||||||
App.Draw()
|
App.Draw()
|
||||||
@@ -148,7 +148,7 @@ func notify(n *notification) {
|
|||||||
time.Sleep(n.timer)
|
time.Sleep(n.timer)
|
||||||
root.Root.RemovePage(currentTime)
|
root.Root.RemovePage(currentTime)
|
||||||
posArr.Free(npos)
|
posArr.Free(npos)
|
||||||
App.SetFocus(Main.Table)
|
App.SetFocus(Main)
|
||||||
App.Draw()
|
App.Draw()
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,14 +22,14 @@ func NewSearchBar() *tview.InputField {
|
|||||||
switch k {
|
switch k {
|
||||||
case tcell.KeyEscape:
|
case tcell.KeyEscape:
|
||||||
{
|
{
|
||||||
App.SetFocus(Main.Table)
|
App.SetFocus(Main)
|
||||||
T.SetText("")
|
T.SetText("")
|
||||||
}
|
}
|
||||||
case tcell.KeyEnter:
|
case tcell.KeyEnter:
|
||||||
{
|
{
|
||||||
searchView.SetSearch(T.GetText())
|
searchView.SetSearch(T.GetText())
|
||||||
SetCurrentView(searchView)
|
SetCurrentView(searchView)
|
||||||
App.SetFocus(Main.Table)
|
App.SetFocus(Main)
|
||||||
T.SetText("")
|
T.SetText("")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ func (a *AlbumView) Content() func() [][]Content {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *AlbumView) AddToPlaylist() {
|
func (a *AlbumView) AddToPlaylist() {
|
||||||
r, _ := Main.Table.GetSelection()
|
r, _ := Main.GetSelection()
|
||||||
track := (*(*a.currentFullAlbum).Tracks)[r]
|
track := (*(*a.currentFullAlbum).Tracks)[r]
|
||||||
addToPlaylist([]spotify.ID{track.ID})
|
addToPlaylist([]spotify.ID{track.ID})
|
||||||
}
|
}
|
||||||
@@ -77,7 +77,7 @@ func (a *AlbumView) AddToPlaylistVisual(start, end int, e *tcell.EventKey) *tcel
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *AlbumView) PlaySelectEntry() {
|
func (a *AlbumView) PlaySelectEntry() {
|
||||||
r, _ := Main.Table.GetSelection()
|
r, _ := Main.GetSelection()
|
||||||
if err := spt.PlaySongWithContext(&a.currentFullAlbum.URI, r); err != nil {
|
if err := spt.PlaySongWithContext(&a.currentFullAlbum.URI, r); err != nil {
|
||||||
SendNotification(err.Error())
|
SendNotification(err.Error())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,20 +47,20 @@ func (a *AlbumsView) Content() func() [][]Content {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *AlbumsView) OpenAlbum() {
|
func (a *AlbumsView) OpenAlbum() {
|
||||||
r, _ := Main.Table.GetSelection()
|
r, _ := Main.GetSelection()
|
||||||
albumView.SetAlbum((*a.savedAlbums)[r].Name, &(*a.savedAlbums)[r].ID)
|
albumView.SetAlbum((*a.savedAlbums)[r].Name, &(*a.savedAlbums)[r].ID)
|
||||||
SetCurrentView(albumView)
|
SetCurrentView(albumView)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *AlbumsView) PlaySelectEntry() {
|
func (a *AlbumsView) PlaySelectEntry() {
|
||||||
r, _ := Main.Table.GetSelection()
|
r, _ := Main.GetSelection()
|
||||||
if err := spt.PlayContext(&(*a.savedAlbums)[r].URI); err != nil {
|
if err := spt.PlayContext(&(*a.savedAlbums)[r].URI); err != nil {
|
||||||
SendNotification(err.Error())
|
SendNotification(err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *AlbumsView) QueueSelectEntry() {
|
func (a *AlbumsView) QueueSelectEntry() {
|
||||||
r, _ := Main.Table.GetSelection()
|
r, _ := Main.GetSelection()
|
||||||
alb := (*a.savedAlbums)[r]
|
alb := (*a.savedAlbums)[r]
|
||||||
msg := SendNotificationWithChan("Queueing " + alb.Name + "...")
|
msg := SendNotificationWithChan("Queueing " + alb.Name + "...")
|
||||||
go func() {
|
go func() {
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ func (a *ArtistView) Content() func() [][]Content {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *ArtistView) PlayEntry() {
|
func (a *ArtistView) PlayEntry() {
|
||||||
r, _ := Main.Table.GetSelection()
|
r, _ := Main.GetSelection()
|
||||||
if r > 0 {
|
if r > 0 {
|
||||||
if r < (len(a.albums) + 1) {
|
if r < (len(a.albums) + 1) {
|
||||||
if err := spt.PlayContext(&a.albums[r-1].URI); err != nil {
|
if err := spt.PlayContext(&a.albums[r-1].URI); err != nil {
|
||||||
@@ -83,7 +83,7 @@ func (a *ArtistView) PlayEntry() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *ArtistView) OpenEntry() {
|
func (a *ArtistView) OpenEntry() {
|
||||||
r, _ := Main.Table.GetSelection()
|
r, _ := Main.GetSelection()
|
||||||
if r > 0 {
|
if r > 0 {
|
||||||
if r < (len(a.albums)+1) && len(a.albums) > 0 {
|
if r < (len(a.albums)+1) && len(a.albums) > 0 {
|
||||||
albumView.SetAlbum(a.albums[r-1].Name, &a.albums[r-1].ID)
|
albumView.SetAlbum(a.albums[r-1].Name, &a.albums[r-1].ID)
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ func (a *ArtistsView) Content() func() [][]Content {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *ArtistsView) OpenArtist() {
|
func (a *ArtistsView) OpenArtist() {
|
||||||
r, _ := Main.Table.GetSelection()
|
r, _ := Main.GetSelection()
|
||||||
artistView.SetArtist(&(*a.followedArtists)[r].ID)
|
artistView.SetArtist(&(*a.followedArtists)[r].ID)
|
||||||
SetCurrentView(artistView)
|
SetCurrentView(artistView)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ func (p *LikedSongsView) Content() func() [][]Content {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (l *LikedSongsView) AddToPlaylist() {
|
func (l *LikedSongsView) AddToPlaylist() {
|
||||||
r, _ := Main.Table.GetSelection()
|
r, _ := Main.GetSelection()
|
||||||
addToPlaylist([]spotify.ID{(*l.likedSongs)[r].ID})
|
addToPlaylist([]spotify.ID{(*l.likedSongs)[r].ID})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ func (l *LikedSongsView) AddToPlaylistVisual(start, end int, e *tcell.EventKey)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (l *LikedSongsView) OpenEntry() {
|
func (l *LikedSongsView) OpenEntry() {
|
||||||
r, _ := Main.Table.GetSelection()
|
r, _ := Main.GetSelection()
|
||||||
if err := spt.PlaySong((*l.likedSongs)[r].URI); err != nil {
|
if err := spt.PlaySong((*l.likedSongs)[r].URI); err != nil {
|
||||||
SendNotification(err.Error())
|
SendNotification(err.Error())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ func (p *PlaylistView) Content() func() [][]Content {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *PlaylistView) AddToPlaylist() {
|
func (p *PlaylistView) AddToPlaylist() {
|
||||||
r, _ := Main.Table.GetSelection()
|
r, _ := Main.GetSelection()
|
||||||
addToPlaylist([]spotify.ID{(*(*p.currentUserFullPlaylist).Tracks)[r].Track.ID})
|
addToPlaylist([]spotify.ID{(*(*p.currentUserFullPlaylist).Tracks)[r].Track.ID})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ func (p *PlaylistView) AddToPlaylistVisual(start, end int, e *tcell.EventKey) *t
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *PlaylistView) PlaySelectEntry() {
|
func (p *PlaylistView) PlaySelectEntry() {
|
||||||
r, _ := Main.Table.GetSelection()
|
r, _ := Main.GetSelection()
|
||||||
if err := spt.PlaySongWithContext(&p.currentPlaylist.URI, r); err != nil {
|
if err := spt.PlaySongWithContext(&p.currentPlaylist.URI, r); err != nil {
|
||||||
SendNotification(err.Error())
|
SendNotification(err.Error())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ func (r *RecentlyPlayedView) Content() func() [][]Content {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *RecentlyPlayedView) AddToPlaylist() {
|
func (r *RecentlyPlayedView) AddToPlaylist() {
|
||||||
_r, _ := Main.Table.GetSelection()
|
_r, _ := Main.GetSelection()
|
||||||
addToPlaylist([]spotify.ID{r.recentlyPlayed[_r].Track.ID})
|
addToPlaylist([]spotify.ID{r.recentlyPlayed[_r].Track.ID})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ func (r *RecentlyPlayedView) RefreshState() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (re *RecentlyPlayedView) SelectEntry(e *tcell.EventKey) *tcell.EventKey {
|
func (re *RecentlyPlayedView) SelectEntry(e *tcell.EventKey) *tcell.EventKey {
|
||||||
r, _ := Main.Table.GetSelection()
|
r, _ := Main.GetSelection()
|
||||||
trackUri := re.recentlyPlayed[r].Track.URI
|
trackUri := re.recentlyPlayed[r].Track.URI
|
||||||
contextUri := re.recentlyPlayed[r].PlaybackContext.URI
|
contextUri := re.recentlyPlayed[r].PlaybackContext.URI
|
||||||
if string(contextUri) != "" {
|
if string(contextUri) != "" {
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ func (a *SearchView) Content() func() [][]Content {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *SearchView) SelectEntry() {
|
func (a *SearchView) SelectEntry() {
|
||||||
r, _ := Main.Table.GetSelection()
|
r, _ := Main.GetSelection()
|
||||||
switch a.searchContent[r].Type {
|
switch a.searchContent[r].Type {
|
||||||
case "track":
|
case "track":
|
||||||
{
|
{
|
||||||
@@ -134,7 +134,7 @@ func (a *SearchView) SelectEntry() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *SearchView) PlaySelectEntry() {
|
func (a *SearchView) PlaySelectEntry() {
|
||||||
r, _ := Main.Table.GetSelection()
|
r, _ := Main.GetSelection()
|
||||||
switch a.searchContent[r].Type {
|
switch a.searchContent[r].Type {
|
||||||
case "album", "artist", "playlist":
|
case "album", "artist", "playlist":
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ func (a *TopTracksView) Content() func() [][]Content {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *TopTracksView) PlaySelectedEntry() {
|
func (a *TopTracksView) PlaySelectedEntry() {
|
||||||
r, _ := Main.Table.GetSelection()
|
r, _ := Main.GetSelection()
|
||||||
if r > 0 {
|
if r > 0 {
|
||||||
if r < (len(a.topArtists) + 1) {
|
if r < (len(a.topArtists) + 1) {
|
||||||
if err := spt.PlayContext(&a.topArtists[r-1].URI); err != nil {
|
if err := spt.PlayContext(&a.topArtists[r-1].URI); err != nil {
|
||||||
@@ -82,7 +82,7 @@ func (a *TopTracksView) PlaySelectedEntry() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *TopTracksView) OpenSelectEntry() {
|
func (a *TopTracksView) OpenSelectEntry() {
|
||||||
r, _ := Main.Table.GetSelection()
|
r, _ := Main.GetSelection()
|
||||||
if r > 0 {
|
if r > 0 {
|
||||||
if r < (len(a.topArtists) + 1) {
|
if r < (len(a.topArtists) + 1) {
|
||||||
artistView.SetArtist(&(a.topArtists)[r-1].ID)
|
artistView.SetArtist(&(a.topArtists)[r-1].ID)
|
||||||
|
|||||||
Reference in New Issue
Block a user