feat(panic): panic handler to recover termios when crashing
This commit is contained in:
@@ -188,6 +188,7 @@ pub fn main() !void {
|
||||
}
|
||||
}
|
||||
|
||||
pub const panic = App.panic_handler;
|
||||
const log = std.log.scoped(.default);
|
||||
|
||||
const std = @import("std");
|
||||
|
||||
@@ -90,6 +90,7 @@ pub fn main() !void {
|
||||
}
|
||||
}
|
||||
|
||||
pub const panic = App.panic_handler;
|
||||
const log = std.log.scoped(.default);
|
||||
|
||||
const std = @import("std");
|
||||
|
||||
@@ -137,6 +137,7 @@ pub fn main() !void {
|
||||
}
|
||||
}
|
||||
|
||||
pub const panic = App.panic_handler;
|
||||
const log = std.log.scoped(.default);
|
||||
|
||||
const std = @import("std");
|
||||
|
||||
@@ -217,6 +217,7 @@ pub fn main() !void {
|
||||
}
|
||||
}
|
||||
|
||||
pub const panic = App.panic_handler;
|
||||
const log = std.log.scoped(.default);
|
||||
|
||||
const std = @import("std");
|
||||
|
||||
@@ -189,6 +189,7 @@ pub fn main() !void {
|
||||
}
|
||||
}
|
||||
|
||||
pub const panic = App.panic_handler;
|
||||
const log = std.log.scoped(.default);
|
||||
|
||||
const std = @import("std");
|
||||
|
||||
@@ -150,6 +150,7 @@ pub fn main() !void {
|
||||
}
|
||||
}
|
||||
|
||||
pub const panic = App.panic_handler;
|
||||
const log = std.log.scoped(.default);
|
||||
|
||||
const std = @import("std");
|
||||
|
||||
@@ -106,6 +106,7 @@ pub fn main() !void {
|
||||
}
|
||||
}
|
||||
|
||||
pub const panic = App.panic_handler;
|
||||
const log = std.log.scoped(.default);
|
||||
|
||||
const std = @import("std");
|
||||
|
||||
@@ -98,6 +98,7 @@ pub fn main() !void {
|
||||
}
|
||||
}
|
||||
|
||||
pub const panic = App.panic_handler;
|
||||
const log = std.log.scoped(.default);
|
||||
|
||||
const std = @import("std");
|
||||
|
||||
@@ -114,6 +114,7 @@ pub fn main() !void {
|
||||
}
|
||||
}
|
||||
|
||||
pub const panic = App.panic_handler;
|
||||
const log = std.log.scoped(.default);
|
||||
|
||||
const std = @import("std");
|
||||
|
||||
@@ -97,6 +97,7 @@ pub fn main() !void {
|
||||
}
|
||||
}
|
||||
|
||||
pub const panic = App.panic_handler;
|
||||
const log = std.log.scoped(.default);
|
||||
|
||||
const std = @import("std");
|
||||
|
||||
@@ -93,6 +93,7 @@ pub fn main() !void {
|
||||
}
|
||||
}
|
||||
|
||||
pub const panic = App.panic_handler;
|
||||
const log = std.log.scoped(.default);
|
||||
|
||||
const std = @import("std");
|
||||
|
||||
@@ -148,6 +148,7 @@ pub fn main() !void {
|
||||
}
|
||||
}
|
||||
|
||||
pub const panic = App.panic_handler;
|
||||
const log = std.log.scoped(.default);
|
||||
|
||||
const std = @import("std");
|
||||
|
||||
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