fix(terminal): correctly restore termios and screen's during panic_handler
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 1m1s
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 1m1s
This commit is contained in:
13
src/app.zig
13
src/app.zig
@@ -88,11 +88,11 @@ pub fn App(comptime E: type) type {
|
|||||||
|
|
||||||
pub fn stop(this: *@This()) !void {
|
pub fn stop(this: *@This()) !void {
|
||||||
try this.interrupt();
|
try this.interrupt();
|
||||||
if (this.termios) |*termios| {
|
if (this.termios) |termios| {
|
||||||
try terminal.disableMouseSupport();
|
try terminal.disableMouseSupport();
|
||||||
try terminal.showCursor();
|
try terminal.showCursor();
|
||||||
try terminal.restoreScreen();
|
try terminal.restoreScreen();
|
||||||
try terminal.disableRawMode(termios);
|
try terminal.disableRawMode(&termios);
|
||||||
try terminal.exitAltScreen();
|
try terminal.exitAltScreen();
|
||||||
}
|
}
|
||||||
this.termios = null;
|
this.termios = null;
|
||||||
@@ -391,9 +391,9 @@ pub fn App(comptime E: type) type {
|
|||||||
|
|
||||||
pub fn panic_handler(msg: []const u8, _: ?*std.builtin.StackTrace, ret_addr: ?usize) noreturn {
|
pub fn panic_handler(msg: []const u8, _: ?*std.builtin.StackTrace, ret_addr: ?usize) noreturn {
|
||||||
terminal.disableMouseSupport() catch {};
|
terminal.disableMouseSupport() catch {};
|
||||||
terminal.exitAltScreen() catch {};
|
|
||||||
terminal.showCursor() catch {};
|
terminal.showCursor() catch {};
|
||||||
var termios: posix.termios = .{
|
terminal.restoreScreen() catch {};
|
||||||
|
terminal.disableRawMode(&.{
|
||||||
.iflag = .{},
|
.iflag = .{},
|
||||||
.lflag = .{},
|
.lflag = .{},
|
||||||
.cflag = .{},
|
.cflag = .{},
|
||||||
@@ -402,9 +402,8 @@ pub fn App(comptime E: type) type {
|
|||||||
.line = 0,
|
.line = 0,
|
||||||
.ispeed = undefined,
|
.ispeed = undefined,
|
||||||
.ospeed = undefined,
|
.ospeed = undefined,
|
||||||
};
|
}) catch {};
|
||||||
terminal.disableRawMode(&termios) catch {};
|
terminal.exitAltScreen() catch {};
|
||||||
terminal.restoreScreen() catch {};
|
|
||||||
std.debug.defaultPanic(msg, ret_addr);
|
std.debug.defaultPanic(msg, ret_addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ pub fn enableRawMode(bak: *posix.termios) !void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Reverts `enableRawMode` to restore initial functionality.
|
/// Reverts `enableRawMode` to restore initial functionality.
|
||||||
pub fn disableRawMode(bak: *posix.termios) !void {
|
pub fn disableRawMode(bak: *const posix.termios) !void {
|
||||||
try posix.tcsetattr(
|
try posix.tcsetattr(
|
||||||
posix.STDIN_FILENO,
|
posix.STDIN_FILENO,
|
||||||
.FLUSH,
|
.FLUSH,
|
||||||
|
|||||||
Reference in New Issue
Block a user