core: implement querying with OSC 4

This commit is contained in:
Gregory Anders
2023-11-06 21:40:20 -06:00
parent 6bf9c05f2a
commit f397353282
4 changed files with 88 additions and 11 deletions

View File

@@ -241,6 +241,25 @@ pub const VTEvent = struct {
try alloc.dupeZ(u8, @tagName(value)),
),
.Union => |u| if (u.tag_type) |Tag| {
const tag_name = @tagName(@as(Tag, value));
inline for (u.fields) |field| {
if (std.mem.eql(u8, field.name, tag_name)) {
const s = if (field.type == void)
try alloc.dupeZ(u8, tag_name)
else
try std.fmt.allocPrintZ(alloc, "{s}={}", .{
tag_name,
@field(value, field.name),
});
try md.put(key, s);
}
}
} else {
@compileError("Unions must have a tag");
},
else => switch (Value) {
u8 => try md.put(
key,