Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/terminal/modes.zig
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ 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 {
// DECECM (Erase Color Mode) is DEC private mode 117. Ghostty behaves as
// if it is permanently reset and does not implement it as a mutable mode.
if (!tag.ansi and tag.value == 117) {
return .{ .tag = tag, .state = .permanently_reset };
}
const mode = modeFromInt(tag.value, tag.ansi) orelse return .{
.tag = tag,
.state = .not_recognized,
Expand Down Expand Up @@ -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 });
Expand Down
4 changes: 4 additions & 0 deletions src/terminal/stream_terminal.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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.?);
}
}

Expand Down
Loading