16class keyboard_bindings {
35 void add_system_command(gui_event_type cmd)
noexcept
37 hilet i =
std::find(system.cbegin(), system.cend(), cmd);
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()) {
94 keyboard_bindings() noexcept : bindings() {}
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) {
119 hilet i = bindings.find(
keyboard_key{
event.keyboard_modifiers,
event.key()});
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);
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