From 05f2efb77eea2954dacd88c673017009115388c1 Mon Sep 17 00:00:00 2001 From: Shmuel Zeigerman Date: Sat, 2 Nov 2024 23:31:08 +0200 Subject: [PATCH] Update WinPort from far2l --- WinPort/src/Backend/TTY/TTYInputSequenceParser.cpp | 12 ++++++++++-- WinPort/src/Backend/TTY/TTYInputSequenceParser.h | 1 + .../src/Backend/TTY/TTYInputSequenceParserExts.cpp | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/WinPort/src/Backend/TTY/TTYInputSequenceParser.cpp b/WinPort/src/Backend/TTY/TTYInputSequenceParser.cpp index a2d4532ce..4b84e405f 100644 --- a/WinPort/src/Backend/TTY/TTYInputSequenceParser.cpp +++ b/WinPort/src/Backend/TTY/TTYInputSequenceParser.cpp @@ -5,7 +5,6 @@ #include "TTYInputSequenceParser.h" #include "Backend.h" - //See: // http://www.manmrk.net/tutorials/ISPF/XE/xehelp/html/HID00000579.htm // http://www.leonerd.org.uk/hacks/fixterms/ @@ -179,7 +178,7 @@ TTYInputSequenceParser::TTYInputSequenceParser(ITTYInputSpecialSequenceHandler * AddStrF1F5(VK_F2, "Q"); AddStr(VK_F2, 0, "[[B"); AddStrF1F5(VK_F3, "R"); AddStr(VK_F3, 0, "[[C"); AddStrF1F5(VK_F4, "S"); AddStr(VK_F4, 0, "[[D"); - AddStrF1F5(VK_F5, "E"); AddStr(VK_F5, 0, "[[E"); + AddStrF1F5(VK_CLEAR, "E"); AddStr(VK_CLEAR, 0, "[[E"); // NumPad center (5) AddStrTilde(VK_HOME, 1); AddStrTilde(VK_INSERT, 2); @@ -420,6 +419,13 @@ size_t TTYInputSequenceParser::ParseIntoPending(const char *s, size_t l) case 0x01: case 0x02: case 0x03: case 0x04: case 0x05: case 0x06: case 0x07: case 0x08: case 0x0a: case 0x0b: case 0x0c: case 0x0e: case 0x0f: case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x16: case 0x17: case 0x18: case 0x19: case 0x1a: + + // workaround for \x0a received instead of \x0d in kitty and wezterm in bracketed paste mode + if (_bracketed_paste_mode && *s == 0x0a) { + AddPendingKeyEvent(TTYInputKey{VK_RETURN, 0}); + return 1; + } + AddPendingKeyEvent(TTYInputKey{WORD('A' + (*s - 0x01)), LEFT_CTRL_PRESSED}); return 1; @@ -661,6 +667,8 @@ void TTYInputSequenceParser::OnBracketedPaste(bool start) ir.EventType = BRACKETED_PASTE_EVENT; ir.Event.BracketedPaste.bStartPaste = start ? TRUE : FALSE; _ir_pending.emplace_back(ir); + + _bracketed_paste_mode = start; } //work-around for double encoded events in win32-input mode diff --git a/WinPort/src/Backend/TTY/TTYInputSequenceParser.h b/WinPort/src/Backend/TTY/TTYInputSequenceParser.h index 07517f5d6..184390318 100644 --- a/WinPort/src/Backend/TTY/TTYInputSequenceParser.h +++ b/WinPort/src/Backend/TTY/TTYInputSequenceParser.h @@ -110,6 +110,7 @@ class TTYInputSequenceParser StackSerializer _tmp_stk_ser; DWORD _extra_control_keys = 0; std::vector _ir_pending; + bool _bracketed_paste_mode = false; bool _kitty_right_ctrl_down = false; int _iterm_last_flags = 0; char _using_extension = 0; diff --git a/WinPort/src/Backend/TTY/TTYInputSequenceParserExts.cpp b/WinPort/src/Backend/TTY/TTYInputSequenceParserExts.cpp index 2e6332103..4938d50c3 100644 --- a/WinPort/src/Backend/TTY/TTYInputSequenceParserExts.cpp +++ b/WinPort/src/Backend/TTY/TTYInputSequenceParserExts.cpp @@ -345,7 +345,7 @@ size_t TTYInputSequenceParser::TryParseAsKittyEscapeSequence(const char *s, size ir.Event.KeyEvent.dwControlKeyState |= ENHANCED_KEY; break; case 'D': ir.Event.KeyEvent.wVirtualKeyCode = VK_LEFT; ir.Event.KeyEvent.dwControlKeyState |= ENHANCED_KEY; break; - case 'E': ir.Event.KeyEvent.wVirtualKeyCode = VK_NUMPAD5; break; + case 'E': ir.Event.KeyEvent.wVirtualKeyCode = VK_CLEAR; break; // NumPad center (5) case 'H': ir.Event.KeyEvent.wVirtualKeyCode = VK_HOME; ir.Event.KeyEvent.dwControlKeyState |= ENHANCED_KEY; break; case 'F': ir.Event.KeyEvent.wVirtualKeyCode = VK_END;