From 3daa6fbf07d635a3dbd74a2d22d2c4e22eeb55cf Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Sat, 18 Oct 2025 11:47:37 -0400 Subject: kern: cons: Add horizontal tab rendering Implements support for the tab ('\t') characters Signed-off-by: Ian Moffett --- src/sys/io/cons/cons.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/sys') diff --git a/src/sys/io/cons/cons.c b/src/sys/io/cons/cons.c index a80644c..65d1f1b 100644 --- a/src/sys/io/cons/cons.c +++ b/src/sys/io/cons/cons.c @@ -37,6 +37,8 @@ #include #include +#define TAB_WIDTH (FONT_WIDTH * 4) + /* kconf background color config */ #if defined(__CONS_BG) #define DEFAULT_BG __CONS_BG @@ -180,6 +182,21 @@ cons_backspace(struct cons_scr *scr) cons_draw_cursor(scr, false); } +static void +cons_tab(struct cons_scr *scr) +{ + cons_draw_cursor(scr, true); + scr->text_x += TAB_WIDTH; + scr->cursor_x += TAB_WIDTH; + + /* Wrap to next line if needed */ + if (scr->cursor_x >= scr->max_col) { + cons_newline(scr); + } + + cons_draw_cursor(scr, false); +} + /* * Fill a screen with a desired background * color @@ -224,6 +241,9 @@ cons_handle_spec(struct cons_scr *scr, int c) case ASCII_BS: cons_backspace(scr); return c; + case ASCII_HT: + cons_tab(scr); + return c; } return -1; -- cgit v1.2.3