refactor: improve capsulation and safety of tui module public api

This commit is contained in:
CJ van den Berg 2025-01-23 16:45:04 +01:00
parent 4145460012
commit 1d947ab499
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
28 changed files with 239 additions and 198 deletions

View file

@ -24,7 +24,7 @@ pub fn create(allocator: Allocator, parent: Plane, _: ?EventHandler) @import("wi
self.* = .{
.plane = try Plane.init(&(Widget.Box{}).opts(@typeName(Self)), parent),
};
try tui.current().input_listeners.add(EventHandler.bind(self, listen));
try tui.input_listeners().add(EventHandler.bind(self, listen));
return self.widget();
}
@ -33,7 +33,7 @@ pub fn widget(self: *Self) Widget {
}
pub fn deinit(self: *Self, allocator: Allocator) void {
tui.current().input_listeners.remove_ptr(self);
tui.input_listeners().remove_ptr(self);
self.plane.deinit();
allocator.destroy(self);
}