From a1a5ba594ee4c49c5d52fedf738ce5c42824b15c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Gr=C3=A9goire?= Date: Sat, 27 Jun 2026 16:30:08 -0400 Subject: [PATCH] dev: add backspace to fbconsole --- src/dev/fbconsole.zig | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/dev/fbconsole.zig b/src/dev/fbconsole.zig index 4d6bbbe..2a68ff1 100644 --- a/src/dev/fbconsole.zig +++ b/src/dev/fbconsole.zig @@ -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') {