Quick backspace fix

This commit is contained in:
2025-12-28 11:14:22 +01:00
parent 4607b5aba5
commit b886f03f7a

View File

@@ -87,11 +87,26 @@ void putchar(char c)
return; return;
} }
// Improperly handled. // TODO: Improperly handled.
// When we're on an empty line it should get to the upper line's last character // 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') 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 px = cursor.x * FONT_WIDTH;
int py = cursor.y * FONT_HEIGHT; int py = cursor.y * FONT_HEIGHT;
erase_char(px, py); erase_char(px, py);