From 5cbb8c9e52d762c08f000b7195a3ca06c8c6ec3f Mon Sep 17 00:00:00 2001 From: bagajjal Date: Fri, 18 Aug 2017 12:21:26 -0700 Subject: [PATCH] Fix ctrl sequences (#196) PowerShell/Win32-OpenSSH#850 - Fixed alt+shift+? control sequence at ssh client and ssh server side. PowerShell/Win32-OpenSSH#849 - Fixed ctrl sequences (ctrl+pageup/ctrl+home, etc)... --- contrib/win32/win32compat/shell-host.c | 11 ++++------- contrib/win32/win32compat/tncon.c | 3 +++ contrib/win32/win32compat/tncon.h | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/contrib/win32/win32compat/shell-host.c b/contrib/win32/win32compat/shell-host.c index 22a5c5cac..621099e3b 100644 --- a/contrib/win32/win32compat/shell-host.c +++ b/contrib/win32/win32compat/shell-host.c @@ -163,7 +163,8 @@ struct key_translation keys[] = { { L"\x1bOP", VK_F1, 0 , 0 , 0}, { L"\x1bOQ", VK_F2, 0 , 0 , 0}, { L"\x1bOR", VK_F3, 0 , 0 , 0}, - { L"\x1bOS", VK_F4, 0 , 0 , 0}, + { L"\x1bOS", VK_F4, 0 , 0 , 0}, + { L"\x1b?", VK_OEM_2, L'?' , 0 , SHIFT_PRESSED | LEFT_ALT_PRESSED}, { L"\x1", VK_A, L'\x1' , 0 , LEFT_CTRL_PRESSED}, { L"\x2", VK_B, L'\x2' , 0 , LEFT_CTRL_PRESSED}, //{ L"\x3", VK_C, L'\x3' , 0 , LEFT_CTRL_PRESSED}, /* Control + C is handled differently */ @@ -356,12 +357,8 @@ ProcessCtrlSequence(wchar_t *buf, int buf_len) if (!vkey && buf_len == 6 && buf[2] == L'1' && isalpha(buf[5])) vkey = GetVirtualKeyByMask(L'O', &buf[5], 1, 0); } - if (vkey) { - SendKeyStrokeEx(child_in, VK_CONTROL, 0, LEFT_CTRL_PRESSED, TRUE); - SendKeyStrokeEx(child_in, vkey, 0, LEFT_CTRL_PRESSED, TRUE); - SendKeyStrokeEx(child_in, VK_CONTROL, 0, 0, FALSE); - SendKeyStrokeEx(child_in, vkey, 0, 0, FALSE); - } + if (vkey) + SendKeyStroke(child_in, vkey, 0, LEFT_CTRL_PRESSED); } return vkey; diff --git a/contrib/win32/win32compat/tncon.c b/contrib/win32/win32compat/tncon.c index ece0abda3..b9c5bd933 100644 --- a/contrib/win32/win32compat/tncon.c +++ b/contrib/win32/win32compat/tncon.c @@ -208,6 +208,9 @@ ReadConsoleForTermEmul(HANDLE hInput, char *destin, int destinlen) case VK_ESCAPE: NetWriteString2(pParams->Socket, (char *)ESCAPE_KEY, 1, 0); break; + case VK_OEM_2: + NetWriteString2(pParams->Socket, (char *)SHIFT_ALT_Q, 2, 0); + break; case VK_SHIFT: case VK_CONTROL: case VK_CAPITAL: diff --git a/contrib/win32/win32compat/tncon.h b/contrib/win32/win32compat/tncon.h index aa82369cf..d58f596db 100644 --- a/contrib/win32/win32compat/tncon.h +++ b/contrib/win32/win32compat/tncon.h @@ -54,6 +54,7 @@ #define PREV_KEY "\x1b[5~" #define NEXT_KEY "\x1b[6~" #define SHIFT_TAB_KEY "\x1b[~" +#define SHIFT_ALT_Q "\x1b?" #define ESCAPE_KEY "\x1b" #define BACKSPACE_KEY "\b"