inLimbo
TUI Music Player that keeps you in Limbo.
 
Loading...
Searching...
No Matches
keymaps.hpp File Reference
#include "../parser/toml_parser.hpp"
#include <cstdlib>
#include <iostream>
#include <string_view>
#include <unordered_map>

Go to the source code of this file.

Classes

struct  Keybinds
 Struct to hold keybinding mappings. More...
 

Functions

Keybinds parseKeybinds ()
 Parses the keybinds from the TOML configuration.
 

Function Documentation

◆ parseKeybinds()

Keybinds parseKeybinds ( )

Parses the keybinds from the TOML configuration.

This function reads the keybind configurations from the TOML file, maps them to their respective key values, and returns a populated Keybinds struct.

Returns
A Keybinds struct with the key mappings for various actions.

< Special key for Tab

< Special key for Space

< Special key for Enter

< Special key for Escape

Reports an error for unsupported or empty keybind.

This lambda function prints an error message and terminates the program if an unsupported or empty keybind is detected in the configuration.

Parameters
fieldThe field in which the invalid keybind was found.
keyThe keybind that was invalid or empty.

< Exit the program on invalid keybind

Handles the mapping of special keys and single-character keys.

This lambda function checks whether a keybind is a special key (e.g., Tab, Enter) or a single character, and returns the corresponding ASCII value. It reports an error if the key is invalid or unsupported.

Parameters
keyThe keybind to be processed.
fieldThe field name that the keybind belongs to.
Returns
The ASCII value of the key.

< Report error if key is empty

< Return the mapped special key

< Report error if the key is not supported

< Handle each keybind

< Return the populated Keybinds struct