feat: map kp_ movement keys as regular keys if the kp_ variants are not explicitly mapped
This makes it possible to use keypad movements without duplicating keybinds.
This commit is contained in:
parent
6633dd1c0e
commit
93c2c87632
1 changed files with 12 additions and 1 deletions
|
|
@ -435,11 +435,22 @@ pub const Binding = struct {
|
|||
if (self.key_events.len == 0) return .match_impossible;
|
||||
for (self.key_events, 0..) |key_event, i| {
|
||||
if (match_key_events.len <= i) return .match_possible;
|
||||
if (!(key_event.eql(match_key_events[i]) or key_event.eql_unshifted(match_key_events[i])))
|
||||
if (!keyevents_eql(key_event, match_key_events[i]))
|
||||
return .match_impossible;
|
||||
}
|
||||
return if (self.key_events.len == match_key_events.len) .matched else .match_possible;
|
||||
}
|
||||
|
||||
fn keyevents_eql(lhs: KeyEvent, rhs: KeyEvent) bool {
|
||||
if (lhs.eql(rhs) or lhs.eql_unshifted(rhs)) return true;
|
||||
if (input.map_non_input_kp_key_to_regular_key(rhs.key)) |key| {
|
||||
var mapped = rhs;
|
||||
mapped.key = key;
|
||||
mapped.key_unshifted = key;
|
||||
if (lhs.eql(mapped) or lhs.eql_unshifted(mapped)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
pub const KeybindHints = std.StringHashMapUnmanaged([]u8);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue