mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-24 09:18:08 +02: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:
@@ -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 { 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;
|
typedef enum { PRESS = 0, REPEAT = 1, RELEASE = 2} KeyAction;
|
||||||
|
#define LOCK_MASK (CAPS_LOCK | NUM_LOCK)
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t key, shifted_key, alternate_key;
|
uint32_t key, shifted_key, alternate_key;
|
||||||
struct {
|
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);
|
int num = legacy_functional_key_encoding_with_modifiers(key_number, ev, output);
|
||||||
if (num > -1) return num;
|
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
|
#undef SIMPLE
|
||||||
#define S(number, trailer) key_number = number; csi_trailer = trailer; break
|
#define S(number, trailer) key_number = number; csi_trailer = trailer; break
|
||||||
switch(key_number) {
|
switch(key_number) {
|
||||||
|
|||||||
@@ -441,6 +441,9 @@ class TestKeys(BaseTest):
|
|||||||
tq = partial(enc, key_encoding_flags=0b11)
|
tq = partial(enc, key_encoding_flags=0b11)
|
||||||
ae(tq(defines.GLFW_FKEY_BACKSPACE), '\x7f')
|
ae(tq(defines.GLFW_FKEY_BACKSPACE), '\x7f')
|
||||||
ae(tq(defines.GLFW_FKEY_BACKSPACE, action=release), '')
|
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
|
# test alternate key reporting
|
||||||
aq = partial(enc, key_encoding_flags=0b100)
|
aq = partial(enc, key_encoding_flags=0b100)
|
||||||
|
|||||||
Reference in New Issue
Block a user