summaryrefslogtreecommitdiff
path: root/Libraries/LibLine/Editor.cpp
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2020-08-06 11:46:45 -0400
committerAndreas Kling <kling@serenityos.org>2020-08-06 19:03:06 +0200
commitf29c5c3a416bd62298cbcdec428a3759956b37e7 (patch)
tree9b53aea7b3e58164040fb0ab5dce1d414853b224 /Libraries/LibLine/Editor.cpp
parente521daeedca332ecc6dad8ef2b67b54bbedce342 (diff)
downloadserenity-f29c5c3a416bd62298cbcdec428a3759956b37e7.zip
LibLine: Add Alt-d binding to forward-delete a word
Diffstat (limited to 'Libraries/LibLine/Editor.cpp')
-rw-r--r--Libraries/LibLine/Editor.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/Libraries/LibLine/Editor.cpp b/Libraries/LibLine/Editor.cpp
index cf072b06ce..3e107b28ff 100644
--- a/Libraries/LibLine/Editor.cpp
+++ b/Libraries/LibLine/Editor.cpp
@@ -571,6 +571,21 @@ void Editor::handle_read_event()
do_cursor_left(Word);
m_state = InputState::Free;
continue;
+ case 'd': // ^[d: alt-d
+ {
+ bool has_seen_nonspace = false;
+ while (m_cursor < m_buffer.size()) {
+ if (isspace(m_buffer[m_cursor])) {
+ if (has_seen_nonspace)
+ break;
+ } else {
+ has_seen_nonspace = true;
+ }
+ do_delete();
+ }
+ m_state = InputState::Free;
+ continue;
+ }
case 'f': // ^[f: alt-f
do_cursor_right(Word);
m_state = InputState::Free;