From d1aab61698855709e2dc9ffb264d7d668a101fbc Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Tue, 22 Apr 2025 23:35:17 -0400 Subject: kernel: cons: Add backspace support Signed-off-by: Ian Moffett --- sys/dev/cons/cons.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sys/dev/cons/cons.c b/sys/dev/cons/cons.c index 365aa0b..b89727f 100644 --- a/sys/dev/cons/cons.c +++ b/sys/dev/cons/cons.c @@ -150,12 +150,25 @@ cons_flush(struct cons_screen *scr) static int cons_handle_special(struct cons_screen *scr, char c) { + struct cons_buf *bp; + if (scr->ch_col >= scr->ncols - 20) { scr->ch_col = 0; cons_handle_special(scr, '\n'); } switch (c) { + case ASCII_BS: + bp = scr->ob[scr->ch_row]; + if (bp->head > bp->tail) { + --bp->head; + } + + HIDE_CURSOR(scr); + --scr->ch_col; + --scr->curs_col; + SHOW_CURSOR(scr); + return 0; case ASCII_LF: HIDE_CURSOR(scr); -- cgit v1.2.3