From d452fee5efe046278e4dc88bbd00ae78dca03444 Mon Sep 17 00:00:00 2001 From: RadsammyT Date: Tue, 17 Mar 2026 15:47:49 -0400 Subject: [PATCH] reword panics, label errors, config.ini tidbit --- res/config.ini | 1 + src/config/migrator.zig | 24 ++++++++++++------------ src/main.zig | 5 ++++- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/res/config.ini b/res/config.ini index f598047..3b50916 100644 --- a/res/config.ini +++ b/res/config.ini @@ -401,6 +401,7 @@ posY = 1 # See posX for [cmd:F8]. posX = 0 # Optional. Moves the label to the right of the terminal. Positive Axis now goes left. +# If 0, only run once and do not refresh afterwards invertX = true # Optional. Moves the label to the bottom of the terminal. Positive Axis now goes up. invertY = true diff --git a/src/config/migrator.zig b/src/config/migrator.zig index cb150bc..b8562fe 100644 --- a/src/config/migrator.zig +++ b/src/config/migrator.zig @@ -164,22 +164,22 @@ pub fn configFieldHandler(_: std.mem.Allocator, field: ini.IniField) ?ini.IniFie if (std.mem.startsWith(u8, field.header, "cmd:")) { const key = field.header[4..]; - const keyZ = temporary_allocator.dupe(u8, key) catch @panic("FUCK"); + const keyZ = temporary_allocator.dupe(u8, key) catch |e| + std.debug.panic("CustomCommands.binds: {} while duping key {s}", .{e, key}); if (!CustomCommands.binds.contains(key)) { CustomCommands.binds.put(keyZ, .{}) catch |e| { - std.log.err("CustomCommands.binds: {} while putting for key {s}", .{e, key}); - @panic("CustomCommands.binds failed"); + std.debug.panic("CustomCommands.binds: {} while putting for key {s}", .{e, key}); }; } if (CustomCommands.binds.getPtr(keyZ)) |command| { if (std.mem.eql(u8, field.key, "name")) { - command.name = temporary_allocator.dupe(u8, field.value) catch { - @panic("FUCK"); + command.name = temporary_allocator.dupe(u8, field.value) catch |e| { + std.debug.panic("CustomCommands.binds: {} while duping name '{s}'", .{e, field.value}); }; } if (std.mem.eql(u8, field.key, "cmd")) { - command.cmd = temporary_allocator.dupe(u8, field.value) catch { - @panic("FUCK"); + command.cmd = temporary_allocator.dupe(u8, field.value) catch |e| { + std.debug.panic("CustomCommands.binds: {} while duping command '{s}", .{e, field.value}); }; } if (std.mem.eql(u8, field.key, "posX")) { @@ -193,19 +193,19 @@ pub fn configFieldHandler(_: std.mem.Allocator, field: ini.IniField) ?ini.IniFie if (std.mem.startsWith(u8, field.header, "lbl:")) { const key = field.header[4..]; - const keyZ = temporary_allocator.dupe(u8, key) catch @panic("FUCK"); + const keyZ = temporary_allocator.dupe(u8, key) catch |e| + std.debug.panic("CustomCommands.labels: {} while duping key {s}", .{e, key}); if (!CustomCommands.labels.contains(keyZ)) { CustomCommands.labels.put(keyZ, .{ .name = keyZ }) catch |e| { - std.log.err("CustomCommands.labels: {} while putting for key {s}", .{e, key}); - @panic("CustomCommands.labels failed"); + std.debug.panic("CustomCommands.labels: {} while putting for key {s}", .{e, key}); }; } if (CustomCommands.labels.getPtr(keyZ)) |label| { if (std.mem.eql(u8, field.key, "cmd")) { - label.cmd = temporary_allocator.dupe(u8, field.value) catch { - @panic("FUCK"); + label.cmd = temporary_allocator.dupe(u8, field.value) catch |e| { + std.debug.panic("CustomCommands.labels: {} while duping command '{s}'", .{e, field.value}); }; } if (std.mem.eql(u8, field.key, "posX")) { diff --git a/src/main.zig b/src/main.zig index dfc1d59..5e7b543 100644 --- a/src/main.zig +++ b/src/main.zig @@ -1746,9 +1746,12 @@ fn updateCustomInfo(lbl: *Label, ptr: *anyopaque) !void { if (stdout.items.len != 0 and !std.ascii.isPrint(stdout.items[stdout.items.len-1])) _ = stdout.pop() else if (stdout.items.len == 0) - try stdout.appendSlice(state.allocator, "[Something went wrong!]"); + try stdout.print(state.allocator, "{s}: [Command didn't print anything!]", .{i.info.name}); state.allocator.free(lbl.text); lbl.text = try state.allocator.dupe(u8, stdout.items); + + // we reposition the widgets in the event of a inverted label. + // not doing so causes the inverted label to not be positioned correctly try positionWidgets(state); if (i.info.refresh != 0) i.info.counter = i.info.refresh;