mirror of
https://github.com/fairyglade/ly.git
synced 2026-03-21 22:43:38 +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 {
|
||||
return Widget.init(
|
||||
"Cascade",
|
||||
self,
|
||||
null,
|
||||
null,
|
||||
|
||||
@@ -55,6 +55,7 @@ pub fn init(
|
||||
|
||||
pub fn widget(self: *ColorMix) Widget {
|
||||
return Widget.init(
|
||||
"ColorMix",
|
||||
self,
|
||||
null,
|
||||
null,
|
||||
|
||||
@@ -62,6 +62,7 @@ pub fn init(
|
||||
|
||||
pub fn widget(self: *Doom) Widget {
|
||||
return Widget.init(
|
||||
"Doom",
|
||||
self,
|
||||
deinit,
|
||||
realloc,
|
||||
|
||||
@@ -417,6 +417,7 @@ pub fn init(
|
||||
|
||||
pub fn widget(self: *DurFile) Widget {
|
||||
return Widget.init(
|
||||
"DurFile",
|
||||
self,
|
||||
deinit,
|
||||
realloc,
|
||||
|
||||
@@ -72,6 +72,7 @@ pub fn init(
|
||||
|
||||
pub fn widget(self: *GameOfLife) Widget {
|
||||
return Widget.init(
|
||||
"GameOfLife",
|
||||
self,
|
||||
deinit,
|
||||
realloc,
|
||||
|
||||
@@ -69,6 +69,7 @@ pub fn init(
|
||||
|
||||
pub fn widget(self: *Matrix) Widget {
|
||||
return Widget.init(
|
||||
"Matrix",
|
||||
self,
|
||||
deinit,
|
||||
realloc,
|
||||
|
||||
25
src/main.zig
25
src/main.zig
@@ -1133,8 +1133,8 @@ pub fn main() !void {
|
||||
);
|
||||
try state.log_file.err(
|
||||
"tui",
|
||||
"failed to set cursor in active widget: {s}",
|
||||
.{@errorName(err)},
|
||||
"failed to set cursor in active widget '{s}': {s}",
|
||||
.{ 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 });
|
||||
|
||||
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| {
|
||||
widget.realloc() catch |err| {
|
||||
try state.info_line.addMessage(
|
||||
@@ -1235,8 +1222,8 @@ pub fn main() !void {
|
||||
);
|
||||
try state.log_file.err(
|
||||
"tui",
|
||||
"failed to reallocate widget: {s}",
|
||||
.{@errorName(err)},
|
||||
"failed to reallocate widget '{s}': {s}",
|
||||
.{ widget.display_name, @errorName(err) },
|
||||
);
|
||||
};
|
||||
}
|
||||
@@ -1265,8 +1252,8 @@ pub fn main() !void {
|
||||
);
|
||||
try state.log_file.err(
|
||||
"tui",
|
||||
"failed to handle active widget: {s}",
|
||||
.{@errorName(err)},
|
||||
"failed to handle active widget '{s}': {s}",
|
||||
.{ current_widget.display_name, @errorName(err) },
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -12,10 +12,12 @@ const VTable = struct {
|
||||
};
|
||||
|
||||
id: u64,
|
||||
display_name: []const u8,
|
||||
pointer: *anyopaque,
|
||||
vtable: VTable,
|
||||
|
||||
pub fn init(
|
||||
display_name: []const u8,
|
||||
pointer: anytype,
|
||||
comptime deinit_fn: ?fn (ptr: @TypeOf(pointer)) void,
|
||||
comptime realloc_fn: ?fn (ptr: @TypeOf(pointer)) anyerror!void,
|
||||
@@ -86,6 +88,7 @@ pub fn init(
|
||||
|
||||
return .{
|
||||
.id = @intFromPtr(Impl.vtable.draw_fn),
|
||||
.display_name = display_name,
|
||||
.pointer = pointer,
|
||||
.vtable = Impl.vtable,
|
||||
};
|
||||
|
||||
@@ -84,6 +84,7 @@ pub fn deinit(self: *BigLabel) void {
|
||||
|
||||
pub fn widget(self: *BigLabel) Widget {
|
||||
return Widget.init(
|
||||
"BigLabel",
|
||||
self,
|
||||
deinit,
|
||||
null,
|
||||
|
||||
@@ -61,6 +61,7 @@ pub fn init(
|
||||
|
||||
pub fn widget(self: *CenteredBox) Widget {
|
||||
return Widget.init(
|
||||
"CenteredBox",
|
||||
self,
|
||||
null,
|
||||
null,
|
||||
|
||||
@@ -47,6 +47,7 @@ pub fn deinit(self: *InfoLine) void {
|
||||
|
||||
pub fn widget(self: *InfoLine) Widget {
|
||||
return Widget.init(
|
||||
"InfoLine",
|
||||
self,
|
||||
deinit,
|
||||
null,
|
||||
|
||||
@@ -42,6 +42,7 @@ pub fn deinit(self: *Label) void {
|
||||
|
||||
pub fn widget(self: *Label) Widget {
|
||||
return Widget.init(
|
||||
"Label",
|
||||
self,
|
||||
deinit,
|
||||
null,
|
||||
|
||||
@@ -57,6 +57,7 @@ pub fn deinit(self: *Session) void {
|
||||
|
||||
pub fn widget(self: *Session) Widget {
|
||||
return Widget.init(
|
||||
"Session",
|
||||
self,
|
||||
deinit,
|
||||
null,
|
||||
|
||||
@@ -56,6 +56,7 @@ pub fn deinit(self: *Text) void {
|
||||
|
||||
pub fn widget(self: *Text) Widget {
|
||||
return Widget.init(
|
||||
"Text",
|
||||
self,
|
||||
deinit,
|
||||
null,
|
||||
|
||||
@@ -89,6 +89,7 @@ pub fn deinit(self: *UserList) void {
|
||||
|
||||
pub fn widget(self: *UserList) Widget {
|
||||
return Widget.init(
|
||||
"UserList",
|
||||
self,
|
||||
deinit,
|
||||
null,
|
||||
|
||||
Reference in New Issue
Block a user