From 142f6e51aeef857386d2d404135f2e5ab048cb2b Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Mon, 20 Jan 2025 20:30:24 +0100 Subject: [PATCH] feat(tui): show screen dimentions on resize --- src/tui/tui.zig | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/tui/tui.zig b/src/tui/tui.zig index 198362e..7677103 100644 --- a/src/tui/tui.zig +++ b/src/tui/tui.zig @@ -311,6 +311,8 @@ fn receive_safe(self: *Self, from: tp.pid_ref, m: tp.message) !void { if (try m.match(.{"resize"})) { self.resize(); + const box = self.screen(); + message("{d}x{d}", .{ box.w, box.h }); return; } @@ -1174,3 +1176,8 @@ pub fn is_cursor_beam(self: *Self) bool { else => false, }; } + +pub fn message(comptime fmt: anytype, args: anytype) void { + var buf: [256]u8 = undefined; + tp.self_pid().send(.{ "message", std.fmt.bufPrint(&buf, fmt, args) catch @panic("too large") }) catch {}; +}