diff --git a/src/keybind/keybind.zig b/src/keybind/keybind.zig index 89a3507..2ca6d50 100644 --- a/src/keybind/keybind.zig +++ b/src/keybind/keybind.zig @@ -774,11 +774,13 @@ const BindingSet = struct { } } - fn send_match_event(_: *const @This(), binding: *const Binding) void { + fn send_match_event(self: *const @This(), binding: *const Binding) void { var buf: [tp.max_message_size]u8 = undefined; var stream: std.Io.Writer = .fixed(&buf); - cbor.writeArrayHeader(&stream, 2) catch return; - cbor.writeValue(&stream, "keybind_match") catch return; + cbor.writeArrayHeader(&stream, 4) catch return; + cbor.writeValue(&stream, "K") catch return; + cbor.writeValue(&stream, self.name) catch return; + cbor.writeValue(&stream, self.config_section) catch return; cbor.writeArrayHeader(&stream, binding.commands.len) catch return; for (binding.commands) |cmd| { cbor.writeArrayHeader(&stream, 2) catch return; diff --git a/src/tui/inputview.zig b/src/tui/inputview.zig index 2ff2a1b..810126d 100644 --- a/src/tui/inputview.zig +++ b/src/tui/inputview.zig @@ -136,14 +136,15 @@ fn listen(self: *Self, _: tp.pid_ref, m: tp.message) tp.result { } fn keybind_match(self: *Self, _: tp.pid_ref, m: tp.message) MessageFilter.Error!bool { + var namespace: []const u8 = undefined; + var section: []const u8 = undefined; var cmds: []const u8 = undefined; - if (!(m.match(.{ "keybind_match", tp.extract_cbor(&cmds) }) catch false)) return false; + if (!(m.match(.{ "K", tp.extract(&namespace), tp.extract(§ion), tp.extract_cbor(&cmds) }) catch false)) return false; var result: Writer.Allocating = .init(self.allocator); defer result.deinit(); const writer = &result.writer; - writer.writeAll("keybind -> ") catch return true; - cbor.toJsonWriter(cmds, writer, .{}) catch return true; + cbor.toJsonWriter(m.buf, writer, .{}) catch return true; self.append(result.written()) catch return true; return true; diff --git a/src/tui/tui.zig b/src/tui/tui.zig index 1203973..b23d803 100644 --- a/src/tui/tui.zig +++ b/src/tui/tui.zig @@ -500,7 +500,7 @@ fn receive_safe(self: *Self, from: tp.pid_ref, m: tp.message) !void { if (try m.match(.{"focus_out"})) return; - if (try m.match(.{ "keybind_match", tp.more })) + if (try m.match(.{ "K", tp.more })) return; if (try self.send_widgets(from, m))