diff --git a/src/app.zig b/src/app.zig index 6a249f9..ae01b69 100644 --- a/src/app.zig +++ b/src/app.zig @@ -55,7 +55,7 @@ command_history: CommandHistory = CommandHistory{}, drawer: Drawer = Drawer{}, directories: Directories, -notification: Notification, +notification: Notification = Notification{}, // Assigned in main after config parsing. file_logger: FileLogger = undefined, @@ -76,9 +76,6 @@ pub fn init(alloc: std.mem.Allocator) !App { }, }); - var notification = Notification{}; - notification.init(); - return App{ .alloc = alloc, .should_quit = false, @@ -86,7 +83,6 @@ pub fn init(alloc: std.mem.Allocator) !App { .tty = try vaxis.Tty.init(), .directories = try Directories.init(alloc), .text_input = vaxis.widgets.TextInput.init(alloc, &vx.unicode), - .notification = notification, .actions = CircStack(Action, actions_len).init(), .last_known_height = vx.window().height, }; diff --git a/src/notification.zig b/src/notification.zig index a05dba2..07a21a7 100644 --- a/src/notification.zig +++ b/src/notification.zig @@ -47,17 +47,13 @@ const Info = enum { const Warn = enum { DeprecatedConfigPath, DuplicateFileOnUndo }; -buf: [1024]u8 = undefined, +var buf: [1024]u8 = undefined; + style: Style = Style.info, -fbs: std.io.FixedBufferStream([]u8) = undefined, +fbs: std.io.FixedBufferStream([]u8) = std.io.fixedBufferStream(&buf), /// How long until the notification disappears in seconds. timer: i64 = 0, -pub fn init(self: *Self) void { - self.fbs = std.io.fixedBufferStream(&self.buf); - self.timer = std.time.timestamp(); -} - pub fn write(self: *Self, text: []const u8, style: Style) !void { self.fbs.reset(); _ = try self.fbs.write(text);