GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-128388: pyrepl on Windows: add meta and ctrl+arrow keybindings by paulie4 · Pull Request #128389 · python/cpython gh-128388: pyrepl on Windows: add meta and ctrl+arrow keybindings #128389New issueHave a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community. By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails. Already on GitHub? Sign in to your account
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
283e7c3
pyrepl on Windows: add meta and ctrl+arrow keybindings
paulie4 d3df8a2
📜🤖 Added by blurb_it.
blurb-it[bot] 459b379
`2025-01-01-19-24-43.gh-issue-128388.8UdMz_.rst`: fix typo
paulie4 abe1f62
lint fix `Misc/NEWS.d/next/Library/2025-01-01-19-24-43.gh-issue-12838…
paulie4 3d07c34
`Lib/_pyrepl/windows_console.py`: temp var `ctrlstate` is not needed
paulie4 16f2a13
`Lib/_pyrepl/windows_console.py`: clearer comment
paulie4 e3f6438
PR suggestions
paulie4 46b22d1
`Lib\_pyrepl\windows_console.py`: fix `Alt`+`←` handling
paulie4 55e4fbf
`Lib/_pyrepl/windows_console.py`: standardize `Ctrl`+special key
paulie4 d117d52
Merge branch 'main' into fix-issue-128388
paulie4 File filterConversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page. Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page. Diff viewDiff viewThere are no files selected for viewing
Doesn't look useful, so it's probably best to have Linux-like behaviour here.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand what you are saying. Are you saying because the existing functionality isn't useful, we should continue to make the right Either way, if this is about
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't know that other keyboards have a right ALT key different than AltGr. In this case, I'm fine with
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Sorry for being unclear!
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It's a feature of the keyboard layout, not the physical keyboard. To test it you can add, for example, French "AZERTY" in system settings.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
|
|
CTRL_ACTIVE = 0x04 | 0x08 |
|
|
|
|
|
|
|
|
class _error(Exception): |
|
|
pass |
|
@@ -407,31 +411,37 @@ def get_event(self, block: bool = True) -> Event | None: |
|
|
continue |
|
|
return None |
|
|
|
|
|
key = rec.Event.KeyEvent.uChar.UnicodeChar |
|
|
key_event = rec.Event.KeyEvent |
|
|
raw_key = key = key_event.uChar.UnicodeChar |
|
eendebakpt marked this conversation as resolved.
Resolved
Uh oh!
There was an error while loading. Please reload this page.
|
|
|
|
|
if rec.Event.KeyEvent.uChar.UnicodeChar == "\r": |
|
|
# Make enter make unix-like |
|
|
if key == "\r": |
|
|
# Make enter unix-like |
|
|
return Event(evt="key", data="\n", raw=b"\n") |
|
|
elif rec.Event.KeyEvent.wVirtualKeyCode == 8: |
|
|
elif key_event.wVirtualKeyCode == 8: |
|
|
# Turn backspace directly into the command |
|
|
return Event( |
|
|
evt="key", |
|
|
data="backspace", |
|
|
raw=rec.Event.KeyEvent.uChar.UnicodeChar, |
|
|
) |
|
|
elif rec.Event.KeyEvent.uChar.UnicodeChar == "\x00": |
|
|
key = "backspace" |
|
|
elif key == "\x00": |
|
|
# Handle special keys like arrow keys and translate them into the appropriate command |
|
|
code = VK_MAP.get(rec.Event.KeyEvent.wVirtualKeyCode) |
|
|
if code: |
|
|
return Event( |
|
|
evt="key", data=code, raw=rec.Event.KeyEvent.uChar.UnicodeChar |
|
|
) |
|
|
key = VK_MAP.get(key_event.wVirtualKeyCode) |
|
|
if key: |
|
|
if key_event.dwControlKeyState & CTRL_ACTIVE: |
|
|
key = f"ctrl {key}" |
|
|
elif key_event.dwControlKeyState & ALT_ACTIVE: |
|
|
# queue the key, return the meta command |
|
|
self.event_queue.insert(0, Event(evt="key", data=key, raw=key)) |
|
|
return Event(evt="key", data="\033") # keymap.py uses this for meta |
|
Comment on lines
+431
to
+432
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know the answer. But why pass the ctrl modifier as a key f'ctrl {key}`, and the alt modifier using a special event?
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, it took me a while to figure out what was going on in
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
|
|
return Event(evt="key", data=key, raw=key) |
|
|
if block: |
|
|
continue |
|
|
|
|
|
return None |
|
|
|
|
|
return Event(evt="key", data=key, raw=rec.Event.KeyEvent.uChar.UnicodeChar) |
|
|
if key_event.dwControlKeyState & ALT_ACTIVE: |
|
|
# queue the key, return the meta command |
|
|
self.event_queue.insert(0, Event(evt="key", data=key, raw=raw_key)) |
|
|
return Event(evt="key", data="\033") # keymap.py uses this for meta |
|
paulie4 marked this conversation as resolved.
Resolved
Uh oh!
There was an error while loading. Please reload this page.
|
|
|
|
|
return Event(evt="key", data=key, raw=raw_key) |
|
|
|
|
|
def push_char(self, char: int | bytes) -> None: |
|
|
""" |
|
|
1 change: 1 addition & 0 deletions
1
Misc/NEWS.d/next/Library/2025-01-01-19-24-43.gh-issue-128388.8UdMz_.rst
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||