mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
add a formatter for CSI logs so that they're more easy to read
This commit is contained in:
@ -78,6 +78,22 @@ pub const Action = union(enum) {
|
|||||||
intermediates: []u8,
|
intermediates: []u8,
|
||||||
params: []u16,
|
params: []u16,
|
||||||
final: u8,
|
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 {
|
pub const ESC = struct {
|
||||||
|
@ -49,8 +49,9 @@ pub fn Stream(comptime Handler: type) type {
|
|||||||
const actions = self.parser.next(c);
|
const actions = self.parser.next(c);
|
||||||
for (actions) |action_opt| {
|
for (actions) |action_opt| {
|
||||||
// if (action_opt) |action| {
|
// if (action_opt) |action| {
|
||||||
// if (action != .print) {
|
// switch (action) {
|
||||||
// log.info("action: {}", .{action});
|
// .print => |p| log.info("action: print '{u}'", .{p}),
|
||||||
|
// else => log.info("action: {}", .{action}),
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
switch (action_opt orelse continue) {
|
switch (action_opt orelse continue) {
|
||||||
|
Reference in New Issue
Block a user