LibLine: Support Ctrl-b/f and Ctrl-d

And make the existing cltr-h handler easier to see.
This commit is contained in:
Nico Weber 2020-07-06 12:39:58 -04:00 committed by Andreas Kling
parent 72f8b3d185
commit f27e5ac68d
Notes: sideshowbarker 2024-07-19 05:05:29 +09:00

View File

@ -737,10 +737,6 @@ void Editor::handle_read_event()
} }
m_times_tab_pressed = 0; // Safe to say if we get here, the user didn't press TAB m_times_tab_pressed = 0; // Safe to say if we get here, the user didn't press TAB
if (codepoint == '\b' || codepoint == m_termios.c_cc[VERASE]) {
do_backspace();
continue;
}
if (codepoint == m_termios.c_cc[VWERASE]) { if (codepoint == m_termios.c_cc[VWERASE]) {
bool has_seen_nonspace = false; bool has_seen_nonspace = false;
while (m_cursor > 0) { while (m_cursor > 0) {
@ -766,11 +762,30 @@ void Editor::handle_read_event()
m_cursor = 0; m_cursor = 0;
continue; continue;
} }
if (codepoint == ctrl('B')) {
do_cursor_left(Character);
continue;
}
// ^D
if (codepoint == ctrl('D')) {
do_delete();
continue;
}
// ^E // ^E
if (codepoint == ctrl('E')) { if (codepoint == ctrl('E')) {
m_cursor = m_buffer.size(); m_cursor = m_buffer.size();
continue; continue;
} }
// ^F
if (codepoint == ctrl('F')) {
do_cursor_right(Character);
continue;
}
// ^H: ctrl('H') == '\b'
if (codepoint == '\b' || codepoint == m_termios.c_cc[VERASE]) {
do_backspace();
continue;
}
// ^L // ^L
if (codepoint == ctrl('L')) { if (codepoint == ctrl('L')) {
printf("\033[3J\033[H\033[2J"); // Clear screen. printf("\033[3J\033[H\033[2J"); // Clear screen.