refactor: zigify imports and correct minor mistakes
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user