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