From b886f03f7adeb036c14664c7bae6d1fe6cc6a0eb Mon Sep 17 00:00:00 2001 From: xamidev Date: Sun, 28 Dec 2025 11:14:22 +0100 Subject: [PATCH] Quick backspace fix --- src/io/term.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/io/term.c b/src/io/term.c index 0852355..50d2552 100644 --- a/src/io/term.c +++ b/src/io/term.c @@ -87,11 +87,26 @@ void putchar(char c) return; } - // Improperly handled. + // TODO: Improperly handled. // When we're on an empty line it should get to the upper line's last character + // NOT just the last position possible; we would need to track the last line's character amount for that if (c == '\b') { - cursor.x--; + if (cursor.x == 0 && cursor.y == 0) + { + // Top-left corner + return; + } + + if (cursor.x == 0) + { + cursor.y--; + cursor.x = (framebuffer->width / FONT_WIDTH) -1; // here + } + else { + cursor.x--; + } + int px = cursor.x * FONT_WIDTH; int py = cursor.y * FONT_HEIGHT; erase_char(px, py);