mirror of
https://github.com/fairyglade/ly.git
synced 2026-03-24 09:16:05 +00:00
Switch to single-instance Widget model
And make widget() functions return pointers to widgets instead of just widgets Signed-off-by: AnErrupTion <anerruption@disroot.org>
This commit is contained in:
@@ -16,6 +16,7 @@ pub const STEPS = 12;
|
||||
pub const HEIGHT_MAX = 9;
|
||||
pub const SPREAD_MAX = 4;
|
||||
|
||||
instance: ?Widget = null,
|
||||
start_time: TimeOfDay,
|
||||
allocator: Allocator,
|
||||
terminal_buffer: *TerminalBuffer,
|
||||
@@ -60,6 +61,7 @@ pub fn init(
|
||||
};
|
||||
|
||||
return .{
|
||||
.instance = null,
|
||||
.start_time = try interop.getTimeOfDay(),
|
||||
.allocator = allocator,
|
||||
.terminal_buffer = terminal_buffer,
|
||||
@@ -73,8 +75,9 @@ pub fn init(
|
||||
};
|
||||
}
|
||||
|
||||
pub fn widget(self: *Doom) Widget {
|
||||
return Widget.init(
|
||||
pub fn widget(self: *Doom) *Widget {
|
||||
if (self.instance) |*instance| return instance;
|
||||
self.instance = Widget.init(
|
||||
"Doom",
|
||||
null,
|
||||
self,
|
||||
@@ -85,6 +88,7 @@ pub fn widget(self: *Doom) Widget {
|
||||
null,
|
||||
calculateTimeout,
|
||||
);
|
||||
return &self.instance.?;
|
||||
}
|
||||
|
||||
fn deinit(self: *Doom) void {
|
||||
|
||||
Reference in New Issue
Block a user