mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-08-25 00:21:46 +00:00
terminal: report DECECM as permanently reset (#12660)
Closes #12505 This PR allows Ghostty to respond to DECRQM queries for DECECM with the "permanently reset". AI disclosure: I used Codex to help inspect the relevant code path and explain the issue, but I reviewed and made the code changes myself.
This commit is contained in:
@@ -79,6 +79,19 @@ 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, DEC private mode 117) controls whether erasing
|
||||
// and scrolling use the default background or the active background color.
|
||||
// Ghostty's behavior is fixed equivalent to DECECM reset, and DECRQM has a
|
||||
// "permanently reset" response for recognized modes that cannot be changed.
|
||||
// Report that instead of "not recognized" so applications can query and adapt
|
||||
// to Ghostty's erase-color behavior.
|
||||
//
|
||||
// See VT520/VT525 Programmer Information, "Erase Color" and DECRQM/DECRPM:
|
||||
// https://web.mit.edu/dosathena/doc/www/ek-vt520-rm.pdf
|
||||
|
||||
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,
|
||||
@@ -334,6 +347,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 });
|
||||
|
||||
@@ -2385,6 +2385,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.?);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user