7#include "keyboard_key.hpp"
10#include "../command.hpp"
11#include "../subsystem.hpp"
12#include <unordered_map>
15namespace hi::inline v1 {
36 void add_system_command(command cmd)
noexcept
39 if (i == system.cend()) {
40 system.push_back(cmd);
45 void add_ignored_command(command cmd)
noexcept
48 if (i == ignored.
cend()) {
54 void add_user_command(command cmd)
noexcept
57 if (i == user.
cend()) {
63 void update_cache()
noexcept
65 cache.
reserve(ssize(system) + ssize(user));
67 for (
hilet cmd : system) {
69 if (i == cache.
cend()) {
74 for (
hilet cmd : ignored) {
76 if (i != cache.
cend()) {
81 for (
hilet cmd : user) {
83 if (i == cache.
cend()) {
97 void add_system_binding(
keyboard_key key, command command)
noexcept
99 bindings[key].add_system_command(command);
102 void add_ignored_binding(
keyboard_key key, command command)
noexcept
104 bindings[key].add_ignored_command(command);
107 void add_user_binding(
keyboard_key key, command command)
noexcept
109 bindings[key].add_user_command(command);
119 if (i != bindings.
cend()) {
120 return i->second.get_commands();
122 return empty_commands;
#define hilet
Invariant should be the default for variables.
Definition required.hpp:23
Functions and macros for handling architectural difference between compilers, CPUs and operating syst...
Definition keyboard_bindings.hpp:17
void load_bindings(URL url, bool system_binding=false)
Load bindings from a JSON file.
std::vector< command > const & translate(keyboard_key key) const noexcept
translate a key press in the empty-context to a command.
Definition keyboard_bindings.hpp:114
void clear() noexcept
Clear all bindings.
Definition keyboard_bindings.hpp:131
A key in combination with modifiers.
Definition keyboard_key.hpp:20