地圖 (Jido) is a lightweight Unix TUI file explorer designed for speed and simplicity.

fix: notifications not rendered once announced

Due to the rendering logic, notifications wouldn't be rendered until the
next action the user took. Now they update the UI on publish.

+12
+1
src/app.zig
··· 74 74 75 75 pub const Event = union(enum) { 76 76 image_ready, 77 + notification, 77 78 key_press: Key, 78 79 winsize: vaxis.Winsize, 79 80 };
+3
src/event_handlers.zig
··· 133 133 } 134 134 }, 135 135 .image_ready => {}, 136 + .notification => {}, 136 137 .winsize => |ws| try app.vx.resize(app.alloc, app.tty.writer(), ws), 137 138 } 138 139 } ··· 283 284 } 284 285 }, 285 286 .image_ready => {}, 287 + .notification => {}, 286 288 .winsize => |ws| try app.vx.resize(app.alloc, app.tty.writer(), ws), 287 289 } 288 290 } ··· 298 300 } 299 301 }, 300 302 .image_ready => {}, 303 + .notification => {}, 301 304 .winsize => |ws| try app.vx.resize(app.alloc, app.tty.writer(), ws), 302 305 } 303 306 }
+8
src/notification.zig
··· 1 1 const std = @import("std"); 2 + const vaxis = @import("vaxis"); 3 + const Event = @import("app.zig").Event; 4 + 2 5 const FileLogger = @import("file_logger.zig"); 3 6 4 7 const Self = @This(); ··· 18 21 fbs: std.io.FixedBufferStream([]u8) = std.io.fixedBufferStream(&buf), 19 22 /// How long until the notification disappears in seconds. 20 23 timer: i64 = 0, 24 + loop: ?*vaxis.Loop(Event) = null, 21 25 22 26 pub fn write(self: *Self, text: []const u8, style: Style) !void { 23 27 self.fbs.reset(); 24 28 _ = try self.fbs.write(text); 25 29 self.timer = std.time.timestamp(); 26 30 self.style = style; 31 + 32 + if (self.loop) |loop| { 33 + loop.postEvent(.notification); 34 + } 27 35 } 28 36 29 37 pub fn reset(self: *Self) void {