mod(renderer/direct): buffer and flush screen output accordingly
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 2m31s
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 2m31s
This commit is contained in:
@@ -201,12 +201,33 @@ pub const Direct = struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn flush(this: *@This()) !void {
|
pub fn flush(this: *@This()) !void {
|
||||||
var writer = terminal.writer();
|
const stdout_file = std.fs.File.stdout();
|
||||||
for (0..this.size.y) |row| {
|
var buffer: [4096]u8 = undefined;
|
||||||
|
var stdout_writer = stdout_file.writer(&buffer);
|
||||||
|
var writer = &stdout_writer.interface;
|
||||||
|
defer writer.flush() catch {};
|
||||||
|
|
||||||
|
row: for (0..this.size.y) |row| {
|
||||||
for (0..this.size.x) |col| {
|
for (0..this.size.x) |col| {
|
||||||
const idx = (row * this.size.x) + col;
|
const idx = (row * this.size.x) + col;
|
||||||
const cvs = this.screen[idx];
|
const cvs = this.screen[idx];
|
||||||
try cvs.value(&writer);
|
// are we done for this row already?
|
||||||
|
if (col + 1 < this.size.x and meta.eql(cvs, .{})) {
|
||||||
|
// check the remaining line
|
||||||
|
var last_cell = true;
|
||||||
|
for (col..this.size.x) |x| {
|
||||||
|
if (!meta.eql(cvs, this.screen[(row * this.size.x) + x])) {
|
||||||
|
last_cell = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (last_cell) {
|
||||||
|
//std.log.debug("Found the last cell in row: {d} at column: {d}", .{row, col});
|
||||||
|
_ = try writer.write("\n");
|
||||||
|
continue :row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try cvs.value(writer);
|
||||||
if (cvs.style.cursor) return; // that's where the cursor should be left!
|
if (cvs.style.cursor) return; // that's where the cursor should be left!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user