From 02bdcd76258f7bbe7bb5a9beb63e67130d21d705 Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Fri, 19 Jan 2024 10:59:47 -0600 Subject: [PATCH] vaxis: adjust alt screen logic Signed-off-by: Tim Culverhouse --- src/vaxis.zig | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/vaxis.zig b/src/vaxis.zig index 3278ab8..f6e5b95 100644 --- a/src/vaxis.zig +++ b/src/vaxis.zig @@ -106,7 +106,10 @@ pub fn Vaxis(comptime T: type) type { }; } + /// enter the alternate screen. The alternate screen will automatically + /// be exited if calling deinit while in the alt screen pub fn enterAltScreen(self: *Self) !void { + if (self.alt_screen) return; if (self.tty) |_| { var tty = &self.tty.?; _ = try tty.write(ctlseqs.smcup); @@ -114,10 +117,10 @@ pub fn Vaxis(comptime T: type) type { } } + /// exit the alternate screen pub fn exitaltScreen(self: *Self) !void { + if (!self.alt_screen) return; if (self.tty) |_| { - if (!self.alt_screen) return; - var tty = &self.tty.?; _ = try tty.write(ctlseqs.rmcup); self.alt_screen = false;