terminal: ignore invalid C0 escape codes

This commit is contained in:
Mitchell Hashimoto
2022-12-14 20:57:31 -08:00
parent c01a9f583f
commit 36c6e95dfc
2 changed files with 6 additions and 1 deletions

View File

@ -23,6 +23,10 @@ pub const C0 = enum(u7) {
SO = 0x0E, SO = 0x0E,
/// Shift in /// Shift in
SI = 0x0F, SI = 0x0F,
// Non-exhaustive so that @intToEnum never fails since the inputs are
// user-generated.
_,
}; };
/// The SGR rendition aspects that can be set, sometimes known as attributes. /// The SGR rendition aspects that can be set, sometimes known as attributes.

View File

@ -73,7 +73,6 @@ pub fn Stream(comptime Handler: type) type {
tracy.value(@intCast(u64, c)); tracy.value(@intCast(u64, c));
defer tracy.end(); defer tracy.end();
// log.warn("C0: {}", .{c});
switch (@intToEnum(ansi.C0, c)) { switch (@intToEnum(ansi.C0, c)) {
.NUL => {}, .NUL => {},
@ -122,6 +121,8 @@ pub fn Stream(comptime Handler: type) type {
try self.handler.invokeCharset(.GL, .G0, false) try self.handler.invokeCharset(.GL, .G0, false)
else else
log.warn("unimplemented invokeCharset: {x}", .{c}), log.warn("unimplemented invokeCharset: {x}", .{c}),
else => log.warn("invalid C0 character, ignoring: {x}", .{c}),
} }
} }