From 9c5e8898cda6de402f9704f6625043a28fe5a53b Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Mon, 10 Jun 2024 14:00:28 -0500 Subject: [PATCH] parser: fix parsing of DECRPM and tests We were looking for the wrong sequence --- src/Parser.zig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Parser.zig b/src/Parser.zig index 37a2672..adaeacb 100644 --- a/src/Parser.zig +++ b/src/Parser.zig @@ -539,9 +539,9 @@ inline fn parseCsi(input: []const u8, text_buf: []u8) Result { }, 'y' => { // DECRPM (CSI ? Ps ; Pm $ y) - const delim_idx = std.mem.indexOfScalarPos(u8, input, 2, ';') orelse return null_event; - const ps = std.fmt.parseUnsigned(u16, input[2..delim_idx], 10) catch return null_event; - const pm = std.fmt.parseUnsigned(u8, input[delim_idx + 1 .. sequence.len - 1], 10) catch return null_event; + const delim_idx = std.mem.indexOfScalarPos(u8, input, 3, ';') orelse return null_event; + const ps = std.fmt.parseUnsigned(u16, input[3..delim_idx], 10) catch return null_event; + const pm = std.fmt.parseUnsigned(u8, input[delim_idx + 1 .. sequence.len - 2], 10) catch return null_event; switch (ps) { // Mouse Pixel reporting 1016 => switch (pm) { @@ -974,7 +974,7 @@ test "parse: multiple codepoint grapheme with more after" { test "parse(csi): decrpm" { var buf: [1]u8 = undefined; { - const input = "\x1b[1016;1y"; + const input = "\x1b[?1016;1$y"; const result = parseCsi(input, &buf); const expected: Result = .{ .event = .cap_sgr_pixels,