Shell: Added support for ctr-e/a.
By pressing ctr-e/a the cursor goes to the end/beginning of the current line.
This commit is contained in:
parent
1f56612c8a
commit
ac154999f5
Notes:
sideshowbarker
2024-07-19 12:24:04 +09:00
Author: https://github.com/marprok Commit: https://github.com/SerenityOS/serenity/commit/ac154999f55 Pull-request: https://github.com/SerenityOS/serenity/pull/514 Reviewed-by: https://github.com/awesomekling
1 changed files with 16 additions and 0 deletions
|
@ -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') {
|
||||
|
|
Loading…
Add table
Reference in a new issue