mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-06-27 19:31:46 +00:00
Dont encode enter, tab and backspace when lock mods are set
Otherwise user cant type reset when num lock is set.
This commit is contained in:
parent
f13ee32c3c
commit
dd249df5eb
2 changed files with 12 additions and 0 deletions
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
typedef enum { SHIFT=1, ALT=2, CTRL=4, SUPER=8, HYPER=16, META=32, CAPS_LOCK=64, NUM_LOCK=128} ModifierMasks;
|
||||
typedef enum { PRESS = 0, REPEAT = 1, RELEASE = 2} KeyAction;
|
||||
#define LOCK_MASK (CAPS_LOCK | NUM_LOCK)
|
||||
typedef struct {
|
||||
uint32_t key, shifted_key, alternate_key;
|
||||
struct {
|
||||
|
|
@ -186,6 +187,14 @@ encode_function_key(const KeyEvent *ev, char *output) {
|
|||
int num = legacy_functional_key_encoding_with_modifiers(key_number, ev, output);
|
||||
if (num > -1) return num;
|
||||
}
|
||||
if (!(ev->mods.value & ~LOCK_MASK) && !ev->report_text) {
|
||||
switch(key_number) {
|
||||
case GLFW_FKEY_ENTER: if (ev->action == RELEASE) return -1; SIMPLE("\r");
|
||||
case GLFW_FKEY_BACKSPACE: if (ev->action == RELEASE) return -1; SIMPLE("\x7f");
|
||||
case GLFW_FKEY_TAB: if (ev->action == RELEASE) return -1; SIMPLE("\t");
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
#undef SIMPLE
|
||||
#define S(number, trailer) key_number = number; csi_trailer = trailer; break
|
||||
switch(key_number) {
|
||||
|
|
|
|||
|
|
@ -441,6 +441,9 @@ class TestKeys(BaseTest):
|
|||
tq = partial(enc, key_encoding_flags=0b11)
|
||||
ae(tq(defines.GLFW_FKEY_BACKSPACE), '\x7f')
|
||||
ae(tq(defines.GLFW_FKEY_BACKSPACE, action=release), '')
|
||||
tq = partial(enc, key_encoding_flags=0b11, mods=num_lock|caps_lock)
|
||||
ae(tq(defines.GLFW_FKEY_ENTER), '\r')
|
||||
ae(tq(defines.GLFW_FKEY_ENTER, action=release), '')
|
||||
|
||||
# test alternate key reporting
|
||||
aq = partial(enc, key_encoding_flags=0b100)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue