From d0ac08059bb95799c8015fcb549d87d5fbe4ff29 Mon Sep 17 00:00:00 2001 From: aditya-K2 Date: Sat, 29 Apr 2023 17:40:29 +0530 Subject: [PATCH] Change documentation for the update mappings API --- README.md | 11 ++++- extras/CONFIG.md | 117 +++++++++++++++++++++++++++------------------ extras/generate.go | 17 ++++--- 3 files changed, 90 insertions(+), 55 deletions(-) diff --git a/README.md b/README.md index 5b1a73f..ef5a196 100644 --- a/README.md +++ b/README.md @@ -170,12 +170,19 @@ colors: # Key mappings has the following API mappings: view: - function: key_mapping + mode: # normal/visual + function: key_mapping # for e.g mappings: recently_played_view: - open_entry: "ctrl-p" + normal: + play_entry: "ctrl-p" + visual: + add_to_playlist: "a" + +# Visual Mode is similar to vim. Only some views support it. +# (viz. playlist_view, recently_played_view, liked_songs_view, album_view) # For the default mappings for each view please see: # https://github.com/aditya-K2/gspt/blob/master/extras/CONFIG.md diff --git a/extras/CONFIG.md b/extras/CONFIG.md index 008a6a5..532c3c3 100644 --- a/extras/CONFIG.md +++ b/extras/CONFIG.md @@ -67,62 +67,87 @@ image_width_extra_y: 0 hide_image: false rounded_corners: false mappings: - top_tracks_view: - open_entry: "ctrl-m" - play_entry: "ctrl-p" - liked_songs_view: - open_entry: "ctrl-m" - albums_view: - open_entry: "ctrl-m" - play_entry: "ctrl-p" artists_view: - open_entry: "ctrl-m" + normal: + open_entry: "ctrl-m" artist_view: - open_entry: "ctrl-m" - play_entry: "ctrl-p" + normal: + open_entry: "ctrl-m" + play_entry: "ctrl-p" + albums_view: + normal: + queue_entry: "i" + open_entry: "ctrl-m" + play_entry: "ctrl-p" recently_played_view: - open_entry: "ctrl-m" - nav_menu: - open_entry: "ctrl-m" - search_view: - open_entry: "ctrl-m" - play_entry: "ctrl-p" + normal: + add_to_playlist: "a" + open_entry: "ctrl-m" + visual: + add_to_playlist: "a" global: - focus_playlists: "2" - focus_main_view: "3" - focus_search: "?" - open_current_track_album: "o" - open_current_track_artist: "O" - next: "n" - previous: "p" - choose_device: "d" - toggle_playback: " " - open_current_context: "ctrl-o" - focus_nav: "1" + normal: + focus_nav: "1" + focus_main_view: "3" + focus_search: "?" + open_current_track_artist: "O" + previous: "p" + open_current_context: "ctrl-o" + choose_device: "d" + focus_playlists: "2" + toggle_playback: " " + open_current_track_album: "o" + next: "n" playlist_nav: - open_entry: "ctrl-m" - play_entry: "ctrl-p" + normal: + open_entry: "ctrl-m" + play_entry: "ctrl-p" playlist_view: - open_entry: "ctrl-m" + normal: + open_entry: "ctrl-m" + add_to_playlist: "a" + visual: + add_to_playlist: "a" album_view: - open_entry: "ctrl-m" + normal: + open_entry: "ctrl-m" + add_to_playlist: "a" + visual: + add_to_playlist: "a" + nav_menu: + normal: + open_entry: "ctrl-m" + search_view: + normal: + open_entry: "ctrl-m" + play_entry: "ctrl-p" + top_tracks_view: + normal: + play_entry: "ctrl-p" + open_entry: "ctrl-m" + liked_songs_view: + normal: + open_entry: "ctrl-m" + add_to_playlist: "a" + visual: + add_to_playlist: "a" ``` ## Keys available to map ||| |--|--| | a-z | A-Z | | ctrl-a - ctrl-z | 0-9 | -| ., [, ], @, &, *, (, _, , $, ), =, \|:, +, >, ", %, ?, {, ;, !, ^, -, ,, <, }, #, /, \, ' | enter | -| down | up_left | -| pause | escape | -| esc | print | -| center | home | -| tab | pgup | -| backspace | backtab | -| up | exit | -| right | up_right | -| end | down_right | -| pgdn | insert | -| backspace2 | left | -| help | clear | -| delete | cancel | +| {, ), ,, ., <, ^, (, :, ', =, \|;, ", #, *, [, ], \, ?, }, $, &, -, _, +, !, %, >, /, , @ | exit | +| tab | pause | +| right | home | +| enter | down_right | +| end | help | +| escape | clear | +| print | down | +| backtab | backspace2 | +| pgup | pgdn | +| center | up | +| left | up_left | +| up_right | delete | +| cancel | insert | +| down_left | esc | diff --git a/extras/generate.go b/extras/generate.go index c26256b..0b6f894 100644 --- a/extras/generate.go +++ b/extras/generate.go @@ -54,13 +54,16 @@ func main() { } s := "" - for k, v := range config.DefaultMappings { - s += fmt.Sprintf(" %s:\n", k) - for x, y := range v { - if x.R != 0 { - s += fmt.Sprintf(" %s: \"%s\"\n", y, string(x.R)) - } else { - s += fmt.Sprintf(" %s: \"%s\"\n", y, _m[x.K]) + for view, modes := range config.DefaultMappings { + s += fmt.Sprintf(" %s:\n", view) + for mode, mappings := range modes { + s += fmt.Sprintf(" %s:\n", mode) + for key, function := range mappings { + if key.R != 0 { + s += fmt.Sprintf(" %s: \"%s\"\n", function, string(key.R)) + } else { + s += fmt.Sprintf(" %s: \"%s\"\n", function, _m[key.K]) + } } } }