From ac154999f558eb18bf22e5894337cbef1df98293 Mon Sep 17 00:00:00 2001 From: marprok Date: Sun, 1 Sep 2019 11:47:35 +0300 Subject: [PATCH] Shell: Added support for ctr-e/a. By pressing ctr-e/a the cursor goes to the end/beginning of the current line. --- Shell/LineEditor.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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') {