From 4a620a2e45ec4e84bdec1a60f7b676328424c7eb Mon Sep 17 00:00:00 2001 From: Tom-on64 Date: Thu, 2 May 2024 10:01:26 +0200 Subject: [PATCH] Made input text go to next line when it runs out of space instead of just wrapping around --- include/screen.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/include/screen.h b/include/screen.h index 1696e64..812502e 100644 --- a/include/screen.h +++ b/include/screen.h @@ -129,12 +129,24 @@ void putc(char c) { cursor.y++; cursor.x = 0; } else if (c == '\b') { - putcAt(' ', cursor.x, cursor.y); // Make sure we don't leave an extra cursor TODO: make this better - cursor.x--; + putcAt(' ', cursor.x, cursor.y); // Make sure we don't leave an extra cursor + + if (cursor.x == 0) { + cursor.x = gfxMode->xRes / CHAR_WIDTH - 1; // Subtract one so we don't overflow to the line start + cursor.y--; // y could be 0 + } else { + cursor.x--; + } + putcAt(' ', cursor.x, cursor.y); } else { putcAt(c, cursor.x, cursor.y); cursor.x++; + + if (cursor.x >= gfxMode->xRes / CHAR_WIDTH) { + cursor.y++; // TODO: Scrolling + cursor.x = 0; + } } }