Skip to content

Commit

Permalink
Update WinPort from far2l
Browse files Browse the repository at this point in the history
  • Loading branch information
shmuz committed Nov 2, 2024
1 parent 5bf5283 commit 05f2efb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
12 changes: 10 additions & 2 deletions WinPort/src/Backend/TTY/TTYInputSequenceParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions WinPort/src/Backend/TTY/TTYInputSequenceParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class TTYInputSequenceParser
StackSerializer _tmp_stk_ser;
DWORD _extra_control_keys = 0;
std::vector<INPUT_RECORD> _ir_pending;
bool _bracketed_paste_mode = false;
bool _kitty_right_ctrl_down = false;
int _iterm_last_flags = 0;
char _using_extension = 0;
Expand Down
2 changes: 1 addition & 1 deletion WinPort/src/Backend/TTY/TTYInputSequenceParserExts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 05f2efb

Please sign in to comment.