feat(panic): panic handler to recover termios when crashing
This commit is contained in:
19
src/app.zig
19
src/app.zig
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user