diff --git a/src/terminal/Parser.zig b/src/terminal/Parser.zig index 30fe5259a..b3b8b84b0 100644 --- a/src/terminal/Parser.zig +++ b/src/terminal/Parser.zig @@ -78,6 +78,22 @@ pub const Action = union(enum) { intermediates: []u8, params: []u16, final: u8, + + // Implement formatter for logging + pub fn format( + self: CSI, + comptime layout: []const u8, + opts: std.fmt.FormatOptions, + writer: anytype, + ) !void { + _ = layout; + _ = opts; + try std.fmt.format(writer, "ESC [ {s} {any} {c}", .{ + self.intermediates, + self.params, + self.final, + }); + } }; pub const ESC = struct { diff --git a/src/terminal/stream.zig b/src/terminal/stream.zig index 7f456fc98..39b7e9080 100644 --- a/src/terminal/stream.zig +++ b/src/terminal/stream.zig @@ -49,8 +49,9 @@ pub fn Stream(comptime Handler: type) type { const actions = self.parser.next(c); for (actions) |action_opt| { // if (action_opt) |action| { - // if (action != .print) { - // log.info("action: {}", .{action}); + // switch (action) { + // .print => |p| log.info("action: print '{u}'", .{p}), + // else => log.info("action: {}", .{action}), // } // } switch (action_opt orelse continue) {