From 44ff960cb0909fdd0ba930927bd1258164eaeb33 Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Tue, 23 Jan 2024 08:10:59 -0600 Subject: [PATCH] caps: implement first capability response (kitty keyboard) Signed-off-by: Tim Culverhouse --- src/Tty.zig | 5 +++++ src/event.zig | 1 + src/main.zig | 1 + src/parser.zig | 9 ++++++++- 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Tty.zig b/src/Tty.zig index 2e84f02..7b16cda 100644 --- a/src/Tty.zig +++ b/src/Tty.zig @@ -175,6 +175,11 @@ pub fn run( vx.postEvent(.paste_end); } }, + .cap_kitty_keyboard => { + if (@hasField(EventType, "cap_kitty_keyboard")) { + vx.postEvent(.cap_kitty_keyboard); + } + }, } } } diff --git a/src/event.zig b/src/event.zig index 92212eb..1f75be9 100644 --- a/src/event.zig +++ b/src/event.zig @@ -8,4 +8,5 @@ pub const Event = union(enum) { focus_out, paste_start, paste_end, + cap_kitty_keyboard, }; diff --git a/src/main.zig b/src/main.zig index 53ff87a..19f4bb5 100644 --- a/src/main.zig +++ b/src/main.zig @@ -7,6 +7,7 @@ pub const Style = cell.Style; pub const Key = @import("Key.zig"); pub const Winsize = @import("Tty.zig").Winsize; +pub const Event = @import("event.zig").Event; pub const widgets = @import("widgets/main.zig"); diff --git a/src/parser.zig b/src/parser.zig index 07e05ff..2bf2e54 100644 --- a/src/parser.zig +++ b/src/parser.zig @@ -273,9 +273,16 @@ pub fn parse(input: []const u8) !Result { } }, 'u' => blk: { - if (seq.private_indicator) |_| { + if (seq.private_indicator) |priv| { // response to our kitty query // 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]}); return .{ .event = null,