From 1e5d39d9b1336f0b95fc2cdaf0175f04ff4f4392 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Mon, 1 Jul 2024 20:06:51 +0200 Subject: [PATCH] fix(windows): unbreak escape sequence handling --- src/windows/Tty.zig | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/windows/Tty.zig b/src/windows/Tty.zig index 503d7a6..fc3d56b 100644 --- a/src/windows/Tty.zig +++ b/src/windows/Tty.zig @@ -166,11 +166,13 @@ pub fn eventFromRecord(self: *Tty, record: *const INPUT_RECORD, state: *EventSta const base_layout: u16 = switch (event.wVirtualKeyCode) { 0x00 => blk: { // delivered when we get an escape sequence or a unicode codepoint + if (state.ansi_idx == 0 and event.uChar.AsciiChar != 27) + break :blk event.uChar.UnicodeChar; state.ansi_buf[state.ansi_idx] = event.uChar.AsciiChar; state.ansi_idx += 1; + if (state.ansi_idx <= 2) return null; switch (state.ansi_buf[1]) { '[' => { // CSI, read until 0x40 to 0xFF - if (state.ansi_idx <= 2) return null; switch (event.uChar.UnicodeChar) { 0x40...0xFF => { return .cap_da1; @@ -197,9 +199,8 @@ pub fn eventFromRecord(self: *Tty, record: *const INPUT_RECORD, state: *EventSta else => return null, } }, - else => {}, + else => return null, } - break :blk event.uChar.UnicodeChar; }, 0x08 => Key.backspace, 0x09 => Key.tab,