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
if (codepoint == '\b' || codepoint == m_termios.c_cc[VERASE]) {
do_backspace();
continue;
}
if (codepoint == m_termios.c_cc[VWERASE]) {
bool has_seen_nonspace = false;
while (m_cursor > 0) {
@ -766,11 +762,30 @@ void Editor::handle_read_event()
m_cursor = 0;
continue;
}
if (codepoint == ctrl('B')) {
do_cursor_left(Character);
continue;
}
// ^D
if (codepoint == ctrl('D')) {
do_delete();
continue;
}
// ^E
if (codepoint == ctrl('E')) {
m_cursor = m_buffer.size();
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
if (codepoint == ctrl('L')) {
printf("\033[3J\033[H\033[2J"); // Clear screen.