osc: fix OSC4 response

When reporting colors via OSC4, the index must also be reported.
This commit is contained in:
Tim Culverhouse
2023-11-21 09:58:09 -06:00
parent bed49e59b3
commit 469c88c0c6

View File

@ -2278,7 +2278,20 @@ const StreamHandler = struct {
var msg: termio.Message = .{ .write_small = .{} }; var msg: termio.Message = .{ .write_small = .{} };
const resp = switch (self.osc_color_report_format) { const resp = switch (self.osc_color_report_format) {
.@"16-bit" => try std.fmt.bufPrint( .@"16-bit" => switch (kind) {
.palette => |i| try std.fmt.bufPrint(
&msg.write_small.data,
"\x1B]{s};{d};rgb:{x:0>4}/{x:0>4}/{x:0>4}{s}",
.{
kind.code(),
i,
@as(u16, color.r) * 257,
@as(u16, color.g) * 257,
@as(u16, color.b) * 257,
terminator.string(),
},
),
else => try std.fmt.bufPrint(
&msg.write_small.data, &msg.write_small.data,
"\x1B]{s};rgb:{x:0>4}/{x:0>4}/{x:0>4}{s}", "\x1B]{s};rgb:{x:0>4}/{x:0>4}/{x:0>4}{s}",
.{ .{
@ -2289,8 +2302,22 @@ const StreamHandler = struct {
terminator.string(), terminator.string(),
}, },
), ),
},
.@"8-bit" => try std.fmt.bufPrint( .@"8-bit" => switch (kind) {
.palette => |i| try std.fmt.bufPrint(
&msg.write_small.data,
"\x1B]{s};{d};rgb:{x:0>2}/{x:0>2}/{x:0>2}{s}",
.{
kind.code(),
i,
@as(u16, color.r),
@as(u16, color.g),
@as(u16, color.b),
terminator.string(),
},
),
else => try std.fmt.bufPrint(
&msg.write_small.data, &msg.write_small.data,
"\x1B]{s};rgb:{x:0>2}/{x:0>2}/{x:0>2}{s}", "\x1B]{s};rgb:{x:0>2}/{x:0>2}/{x:0>2}{s}",
.{ .{
@ -2301,7 +2328,7 @@ const StreamHandler = struct {
terminator.string(), terminator.string(),
}, },
), ),
},
.none => unreachable, // early return above .none => unreachable, // early return above
}; };
msg.write_small.len = @intCast(resp.len); msg.write_small.len = @intCast(resp.len);