From e7ab16f0e1cd2aaa1051a8275f4d1b96e4869e50 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 20 Aug 2023 22:01:49 -0700 Subject: [PATCH] terminal: CSI < u defaults param to "1" if not set (pop kitty keyboard) --- src/terminal/stream.zig | 17 ++++++++++++++++- src/termio/Exec.zig | 8 ++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/terminal/stream.zig b/src/terminal/stream.zig index ccac4b37e..c57fb3122 100644 --- a/src/terminal/stream.zig +++ b/src/terminal/stream.zig @@ -669,7 +669,7 @@ pub fn Stream(comptime Handler: type) type { const number: u16 = if (action.params.len == 1) action.params[0] else - 0; + 1; try self.handler.popKittyKeyboard(number); }, @@ -1073,3 +1073,18 @@ test "stream: restore mode" { for ("\x1B[?42r") |c| try s.next(c); try testing.expect(!s.handler.called); } + +test "stream: pop kitty keyboard with no params defaults to 1" { + const H = struct { + const Self = @This(); + n: u16 = 0, + + pub fn popKittyKeyboard(self: *Self, n: u16) !void { + self.n = n; + } + }; + + var s: Stream(H) = .{ .handler = .{} }; + for ("\x1B[