refactor: zigify imports and correct minor mistakes

This commit is contained in:
2025-05-20 18:23:44 +02:00
parent 50adf32f14
commit aa4adf20f9
26 changed files with 311 additions and 330 deletions

View File

@@ -1,18 +1,14 @@
const std = @import("std");
const terminal = @import("terminal.zig");
const Cell = @import("cell.zig");
const Point = @import("point.zig").Point;
//! Renderer for `zterm`.
/// Double-buffered intermediate rendering pipeline
pub const Buffered = struct {
allocator: std.mem.Allocator,
allocator: Allocator,
created: bool,
size: Point,
screen: []Cell,
virtual_screen: []Cell,
pub fn init(allocator: std.mem.Allocator) @This() {
pub fn init(allocator: Allocator) @This() {
return .{
.allocator = allocator,
.created = false,
@@ -29,9 +25,9 @@ pub const Buffered = struct {
}
}
pub fn resize(this: *@This()) !void {
pub fn resize(this: *@This()) !Point {
const size = terminal.getTerminalSize();
if (std.meta.eql(this.size, size)) return;
if (meta.eql(this.size, size)) return this.size;
this.size = size;
const n = @as(usize, this.size.x) * @as(usize, this.size.y);
@@ -52,6 +48,7 @@ pub const Buffered = struct {
@memset(this.virtual_screen, .{});
}
try this.clear();
return size;
}
/// Clear the entire screen and reset the screen buffer, to force a re-draw with the next `flush` call.
@@ -118,3 +115,10 @@ pub const Buffered = struct {
}
}
};
const std = @import("std");
const meta = std.meta;
const Allocator = std.mem.Allocator;
const terminal = @import("terminal.zig");
const Cell = @import("cell.zig");
const Point = @import("point.zig").Point;