reword panics, label errors, config.ini tidbit

This commit is contained in:
RadsammyT 2026-03-17 15:47:49 -04:00
commit d452fee5ef
No known key found for this signature in database
3 changed files with 17 additions and 13 deletions

View file

@ -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

View file

@ -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")) {

View file

@ -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;