From c092b2bcf51415a83ff9a1f2fddf67caa58b1283 Mon Sep 17 00:00:00 2001 From: Ayush Date: Mon, 11 May 2026 16:06:11 -0700 Subject: [PATCH] terminal: report DECECM as permanently reset --- src/terminal/modes.zig | 12 ++++++++++++ src/terminal/stream_terminal.zig | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/src/terminal/modes.zig b/src/terminal/modes.zig index c92f97b08..6bf44304b 100644 --- a/src/terminal/modes.zig +++ b/src/terminal/modes.zig @@ -10,6 +10,8 @@ const std = @import("std"); const testing = std.testing; +const dececm_mode: u15 = 117; + /// A struct that maintains the state of all the settable modes. pub const ModeState = struct { /// The values of the current modes. @@ -79,6 +81,9 @@ pub const ModeState = struct { /// Return a DECRPM report for the given mode tag. If the tag does /// not correspond to a known mode, the report state is .not_recognized. pub fn getReport(self: *const ModeState, tag: ModeTag) Report { + if (!tag.ansi and tag.value == dececm_mode) { + return .{ .tag = tag, .state = .permanently_reset }; + } const mode = modeFromInt(tag.value, tag.ansi) orelse return .{ .tag = tag, .state = .not_recognized, @@ -347,6 +352,13 @@ test "getReport known ANSI mode" { try testing.expectEqual(true, report.tag.ansi); } +test "getReport DECECM permanently reset" { + const state: ModeState = .{}; + const report = state.getReport(.{ .value = 117, .ansi = false }); + try testing.expectEqual(Report.State.permanently_reset, report.state); + try testing.expectEqual(false, report.tag.ansi); +} + test "getReport unknown mode" { const state: ModeState = .{}; const report = state.getReport(.{ .value = 9999 }); diff --git a/src/terminal/stream_terminal.zig b/src/terminal/stream_terminal.zig index f68f088bf..251105e72 100644 --- a/src/terminal/stream_terminal.zig +++ b/src/terminal/stream_terminal.zig @@ -1366,6 +1366,10 @@ test "request mode DECRQM with write_pty callback" { // Query an unknown mode s.nextSlice("\x1B[?9999$p"); try testing.expectEqualStrings("\x1B[?9999;0$y", S.last_response.?); + + // Query DECECM, which Ghostty recognizes but does not allow changing + s.nextSlice("\x1B[?117$p"); + try testing.expectEqualStrings("\x1B[?117;4$y", S.last_response.?); } }