From 1ee1f7841ce23e163735195ad1b9583eee4a8029 Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Thu, 23 Nov 2023 13:59:30 +0000 Subject: [PATCH 1/6] Add ctrl+up and ctrl+down for rxvt --- src/textual/_ansi_sequences.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/textual/_ansi_sequences.py b/src/textual/_ansi_sequences.py index ac8b94f2ee..0abfd56e8c 100644 --- a/src/textual/_ansi_sequences.py +++ b/src/textual/_ansi_sequences.py @@ -238,8 +238,11 @@ "\x1b[5B": (Keys.ControlDown,), "\x1b[5C": (Keys.ControlRight,), "\x1b[5D": (Keys.ControlLeft,), - "\x1bOc": (Keys.ControlRight,), # rxvt - "\x1bOd": (Keys.ControlLeft,), # rxvt + # Control allow 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,), From 721269557ec8416b23ade6fd1c5d369d16298688 Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Thu, 23 Nov 2023 14:21:49 +0000 Subject: [PATCH 2/6] Add shifted navigation keys for rxvt --- src/textual/_ansi_sequences.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/textual/_ansi_sequences.py b/src/textual/_ansi_sequences.py index 0abfd56e8c..859e8293d7 100644 --- a/src/textual/_ansi_sequences.py +++ b/src/textual/_ansi_sequences.py @@ -200,6 +200,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 From 61c7703b27088e63679e3ae040f394ae17c493af Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Thu, 23 Nov 2023 14:29:37 +0000 Subject: [PATCH 3/6] Add modified delete keys for rxvt --- src/textual/_ansi_sequences.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/textual/_ansi_sequences.py b/src/textual/_ansi_sequences.py index 859e8293d7..6d3b3d6efa 100644 --- a/src/textual/_ansi_sequences.py +++ b/src/textual/_ansi_sequences.py @@ -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), @@ -163,6 +164,7 @@ "\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[3;6~": (Keys.ControlShiftDelete,), From ed14269995cd4954ac5fab962942205ba6944ba2 Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Thu, 23 Nov 2023 14:36:04 +0000 Subject: [PATCH 4/6] Fix a typo --- src/textual/_ansi_sequences.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/textual/_ansi_sequences.py b/src/textual/_ansi_sequences.py index 6d3b3d6efa..7a09ba09b1 100644 --- a/src/textual/_ansi_sequences.py +++ b/src/textual/_ansi_sequences.py @@ -247,7 +247,7 @@ "\x1b[5B": (Keys.ControlDown,), "\x1b[5C": (Keys.ControlRight,), "\x1b[5D": (Keys.ControlLeft,), - # Control allow keys in rxvt + # Control arrow keys in rxvt "\x1bOa": (Keys.ControlUp,), "\x1bOb": (Keys.ControlUp,), "\x1bOc": (Keys.ControlRight,), From 3b89363ece782f0436f75f31498d4cbf65efa789 Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Thu, 23 Nov 2023 14:37:09 +0000 Subject: [PATCH 5/6] Add ctrl+home and ctrl+end support for rxvt --- src/textual/_ansi_sequences.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/textual/_ansi_sequences.py b/src/textual/_ansi_sequences.py index 7a09ba09b1..43b7102c89 100644 --- a/src/textual/_ansi_sequences.py +++ b/src/textual/_ansi_sequences.py @@ -240,6 +240,9 @@ "\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. From dac9ab0c6b524d2fcc244b40e720ec0ee01f94be Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Thu, 23 Nov 2023 14:39:26 +0000 Subject: [PATCH 6/6] Add support for ctrl+pgup/dn under rxvt --- src/textual/_ansi_sequences.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/textual/_ansi_sequences.py b/src/textual/_ansi_sequences.py index 43b7102c89..13280943a9 100644 --- a/src/textual/_ansi_sequences.py +++ b/src/textual/_ansi_sequences.py @@ -167,6 +167,8 @@ "\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,),