diff options
| author | Mitchell Hashimoto <m@mitchellh.com> | 2025-06-09 07:14:59 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-09 07:14:59 -0700 |
| commit | 57cd5ef08520800533596f00a60ce84b9bd8950d (patch) | |
| tree | 29cf88b0558a00e39fd1b5dce7402490cb90de06 /src/termio | |
| parent | 5e77bd6e9bff558b063aae85ece0d3b252d29b94 (diff) | |
| parent | 59bc980250e7b448a8e8693484a9fb5d625fc198 (diff) | |
feat: implement mode 1048 for saving/restoring cursor position (#7553)
Implements mode 1048 for saving/restoring cursor position.
This is the same as mode 1049 but only saves cursor position without
touching the alternate screen.
**save/restore cursor position:**
- `ESC[?1048h` - save cursor position
- `ESC[?1048l` - restore cursor position
**Quick test:**
```bash
printf '\e[5;10H[SAVED HERE]'
printf '\e[?1048h' # save position
printf '\e[15;1HMoved somewhere else...'
printf '\e[?1048l' # restore
printf ' RESTORED!' # should appear next to [SAVED HERE]
```
Fixes #7473
Diffstat (limited to 'src/termio')
| -rw-r--r-- | src/termio/stream_handler.zig | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/termio/stream_handler.zig b/src/termio/stream_handler.zig index b3aa82d20..2069a8ff2 100644 --- a/src/termio/stream_handler.zig +++ b/src/termio/stream_handler.zig @@ -597,6 +597,18 @@ pub const StreamHandler = struct { try self.queueRender(); }, + // Mode 1048 is xterm's conditional save cursor depending + // on if alt screen is enabled or not (at the terminal emulator + // level). Alt screen is always enabled for us so this just + // does a save/restore cursor. + .save_cursor => { + if (enabled) { + self.terminal.saveCursor(); + } else { + try self.terminal.restoreCursor(); + } + }, + // Force resize back to the window size .enable_mode_3 => { const grid_size = self.size.grid(); |
