summaryrefslogtreecommitdiff
path: root/Libraries/LibLine
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2020-07-07 12:44:38 -0400
committerAndreas Kling <kling@serenityos.org>2020-07-07 23:13:25 +0200
commit6105f063cb936e027b5419ae9696ce00f97991e9 (patch)
tree2953ef6e9dab1d130de44ba5caa6914337a771ae /Libraries/LibLine
parentec5845212d506c9651fe9c83a2d4426a852c1cc7 (diff)
downloadserenity-6105f063cb936e027b5419ae9696ce00f97991e9.zip
LibLine: Add ctrl-t shortcut for transposing characters
Diffstat (limited to 'Libraries/LibLine')
-rw-r--r--Libraries/LibLine/Editor.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/Libraries/LibLine/Editor.cpp b/Libraries/LibLine/Editor.cpp
index 75d137695e..076a217c5a 100644
--- a/Libraries/LibLine/Editor.cpp
+++ b/Libraries/LibLine/Editor.cpp
@@ -921,6 +921,17 @@ void Editor::handle_read_event()
}
continue;
}
+ // ^T
+ if (codepoint == ctrl('T')) {
+ if (m_cursor > 0 && m_buffer.size() >= 2) {
+ if (m_cursor < m_buffer.size())
+ ++m_cursor;
+ swap(m_buffer[m_cursor - 1], m_buffer[m_cursor - 2]);
+ // FIXME: Update anchored styles too.
+ m_refresh_needed = true;
+ }
+ continue;
+ }
if (codepoint == '\n') {
finish();
continue;