mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
termio: prevent responses to non-query OSC 21 sequences
The Ghostty implementation of OSC 21 (Kitty color protocol) currently responds to *all* OSC 21 sequences. It should not respond to a set, nor a reset command. Fix the implementation so that we only respond if a query was received.
This commit is contained in:

committed by
Mitchell Hashimoto

parent
f458d48f9b
commit
196bc55757
@ -1418,11 +1418,13 @@ pub const StreamHandler = struct {
|
|||||||
var buf = std.ArrayList(u8).init(self.alloc);
|
var buf = std.ArrayList(u8).init(self.alloc);
|
||||||
defer buf.deinit();
|
defer buf.deinit();
|
||||||
const writer = buf.writer();
|
const writer = buf.writer();
|
||||||
try writer.writeAll("\x1b]21");
|
|
||||||
|
|
||||||
for (request.list.items) |item| {
|
for (request.list.items) |item| {
|
||||||
switch (item) {
|
switch (item) {
|
||||||
.query => |key| {
|
.query => |key| {
|
||||||
|
// If the writer buffer is empty, we need to write our prefix
|
||||||
|
if (buf.items.len == 0) try writer.writeAll("\x1b]21");
|
||||||
|
|
||||||
const color: terminal.color.RGB = switch (key) {
|
const color: terminal.color.RGB = switch (key) {
|
||||||
.palette => |palette| self.terminal.color_palette.colors[palette],
|
.palette => |palette| self.terminal.color_palette.colors[palette],
|
||||||
.special => |special| switch (special) {
|
.special => |special| switch (special) {
|
||||||
@ -1517,14 +1519,16 @@ pub const StreamHandler = struct {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try writer.writeAll(request.terminator.string());
|
// If we had any writes to our buffer, we queue them now
|
||||||
|
if (buf.items.len > 0) {
|
||||||
self.messageWriter(.{
|
try writer.writeAll(request.terminator.string());
|
||||||
.write_alloc = .{
|
self.messageWriter(.{
|
||||||
.alloc = self.alloc,
|
.write_alloc = .{
|
||||||
.data = try buf.toOwnedSlice(),
|
.alloc = self.alloc,
|
||||||
},
|
.data = try buf.toOwnedSlice(),
|
||||||
});
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Note: we don't have to do a queueRender here because every
|
// Note: we don't have to do a queueRender here because every
|
||||||
// processed stream will queue a render once it is done processing
|
// processed stream will queue a render once it is done processing
|
||||||
|
Reference in New Issue
Block a user