mirror of
https://github.com/aditya-K2/gspt.git
synced 2026-01-09 13:58:05 -05:00
Add Default Mappings
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
|
||||
"github.com/aditya-K2/utils"
|
||||
"github.com/fsnotify/fsnotify"
|
||||
"github.com/gdamore/tcell/v2"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
@@ -78,7 +79,39 @@ func ReadConfig() {
|
||||
|
||||
func GenerateMappings() map[string]map[Key]string {
|
||||
all := viper.GetStringMap("mappings")
|
||||
keys := make(map[string]map[Key]string)
|
||||
keys := map[string]map[Key]string{
|
||||
"recently_played_view": {
|
||||
{K: tcell.KeyEnter}: "open_entry",
|
||||
},
|
||||
"playlist_nav": {
|
||||
{K: tcell.KeyEnter}: "open_entry",
|
||||
{K: tcell.KeyCtrlP}: "play_entry",
|
||||
},
|
||||
"playlist_view": {
|
||||
{K: tcell.KeyEnter}: "open_entry",
|
||||
},
|
||||
"top_tracks_view": {
|
||||
{K: tcell.KeyEnter}: "open_entry",
|
||||
{K: tcell.KeyCtrlP}: "play_entry",
|
||||
},
|
||||
"liked_songs_view": {
|
||||
{K: tcell.KeyEnter}: "open_entry",
|
||||
},
|
||||
"artists_view": {
|
||||
{K: tcell.KeyEnter}: "open_entry",
|
||||
},
|
||||
"artist_view": {
|
||||
{K: tcell.KeyEnter}: "open_entry",
|
||||
{K: tcell.KeyCtrlP}: "play_entry",
|
||||
},
|
||||
"albums_view": {
|
||||
{K: tcell.KeyEnter}: "open_entry",
|
||||
{K: tcell.KeyCtrlP}: "play_entry",
|
||||
},
|
||||
"album_view": {
|
||||
{K: tcell.KeyEnter}: "open_entry",
|
||||
},
|
||||
}
|
||||
for view, mappings := range all {
|
||||
if keys[view] == nil {
|
||||
keys[view] = make(map[Key]string)
|
||||
|
||||
120
config/key.go
120
config/key.go
@@ -11,66 +11,66 @@ type Key struct {
|
||||
|
||||
var (
|
||||
m = map[string]tcell.Key{
|
||||
"Backspace": tcell.KeyBackspace,
|
||||
"Tab": tcell.KeyTab,
|
||||
"Esc": tcell.KeyEsc,
|
||||
"Escape": tcell.KeyEscape,
|
||||
"Enter ": tcell.KeyEnter,
|
||||
"Backspace2": tcell.KeyBackspace2,
|
||||
"CtrlSpace": tcell.KeyCtrlSpace,
|
||||
"CtrlA": tcell.KeyCtrlA,
|
||||
"CtrlB": tcell.KeyCtrlB,
|
||||
"CtrlC": tcell.KeyCtrlC,
|
||||
"CtrlD": tcell.KeyCtrlD,
|
||||
"CtrlE": tcell.KeyCtrlE,
|
||||
"CtrlF": tcell.KeyCtrlF,
|
||||
"CtrlG": tcell.KeyCtrlG,
|
||||
"CtrlH": tcell.KeyCtrlH,
|
||||
"CtrlI": tcell.KeyCtrlI,
|
||||
"CtrlJ": tcell.KeyCtrlJ,
|
||||
"CtrlK": tcell.KeyCtrlK,
|
||||
"CtrlL": tcell.KeyCtrlL,
|
||||
"CtrlM": tcell.KeyCtrlM,
|
||||
"CtrlN": tcell.KeyCtrlN,
|
||||
"CtrlO": tcell.KeyCtrlO,
|
||||
"CtrlP": tcell.KeyCtrlP,
|
||||
"CtrlQ": tcell.KeyCtrlQ,
|
||||
"CtrlR": tcell.KeyCtrlR,
|
||||
"CtrlS": tcell.KeyCtrlS,
|
||||
"CtrlT": tcell.KeyCtrlT,
|
||||
"CtrlU": tcell.KeyCtrlU,
|
||||
"CtrlV": tcell.KeyCtrlV,
|
||||
"CtrlW": tcell.KeyCtrlW,
|
||||
"CtrlX": tcell.KeyCtrlX,
|
||||
"CtrlY": tcell.KeyCtrlY,
|
||||
"CtrlZ": tcell.KeyCtrlZ,
|
||||
"CtrlLeftSq": tcell.KeyCtrlLeftSq,
|
||||
"CtrlBackslash": tcell.KeyCtrlBackslash,
|
||||
"CtrlRightSq": tcell.KeyCtrlRightSq,
|
||||
"CtrlCarat": tcell.KeyCtrlCarat,
|
||||
"CtrlUnderscore": tcell.KeyCtrlUnderscore,
|
||||
"Up": tcell.KeyUp,
|
||||
"Down": tcell.KeyDown,
|
||||
"Right": tcell.KeyRight,
|
||||
"Left": tcell.KeyLeft,
|
||||
"UpLeft": tcell.KeyUpLeft,
|
||||
"UpRight": tcell.KeyUpRight,
|
||||
"DownLeft": tcell.KeyDownLeft,
|
||||
"DownRight": tcell.KeyDownRight,
|
||||
"Center": tcell.KeyCenter,
|
||||
"PgUp": tcell.KeyPgUp,
|
||||
"PgDn": tcell.KeyPgDn,
|
||||
"Home": tcell.KeyHome,
|
||||
"End": tcell.KeyEnd,
|
||||
"Insert": tcell.KeyInsert,
|
||||
"Delete": tcell.KeyDelete,
|
||||
"Help": tcell.KeyHelp,
|
||||
"Exit": tcell.KeyExit,
|
||||
"Clear": tcell.KeyClear,
|
||||
"Cancel": tcell.KeyCancel,
|
||||
"Print": tcell.KeyPrint,
|
||||
"Pause": tcell.KeyPause,
|
||||
"Backtab": tcell.KeyBacktab,
|
||||
"backspace": tcell.KeyBackspace,
|
||||
"tab": tcell.KeyTab,
|
||||
"esc": tcell.KeyEsc,
|
||||
"escape": tcell.KeyEscape,
|
||||
"enter ": tcell.KeyEnter,
|
||||
"backspace2": tcell.KeyBackspace2,
|
||||
"ctrl-space": tcell.KeyCtrlSpace,
|
||||
"ctrl-a": tcell.KeyCtrlA,
|
||||
"ctrl-b": tcell.KeyCtrlB,
|
||||
"ctrl-c": tcell.KeyCtrlC,
|
||||
"ctrl-d": tcell.KeyCtrlD,
|
||||
"ctrl-e": tcell.KeyCtrlE,
|
||||
"ctrl-f": tcell.KeyCtrlF,
|
||||
"ctrl-g": tcell.KeyCtrlG,
|
||||
"ctrl-h": tcell.KeyCtrlH,
|
||||
"ctrl-i": tcell.KeyCtrlI,
|
||||
"ctrl-j": tcell.KeyCtrlJ,
|
||||
"ctrl-k": tcell.KeyCtrlK,
|
||||
"ctrl-l": tcell.KeyCtrlL,
|
||||
"ctrl-m": tcell.KeyCtrlM,
|
||||
"ctrl-n": tcell.KeyCtrlN,
|
||||
"ctrl-o": tcell.KeyCtrlO,
|
||||
"ctrl-p": tcell.KeyCtrlP,
|
||||
"ctrl-q": tcell.KeyCtrlQ,
|
||||
"ctrl-r": tcell.KeyCtrlR,
|
||||
"ctrl-s": tcell.KeyCtrlS,
|
||||
"ctrl-t": tcell.KeyCtrlT,
|
||||
"ctrl-u": tcell.KeyCtrlU,
|
||||
"ctrl-v": tcell.KeyCtrlV,
|
||||
"ctrl-w": tcell.KeyCtrlW,
|
||||
"ctrl-x": tcell.KeyCtrlX,
|
||||
"ctrl-y": tcell.KeyCtrlY,
|
||||
"ctrl-z": tcell.KeyCtrlZ,
|
||||
"ctrl-leftsq": tcell.KeyCtrlLeftSq,
|
||||
"ctrl-backslash": tcell.KeyCtrlBackslash,
|
||||
"ctrl-rightsq": tcell.KeyCtrlRightSq,
|
||||
"ctrl-carat": tcell.KeyCtrlCarat,
|
||||
"ctrl-underscore": tcell.KeyCtrlUnderscore,
|
||||
"up": tcell.KeyUp,
|
||||
"down": tcell.KeyDown,
|
||||
"right": tcell.KeyRight,
|
||||
"left": tcell.KeyLeft,
|
||||
"up_left": tcell.KeyUpLeft,
|
||||
"up_light": tcell.KeyUpRight,
|
||||
"down_left": tcell.KeyDownLeft,
|
||||
"down_right": tcell.KeyDownRight,
|
||||
"center": tcell.KeyCenter,
|
||||
"pgup": tcell.KeyPgUp,
|
||||
"pgdn": tcell.KeyPgDn,
|
||||
"home": tcell.KeyHome,
|
||||
"end": tcell.KeyEnd,
|
||||
"insert": tcell.KeyInsert,
|
||||
"delete": tcell.KeyDelete,
|
||||
"help": tcell.KeyHelp,
|
||||
"exit": tcell.KeyExit,
|
||||
"clear": tcell.KeyClear,
|
||||
"cancel": tcell.KeyCancel,
|
||||
"print": tcell.KeyPrint,
|
||||
"pause": tcell.KeyPause,
|
||||
"backtab": tcell.KeyBacktab,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ func NewApplication() *Application {
|
||||
|
||||
// Actions
|
||||
playlistNav.SetActions(map[string]*Action{
|
||||
"playEntry": NewAction(playlistNav.PlaySelectEntry, pBar),
|
||||
"play_entry": NewAction(playlistNav.PlaySelectEntry, pBar),
|
||||
"open_entry": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||
r, _ := playlistNav.Table.GetSelection()
|
||||
playlistView.SetPlaylist(&(*playlistNav.Playlists)[r])
|
||||
@@ -133,7 +133,7 @@ func NewApplication() *Application {
|
||||
})
|
||||
topTracksView.SetActions(map[string]*Action{
|
||||
"open_entry": NewAction(func(e *tcell.EventKey) *tcell.EventKey { topTracksView.OpenSelectEntry(); return nil }, pBar),
|
||||
"playEntry": NewAction(func(e *tcell.EventKey) *tcell.EventKey { topTracksView.PlaySelectedEntry(); return nil }, pBar),
|
||||
"play_entry": NewAction(func(e *tcell.EventKey) *tcell.EventKey { topTracksView.PlaySelectedEntry(); return nil }, pBar),
|
||||
})
|
||||
likedSongsView.SetActions(map[string]*Action{
|
||||
"open_entry": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||
@@ -153,7 +153,7 @@ func NewApplication() *Application {
|
||||
artistView.OpenEntry()
|
||||
return nil
|
||||
}, pBar),
|
||||
"playEntry": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||
"play_entry": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||
artistView.PlayEntry()
|
||||
return nil
|
||||
}, pBar),
|
||||
@@ -163,7 +163,7 @@ func NewApplication() *Application {
|
||||
albumsView.OpenAlbum()
|
||||
return nil
|
||||
}, nil),
|
||||
"playEntry": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||
"play_entry": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||
albumsView.PlaySelectEntry()
|
||||
return nil
|
||||
}, pBar),
|
||||
|
||||
Reference in New Issue
Block a user