diff --git a/src/terminal/Parser.zig b/src/terminal/Parser.zig index 26ddc1237..5f580d44e 100644 --- a/src/terminal/Parser.zig +++ b/src/terminal/Parser.zig @@ -38,17 +38,12 @@ pub const TransitionAction = enum { ignore, print, execute, - clear, collect, param, esc_dispatch, csi_dispatch, - hook, put, - unhook, - osc_start, osc_put, - osc_end, }; /// Action is the action that a caller of the parser is expected to @@ -70,6 +65,11 @@ pub const Action = union(enum) { /// Execute the OSC command. osc_dispatch: osc.Command, + /// DCS-related events. + dcs_hook: DCS, + dcs_put: u8, + dcs_unhook: void, + pub const CSI = struct { intermediates: []u8, params: []u16, @@ -80,6 +80,12 @@ pub const Action = union(enum) { intermediates: []u8, final: u8, }; + + pub const DCS = struct { + intermediates: []u8, + params: []u16, + final: u8, + }; }; /// Maximum number of intermediate characters during parsing. @@ -139,7 +145,7 @@ pub fn next(self: *Parser, c: u8) [3]?Action { Action{ .osc_dispatch = cmd } else null, - .dcs_passthrough => @panic("TODO"), // TODO: unhook + .dcs_passthrough => Action{ .dcs_unhook = {} }, else => null, }, @@ -155,7 +161,13 @@ pub fn next(self: *Parser, c: u8) [3]?Action { self.osc_parser.reset(); break :osc_string null; }, - .dcs_passthrough => @panic("TODO"), // TODO: hook + .dcs_passthrough => Action{ + .dcs_hook = .{ + .intermediates = self.intermediates[0..self.intermediates_idx], + .params = self.params[0..self.params_idx], + .final = c, + }, + }, else => null, }, }; @@ -230,9 +242,8 @@ fn doAction(self: *Parser, action: TransitionAction, c: u8) ?Action { .final = c, }, }, - else => { - std.log.err("unimplemented action: {}", .{action}); - @panic("TODO"); + .put => Action{ + .dcs_put = c, }, }; } diff --git a/src/terminal/Terminal.zig b/src/terminal/Terminal.zig index b281ea4fc..882c06dd3 100644 --- a/src/terminal/Terminal.zig +++ b/src/terminal/Terminal.zig @@ -138,6 +138,9 @@ pub fn appendChar(self: *Terminal, alloc: Allocator, c: u8) !void { .csi_dispatch => |csi| try self.csiDispatch(alloc, csi), .esc_dispatch => |esc| try self.escDispatch(alloc, esc), .osc_dispatch => |cmd| log.warn("unhandled OSC: {}", .{cmd}), + .dcs_hook => |dcs| log.warn("unhandled DCS hook: {}", .{dcs}), + .dcs_put => |code| log.warn("unhandled DCS put: {}", .{code}), + .dcs_unhook => log.warn("unhandled DCS unhook", .{}), } } }