parse DCS sequences (but do nothing)

This commit is contained in:
Mitchell Hashimoto
2022-05-10 14:09:24 -07:00
parent 28b3ac52e9
commit daa0368319
2 changed files with 24 additions and 10 deletions

View File

@ -38,17 +38,12 @@ pub const TransitionAction = enum {
ignore, ignore,
print, print,
execute, execute,
clear,
collect, collect,
param, param,
esc_dispatch, esc_dispatch,
csi_dispatch, csi_dispatch,
hook,
put, put,
unhook,
osc_start,
osc_put, osc_put,
osc_end,
}; };
/// Action is the action that a caller of the parser is expected to /// 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. /// Execute the OSC command.
osc_dispatch: osc.Command, osc_dispatch: osc.Command,
/// DCS-related events.
dcs_hook: DCS,
dcs_put: u8,
dcs_unhook: void,
pub const CSI = struct { pub const CSI = struct {
intermediates: []u8, intermediates: []u8,
params: []u16, params: []u16,
@ -80,6 +80,12 @@ pub const Action = union(enum) {
intermediates: []u8, intermediates: []u8,
final: u8, final: u8,
}; };
pub const DCS = struct {
intermediates: []u8,
params: []u16,
final: u8,
};
}; };
/// Maximum number of intermediate characters during parsing. /// Maximum number of intermediate characters during parsing.
@ -139,7 +145,7 @@ pub fn next(self: *Parser, c: u8) [3]?Action {
Action{ .osc_dispatch = cmd } Action{ .osc_dispatch = cmd }
else else
null, null,
.dcs_passthrough => @panic("TODO"), // TODO: unhook .dcs_passthrough => Action{ .dcs_unhook = {} },
else => null, else => null,
}, },
@ -155,7 +161,13 @@ pub fn next(self: *Parser, c: u8) [3]?Action {
self.osc_parser.reset(); self.osc_parser.reset();
break :osc_string null; 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, else => null,
}, },
}; };
@ -230,9 +242,8 @@ fn doAction(self: *Parser, action: TransitionAction, c: u8) ?Action {
.final = c, .final = c,
}, },
}, },
else => { .put => Action{
std.log.err("unimplemented action: {}", .{action}); .dcs_put = c,
@panic("TODO");
}, },
}; };
} }

View File

@ -138,6 +138,9 @@ pub fn appendChar(self: *Terminal, alloc: Allocator, c: u8) !void {
.csi_dispatch => |csi| try self.csiDispatch(alloc, csi), .csi_dispatch => |csi| try self.csiDispatch(alloc, csi),
.esc_dispatch => |esc| try self.escDispatch(alloc, esc), .esc_dispatch => |esc| try self.escDispatch(alloc, esc),
.osc_dispatch => |cmd| log.warn("unhandled OSC: {}", .{cmd}), .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", .{}),
} }
} }
} }