diff options
author | Zaggy1024 <zaggy1024@gmail.com> | 2022-11-16 04:40:11 -0600 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2022-11-20 03:57:17 +0330 |
commit | 7aabda37d1bca75e15ddd2c926b87a01cd2b67f4 (patch) | |
tree | 41cd5611a4e6bab7d678703927e5dd0ce2f47b4d /Userland/Libraries/LibVT/Terminal.cpp | |
parent | f7a252ae85306bf4750419e9e65a5a5e2a406772 (diff) | |
download | serenity-7aabda37d1bca75e15ddd2c926b87a01cd2b67f4.zip |
LibVT/LibLine: Delete words when pressing Ctrl+Backspace in Terminal
Diffstat (limited to 'Userland/Libraries/LibVT/Terminal.cpp')
-rw-r--r-- | Userland/Libraries/LibVT/Terminal.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Userland/Libraries/LibVT/Terminal.cpp b/Userland/Libraries/LibVT/Terminal.cpp index 829bd5ce48..865c532593 100644 --- a/Userland/Libraries/LibVT/Terminal.cpp +++ b/Userland/Libraries/LibVT/Terminal.cpp @@ -1378,6 +1378,17 @@ void Terminal::handle_key_press(KeyCode key, u32 code_point, u8 flags) case KeyCode::Key_PageDown: emit_tilde_with_modifier(6); return; + case KeyCode::Key_Backspace: + if (ctrl) { + // This is an extension that allows Editor.cpp to delete whole words when + // Ctrl+Backspace is pressed. Ctrl cannot be transmitted without a CSI, and + // ANSI delete (127) is within the valid range for CSI codes in Editor.cpp. + // The code also has the same behavior as backspace when emitted with no CSI, + // though the backspace code (8) is preserved when Ctrl is not pressed. + emit_final_with_modifier(127); + return; + } + break; case KeyCode::Key_Return: // The standard says that CR should be generated by the return key. // The TTY will take care of translating it to CR LF for the terminal. |