summaryrefslogtreecommitdiff
path: root/dev
diff options
context:
space:
mode:
Diffstat (limited to 'dev')
-rw-r--r--dev/tui/tui.zig16
1 files changed, 11 insertions, 5 deletions
diff --git a/dev/tui/tui.zig b/dev/tui/tui.zig
index 9117d54d..5d75722f 100644
--- a/dev/tui/tui.zig
+++ b/dev/tui/tui.zig
@@ -901,12 +901,14 @@ const Screen = struct {
fn leave(sc: *Screen) void {
if (!sc.on) return;
sc.on = false;
- Killed.disarm();
clearNativeImages(&sc.kitty, &sc.vx, &sc.tty);
sc.vx.exitAltScreen(sc.tty.writer()) catch {};
sc.vx.deinit(sc.gpa, sc.tty.writer());
if (comptime !builtin.is_test) vaxis.tty.global_tty = null;
- sc.tty.deinit(); // restore cooked termios LAST, after vx flushed its resets
+ // The cooked modes back LAST, after vx flushed its resets, and Killed
+ // armed until they are.
+ Killed.disarm();
+ sc.tty.deinit();
}
/// Its terminal hung up, or the stub that waits on it is gone.
@@ -950,10 +952,14 @@ const Killed = struct {
_ = std.c.tcsetattr(tty, .FLUSH, termios);
}
- /// The terminal gone (put back, or detached): a TERM still takes the
- /// socket, the prompt files and the shells with it, and leaves the
- /// terminal alone.
+ /// The terminal let go (Screen.leave): its cooked modes put back first,
+ /// so that a TERM anywhere in a leave finds them back or puts them back
+ /// itself (let go first, a TERM before vaxis put them back died leaving
+ /// the terminal raw for good); then a TERM still takes the socket,
+ /// the prompt files and the shells with it, and leaves the terminal
+ /// alone.
fn disarm() void {
+ if (fd >= 0) _ = std.c.tcsetattr(fd, .FLUSH, &cooked);
fd = -1;
}