Fix update_encoding() not filtering GLFW_KEY_LAST_PRINTABLE

b3b830bb5ffb8f42d5e2367e5aab03579be3a45f did not actually make `update_encoding()` filter `GLFW_KEY_LAST_PRINTABLE` because `name` contained the key name after applying `symbolic_name()`, which replaces underscores with spaces. Instead of replacing the underscore in `LAST_PRINTABLE` with a space, I moved the check above the call to `symbolic_name()`. This is more readable and future-proof in my opinion.
This commit is contained in:
Luflosi 2019-09-02 23:04:10 +02:00
parent 70c2765a6e
commit 7c52dd2bd8
No known key found for this signature in database
GPG Key ID: 14140F703B7D8362

6
kitty/key_encoding.py generated
View File

@ -296,11 +296,11 @@ def update_encoding():
key_map = {}
i = len(ans)
for k in sorted(keys, key=lambda k: getattr(defines, k)):
if k in ('GLFW_KEY_LAST', 'GLFW_KEY_LAST_PRINTABLE'):
continue
val = getattr(defines, k)
name = symbolic_name(k)
if val <= defines.GLFW_KEY_LAST and name not in (
'LAST', 'LAST_PRINTABLE'
) and val != defines.GLFW_KEY_UNKNOWN:
if val <= defines.GLFW_KEY_LAST and val != defines.GLFW_KEY_UNKNOWN:
if name not in ans:
ans[name] = encode(i)
i += 1