Skip to content

Commit 68e5b8e

Browse files
Added more vt100 ANSI sequences:
- shift + escape - control + home/end - shift + home/end - shift + control + left/right/up/down/home/end
1 parent 411b8e7 commit 68e5b8e

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

prompt_toolkit/input/ansi_escape_sequences.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"\x19": Keys.ControlY, # Control-Y (25)
4343
"\x1a": Keys.ControlZ, # Control-Z
4444
"\x1b": Keys.Escape, # Also Control-[
45+
"\x9b": Keys.ShiftEscape,
4546
"\x1c": Keys.ControlBackslash, # Both Control-\ (also Ctrl-| )
4647
"\x1d": Keys.ControlSquareClose, # Control-]
4748
"\x1e": Keys.ControlCircumflex, # Control-^
@@ -119,10 +120,14 @@
119120
"\x1b[1;5B": Keys.ControlDown, # Cursor Mode
120121
"\x1b[1;5C": Keys.ControlRight, # Cursor Mode
121122
"\x1b[1;5D": Keys.ControlLeft, # Cursor Mode
123+
"\x1b[1;5H": Keys.ControlHome,
124+
"\x1b[1;5F": Keys.ControlEnd,
122125
"\x1b[1;2A": Keys.ShiftUp,
123126
"\x1b[1;2B": Keys.ShiftDown,
124127
"\x1b[1;2C": Keys.ShiftRight,
125128
"\x1b[1;2D": Keys.ShiftLeft,
129+
"\x1b[1;2H": Keys.ShiftHome,
130+
"\x1b[1;2F": Keys.ShiftEnd,
126131
# Tmux sends following keystrokes when control+arrow is pressed, but for
127132
# Emacs ansi-term sends the same sequences for normal arrow keys. Consider
128133
# it a normal arrow press, because that's more important.
@@ -170,6 +175,13 @@
170175
"\x1b[6;3~": (Keys.Escape, Keys.PageDown),
171176
"\x1b[2;3~": (Keys.Escape, Keys.Insert),
172177
"\x1b[3;3~": (Keys.Escape, Keys.Delete),
178+
# Control+Shift in mintty/wsltty
179+
"\x1b[1;6D": Keys.ShiftControlLeft,
180+
"\x1b[1;6C": Keys.ShiftControlRight,
181+
"\x1b[1;6B": Keys.ShiftControlUp,
182+
"\x1b[1;6A": Keys.ShiftControlDown,
183+
"\x1b[1;6H": Keys.ShiftControlHome,
184+
"\x1b[1;6F": Keys.ShiftControlEnd,
173185
}
174186

175187

prompt_toolkit/keys.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class Keys(str, Enum):
1818
value: str
1919

2020
Escape = "escape" # Also Control-[
21+
ShiftEscape = "s-escape"
2122

2223
ControlAt = "c-@" # Also Control-Space.
2324

@@ -63,6 +64,8 @@ class Keys(str, Enum):
6364

6465
ShiftControlLeft = "s-c-left"
6566
ShiftControlRight = "s-c-right"
67+
ShiftControlUp = "s-c-up"
68+
ShiftControlDown = "s-c-down"
6669
ShiftControlHome = "s-c-home"
6770
ShiftControlEnd = "s-c-end"
6871

0 commit comments

Comments
 (0)