Only register signal handlers after the first successful write to the screen

This commit is contained in:
Cameron Reed 2024-10-17 11:39:00 -06:00
parent ba051a041d
commit 149e09f119

View File

@ -41,6 +41,11 @@ pub fn set_layout(layout: *Pane, initial_focus: *Pane) void {
}
pub fn init(term_io: *TermIO) !void {
term_io.enterRawMode();
term_io.saveScreen();
term_io.hideCursor();
term_io.flush();
var resize_handler = std.posix.Sigaction{
.handler = .{ .handler = resize_signal },
.mask = std.posix.empty_sigset,
@ -62,11 +67,6 @@ pub fn init(term_io: *TermIO) !void {
};
try std.posix.sigaction(std.posix.SIG.SEGV, &panic_handler, null);
term_io.enterRawMode();
term_io.saveScreen();
term_io.hideCursor();
term_io.flush();
window.resize(term_io);
try window.draw(term_io);
}