diff options
author | Ian Moffett <ian@osmora.org> | 2025-04-22 23:35:17 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-05-02 16:43:59 -0400 |
commit | ca0cc7e9b837c01c921626f7fbc4ed46189c718e (patch) | |
tree | 8eec82660b01cfcfd985db93123056b5e8337d1d | |
parent | 0331c642f92dce988446ea2ac6b69f82212f71ab (diff) |
kernel: cons: Add backspace support
Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r-- | sys/dev/cons/cons.c | 13 |
1 files changed, 13 insertions, 0 deletions
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); |