Skip to content

Commit 69dee59

Browse files
committed
stmhal: Add backspace key to readline (along with delete key).
1 parent 10e21b9 commit 69dee59

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

stmhal/readline.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ int readline(vstr_t *line, const char *prompt) {
5858
} else if (c == 27) {
5959
// escape sequence
6060
escape_seq = 1;
61-
} else if (c == 127) {
62-
// backspace
61+
} else if (c == 8 || c == 127) {
62+
// backspace/delete
6363
if (cursor_pos > orig_line_len) {
6464
vstr_cut_out_bytes(line, cursor_pos - 1, 1);
6565
// set redraw parameters
@@ -125,6 +125,7 @@ int readline(vstr_t *line, const char *prompt) {
125125
}
126126

127127
// redraw command prompt, efficiently
128+
// TODO we can probably use some more sophisticated VT100 commands here
128129
if (redraw_step_back > 0) {
129130
for (int i = 0; i < redraw_step_back; i++) {
130131
stdout_tx_str("\b");

0 commit comments

Comments
 (0)