Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panic: move recovery log to separate function #147

Merged
merged 1 commit into from
Jan 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ pub fn init(alloc: std.mem.Allocator, opts: Vaxis.Options) !Vaxis {

/// Resets terminal state on a panic, then calls the default zig panic handler
pub fn panic_handler(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace, ret_addr: ?usize) noreturn {
recover();
std.builtin.default_panic(msg, error_return_trace, ret_addr);
}

/// Resets the terminal state using the global tty instance. Use this only to recover during a panic
pub fn recover() void {
if (tty.global_tty) |gty| {
const reset: []const u8 = ctlseqs.csi_u_pop ++
ctlseqs.mouse_reset ++
Expand All @@ -59,8 +65,6 @@ pub fn panic_handler(msg: []const u8, error_return_trace: ?*std.builtin.StackTra

gty.deinit();
}

std.builtin.default_panic(msg, error_return_trace, ret_addr);
}

pub const log_scopes = enum {
Expand Down
Loading