From 5d8f78ccd21fb71d85e2cd0d61021b3d50d599ad Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Tue, 23 Jan 2024 07:28:57 -0600 Subject: [PATCH] parser: return null events when unhandled Signed-off-by: Tim Culverhouse --- src/parser.zig | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/parser.zig b/src/parser.zig index 6016a5b..07e05ff 100644 --- a/src/parser.zig +++ b/src/parser.zig @@ -226,7 +226,10 @@ pub fn parse(input: []const u8) !Result { // codepoint if (seq.param_idx < 1) { log.warn("unhandled csi: CSI {s}", .{input[start + 1 .. i + 1]}); - continue; + return .{ + .event = null, + .n = i + 1, + }; } switch (seq.params[0]) { 2 => break :blk Key.insert, @@ -262,7 +265,10 @@ pub fn parse(input: []const u8) !Result { 57427 => break :blk Key.kp_begin, else => { log.warn("unhandled csi: CSI {s}", .{input[start + 1 .. i + 1]}); - continue; + return .{ + .event = null, + .n = i + 1, + }; }, } }, @@ -271,11 +277,17 @@ pub fn parse(input: []const u8) !Result { // response to our kitty query // TODO: kitty query handling log.warn("unhandled csi: CSI {s}", .{input[start + 1 .. i + 1]}); - continue; + return .{ + .event = null, + .n = i + 1, + }; } if (seq.param_idx == 0) { log.warn("unhandled csi: CSI {s}", .{input[start + 1 .. i + 1]}); - continue; + return .{ + .event = null, + .n = i + 1, + }; } // In any csi u encoding, the codepoint // directly maps to our keypoint definitions @@ -290,7 +302,10 @@ pub fn parse(input: []const u8) !Result { }, else => { log.warn("unhandled csi: CSI {s}", .{input[start + 1 .. i + 1]}); - continue; + return .{ + .event = null, + .n = i + 1, + }; }, };