summaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'kernel')
-rw-r--r--kernel/tty.c22
-rw-r--r--kernel/tty.h4
2 files changed, 16 insertions, 10 deletions
diff --git a/kernel/tty.c b/kernel/tty.c
index 4cb2cf1..628a21e 100644
--- a/kernel/tty.c
+++ b/kernel/tty.c
@@ -40,7 +40,7 @@ static inline uint16_t make_vgaentry(char c, uint8_t color)
return ((uint16_t) c) | (((uint16_t) color) << VGA_COLOR_SHIFT);
}
-static inline void tty_putentryat(char c, uint8_t color, size_t x, size_t y)
+static inline void tty_putc_at(char c, uint8_t color, size_t x, size_t y)
{
const size_t i = y * VGA_WIDTH + x;
tty_buffer[i] = make_vgaentry(c, color);
@@ -51,21 +51,27 @@ void tty_setcolor(uint8_t color)
tty_color = color;
}
-void tty_putchar(char c)
+void tty_putc(char c)
{
- tty_putentryat(c, tty_color, tty_col, tty_row);
- if (++tty_col == VGA_WIDTH) {
+ if (c == '\n')
+ {
tty_col = 0;
- if (++tty_row == VGA_HEIGHT) {
- tty_row = 0;
+ tty_row++;
+ } else {
+ tty_putc_at(c, tty_color, tty_col, tty_row);
+ if (++tty_col == VGA_WIDTH) {
+ tty_col = 0;
+ if (++tty_row == VGA_HEIGHT) {
+ tty_row = 0;
+ }
}
}
}
-void tty_writestring(const char* data)
+void tty_puts(const char* data)
{
for (const char* p = data; *p != 0; p++)
- tty_putchar(*p);
+ tty_putc(*p);
}
void tty_init()
diff --git a/kernel/tty.h b/kernel/tty.h
index 3c4b09e..27dfe23 100644
--- a/kernel/tty.h
+++ b/kernel/tty.h
@@ -7,8 +7,8 @@ void tty_init();
void tty_setcolor(uint8_t color);
-void tty_putchar(char c);
+void tty_putc(char c);
-void tty_writestring(const char* data);
+void tty_puts(const char* data);
#endif