From 589b1109c55409baf27f79920d8ffc95111eaa01 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 12 Aug 2017 16:39:05 +0200 Subject: patch 8.0.0917: MS-Windows:CTRL-C handling in terminal window is wrong Problem: MS-Windows:CTRL-C handling in terminal window is wrong Solution: Pass CTRL-C as a key. Turn CTRL-BREAK into a key stroke. (Yasuhiro Matsumoto, closes #1965) --- src/os_win32.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/os_win32.c') diff --git a/src/os_win32.c b/src/os_win32.c index 496f95f72..c6d9ad167 100644 --- a/src/os_win32.c +++ b/src/os_win32.c @@ -3741,6 +3741,9 @@ mch_free_acl(vim_acl_T acl) handler_routine( DWORD dwCtrlType) { + INPUT_RECORD ir; + DWORD out; + switch (dwCtrlType) { case CTRL_C_EVENT: @@ -3750,6 +3753,16 @@ handler_routine( case CTRL_BREAK_EVENT: g_fCBrkPressed = TRUE; + ctrl_break_was_pressed = TRUE; + /* ReadConsoleInput is blocking, send a key event to continue. */ + ir.EventType = KEY_EVENT; + ir.Event.KeyEvent.bKeyDown = TRUE; + ir.Event.KeyEvent.wRepeatCount = 1; + ir.Event.KeyEvent.wVirtualKeyCode = VK_CANCEL; + ir.Event.KeyEvent.wVirtualScanCode = 0; + ir.Event.KeyEvent.dwControlKeyState = 0; + ir.Event.KeyEvent.uChar.UnicodeChar = 0; + WriteConsoleInput(g_hConIn, &ir, 1, &out); return TRUE; /* fatal events: shut down gracefully */ -- cgit v1.2.1