feat(panic): panic handler to recover termios when crashing

This commit is contained in:
2025-05-30 23:00:45 +02:00
parent 5ba5b2b372
commit 9a818117d7
13 changed files with 31 additions and 0 deletions

View File

@@ -188,6 +188,7 @@ pub fn main() !void {
}
}
pub const panic = App.panic_handler;
const log = std.log.scoped(.default);
const std = @import("std");

View File

@@ -90,6 +90,7 @@ pub fn main() !void {
}
}
pub const panic = App.panic_handler;
const log = std.log.scoped(.default);
const std = @import("std");

View File

@@ -137,6 +137,7 @@ pub fn main() !void {
}
}
pub const panic = App.panic_handler;
const log = std.log.scoped(.default);
const std = @import("std");

View File

@@ -217,6 +217,7 @@ pub fn main() !void {
}
}
pub const panic = App.panic_handler;
const log = std.log.scoped(.default);
const std = @import("std");

View File

@@ -189,6 +189,7 @@ pub fn main() !void {
}
}
pub const panic = App.panic_handler;
const log = std.log.scoped(.default);
const std = @import("std");

View File

@@ -150,6 +150,7 @@ pub fn main() !void {
}
}
pub const panic = App.panic_handler;
const log = std.log.scoped(.default);
const std = @import("std");

View File

@@ -106,6 +106,7 @@ pub fn main() !void {
}
}
pub const panic = App.panic_handler;
const log = std.log.scoped(.default);
const std = @import("std");

View File

@@ -98,6 +98,7 @@ pub fn main() !void {
}
}
pub const panic = App.panic_handler;
const log = std.log.scoped(.default);
const std = @import("std");

View File

@@ -114,6 +114,7 @@ pub fn main() !void {
}
}
pub const panic = App.panic_handler;
const log = std.log.scoped(.default);
const std = @import("std");

View File

@@ -97,6 +97,7 @@ pub fn main() !void {
}
}
pub const panic = App.panic_handler;
const log = std.log.scoped(.default);
const std = @import("std");

View File

@@ -93,6 +93,7 @@ pub fn main() !void {
}
}
pub const panic = App.panic_handler;
const log = std.log.scoped(.default);
const std = @import("std");

View File

@@ -148,6 +148,7 @@ pub fn main() !void {
}
}
pub const panic = App.panic_handler;
const log = std.log.scoped(.default);
const std = @import("std");

View File

@@ -393,6 +393,25 @@ pub fn App(comptime E: type) type {
}
}
pub fn panic_handler(msg: []const u8, _: ?*std.builtin.StackTrace, ret_addr: ?usize) noreturn {
terminal.disableMouseSupport() catch {};
terminal.exitAltScreen() catch {};
terminal.showCursor() catch {};
var termios: posix.termios = .{
.iflag = .{},
.lflag = .{},
.cflag = .{},
.oflag = .{},
.cc = undefined,
.line = 0,
.ispeed = undefined,
.ospeed = undefined,
};
terminal.disableRawMode(&termios) catch {};
terminal.restoreScreen() catch {};
std.debug.defaultPanic(msg, ret_addr);
}
const element = @import("element.zig");
pub const Event = mergeTaggedUnions(event.SystemEvent, E);
pub const Container = @import("container.zig").Container(Event);