Fix #3471
This commit is contained in:
parent
1aeafcaebf
commit
a7c5b8c634
2 changed files with 4 additions and 2 deletions
|
|
@ -296,10 +296,10 @@ ctrled_key(const char key) { // {{{
|
|||
|
||||
static int
|
||||
encode_printable_ascii_key_legacy(const KeyEvent *ev, char *output) {
|
||||
if (!ev->mods.value) return snprintf(output, KEY_BUFFER_SIZE, "%c", (char)ev->key);
|
||||
unsigned mods = ev->mods.value & ~(GLFW_MOD_NUM_LOCK | GLFW_MOD_CAPS_LOCK);
|
||||
if (!mods) return snprintf(output, KEY_BUFFER_SIZE, "%c", (char)ev->key);
|
||||
|
||||
char key = ev->key;
|
||||
unsigned mods = ev->mods.value;
|
||||
if (mods & SHIFT) {
|
||||
const char shifted = ev->shifted_key;
|
||||
if (shifted && shifted != key && (!(mods & CTRL) || key < 'a' || key > 'z')) {
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ def test_encode_key_event(self):
|
|||
enc = defines.encode_key_for_tty
|
||||
ae = self.assertEqual
|
||||
shift, alt, ctrl, super, hyper, meta = defines.GLFW_MOD_SHIFT, defines.GLFW_MOD_ALT, defines.GLFW_MOD_CONTROL, defines.GLFW_MOD_SUPER, defines.GLFW_MOD_HYPER, defines.GLFW_MOD_META # noqa
|
||||
num_lock, caps_lock = defines.GLFW_MOD_NUM_LOCK, defines.GLFW_MOD_CAPS_LOCK
|
||||
press, repeat, release = defines.GLFW_PRESS, defines.GLFW_REPEAT, defines.GLFW_RELEASE # noqa
|
||||
|
||||
def csi(mods=0, num=1, action=1, shifted_key=0, alternate_key=0, text=None, trailer='u'):
|
||||
|
|
@ -398,6 +399,7 @@ def mkp(name, *a, **kw):
|
|||
for key in '~!@#$%^&*()_+{}|:"<>?':
|
||||
ae(enc(key=ord(key), mods=alt), '\x1b' + key)
|
||||
ae(enc(key=ord(' ')), ' ')
|
||||
ae(enc(key=ord(' '), mods=ctrl | num_lock | caps_lock), '\0')
|
||||
ae(enc(key=ord(' '), mods=ctrl), '\0')
|
||||
ae(enc(key=ord(' '), mods=alt), '\x1b ')
|
||||
ae(enc(key=ord(' '), mods=shift), ' ')
|
||||
|
|
|
|||
Loading…
Reference in a new issue