mirror of
https://github.com/aditya-K2/gspt.git
synced 2026-01-08 21:37:58 -05:00
Make open_entry global
This commit is contained in:
@@ -13,21 +13,14 @@ var (
|
||||
DefaultMappings = map[string]map[string]map[Key]string{
|
||||
"recently_played_view": {
|
||||
"normal": {
|
||||
{K: tcell.KeyEnter}: "open_entry",
|
||||
{R: 'a'}: "add_to_playlist",
|
||||
{R: 'a'}: "add_to_playlist",
|
||||
},
|
||||
"visual": {
|
||||
{R: 'a'}: "add_to_playlist",
|
||||
},
|
||||
},
|
||||
"nav_menu": {
|
||||
"normal": {
|
||||
{K: tcell.KeyEnter}: "open_entry",
|
||||
},
|
||||
},
|
||||
"search_view": {
|
||||
"normal": {
|
||||
{K: tcell.KeyEnter}: "open_entry",
|
||||
{K: tcell.KeyCtrlP}: "play_entry",
|
||||
},
|
||||
},
|
||||
@@ -44,18 +37,17 @@ var (
|
||||
{R: 'n'}: "next",
|
||||
{R: 'p'}: "previous",
|
||||
{K: tcell.KeyCtrlO}: "open_current_context",
|
||||
{K: tcell.KeyEnter}: "open_entry",
|
||||
},
|
||||
},
|
||||
"playlist_nav": {
|
||||
"normal": {
|
||||
{K: tcell.KeyEnter}: "open_entry",
|
||||
{K: tcell.KeyCtrlP}: "play_entry",
|
||||
},
|
||||
},
|
||||
"playlist_view": {
|
||||
"normal": {
|
||||
{K: tcell.KeyEnter}: "open_entry",
|
||||
{R: 'a'}: "add_to_playlist",
|
||||
{R: 'a'}: "add_to_playlist",
|
||||
},
|
||||
"visual": {
|
||||
{R: 'a'}: "add_to_playlist",
|
||||
@@ -63,14 +55,12 @@ var (
|
||||
},
|
||||
"top_tracks_view": {
|
||||
"normal": {
|
||||
{K: tcell.KeyEnter}: "open_entry",
|
||||
{K: tcell.KeyCtrlP}: "play_entry",
|
||||
},
|
||||
},
|
||||
"liked_songs_view": {
|
||||
"normal": {
|
||||
{K: tcell.KeyEnter}: "open_entry",
|
||||
{R: 'a'}: "add_to_playlist",
|
||||
{R: 'a'}: "add_to_playlist",
|
||||
},
|
||||
"visual": {
|
||||
{R: 'a'}: "add_to_playlist",
|
||||
@@ -78,32 +68,29 @@ var (
|
||||
},
|
||||
"artists_view": {
|
||||
"normal": {
|
||||
{K: tcell.KeyEnter}: "open_entry",
|
||||
{K: tcell.KeyCtrlP}: "play_entry",
|
||||
},
|
||||
},
|
||||
"artist_view": {
|
||||
"normal": {
|
||||
{K: tcell.KeyEnter}: "open_entry",
|
||||
{K: tcell.KeyCtrlP}: "play_entry",
|
||||
},
|
||||
},
|
||||
"albums_view": {
|
||||
"normal": {
|
||||
{K: tcell.KeyEnter}: "open_entry",
|
||||
{K: tcell.KeyCtrlP}: "play_entry",
|
||||
{R: 'q'}: "queue_entry",
|
||||
},
|
||||
},
|
||||
"album_view": {
|
||||
"normal": {
|
||||
{K: tcell.KeyEnter}: "open_entry",
|
||||
{R: 'a'}: "add_to_playlist",
|
||||
{R: 'a'}: "add_to_playlist",
|
||||
},
|
||||
"visual": {
|
||||
{R: 'a'}: "add_to_playlist",
|
||||
},
|
||||
},
|
||||
"nav_menu": {},
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
41
ui/app.go
41
ui/app.go
@@ -127,6 +127,10 @@ func NewApplication() *tview.Application {
|
||||
|
||||
// Define Actions
|
||||
globalActions := map[string]*Action{
|
||||
"open_entry": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||
GetCurrentView().OpenEntry()
|
||||
return nil
|
||||
}, progressBar),
|
||||
"focus_search": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||
App.SetFocus(searchbar)
|
||||
return nil
|
||||
@@ -227,81 +231,48 @@ func NewApplication() *tview.Application {
|
||||
nil),
|
||||
}))
|
||||
playlistView.SetActions(utils.MergeMaps(globalActions, map[string]*Action{
|
||||
"open_entry": NewAction(func(*tcell.EventKey) *tcell.EventKey {
|
||||
playlistView.OpenEntry()
|
||||
return nil
|
||||
}, progressBar),
|
||||
"add_to_playlist": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||
playlistView.AddToPlaylist()
|
||||
return nil
|
||||
}, nil),
|
||||
}))
|
||||
recentlyPlayedView.SetActions(utils.MergeMaps(globalActions, map[string]*Action{
|
||||
"open_entry": NewAction(func(*tcell.EventKey) *tcell.EventKey {
|
||||
recentlyPlayedView.OpenEntry()
|
||||
return nil
|
||||
},
|
||||
progressBar),
|
||||
"add_to_playlist": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||
recentlyPlayedView.AddToPlaylist()
|
||||
return nil
|
||||
}, nil),
|
||||
}))
|
||||
topTracksView.SetActions(utils.MergeMaps(globalActions, map[string]*Action{
|
||||
"open_entry": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||
topTracksView.OpenEntry()
|
||||
return nil
|
||||
}, progressBar),
|
||||
"play_entry": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||
topTracksView.PlaySelectedEntry()
|
||||
return nil
|
||||
}, progressBar),
|
||||
}))
|
||||
likedSongsView.SetActions(utils.MergeMaps(globalActions, map[string]*Action{
|
||||
"open_entry": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||
likedSongsView.OpenEntry()
|
||||
return nil
|
||||
}, progressBar),
|
||||
"add_to_playlist": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||
likedSongsView.AddToPlaylist()
|
||||
return nil
|
||||
}, nil),
|
||||
}))
|
||||
searchView.SetActions(utils.MergeMaps(globalActions, map[string]*Action{
|
||||
"open_entry": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||
searchView.OpenEntry()
|
||||
return nil
|
||||
}, nil),
|
||||
"play_entry": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||
searchView.PlayEntry()
|
||||
return nil
|
||||
}, progressBar),
|
||||
}))
|
||||
artistsView.SetActions(utils.MergeMaps(globalActions, map[string]*Action{
|
||||
"open_entry": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||
artistsView.OpenEntry()
|
||||
return nil
|
||||
}, nil),
|
||||
"play_entry": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||
artistsView.PlayEntry()
|
||||
return nil
|
||||
}, nil),
|
||||
}))
|
||||
artistView.SetActions(utils.MergeMaps(globalActions, map[string]*Action{
|
||||
"open_entry": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||
artistView.OpenEntry()
|
||||
return nil
|
||||
}, progressBar),
|
||||
"play_entry": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||
artistView.PlayEntry()
|
||||
return nil
|
||||
}, progressBar),
|
||||
}))
|
||||
albumsView.SetActions(utils.MergeMaps(globalActions, map[string]*Action{
|
||||
"open_entry": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||
albumsView.OpenEntry()
|
||||
return nil
|
||||
}, nil),
|
||||
"play_entry": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||
albumsView.PlayEntry()
|
||||
return nil
|
||||
@@ -312,10 +283,6 @@ func NewApplication() *tview.Application {
|
||||
}, progressBar),
|
||||
}))
|
||||
albumView.SetActions(utils.MergeMaps(globalActions, map[string]*Action{
|
||||
"open_entry": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||
albumView.OpenEntry()
|
||||
return nil
|
||||
}, progressBar),
|
||||
"add_to_playlist": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||
albumView.AddToPlaylist()
|
||||
return nil
|
||||
|
||||
@@ -21,6 +21,7 @@ type View interface {
|
||||
ExternalInputCapture() func(e *tcell.EventKey) *tcell.EventKey
|
||||
VisualCapture() func(start, end int, e *tcell.EventKey) *tcell.EventKey
|
||||
Name() string
|
||||
OpenEntry()
|
||||
}
|
||||
|
||||
func SetCurrentView(v View) {
|
||||
|
||||
Reference in New Issue
Block a user