mirror of
https://github.com/fairyglade/ly.git
synced 2026-03-25 09:46:06 +00:00
Add widget display name to improve logging
Signed-off-by: AnErrupTion <anerruption@disroot.org>
This commit is contained in:
@@ -25,6 +25,7 @@ pub fn init(
|
|||||||
|
|
||||||
pub fn widget(self: *Cascade) Widget {
|
pub fn widget(self: *Cascade) Widget {
|
||||||
return Widget.init(
|
return Widget.init(
|
||||||
|
"Cascade",
|
||||||
self,
|
self,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ pub fn init(
|
|||||||
|
|
||||||
pub fn widget(self: *ColorMix) Widget {
|
pub fn widget(self: *ColorMix) Widget {
|
||||||
return Widget.init(
|
return Widget.init(
|
||||||
|
"ColorMix",
|
||||||
self,
|
self,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ pub fn init(
|
|||||||
|
|
||||||
pub fn widget(self: *Doom) Widget {
|
pub fn widget(self: *Doom) Widget {
|
||||||
return Widget.init(
|
return Widget.init(
|
||||||
|
"Doom",
|
||||||
self,
|
self,
|
||||||
deinit,
|
deinit,
|
||||||
realloc,
|
realloc,
|
||||||
|
|||||||
@@ -417,6 +417,7 @@ pub fn init(
|
|||||||
|
|
||||||
pub fn widget(self: *DurFile) Widget {
|
pub fn widget(self: *DurFile) Widget {
|
||||||
return Widget.init(
|
return Widget.init(
|
||||||
|
"DurFile",
|
||||||
self,
|
self,
|
||||||
deinit,
|
deinit,
|
||||||
realloc,
|
realloc,
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ pub fn init(
|
|||||||
|
|
||||||
pub fn widget(self: *GameOfLife) Widget {
|
pub fn widget(self: *GameOfLife) Widget {
|
||||||
return Widget.init(
|
return Widget.init(
|
||||||
|
"GameOfLife",
|
||||||
self,
|
self,
|
||||||
deinit,
|
deinit,
|
||||||
realloc,
|
realloc,
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ pub fn init(
|
|||||||
|
|
||||||
pub fn widget(self: *Matrix) Widget {
|
pub fn widget(self: *Matrix) Widget {
|
||||||
return Widget.init(
|
return Widget.init(
|
||||||
|
"Matrix",
|
||||||
self,
|
self,
|
||||||
deinit,
|
deinit,
|
||||||
realloc,
|
realloc,
|
||||||
|
|||||||
25
src/main.zig
25
src/main.zig
@@ -1133,8 +1133,8 @@ pub fn main() !void {
|
|||||||
);
|
);
|
||||||
try state.log_file.err(
|
try state.log_file.err(
|
||||||
"tui",
|
"tui",
|
||||||
"failed to set cursor in active widget: {s}",
|
"failed to set cursor in active widget '{s}': {s}",
|
||||||
.{@errorName(err)},
|
.{ current_widget.display_name, @errorName(err) },
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1213,19 +1213,6 @@ pub fn main() !void {
|
|||||||
|
|
||||||
try state.log_file.info("tui", "screen resolution updated to {d}x{d}", .{ state.buffer.width, state.buffer.height });
|
try state.log_file.info("tui", "screen resolution updated to {d}x{d}", .{ state.buffer.width, state.buffer.height });
|
||||||
|
|
||||||
if (animation) |*a| a.realloc() catch |err| {
|
|
||||||
try state.info_line.addMessage(
|
|
||||||
state.lang.err_alloc,
|
|
||||||
state.config.error_bg,
|
|
||||||
state.config.error_fg,
|
|
||||||
);
|
|
||||||
try state.log_file.err(
|
|
||||||
"tui",
|
|
||||||
"failed to reallocate animation buffers: {s}",
|
|
||||||
.{@errorName(err)},
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
for (widgets.items) |*widget| {
|
for (widgets.items) |*widget| {
|
||||||
widget.realloc() catch |err| {
|
widget.realloc() catch |err| {
|
||||||
try state.info_line.addMessage(
|
try state.info_line.addMessage(
|
||||||
@@ -1235,8 +1222,8 @@ pub fn main() !void {
|
|||||||
);
|
);
|
||||||
try state.log_file.err(
|
try state.log_file.err(
|
||||||
"tui",
|
"tui",
|
||||||
"failed to reallocate widget: {s}",
|
"failed to reallocate widget '{s}': {s}",
|
||||||
.{@errorName(err)},
|
.{ widget.display_name, @errorName(err) },
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -1265,8 +1252,8 @@ pub fn main() !void {
|
|||||||
);
|
);
|
||||||
try state.log_file.err(
|
try state.log_file.err(
|
||||||
"tui",
|
"tui",
|
||||||
"failed to handle active widget: {s}",
|
"failed to handle active widget '{s}': {s}",
|
||||||
.{@errorName(err)},
|
.{ current_widget.display_name, @errorName(err) },
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,10 +12,12 @@ const VTable = struct {
|
|||||||
};
|
};
|
||||||
|
|
||||||
id: u64,
|
id: u64,
|
||||||
|
display_name: []const u8,
|
||||||
pointer: *anyopaque,
|
pointer: *anyopaque,
|
||||||
vtable: VTable,
|
vtable: VTable,
|
||||||
|
|
||||||
pub fn init(
|
pub fn init(
|
||||||
|
display_name: []const u8,
|
||||||
pointer: anytype,
|
pointer: anytype,
|
||||||
comptime deinit_fn: ?fn (ptr: @TypeOf(pointer)) void,
|
comptime deinit_fn: ?fn (ptr: @TypeOf(pointer)) void,
|
||||||
comptime realloc_fn: ?fn (ptr: @TypeOf(pointer)) anyerror!void,
|
comptime realloc_fn: ?fn (ptr: @TypeOf(pointer)) anyerror!void,
|
||||||
@@ -86,6 +88,7 @@ pub fn init(
|
|||||||
|
|
||||||
return .{
|
return .{
|
||||||
.id = @intFromPtr(Impl.vtable.draw_fn),
|
.id = @intFromPtr(Impl.vtable.draw_fn),
|
||||||
|
.display_name = display_name,
|
||||||
.pointer = pointer,
|
.pointer = pointer,
|
||||||
.vtable = Impl.vtable,
|
.vtable = Impl.vtable,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ pub fn deinit(self: *BigLabel) void {
|
|||||||
|
|
||||||
pub fn widget(self: *BigLabel) Widget {
|
pub fn widget(self: *BigLabel) Widget {
|
||||||
return Widget.init(
|
return Widget.init(
|
||||||
|
"BigLabel",
|
||||||
self,
|
self,
|
||||||
deinit,
|
deinit,
|
||||||
null,
|
null,
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ pub fn init(
|
|||||||
|
|
||||||
pub fn widget(self: *CenteredBox) Widget {
|
pub fn widget(self: *CenteredBox) Widget {
|
||||||
return Widget.init(
|
return Widget.init(
|
||||||
|
"CenteredBox",
|
||||||
self,
|
self,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ pub fn deinit(self: *InfoLine) void {
|
|||||||
|
|
||||||
pub fn widget(self: *InfoLine) Widget {
|
pub fn widget(self: *InfoLine) Widget {
|
||||||
return Widget.init(
|
return Widget.init(
|
||||||
|
"InfoLine",
|
||||||
self,
|
self,
|
||||||
deinit,
|
deinit,
|
||||||
null,
|
null,
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ pub fn deinit(self: *Label) void {
|
|||||||
|
|
||||||
pub fn widget(self: *Label) Widget {
|
pub fn widget(self: *Label) Widget {
|
||||||
return Widget.init(
|
return Widget.init(
|
||||||
|
"Label",
|
||||||
self,
|
self,
|
||||||
deinit,
|
deinit,
|
||||||
null,
|
null,
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ pub fn deinit(self: *Session) void {
|
|||||||
|
|
||||||
pub fn widget(self: *Session) Widget {
|
pub fn widget(self: *Session) Widget {
|
||||||
return Widget.init(
|
return Widget.init(
|
||||||
|
"Session",
|
||||||
self,
|
self,
|
||||||
deinit,
|
deinit,
|
||||||
null,
|
null,
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ pub fn deinit(self: *Text) void {
|
|||||||
|
|
||||||
pub fn widget(self: *Text) Widget {
|
pub fn widget(self: *Text) Widget {
|
||||||
return Widget.init(
|
return Widget.init(
|
||||||
|
"Text",
|
||||||
self,
|
self,
|
||||||
deinit,
|
deinit,
|
||||||
null,
|
null,
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ pub fn deinit(self: *UserList) void {
|
|||||||
|
|
||||||
pub fn widget(self: *UserList) Widget {
|
pub fn widget(self: *UserList) Widget {
|
||||||
return Widget.init(
|
return Widget.init(
|
||||||
|
"UserList",
|
||||||
self,
|
self,
|
||||||
deinit,
|
deinit,
|
||||||
null,
|
null,
|
||||||
|
|||||||
Reference in New Issue
Block a user