summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-10-18 11:47:37 -0400
committerIan Moffett <ian@osmora.org>2025-10-18 11:47:37 -0400
commit3daa6fbf07d635a3dbd74a2d22d2c4e22eeb55cf (patch)
tree8aaa05781227c206a412622bb932bc168fe39715 /src
parent3de9458c5495d67e1c56f44ef8da9850d64087d0 (diff)
kern: cons: Add horizontal tab rendering
Implements support for the tab ('\t') characters Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'src')
-rw-r--r--src/sys/io/cons/cons.c20
1 files changed, 20 insertions, 0 deletions
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 <stdbool.h>
#include <string.h>
+#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;