parser: handle parsing of apc, sos, pm strings
This lets us detect kitty graphics. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
This commit is contained in:
parent
23a00ede55
commit
8c8c592722
4 changed files with 50 additions and 5 deletions
|
@ -444,6 +444,46 @@ pub fn parse(self: *Parser, input: []const u8) !Result {
|
|||
},
|
||||
}
|
||||
},
|
||||
.apc => {
|
||||
switch (b) {
|
||||
0x1B => {
|
||||
state = .ground;
|
||||
// advance one more for the backslash
|
||||
i += 1;
|
||||
switch (input[start + 1]) {
|
||||
'G' => {
|
||||
return .{
|
||||
.event = .cap_kitty_graphics,
|
||||
.n = i + 1,
|
||||
};
|
||||
},
|
||||
else => {
|
||||
log.warn("unhandled apc: APC {s}", .{input[start + 1 .. i + 1]});
|
||||
return .{
|
||||
.event = null,
|
||||
.n = i + 1,
|
||||
};
|
||||
},
|
||||
}
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
},
|
||||
.sos, .pm => {
|
||||
switch (b) {
|
||||
0x1B => {
|
||||
state = .ground;
|
||||
// advance one more for the backslash
|
||||
i += 1;
|
||||
log.warn("unhandled sos/pm: SOS/PM {s}", .{input[start + 1 .. i + 1]});
|
||||
return .{
|
||||
.event = null,
|
||||
.n = i + 1,
|
||||
};
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -178,9 +178,15 @@ pub fn run(
|
|||
}
|
||||
},
|
||||
.cap_kitty_keyboard => {
|
||||
log.info("kitty capability detected", .{});
|
||||
log.info("kitty keyboard capability detected", .{});
|
||||
vx.caps.kitty_keyboard = true;
|
||||
},
|
||||
.cap_kitty_graphics => {
|
||||
if (!vx.caps.kitty_graphics) {
|
||||
log.info("kitty graphics capability detected", .{});
|
||||
vx.caps.kitty_graphics = true;
|
||||
}
|
||||
},
|
||||
.cap_rgb => {
|
||||
log.info("rgb capability detected", .{});
|
||||
vx.caps.rgb = true;
|
||||
|
|
|
@ -10,6 +10,7 @@ pub const Event = union(enum) {
|
|||
|
||||
// these are delivered as discovered terminal capabilities
|
||||
cap_kitty_keyboard,
|
||||
cap_kitty_graphics,
|
||||
cap_rgb,
|
||||
cap_unicode,
|
||||
cap_da1,
|
||||
|
|
|
@ -222,10 +222,7 @@ pub fn Vaxis(comptime T: type) type {
|
|||
// that
|
||||
// _ = try tty.write(ctlseqs.xtversion);
|
||||
_ = try tty.write(ctlseqs.csi_u_query);
|
||||
// TODO: KITTY_GRAPHICS has an APC response. uncomment when we can
|
||||
// parse that
|
||||
// that
|
||||
// _ = try tty.write(ctlseqs.kitty_graphics_query);
|
||||
_ = try tty.write(ctlseqs.kitty_graphics_query);
|
||||
// TODO: sixel geometry query interferes with F4 keys.
|
||||
// _ = try tty.write(ctlseqs.sixel_geometry_query);
|
||||
|
||||
|
@ -590,6 +587,7 @@ pub fn Vaxis(comptime T: type) type {
|
|||
alloc: std.mem.Allocator,
|
||||
src: Image.Source,
|
||||
) !Image {
|
||||
if (!self.caps.kitty_graphics) return error.NoGraphicsCapability;
|
||||
var tty = self.tty orelse return error.NoTTY;
|
||||
defer self.next_img_id += 1;
|
||||
|
||||
|
|
Loading…
Reference in a new issue