7#include "keyboard_key.hpp"
9#include "../utility/module.hpp"
10#include <unordered_map>
14namespace hi::inline
v1 {
35 void add_system_command(gui_event_type cmd)
noexcept
38 if (i == system.cend()) {
39 system.push_back(cmd);
44 void add_ignored_command(gui_event_type cmd)
noexcept
47 if (i == ignored.
cend()) {
53 void add_user_command(gui_event_type cmd)
noexcept
56 if (i == user.
cend()) {
62 void update_cache()
noexcept
64 cache.
reserve(ssize(system) + ssize(user));
66 for (
hilet cmd : system) {
68 if (i == cache.
cend()) {
73 for (
hilet cmd : ignored) {
75 if (i != cache.
cend()) {
80 for (
hilet cmd : user) {
82 if (i == cache.
cend()) {
96 void add_system_binding(
keyboard_key key, gui_event_type command)
noexcept
98 bindings[key].add_system_command(command);
101 void add_ignored_binding(
keyboard_key key, gui_event_type command)
noexcept
103 bindings[key].add_ignored_command(command);
106 void add_user_binding(
keyboard_key key, gui_event_type command)
noexcept
108 bindings[key].add_user_command(command);
118 if (event == gui_event_type::keyboard_down) {
120 if (i != bindings.
cend()) {
121 hilet& new_events = i->second.get_events();
122 events.insert(events.cend(), new_events.cbegin(), new_events.cend());
139 void load_bindings(std::filesystem::path
const &path,
bool system_binding =
false);
Definition of GUI event types.
#define hilet
Invariant should be the default for variables.
Definition utility.hpp:23
DOXYGEN BUG.
Definition algorithm.hpp:13
Definition keyboard_bindings.hpp:16
void translate(gui_event event, std::vector< gui_event > &events) const noexcept
translate a key press in the empty-context to a command.
Definition keyboard_bindings.hpp:116
void clear() noexcept
Clear all bindings.
Definition keyboard_bindings.hpp:132
void load_bindings(std::filesystem::path const &path, bool system_binding=false)
Load bindings from a JSON file.
A key in combination with modifiers.
Definition keyboard_key.hpp:19
T emplace_back(T... args)