Skip to content
New issue

Have 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

Add support for various modified navigation/edit keys under rxvt #3739

Merged
merged 6 commits into from
Nov 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/textual/_ansi_sequences.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@
# --
# Meta/control/escape + pageup/pagedown/insert/delete.
"\x1b[3;2~": (Keys.ShiftDelete,), # xterm, gnome-terminal.
"\x1b[3$": (Keys.ShiftDelete,), # rxvt
"\x1b[5;2~": (Keys.ShiftPageUp,),
"\x1b[6;2~": (Keys.ShiftPageDown,),
"\x1b[2;3~": (Keys.Escape, Keys.Insert),
Expand All @@ -163,8 +164,11 @@
"\x1b[5;4~": (Keys.Escape, Keys.ShiftPageUp),
"\x1b[6;4~": (Keys.Escape, Keys.ShiftPageDown),
"\x1b[3;5~": (Keys.ControlDelete,), # xterm, gnome-terminal.
"\x1b[3^": (Keys.ControlDelete,), # rxvt
"\x1b[5;5~": (Keys.ControlPageUp,),
"\x1b[6;5~": (Keys.ControlPageDown,),
"\x1b[5^": (Keys.ControlPageUp,), # rxvt
"\x1b[6^": (Keys.ControlPageDown,), # rxvt
"\x1b[3;6~": (Keys.ControlShiftDelete,),
"\x1b[5;6~": (Keys.ControlShiftPageUp,),
"\x1b[6;6~": (Keys.ControlShiftPageDown,),
Expand Down Expand Up @@ -200,6 +204,13 @@
"\x1b[1;2D": (Keys.ShiftLeft,),
"\x1b[1;2F": (Keys.ShiftEnd,),
"\x1b[1;2H": (Keys.ShiftHome,),
# Shift+navigation in rxvt
"\x1b[a": (Keys.ShiftUp,),
"\x1b[b": (Keys.ShiftDown,),
"\x1b[c": (Keys.ShiftRight,),
"\x1b[d": (Keys.ShiftLeft,),
"\x1b[7$": (Keys.ShiftHome,),
"\x1b[8$": (Keys.ShiftEnd,),
# Meta + arrow keys. Several terminals handle this differently.
# The following sequences are for xterm and gnome-terminal.
# (Iterm sends ESC followed by the normal arrow_up/down/left/right
Expand Down Expand Up @@ -231,15 +242,21 @@
"\x1bb": (Keys.ControlLeft,), # iTerm natural editing keys
"\x1b[1;5F": (Keys.ControlEnd,),
"\x1b[1;5H": (Keys.ControlHome,),
# rxvt
"\x1b[7^": (Keys.ControlEnd,),
"\x1b[8^": (Keys.ControlHome,),
# Tmux sends following keystrokes when control+arrow is pressed, but for
# Emacs ansi-term sends the same sequences for normal arrow keys. Consider
# it a normal arrow press, because that's more important.
"\x1b[5A": (Keys.ControlUp,),
"\x1b[5B": (Keys.ControlDown,),
"\x1b[5C": (Keys.ControlRight,),
"\x1b[5D": (Keys.ControlLeft,),
"\x1bOc": (Keys.ControlRight,), # rxvt
"\x1bOd": (Keys.ControlLeft,), # rxvt
# Control arrow keys in rxvt
"\x1bOa": (Keys.ControlUp,),
"\x1bOb": (Keys.ControlUp,),
"\x1bOc": (Keys.ControlRight,),
"\x1bOd": (Keys.ControlLeft,),
# Control + shift + arrows.
"\x1b[1;6A": (Keys.ControlShiftUp,),
"\x1b[1;6B": (Keys.ControlShiftDown,),
Expand Down
Loading