dev: add backspace to fbconsole

This commit is contained in:
Loïc Grégoire
2026-06-27 16:30:08 -04:00
parent 020a6c7d60
commit a1a5ba594e
+17 -1
View File
@@ -1,3 +1,4 @@
//! Very bad and slow framebuffer console.
const r = @import("root");
const pl = r.pl;
@@ -144,11 +145,26 @@ fn newline() void {
}
}
fn write_char(c: u8) void {
pub fn write_char(c: u8) void {
if (font.width == 0 or font.height == 0 or content_w < font.width or visible_h < font.height) {
return;
}
// Backspace.
if (c == '\x08') {
if (cursor_x >= font.width) {
cursor_x -= font.width;
ensure_cursor_visible();
for (0..font.height) |row| {
const dst_y = content_y + cursor_y + row;
for (0..font.width) |col| {
framebuffer[dst_y * framebuffer_width + content_x + cursor_x + col] = bg_color;
}
}
}
return;
}
if (c == '\n') {
newline();
} else if (c == '\r') {