8#include <unordered_map>
55 const std::unordered_map<std::string_view, char> special_keys = {
71 auto reportError = [](
const std::string& field,
const std::string_view& key)
73 std::cerr <<
"Error: Unsupported or empty keybind '" << key <<
"' detected for field '" << field
74 <<
"'. Please check your configuration." << std::endl;
75 std::exit(EXIT_FAILURE);
89 auto handle_special_keys = [&](
const std::string_view& key,
const std::string& field) ->
char
93 reportError(field, key);
95 if (special_keys.find(key) != special_keys.end())
97 return special_keys.at(key);
103 reportError(field, key);
108 const std::unordered_map<std::string, char*> field_map = {
117 {
"vol_up", &keybinds.
vol_up},
134 for (
const auto& [field, member_ptr] : field_map)
Keybinds parseKeybinds()
Parses the keybinds from the TOML configuration.
Definition keymaps.hpp:50
Struct to hold keybinding mappings.
Definition keymaps.hpp:16
char goto_main_screen
Definition keymaps.hpp:32
char show_help
Definition keymaps.hpp:20
char add_artists_songs_to_queue
Definition keymaps.hpp:35
char scroll_up
Definition keymaps.hpp:17
char seek_ahead_5
Definition keymaps.hpp:29
char toggle_mute
Definition keymaps.hpp:27
char replay_song
Definition keymaps.hpp:33
char vol_down
Definition keymaps.hpp:26
char view_song_queue
Definition keymaps.hpp:38
char view_lyrics
Definition keymaps.hpp:31
char play_song_prev
Definition keymaps.hpp:24
char seek_behind_5
Definition keymaps.hpp:30
char scroll_down
Definition keymaps.hpp:18
char play_song_next
Definition keymaps.hpp:23
char toggle_play
Definition keymaps.hpp:21
char remove_song_from_queue
Definition keymaps.hpp:36
char play_this_song_next
Definition keymaps.hpp:37
char toggle_focus
Definition keymaps.hpp:19
char vol_up
Definition keymaps.hpp:25
char add_song_to_queue
Definition keymaps.hpp:34
char quit_app
Definition keymaps.hpp:28
char view_current_song_info
Definition keymaps.hpp:39
char play_song
Definition keymaps.hpp:22
string_view parseTOMLField(string parent, string field)
Parses a string field from the TOML configuration.
Definition toml_parser.hpp:121
#define PARENT_KEYBINDS
Definition toml_parser.hpp:30