terminal: report DECECM as permanently reset

This commit is contained in:
Ayush
2026-05-11 16:06:11 -07:00
parent ce6a00bfbf
commit c092b2bcf5
2 changed files with 16 additions and 0 deletions

View File

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

View File

@@ -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.?);
}
}