summaryrefslogtreecommitdiff
path: root/Shell/LineEditor.cpp
diff options
context:
space:
mode:
authormarprok <mariosprokopakis@gmail.com>2019-09-01 11:47:35 +0300
committerAndreas Kling <awesomekling@gmail.com>2019-09-02 09:42:05 +0200
commitac154999f558eb18bf22e5894337cbef1df98293 (patch)
treea6a4cd4b3b3d30de70419d51b1036b230f145518 /Shell/LineEditor.cpp
parent1f56612c8a4f74835994c685260e4f8ab77d8572 (diff)
downloadserenity-ac154999f558eb18bf22e5894337cbef1df98293.zip
Shell: Added support for ctr-e/a.
By pressing ctr-e/a the cursor goes to the end/beginning of the current line.
Diffstat (limited to 'Shell/LineEditor.cpp')
-rw-r--r--Shell/LineEditor.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/Shell/LineEditor.cpp b/Shell/LineEditor.cpp
index 5c1e6a45da..5e36ca16c5 100644
--- a/Shell/LineEditor.cpp
+++ b/Shell/LineEditor.cpp
@@ -226,6 +226,22 @@ String LineEditor::get_line(const String& prompt)
fflush(stdout);
continue;
}
+ if (ch == 0x01) { // ^A
+ if (m_cursor > 0) {
+ printf("\033[%dD", m_cursor);
+ fflush(stdout);
+ m_cursor = 0;
+ }
+ continue;
+ }
+ if (ch == 0x05) { // ^E
+ if (m_cursor < m_buffer.size()) {
+ printf("\033[%dC", m_buffer.size() - m_cursor);
+ fflush(stdout);
+ m_cursor = m_buffer.size();
+ }
+ continue;
+ }
putchar(ch);
fflush(stdout);
if (ch == '\n') {