before I let my model do something to this

This commit is contained in:
2026-04-19 22:13:24 -05:00
parent ffd4575b9b
commit e8fc65fcd8
3 changed files with 55 additions and 5 deletions
+51 -1
View File
@@ -1,3 +1,53 @@
const std = @import("std");
const grome = @import("root.zig");
const grome = @import("../root.zig");
const style = grome.view.style;
const Point = grome.container.Point;
const Block = grome.container.Block;
const SubMatrix = grome.container.SubMatrix;
const Widget = grome.view.Widget;
const WidgetError = grome.view.WidgetError;
const Cell = grome.view.Cell;
const Style = grome.view.style.Style;
pub const Nucleus = struct {
location: Point,
style_loop_ctr: usize,
const healthy_loop = [_]Style{
"\x1b[92m[1] \x1b[0m", // 92 - bright green
"\x1b[10106m[2] \x1b[0m", // 256 color 10106 (85)
"\x1b[38;2;56;142;60m[3] \x1b[0m", // RGB(56,142,60)
"\x1b[32m[4] \x1b[0m", // standard green (92)
"\x1b[39m[5] \x1b[0m", // even lighter
"\x1b[35m[6] \x1b[0m", // medium green (64)
.{ .escape = },
.{ .escape = "" },
.{ .escape = "" },
.{ .escape = "" },
.{ .escape = "" },
.{ .escape = "" },
};
pub fn init(loc: Point) Nucleus {
return .{
.location = loc,
.stlye_loop_ctr = 0,
};
}
pub fn geometry(widget: *Widget) Block {
const self: *@This() = @fieldParentPtr("widget", widget);
return Block{
.loc = self.location,
.size = .{ .height = 1, .width = 1 },
};
}
pub fn render(widget: *Widget, frame: *SubMatrix(Cell)) WidgetError!void {
const self: *@This() = @fieldParentPtr("widget", widget);
var row = frame.rowable.row(0) catch return WidgetError.UnknownError;
@memcpy(row[0..ending], self.text[0..ending]);
}
};
+2 -2
View File
@@ -40,8 +40,8 @@ pub const Text = struct {
};
}
pub fn geometry(widget: *const Widget) Block {
const self: *const @This() = @fieldParentPtr("widget", widget);
pub fn geometry(widget: *Widget) Block {
const self: *@This() = @fieldParentPtr("widget", widget);
return Block{
.loc = .{ .x = 0, .y = 0 },
.size = .{ .height = 1, .width = self.text_width },
+2 -2
View File
@@ -19,7 +19,7 @@ pub const WidgetError = error{
pub const Widget = struct {
/// geometryFn returns a Block, which specifies the location and size of the
/// submatrix which will be passed into the render function
geometryFn: *const fn (*const @This()) Block,
geometryFn: *const fn (*@This()) Block,
/// renderFn passes in the SubMatrix which can be written to...
/// neat
@@ -27,7 +27,7 @@ pub const Widget = struct {
/// geometry is the driver for geometryFn for the Widget interface.
/// you must create the geometryFn.
pub fn geometry(self: *const @This()) Block {
pub fn geometry(self: *@This()) Block {
return self.geometryFn(self);
}