mirror of
https://github.com/rdmsr/zag.git
synced 2026-10-27 13:58:20 +00:00
dev: add backspace to fbconsole
This commit is contained in:
+17
-1
@@ -1,3 +1,4 @@
|
|||||||
|
//! Very bad and slow framebuffer console.
|
||||||
const r = @import("root");
|
const r = @import("root");
|
||||||
|
|
||||||
const pl = r.pl;
|
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) {
|
if (font.width == 0 or font.height == 0 or content_w < font.width or visible_h < font.height) {
|
||||||
return;
|
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') {
|
if (c == '\n') {
|
||||||
newline();
|
newline();
|
||||||
} else if (c == '\r') {
|
} else if (c == '\r') {
|
||||||
|
|||||||
Reference in New Issue
Block a user