Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8860f83

Browse filesBrowse files
[3.13] gh-119035: Add Ctrl+← and Ctrl+→ word-skipping keybindings to new repl (GH-119248) (#119323)
add word-skipping ctrl keybindings to new repl (cherry picked from commit 0398d93) Co-authored-by: Alastair Stanley <alastairstanley@ntlworld.com>
1 parent 256b791 commit 8860f83
Copy full SHA for 8860f83

File tree

2 files changed

+8
-3
lines changed
Filter options

2 files changed

+8
-3
lines changed

‎Lib/_pyrepl/keymap.py

Copy file name to clipboardExpand all lines: Lib/_pyrepl/keymap.py
+6-3Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,12 @@ def _parse_key1(key, s):
177177
ret = key[s]
178178
s += 1
179179
if ctrl:
180-
if len(ret) > 1:
181-
raise KeySpecError("\\C- must be followed by a character")
182-
ret = chr(ord(ret) & 0x1F) # curses.ascii.ctrl()
180+
if len(ret) == 1:
181+
ret = chr(ord(ret) & 0x1F) # curses.ascii.ctrl()
182+
elif ret in {"left", "right"}:
183+
ret = f"ctrl {ret}"
184+
else:
185+
raise KeySpecError("\\C- followed by invalid key")
183186
if meta:
184187
ret = ["\033", ret]
185188
else:

‎Lib/_pyrepl/reader.py

Copy file name to clipboardExpand all lines: Lib/_pyrepl/reader.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ def make_default_commands() -> dict[CommandName, type[Command]]:
136136
(r"\<up>", "up"),
137137
(r"\<down>", "down"),
138138
(r"\<left>", "left"),
139+
(r"\C-\<left>", "backward-word"),
139140
(r"\<right>", "right"),
141+
(r"\C-\<right>", "forward-word"),
140142
(r"\<delete>", "delete"),
141143
(r"\<backspace>", "backspace"),
142144
(r"\M-\<backspace>", "backward-kill-word"),

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.