Skip to content

Commit

Permalink
[3.13] pythongh-124027: Support Del, PgUp, and PgDn on TERM=vt100 (py…
Browse files Browse the repository at this point in the history
…thonGH-124028) (python#124029)

pythongh-124027: Support Del, PgUp, and PgDn on TERM=vt100 (pythonGH-124028)

pyrepl: Support Del, PgUp, and PgDn on TERM=vt100

From Fedora's /etc/inputrc:

    "\e[5~": history-search-backward
    "\e[6~": history-search-forward
    "\e[3~": delete-char

Fixes python#124027
(cherry picked from commit f4e5643)

Co-authored-by: Miro Hrončok <miro@hroncok.cz>
  • Loading branch information
miss-islington and hroncok committed Sep 13, 2024
1 parent 660baa1 commit 112b170
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Lib/_pyrepl/historical_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,9 @@ def collect_keymap(self) -> tuple[tuple[KeySpec, CommandName], ...]:
(r"\M-r", "restore-history"),
(r"\M-.", "yank-arg"),
(r"\<page down>", "history-search-forward"),
(r"\x1b[6~", "history-search-forward"),
(r"\<page up>", "history-search-backward"),
(r"\x1b[5~", "history-search-backward"),
)

def select_item(self, i: int) -> None:
Expand Down
1 change: 1 addition & 0 deletions Lib/_pyrepl/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ def make_default_commands() -> dict[CommandName, type[Command]]:
(r"\<right>", "right"),
(r"\C-\<right>", "forward-word"),
(r"\<delete>", "delete"),
(r"\x1b[3~", "delete"),
(r"\<backspace>", "backspace"),
(r"\M-\<backspace>", "backward-kill-word"),
(r"\<end>", "end-of-line"), # was 'end'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Support ``<page up>``, ``<page down>``, and ``<delete>`` keys in the Python
REPL when ``$TERM`` is set to ``vt100``.

0 comments on commit 112b170

Please sign in to comment.