From 77df7a0e7f82835856893d9370606963b68bcd1f Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 12 Aug 2023 22:42:36 -0700 Subject: [PATCH] terminal: support disable modify key format sequence ESC[>n --- src/terminal/stream.zig | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/src/terminal/stream.zig b/src/terminal/stream.zig index 4fe6bed32..ddb99ac28 100644 --- a/src/terminal/stream.zig +++ b/src/terminal/stream.zig @@ -508,17 +508,38 @@ pub fn Stream(comptime Handler: type) type { }, }, - // CPR - Request Cursor Position Report // TODO: test - 'n' => if (@hasDecl(T, "deviceStatusReport")) try self.handler.deviceStatusReport( - switch (action.params.len) { - 1 => @enumFromInt(action.params[0]), - else => { - log.warn("invalid erase characters command: {}", .{action}); - return; + 'n' => switch (action.intermediates.len) { + 0 => if (@hasDecl(T, "deviceStatusReport")) try self.handler.deviceStatusReport( + switch (action.params.len) { + 1 => @enumFromInt(action.params[0]), + else => { + log.warn("invalid erase characters command: {}", .{action}); + return; + }, }, + ) else log.warn("unimplemented CSI callback: {}", .{action}), + + 1 => switch (action.intermediates[0]) { + '>' => if (@hasDecl(T, "setModifyKeyFormat")) { + // This isn't strictly correct. CSI > n has parameters that + // control what exactly is being disabled. However, we + // only support reverting back to modify other keys in + // numeric except format. + try self.handler.setModifyKeyFormat(.{ .other_keys = .numeric_except }); + } else log.warn("unimplemented setModifyKeyFormat: {}", .{action}), + + else => log.warn( + "unknown CSI m with intermediate: {}", + .{action.intermediates[0]}, + ), }, - ) else log.warn("unimplemented CSI callback: {}", .{action}), + + else => log.warn( + "ignoring unimplemented CSI n with intermediates: {s}", + .{action.intermediates}, + ), + }, // DECSCUSR - Select Cursor Style // TODO: test