Add custom panic handler

Sadly, it doesn't seem to be called on segfaults, which means that will
still output garbage. I could install a custom segfault handler, but not
sure that's worth the effort.
This commit is contained in:
Yorhel 2024-08-06 14:43:44 +02:00
parent 30d6ddf149
commit 22dca22450

View file

@ -61,6 +61,14 @@ pub const allocator = std.mem.Allocator{
};
// Custom panic impl to reset the terminal before spewing out an error message.
pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace, ret_addr: ?usize) noreturn {
@setCold(true);
ui.deinit();
std.debug.panicImpl(error_return_trace, ret_addr orelse @returnAddress(), msg);
}
pub const config = struct {
pub const SortCol = enum { name, blocks, size, items, mtime };
pub const SortOrder = enum { asc, desc };