Skip to content

Commit 9a522dd

Browse files
stinospfalcon
authored andcommitted
lib/mp-readline: Add implementation for deleting a character
xterm and others use the ESC[~3 sequence when pressing the delete key
1 parent 100004e commit 9a522dd

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/mp-readline/readline.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,12 @@ int readline_process_char(int c) {
228228
} else if (rl.escape_seq_buf[0] == '4' || rl.escape_seq_buf[0] == '8') {
229229
end_key:
230230
redraw_step_forward = rl.line->len - rl.cursor_pos;
231+
} else if (rl.escape_seq_buf[0] == '3') {
232+
// delete
233+
if (rl.cursor_pos >= rl.orig_line_len && rl.cursor_pos < rl.line->len) {
234+
vstr_cut_out_bytes(rl.line, rl.cursor_pos, 1);
235+
redraw_from_cursor = true;
236+
}
231237
} else {
232238
DEBUG_printf("(ESC [ %c %d)", rl.escape_seq_buf[0], c);
233239
}

0 commit comments

Comments
 (0)