From e8fc65fcd88a0f7ea2b1fa3bc66262545bf30fee Mon Sep 17 00:00:00 2001 From: Paul Montag Date: Sun, 19 Apr 2026 22:13:24 -0500 Subject: [PATCH] before I let my model do something to this --- src/game/nucleus.zig | 52 +++++++++++++++++++++++++++++++++++++++++++- src/game/text.zig | 4 ++-- src/view/widget.zig | 4 ++-- 3 files changed, 55 insertions(+), 5 deletions(-) diff --git a/src/game/nucleus.zig b/src/game/nucleus.zig index 49be240..5da2bcf 100644 --- a/src/game/nucleus.zig +++ b/src/game/nucleus.zig @@ -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]); + } +}; diff --git a/src/game/text.zig b/src/game/text.zig index 0ec6bfa..3232673 100644 --- a/src/game/text.zig +++ b/src/game/text.zig @@ -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 }, diff --git a/src/view/widget.zig b/src/view/widget.zig index 12f7549..9227c76 100644 --- a/src/view/widget.zig +++ b/src/view/widget.zig @@ -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); }