https://github.com/python/cpython/commit/8860f83e4b451181e46b0400a4c5019387776b1d
commit: 8860f83e4b451181e46b0400a4c5019387776b1d
branch: 3.13
author: Miss Islington (bot) <[email protected]>
committer: lysnikolaou <[email protected]>
date: 2024-05-21T17:16:06-04:00
summary:

[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 0398d9339217aa0710c0de45a7e9b587136e7129)

Co-authored-by: Alastair Stanley <[email protected]>

files:
M Lib/_pyrepl/keymap.py
M Lib/_pyrepl/reader.py

diff --git a/Lib/_pyrepl/keymap.py b/Lib/_pyrepl/keymap.py
index 31a02642ce8ceb..9f1aff88e06f6a 100644
--- a/Lib/_pyrepl/keymap.py
+++ b/Lib/_pyrepl/keymap.py
@@ -177,9 +177,12 @@ def _parse_key1(key, s):
             ret = key[s]
             s += 1
     if ctrl:
-        if len(ret) > 1:
-            raise KeySpecError("\\C- must be followed by a character")
-        ret = chr(ord(ret) & 0x1F)  # curses.ascii.ctrl()
+        if len(ret) == 1:
+            ret = chr(ord(ret) & 0x1F)  # curses.ascii.ctrl()
+        elif ret in {"left", "right"}:
+            ret = f"ctrl {ret}"
+        else:
+            raise KeySpecError("\\C- followed by invalid key")
     if meta:
         ret = ["\033", ret]
     else:
diff --git a/Lib/_pyrepl/reader.py b/Lib/_pyrepl/reader.py
index d15a150180811d..2c8c9e7dc4b5da 100644
--- a/Lib/_pyrepl/reader.py
+++ b/Lib/_pyrepl/reader.py
@@ -136,7 +136,9 @@ def make_default_commands() -> dict[CommandName, 
type[Command]]:
         (r"\<up>", "up"),
         (r"\<down>", "down"),
         (r"\<left>", "left"),
+        (r"\C-\<left>", "backward-word"),
         (r"\<right>", "right"),
+        (r"\C-\<right>", "forward-word"),
         (r"\<delete>", "delete"),
         (r"\<backspace>", "backspace"),
         (r"\M-\<backspace>", "backward-kill-word"),

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to