Skip to content

Commit

Permalink
Merge pull request #2401 from unxed/win32_input_fix
Browse files Browse the repository at this point in the history
fix cyrillic chars paste in win32-input-mode
  • Loading branch information
elfmz authored Sep 29, 2024
2 parents 04918f9 + 0167649 commit 9b37a21
Showing 1 changed file with 17 additions and 32 deletions.
49 changes: 17 additions & 32 deletions WinPort/src/Backend/TTY/TTYInputSequenceParserExts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ size_t TTYInputSequenceParser::TryParseAsWinTermEscapeSequence(const char *s, si
int args[6] = {0};
int args_cnt = 0;

size_t n;
size_t n = 0;
for (size_t i = n = 1;; ++i) {
if (i == l) {
return LIKELY(l < 32) ? TTY_PARSED_WANTMORE : TTY_PARSED_BADSEQUENCE;
Expand All @@ -419,8 +419,10 @@ size_t TTYInputSequenceParser::TryParseAsWinTermEscapeSequence(const char *s, si
}
if (i > n) {
args[args_cnt] = atoi(&s[n]);
++args_cnt;
} else {
args[args_cnt] = 0;
}
++args_cnt;
n = i + 1;
if (s[i] == '_') {
break;
Expand All @@ -431,34 +433,15 @@ size_t TTYInputSequenceParser::TryParseAsWinTermEscapeSequence(const char *s, si
}
}



//do not create invalid input event
//wVirtualKeyCode, wVirtualScanCode 0 with bKeyDown 1 doesn't make sense
if ( !((args[0] == 0) && (args[1] == 0) && (args[3] == 1) && (args[4] == 0)) )
{
INPUT_RECORD ir = {};
ir.EventType = KEY_EVENT;
ir.Event.KeyEvent.wVirtualKeyCode = args[0];
ir.Event.KeyEvent.wVirtualScanCode = args[1];
ir.Event.KeyEvent.uChar.UnicodeChar = args[2];
ir.Event.KeyEvent.bKeyDown = (args[3] ? TRUE : FALSE);
ir.Event.KeyEvent.dwControlKeyState = args[4];
ir.Event.KeyEvent.wRepeatCount = args[5];
_ir_pending.emplace_back(ir);
}
else if ((args[0] == 0) && (args[1] == 0) && (args[2] != 0)) {
// it can be non-latin paste char event
INPUT_RECORD ir = {};
ir.EventType = KEY_EVENT;
ir.Event.KeyEvent.wVirtualKeyCode = VK_UNASSIGNED;
ir.Event.KeyEvent.wVirtualScanCode = 0;
ir.Event.KeyEvent.uChar.UnicodeChar = args[2];
ir.Event.KeyEvent.bKeyDown = (args[3] ? TRUE : FALSE);
ir.Event.KeyEvent.dwControlKeyState = args[4];
ir.Event.KeyEvent.wRepeatCount = args[5];
_ir_pending.emplace_back(ir);
}
INPUT_RECORD ir = {};
ir.EventType = KEY_EVENT;
ir.Event.KeyEvent.wVirtualKeyCode = args[0] ? args[0] : VK_UNASSIGNED;
ir.Event.KeyEvent.wVirtualScanCode = args[1];
ir.Event.KeyEvent.uChar.UnicodeChar = args[2];
ir.Event.KeyEvent.bKeyDown = (args[3] ? TRUE : FALSE);
ir.Event.KeyEvent.dwControlKeyState = args[4];
ir.Event.KeyEvent.wRepeatCount = args[5];
_ir_pending.emplace_back(ir);

if (!_using_extension) {
fprintf(stderr, "TTYInputSequenceParser: using WinTerm extension\n");
Expand All @@ -477,7 +460,7 @@ size_t TTYInputSequenceParser::TryUnwrappWinDoubleEscapeSequence(const char *s,
int args[6] = {0};
int args_cnt = 0;

size_t n;
size_t n = 0;
for (size_t i = n = 1;; ++i) {
if (i == l) {
//fprintf(stderr, "\nwant mooore characters... \n");
Expand All @@ -489,8 +472,10 @@ size_t TTYInputSequenceParser::TryUnwrappWinDoubleEscapeSequence(const char *s,
}
if (i > n) {
args[args_cnt] = atoi(&s[n]);
++args_cnt;
} else {
args[args_cnt] = 0;
}
++args_cnt;
n = i + 1;
if (s[i] == '_') {
break;
Expand Down

0 comments on commit 9b37a21

Please sign in to comment.