summaryrefslogtreecommitdiff
path: root/Libraries/LibVT
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2020-09-13 21:31:59 -0400
committerAndreas Kling <kling@serenityos.org>2020-09-15 09:45:13 +0200
commit5198eb7c1ce5f11a475a9b8c01cc76cb3d6a7fc8 (patch)
tree3fb7b343bed77d5b89c729f97ce6b2ae5cfbca10 /Libraries/LibVT
parentd7539cf49733157c481f438f83b317745450cbd2 (diff)
downloadserenity-5198eb7c1ce5f11a475a9b8c01cc76cb3d6a7fc8.zip
LibVT: Use xterm modifier scheme for tilde keys too
Diffstat (limited to 'Libraries/LibVT')
-rw-r--r--Libraries/LibVT/Terminal.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/Libraries/LibVT/Terminal.cpp b/Libraries/LibVT/Terminal.cpp
index 1b7aeee0f2..1dfe2aaf08 100644
--- a/Libraries/LibVT/Terminal.cpp
+++ b/Libraries/LibVT/Terminal.cpp
@@ -1034,6 +1034,12 @@ void Terminal::handle_key_press(KeyCode key, u32 code_point, u8 flags)
else
emit_string(String::format("\e[%c", final));
};
+ auto emit_tilde_with_modifier = [this, modifier_mask](unsigned num) {
+ if (modifier_mask)
+ emit_string(String::format("\e[%d;%d~", num, modifier_mask + 1));
+ else
+ emit_string(String::format("\e[%d~", num));
+ };
switch (key) {
case KeyCode::Key_Up:
@@ -1049,10 +1055,10 @@ void Terminal::handle_key_press(KeyCode key, u32 code_point, u8 flags)
emit_final_with_modifier('D');
return;
case KeyCode::Key_Insert:
- emit_string("\033[2~");
+ emit_tilde_with_modifier(2);
return;
case KeyCode::Key_Delete:
- emit_string("\033[3~");
+ emit_tilde_with_modifier(3);
return;
case KeyCode::Key_Home:
emit_final_with_modifier('H');
@@ -1061,10 +1067,10 @@ void Terminal::handle_key_press(KeyCode key, u32 code_point, u8 flags)
emit_final_with_modifier('F');
return;
case KeyCode::Key_PageUp:
- emit_string("\033[5~");
+ emit_tilde_with_modifier(5);
return;
case KeyCode::Key_PageDown:
- emit_string("\033[6~");
+ emit_tilde_with_modifier(6);
return;
default:
break;