From 8137a66ef6cc92ae0e00533c4613043f53a0c208 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 25 Sep 2023 09:45:16 -0700 Subject: [PATCH] terminal: CSI Ps " q for setting DEC protected mode --- src/terminal/stream.zig | 52 +++++++++++++++++++++++++++++++++++++++++ src/termio/Exec.zig | 4 ++++ 2 files changed, 56 insertions(+) diff --git a/src/terminal/stream.zig b/src/terminal/stream.zig index 739768b7c..bc8576ad8 100644 --- a/src/terminal/stream.zig +++ b/src/terminal/stream.zig @@ -651,6 +651,29 @@ pub fn Stream(comptime Handler: type) type { }, ) else log.warn("unimplemented CSI callback: {}", .{action}); }, + + // DECSCA + '"' => { + if (@hasDecl(T, "setProtectedMode")) { + const mode_: ?ansi.ProtectedMode = switch (action.params.len) { + else => null, + 0 => .off, + 1 => switch (action.params[0]) { + 0, 2 => .off, + 1 => .dec, + else => null, + }, + }; + + const mode = mode_ orelse { + log.warn("invalid set protected mode command: {}", .{action}); + return; + }; + + try self.handler.setProtectedMode(mode); + } else log.warn("unimplemented CSI callback: {}", .{action}); + }, + // XTVERSION '>' => { if (@hasDecl(T, "reportXtversion")) try self.handler.reportXtversion(); @@ -1202,3 +1225,32 @@ test "stream: pop kitty keyboard with no params defaults to 1" { for ("\x1B[