restructuring

This commit is contained in:
2026-04-17 22:31:45 -05:00
parent 3c1077bbfa
commit 6589ac9c58
15 changed files with 356 additions and 288 deletions
+17
View File
@@ -0,0 +1,17 @@
const std = @import("std");
const mem = std.mem;
// Cell is a single cell in the [DoubleBuffer].
pub const Cell = struct {
char: [8]u8,
width: usize,
/// eql returns
pub fn eql(self: *const Cell, b: *const Cell) bool {
return mem.eql(u8, &self.char, &b.char) and self.width == b.width;
}
pub fn render(self: *const @This(), w: *std.Io.Writer) !void {
_ = try w.write(self.char[0..self.width]);
}
};
@@ -4,10 +4,11 @@ const mem = std.mem;
const grome = @import("../root.zig");
const Allocator = mem.Allocator;
const Matrix = grome.matrix.Matrix;
const SubMatrix = grome.matrix.SubMatrix;
const Point = grome.matrix.Point;
const Rect = grome.matrix.Rect;
const Matrix = grome.container.Matrix;
const SubMatrix = grome.container.SubMatrix;
const Point = grome.container.Point;
const Rect = grome.container.Rect;
const Cell = grome.view.Cell;
/// DoubleBuffer manages two buffers for efficient rendering: a display buffer
/// showing the current screen state, and a write buffer for accumulating changes
@@ -98,17 +99,3 @@ pub const DoubleBuffer = struct {
self.swap();
}
};
pub const Cell = struct {
char: [8]u8,
width: usize,
/// eql returns
pub fn eql(self: *const Cell, b: *const Cell) bool {
return mem.eql(u8, &self.char, &b.char) and self.width == b.width;
}
pub fn render(self: *const @This(), w: *std.Io.Writer) !void {
_ = try w.write(self.char[0..self.width]);
}
};
+6
View File
@@ -0,0 +1,6 @@
pub const DoubleBuffer = @import("double_buffer.zig").DoubleBuffer;
pub const Cell = @import("cell.zig").Cell;
test {
@import("std").testing.refAllDecls(@This());
}
+8
View File
@@ -0,0 +1,8 @@
const std = @import("std");
const grome = @import("../root.zig");
const DoubleBuffer = grome.draw.DoubleBuffer;
pub const Viewport = struct {
buffer: DoubleBuffer,
};
+8
View File
@@ -0,0 +1,8 @@
const std = @import("std");
const mem = std.mem;
const grome = @import("../root.zig");
/// A widget is an intrusive interface that allows the implementor to draw
/// a specific item to a frame.
pub const Widget = struct {};