feat: implement mode 1048 for saving/restoring cursor position

This commit is contained in:
Alex Straight
2025-06-08 23:22:04 -07:00
committed by Mitchell Hashimoto
parent e986beb6a7
commit 59bc980250
2 changed files with 13 additions and 0 deletions

View File

@@ -223,6 +223,7 @@ const entries: []const ModeEntry = &.{
.{ .name = "alt_sends_escape", .value = 1039 },
.{ .name = "reverse_wrap_extended", .value = 1045 },
.{ .name = "alt_screen", .value = 1047 },
.{ .name = "save_cursor", .value = 1048 },
.{ .name = "alt_screen_save_cursor_clear_enter", .value = 1049 },
.{ .name = "bracketed_paste", .value = 2004 },
.{ .name = "synchronized_output", .value = 2026 },

View File

@@ -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();