From 55553ae245a90d5736cd5e9229a80bfa3397e821 Mon Sep 17 00:00:00 2001
From: ay4-ibrahim <ahmed13.ibrahim@live.uwe.ac.uk>
Date: Wed, 6 Mar 2024 21:45:17 +0500
Subject: [PATCH] feat: update kernel to support newlines and output coloured
 Hello World

---
 kernel.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/kernel.c b/kernel.c
index e41db16..2217dc0 100644
--- a/kernel.c
+++ b/kernel.c
@@ -85,6 +85,12 @@ void terminal_putentryat(char c, uint8_t color, size_t x, size_t y) {
 }
 
 void terminal_putchar(char c) {
+  if (c == '\n') {
+    terminal_column = 0;
+    ++terminal_row;
+    return;
+  }
+
   terminal_putentryat(c, terminal_color, terminal_column, terminal_row);
   if (++terminal_column == VGA_WIDTH) {
     terminal_column = 0;
@@ -106,10 +112,10 @@ extern "C" /* Use C linkage for kernel_main. */
 void kernel_main() {
   /* Initialize terminal interface */
   terminal_initialize();
-  
-  /* Since there is no support for newlines in terminal_putchar
-   * yet, '\n' will produce some VGA specific character instead.
-   * This is normal.
-   */
-  terminal_writestring("Hello, kernel World!\n");
+
+  terminal_setcolor(make_color(COLOR_BLUE, COLOR_BLACK));
+  terminal_writestring("Hello World!\n");
+
+  terminal_setcolor(make_color(COLOR_RED, COLOR_BLACK));
+  terminal_writestring("Hello, World!\n");
 }
-- 
GitLab