mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-28 03:01:57 +02:00
Fix alt+key resulting in the upper case version of key even when shift is not pressed
Fixes #78
This commit is contained in:
@@ -271,12 +271,13 @@ class Boss(Thread):
|
|||||||
|
|
||||||
@callback
|
@callback
|
||||||
def on_text_input(self, window, codepoint, mods):
|
def on_text_input(self, window, codepoint, mods):
|
||||||
data = interpret_text_event(codepoint, mods)
|
w = self.active_window
|
||||||
if data:
|
if w is not None:
|
||||||
w = self.active_window
|
yield w
|
||||||
if w is not None:
|
if w is not None:
|
||||||
yield w
|
data = interpret_text_event(codepoint, mods, w)
|
||||||
w.write_to_child(data)
|
if data:
|
||||||
|
w.write_to_child(data)
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def on_key(self, window, key, scancode, action, mods):
|
def on_key(self, window, key, scancode, action, mods):
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ alt_codes = {
|
|||||||
range(defines.GLFW_KEY_SPACE, defines.GLFW_KEY_RIGHT_BRACKET + 1)
|
range(defines.GLFW_KEY_SPACE, defines.GLFW_KEY_RIGHT_BRACKET + 1)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
alt_mods = (defines.GLFW_MOD_ALT, defines.GLFW_MOD_SHIFT | defines.GLFW_MOD_ALT)
|
||||||
|
|
||||||
rmkx_key_map = smkx_key_map.copy()
|
rmkx_key_map = smkx_key_map.copy()
|
||||||
rmkx_key_map.update({
|
rmkx_key_map.update({
|
||||||
@@ -143,9 +144,9 @@ def interpret_key_event(key, scancode, mods, window, action):
|
|||||||
if mods == defines.GLFW_MOD_CONTROL and key in control_codes:
|
if mods == defines.GLFW_MOD_CONTROL and key in control_codes:
|
||||||
# Map Ctrl-key to ascii control code
|
# Map Ctrl-key to ascii control code
|
||||||
data.extend(control_codes[key])
|
data.extend(control_codes[key])
|
||||||
elif mods == defines.GLFW_MOD_ALT and key in alt_codes:
|
elif mods in alt_mods and key in alt_codes:
|
||||||
# Map Alt+key to Esc-key
|
# Handled by interpret text event
|
||||||
data.extend(alt_codes[key])
|
pass
|
||||||
else:
|
else:
|
||||||
key_map = get_key_map(screen)
|
key_map = get_key_map(screen)
|
||||||
x = key_map.get(key)
|
x = key_map.get(key)
|
||||||
@@ -156,8 +157,13 @@ def interpret_key_event(key, scancode, mods, window, action):
|
|||||||
return bytes(data)
|
return bytes(data)
|
||||||
|
|
||||||
|
|
||||||
def interpret_text_event(codepoint, mods):
|
def interpret_text_event(codepoint, mods, window):
|
||||||
|
screen = window.screen
|
||||||
if mods > defines.GLFW_MOD_SHIFT:
|
if mods > defines.GLFW_MOD_SHIFT:
|
||||||
|
if mods in alt_mods and not screen.extended_keyboard:
|
||||||
|
data = chr(codepoint).encode('utf-8')
|
||||||
|
if len(data) == 1:
|
||||||
|
return b'\x1b' + data
|
||||||
return b'' # Handled by interpret_key_event above
|
return b'' # Handled by interpret_key_event above
|
||||||
data = chr(codepoint).encode('utf-8')
|
data = chr(codepoint).encode('utf-8')
|
||||||
return data
|
return data
|
||||||
|
|||||||
Reference in New Issue
Block a user