diff options
| author | t <t@tjp.lol> | 2026-06-08 14:48:33 -0600 |
|---|---|---|
| committer | t <t@tjp.lol> | 2026-06-08 19:56:47 -0600 |
| commit | 104001d25c9c8cb5ec45ced1678f7c7b70888808 (patch) | |
| tree | e0fd9d5c89e953dd9db9253b87be8426e56d63f1 /src/tui_terminal.zig | |
| parent | b5eb3f1776a540a55d5675f786a4421c49a6283d (diff) | |
keybinding fixes
Diffstat (limited to 'src/tui_terminal.zig')
| -rw-r--r-- | src/tui_terminal.zig | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/tui_terminal.zig b/src/tui_terminal.zig index 0f8b3d9..0b00bb4 100644 --- a/src/tui_terminal.zig +++ b/src/tui_terminal.zig @@ -252,6 +252,31 @@ pub const Terminal = struct { if (active_restore == &self.restore) active_restore = null; } + /// Temporarily return the tty to its ORIGINAL (cooked) termios so a child + /// process (e.g. `$EDITOR`) can drive the terminal normally, and show the + /// cursor. Pairs with `resumeRawMode`. Unlike `deinit`, this does NOT clear + /// the global restore record or mark the restore done — the signal/panic + /// restore path stays armed with the original termios (restoring to cooked + /// is exactly what we'd want on a crash mid-editor), and we re-enter raw + /// mode afterward. + /// + /// No-op if not currently in raw mode. + pub fn suspendRawMode(self: *Terminal) void { + if (!self.raw_mode) return; + posix.tcsetattr(self.fd, .FLUSH, self.restore.original) catch {}; + self.raw_mode = false; + self.writeAll(seq.show_cursor); + } + + /// Re-enter raw mode after `suspendRawMode` and hide the cursor again. The + /// global restore record and signal handlers are already installed (they + /// were never torn down), so this just reapplies the raw termios. + pub fn resumeRawMode(self: *Terminal) Error!void { + if (self.raw_mode) return; + try self.enableRawMode(); + self.writeAll(seq.hide_cursor); + } + // -- output helpers ----------------------------------------------------- /// Raw write of `bytes` to the tty. Returns the count written (short |
