From 2e9e814dcb73fc7d5e724935d50775dd1758c759 Mon Sep 17 00:00:00 2001 From: RadsammyT Date: Wed, 18 Mar 2026 08:20:24 -0400 Subject: [PATCH] Review part 1 --- ly-ui/src/components/generic.zig | 3 +++ src/config/custom.zig | 12 ++++++------ src/main.zig | 24 ++++++++++++------------ 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/ly-ui/src/components/generic.zig b/ly-ui/src/components/generic.zig index ff7a532..d7a609d 100644 --- a/ly-ui/src/components/generic.zig +++ b/ly-ui/src/components/generic.zig @@ -76,16 +76,19 @@ pub fn CyclableLabel(comptime ItemType: type, comptime ChangeItemType: type) typ pub fn positionX(self: *Self, original_pos: Position) void { self.component_pos = original_pos; + self.cursor = self.component_pos.x + 2; self.children_pos = original_pos.addX(self.width); } pub fn positionY(self: *Self, original_pos: Position) void { self.component_pos = original_pos; + self.cursor = self.component_pos.x + 2; self.children_pos = original_pos.addY(1); } pub fn positionXY(self: *Self, original_pos: Position) void { self.component_pos = original_pos; + self.cursor = self.component_pos.x + 2; self.children_pos = Position.init( self.width, 1, diff --git a/src/config/custom.zig b/src/config/custom.zig index 1da9a9f..3b430bc 100644 --- a/src/config/custom.zig +++ b/src/config/custom.zig @@ -2,16 +2,16 @@ const std = @import("std"); const custom = @This(); -pub const customCommandBind = struct { - name: []const u8 = undefined, - cmd: []const u8 = undefined, +pub const CustomCommandBind = struct { + name: []const u8 = "", + cmd: []const u8 = "", posX: u32 = 0, posY: u32 = 0, }; pub const UNDEFINED_CMD: []const u8 = "echo \"You forgot to define 'cmd'!\""; -pub const customCommandInfo = struct { +pub const CustomCommandInfo = struct { name: []const u8 = "", cmd: []const u8 = UNDEFINED_CMD, /// To be set to the label widget's `lid` @@ -27,5 +27,5 @@ pub const customCommandInfo = struct { invertX: bool = false, }; -pub var binds: std.StringHashMap(customCommandBind) = undefined; -pub var labels: std.StringHashMap(customCommandInfo) = undefined; +pub var binds: std.StringHashMap(CustomCommandBind) = undefined; +pub var labels: std.StringHashMap(CustomCommandInfo) = undefined; diff --git a/src/main.zig b/src/main.zig index 4d0434b..8ce6274 100644 --- a/src/main.zig +++ b/src/main.zig @@ -38,7 +38,7 @@ const Lang = @import("config/Lang.zig"); const migrator = @import("config/migrator.zig"); const OldSave = @import("config/OldSave.zig"); const SavedUsers = @import("config/SavedUsers.zig"); -const CustomCommands = @import("config/custom.zig"); +const custom = @import("config/custom.zig"); const DisplayServer = @import("enums.zig").DisplayServer; const Environment = @import("Environment.zig"); const Entry = Environment.Entry; @@ -65,13 +65,13 @@ fn ttyControlTransferSignalHandler(_: c_int) callconv(.c) void { } const CustomBindLabel = struct { - cmd: CustomCommands.customCommandBind, + cmd: custom.CustomCommandBind, key: []const u8, lbl: Label }; const CustomInfoLabel = struct { - info: CustomCommands.customCommandInfo, + info: custom.CustomCommandInfo, lbl: Label }; @@ -220,27 +220,27 @@ pub fn main() !void { const config_path = try std.fs.path.join(state.allocator, &[_][]const u8{ config_parent_path, "config.ini" }); defer state.allocator.free(config_path); - CustomCommands.binds = .init(state.allocator); - CustomCommands.labels = .init(state.allocator); + custom.binds = .init(state.allocator); + custom.labels = .init(state.allocator); var config_parser = try IniParser(Config).init(state.allocator, config_path, migrator.configFieldHandler); defer config_parser.deinit(); // mapping.deinit() has to be done here defer { if (!shutdown or !restart) { - var iter = CustomCommands.binds.iterator(); + var iter = custom.binds.iterator(); while (iter.next()) |i| { temporary_allocator.free(i.key_ptr.*); temporary_allocator.free(i.value_ptr.*.cmd); temporary_allocator.free(i.value_ptr.*.name); } - CustomCommands.binds.deinit(); - var labelIter = CustomCommands.labels.iterator(); + custom.binds.deinit(); + var labelIter = custom.labels.iterator(); while (labelIter.next()) |i| { temporary_allocator.free(i.key_ptr.*); - if (i.value_ptr.cmd.ptr != CustomCommands.UNDEFINED_CMD.ptr) + if (i.value_ptr.cmd.ptr != custom.UNDEFINED_CMD.ptr) temporary_allocator.free(i.value_ptr.*.cmd); } - CustomCommands.labels.deinit(); + custom.labels.deinit(); } } @@ -1081,7 +1081,7 @@ pub fn main() !void { defer state.custom_info.deinit(state.allocator); defer layer2.deinit(state.allocator); - var lblIter = CustomCommands.labels.iterator(); + var lblIter = custom.labels.iterator(); while (lblIter.next()) |i| { const w = Label.init("", null, @@ -1104,7 +1104,7 @@ pub fn main() !void { } } - var iter = CustomCommands.binds.iterator(); + var iter = custom.binds.iterator(); while (iter.next()) |i| { var concat = try std.mem.concat(state.allocator, u8, &[_][]const u8{