mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
GH-132439: Fix REPL swallowing characters entered with AltGr on cmd.exe (GH-132440)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
This commit is contained in:
parent
b6c2ef0c7a
commit
07f416a3f0
3 changed files with 233 additions and 8 deletions
|
@ -464,7 +464,7 @@ class WindowsConsole(Console):
|
|||
|
||||
if key == "\r":
|
||||
# Make enter unix-like
|
||||
return Event(evt="key", data="\n", raw=b"\n")
|
||||
return Event(evt="key", data="\n")
|
||||
elif key_event.wVirtualKeyCode == 8:
|
||||
# Turn backspace directly into the command
|
||||
key = "backspace"
|
||||
|
@ -476,9 +476,9 @@ class WindowsConsole(Console):
|
|||
key = f"ctrl {key}"
|
||||
elif key_event.dwControlKeyState & ALT_ACTIVE:
|
||||
# queue the key, return the meta command
|
||||
self.event_queue.insert(Event(evt="key", data=key, raw=key))
|
||||
self.event_queue.insert(Event(evt="key", data=key))
|
||||
return Event(evt="key", data="\033") # keymap.py uses this for meta
|
||||
return Event(evt="key", data=key, raw=key)
|
||||
return Event(evt="key", data=key)
|
||||
if block:
|
||||
continue
|
||||
|
||||
|
@ -490,11 +490,15 @@ class WindowsConsole(Console):
|
|||
continue
|
||||
|
||||
if key_event.dwControlKeyState & ALT_ACTIVE:
|
||||
# queue the key, return the meta command
|
||||
self.event_queue.insert(Event(evt="key", data=key, raw=raw_key))
|
||||
return Event(evt="key", data="\033") # keymap.py uses this for meta
|
||||
# Do not swallow characters that have been entered via AltGr:
|
||||
# Windows internally converts AltGr to CTRL+ALT, see
|
||||
# https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-vkkeyscanw
|
||||
if not key_event.dwControlKeyState & CTRL_ACTIVE:
|
||||
# queue the key, return the meta command
|
||||
self.event_queue.insert(Event(evt="key", data=key))
|
||||
return Event(evt="key", data="\033") # keymap.py uses this for meta
|
||||
|
||||
return Event(evt="key", data=key, raw=raw_key)
|
||||
return Event(evt="key", data=key)
|
||||
return self.event_queue.get()
|
||||
|
||||
def push_char(self, char: int | bytes) -> None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue