caps: implement first capability response (kitty keyboard)

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
This commit is contained in:
Tim Culverhouse 2024-01-23 08:10:59 -06:00
parent 59470f18e8
commit 44ff960cb0
4 changed files with 15 additions and 1 deletions

View file

@ -175,6 +175,11 @@ pub fn run(
vx.postEvent(.paste_end); vx.postEvent(.paste_end);
} }
}, },
.cap_kitty_keyboard => {
if (@hasField(EventType, "cap_kitty_keyboard")) {
vx.postEvent(.cap_kitty_keyboard);
}
},
} }
} }
} }

View file

@ -8,4 +8,5 @@ pub const Event = union(enum) {
focus_out, focus_out,
paste_start, paste_start,
paste_end, paste_end,
cap_kitty_keyboard,
}; };

View file

@ -7,6 +7,7 @@ pub const Style = cell.Style;
pub const Key = @import("Key.zig"); pub const Key = @import("Key.zig");
pub const Winsize = @import("Tty.zig").Winsize; pub const Winsize = @import("Tty.zig").Winsize;
pub const Event = @import("event.zig").Event;
pub const widgets = @import("widgets/main.zig"); pub const widgets = @import("widgets/main.zig");

View file

@ -273,9 +273,16 @@ pub fn parse(input: []const u8) !Result {
} }
}, },
'u' => blk: { 'u' => blk: {
if (seq.private_indicator) |_| { if (seq.private_indicator) |priv| {
// response to our kitty query // response to our kitty query
// TODO: kitty query handling // TODO: kitty query handling
if (priv == '?') {
return .{
.event = .cap_kitty_keyboard,
.n = i + 1,
};
}
log.warn("unhandled csi: CSI {s}", .{input[start + 1 .. i + 1]}); log.warn("unhandled csi: CSI {s}", .{input[start + 1 .. i + 1]});
return .{ return .{
.event = null, .event = null,