holy SHIFT

This commit is contained in:
2025-12-28 11:06:33 +01:00
parent cc36c768cf
commit 4607b5aba5
4 changed files with 77 additions and 35 deletions

View File

@@ -66,7 +66,19 @@ static void draw_char(char c, int px, int py, int fg, int bg)
}
}
static void putchar(char c)
static void erase_char(int px, int py)
{
for (size_t y=0; y<FONT_HEIGHT; y++)
{
for (size_t x=0; x<8; x++)
{
// Black
putpixel(px+x, py+y, 0);
}
}
}
void putchar(char c)
{
if (c == '\n')
{
@@ -75,6 +87,17 @@ static void putchar(char c)
return;
}
// Improperly handled.
// When we're on an empty line it should get to the upper line's last character
if (c == '\b')
{
cursor.x--;
int px = cursor.x * FONT_WIDTH;
int py = cursor.y * FONT_HEIGHT;
erase_char(px, py);
return;
}
if ((cursor.x+1)*FONT_WIDTH >= framebuffer->width)
{
cursor.x = 0;
@@ -87,7 +110,7 @@ static void putchar(char c)
cursor.x++;
}
// Overhead that could be avoided, right?
// Overhead that could be avoided, right? (for printf)
void _putchar(char character)
{
putchar(character);

View File

@@ -3,6 +3,7 @@
int term_init();
void kputs(const char* str);
void putchar(char c);
enum TermColors
{