- commit
- a166953
- parent
- 684604d
- author
- Eric Bower
- date
- 2025-12-19 09:16:30 -0500 EST
fix: reset terminal modes on detach Closes: https://github.com/neurosnap/zmx/issues/26
1 files changed,
+7,
-2
+7,
-2
1@@ -477,8 +477,13 @@ fn attach(daemon: *Daemon) !void {
2 // Use TCSAFLUSH to discard any unread input, preventing stale input after detach.
3 defer {
4 _ = c.tcsetattr(posix.STDIN_FILENO, c.TCSAFLUSH, &orig_termios);
5- // Clear screen and show cursor on detach
6- const restore_seq = "\x1b[?25h\x1b[2J\x1b[H";
7+ // Reset terminal modes on detach:
8+ // - Mouse: 1000=basic, 1002=button-event, 1003=any-event, 1006=SGR extended
9+ // - 2004=bracketed paste, 1004=focus events, 1049=alt screen
10+ // - 25h=show cursor, 2J=clear screen, H=cursor home
11+ const restore_seq = "\x1b[?1000l\x1b[?1002l\x1b[?1003l\x1b[?1006l" ++
12+ "\x1b[?2004l\x1b[?1004l\x1b[?1049l" ++
13+ "\x1b[?25h\x1b[2J\x1b[H";
14 _ = posix.write(posix.STDOUT_FILENO, restore_seq) catch {};
15 }
16