mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 19:27:45 +00:00
LibVT/LibLine: Delete words when pressing Ctrl+Backspace in Terminal
This commit is contained in:
parent
f7a252ae85
commit
7aabda37d1
2 changed files with 17 additions and 0 deletions
|
@ -986,6 +986,12 @@ void Editor::handle_read_event()
|
||||||
case 'F': // ^[[F: end
|
case 'F': // ^[[F: end
|
||||||
go_end();
|
go_end();
|
||||||
continue;
|
continue;
|
||||||
|
case 127:
|
||||||
|
if (modifiers == CSIMod::Ctrl)
|
||||||
|
erase_alnum_word_backwards();
|
||||||
|
else
|
||||||
|
erase_character_backwards();
|
||||||
|
continue;
|
||||||
case '~':
|
case '~':
|
||||||
if (param1 == 3) { // ^[[3~: delete
|
if (param1 == 3) { // ^[[3~: delete
|
||||||
if (modifiers == CSIMod::Ctrl)
|
if (modifiers == CSIMod::Ctrl)
|
||||||
|
|
|
@ -1378,6 +1378,17 @@ void Terminal::handle_key_press(KeyCode key, u32 code_point, u8 flags)
|
||||||
case KeyCode::Key_PageDown:
|
case KeyCode::Key_PageDown:
|
||||||
emit_tilde_with_modifier(6);
|
emit_tilde_with_modifier(6);
|
||||||
return;
|
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:
|
case KeyCode::Key_Return:
|
||||||
// The standard says that CR should be generated by the return key.
|
// 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.
|
// The TTY will take care of translating it to CR LF for the terminal.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue