From e53bb7880b95352f61e668750bb5f046d335c5f9 Mon Sep 17 00:00:00 2001 From: Yves Biener Date: Wed, 5 Nov 2025 18:32:49 +0100 Subject: [PATCH] mod: cleanup TODO and outdated comments --- examples/demo.zig | 1 - examples/elements/scrollable.zig | 1 - src/cell.zig | 1 - src/color.zig | 2 -- src/element.zig | 8 +++++++- src/event.zig | 3 +++ src/input.zig | 2 -- src/style.zig | 2 -- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/demo.zig b/examples/demo.zig index 846f9a1..bb526b7 100644 --- a/examples/demo.zig +++ b/examples/demo.zig @@ -27,7 +27,6 @@ const QuitText = struct { pub fn main() !void { errdefer |err| log.err("Application Error: {any}", .{err}); - // TODO maybe create own allocator as some sort of arena allocator to have consistent memory usage var gpa: std.heap.DebugAllocator(.{}) = .init; defer if (gpa.deinit() == .leak) log.err("memory leak", .{}); diff --git a/examples/elements/scrollable.zig b/examples/elements/scrollable.zig index fdfe6ca..dd17227 100644 --- a/examples/elements/scrollable.zig +++ b/examples/elements/scrollable.zig @@ -56,7 +56,6 @@ const HelloWorldText = packed struct { pub fn main() !void { errdefer |err| log.err("Application Error: {any}", .{err}); - // TODO maybe create own allocator as some sort of arena allocator to have consistent memory usage var gpa: std.heap.DebugAllocator(.{}) = .init; defer { const deinit_status = gpa.deinit(); diff --git a/src/cell.zig b/src/cell.zig index 27a77cc..271f805 100644 --- a/src/cell.zig +++ b/src/cell.zig @@ -1,6 +1,5 @@ //! Cell type containing content and formatting for each character in the terminal screen. -// TODO embrace `zg` dependency more due to utf-8 encoding cp: u21 = ' ', style: Style = .{ .emphasis = &.{} }, diff --git a/src/color.zig b/src/color.zig index a050a39..4ee7c88 100644 --- a/src/color.zig +++ b/src/color.zig @@ -18,8 +18,6 @@ pub const Color = enum(u8) { white, // TODO add further colors as described in https://gist.github.com/ConnerWill/d4b6c776b509add763e17f9f113fd25b # Color / Graphics Mode - 256 Colors - // TODO might be useful to use the std.ascii stuff! - pub inline fn write(this: Color, writer: *std.Io.Writer, comptime coloring: enum { fg, bg, ul }) !void { if (this == .default) { switch (coloring) { diff --git a/src/element.zig b/src/element.zig index 690f9ac..0ac37fa 100644 --- a/src/element.zig +++ b/src/element.zig @@ -228,11 +228,16 @@ pub fn Scrollable(Model: type, Event: type) type { configuration: Configuration, pub const Configuration = packed struct { - // TODO the scrollbar bool and the color should be in their own struct using `enabled` and `color` inside of the struct to be more consistent with other `Configuration` structs scrollbar: bool, + /// Primary color to be used for the scrollbar (and background if enabled) color: Color = .default, + /// With a backgroud the `color` rendered with emphasis `.dim` + /// will be used to highlight the scrollbar from the background; + /// otherwise nothing is shown for the background show_background: bool = false, + /// should the scrollbar be shown for the x-axis (horizontal) x_axis: bool = false, + /// should the scrollbar be shown for the y-axis (vertical) y_axis: bool = false, pub const disabled: @This() = .{ .scrollbar = false }; @@ -671,6 +676,7 @@ pub fn Button(Model: type, Event: type, Queue: type) fn (meta.FieldEnum(Event)) pub fn button_fn(accept_event: meta.FieldEnum(Event)) type { { // check for type correctness and the associated type to use for the passed `accept_event` const err_msg = "Unexpected type for the associated input completion event to trigger. Only `void` is allowed."; + // TODO supported nested tagged unions to be also be used for triggering if the enum is then still of `void`type! switch (@typeInfo(@FieldType(Event, @tagName(accept_event)))) { .void => |_| {}, else => @compileError(err_msg), diff --git a/src/event.zig b/src/event.zig index 3e5f05e..ec23600 100644 --- a/src/event.zig +++ b/src/event.zig @@ -9,6 +9,9 @@ pub const SystemEvent = union(enum) { /// Quit event to signify the end of the event loop (rendering should stop afterwards) quit, /// Resize event to signify that the application should re-draw to resize + /// + /// Usually no `Container` nor `Element` should act on that event, as it + /// only serves for event based loops to force a re-draw with a new `Event`. resize, /// Error event to notify other containers about a recoverable error err: struct { diff --git a/src/input.zig b/src/input.zig index 9340fc4..4ea6343 100644 --- a/src/input.zig +++ b/src/input.zig @@ -65,8 +65,6 @@ pub const Key = packed struct { return meta.eql(this, other); } - // TODO might be useful to use the std.ascii stuff! - /// Determine if the `Key` is an ascii character that can be printed to /// the screen. This means that the code point of the `Key` is an ascii /// character between 32 - 255 (with the exception of 127 = Delete) and no diff --git a/src/style.zig b/src/style.zig index a1ec924..5707d49 100644 --- a/src/style.zig +++ b/src/style.zig @@ -40,8 +40,6 @@ pub fn eql(this: Style, other: Style) bool { return meta.eql(this, other); } -// TODO might be useful to use the std.ascii stuff! - pub fn value(this: Style, writer: *std.Io.Writer, cp: u21) !void { var buffer: [4]u8 = undefined; const bytes = try unicode.utf8Encode(cp, &buffer);