summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-08-12 16:39:05 +0200
committerBram Moolenaar <Bram@vim.org>2017-08-12 16:39:05 +0200
commit589b1109c55409baf27f79920d8ffc95111eaa01 (patch)
treeefe2a01927102431f2e5e1bb209ac4d6f03f2e4f
parent37c45835945fc433a3bb85fcfc0b4fd58b1ee0e7 (diff)
downloadvim-git-589b1109c55409baf27f79920d8ffc95111eaa01.tar.gz
patch 8.0.0917: MS-Windows:CTRL-C handling in terminal window is wrongv8.0.0917
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)
-rw-r--r--src/os_win32.c13
-rw-r--r--src/terminal.c9
-rw-r--r--src/version.c2
3 files changed, 18 insertions, 6 deletions
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 */
diff --git a/src/terminal.c b/src/terminal.c
index 0b4c2ef68..e8727ee6e 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -1207,12 +1207,8 @@ terminal_loop(void)
may_send_sigint(c, curbuf->b_term->tl_job->jv_pid, 0);
#endif
#ifdef WIN3264
- /* On Windows we do not know whether the job can handle CTRL-C itself
- * or not. Therefore CTRL-C only sends a CTRL_C_EVENT to avoid killing
- * the shell instead of a command running in the shell.
+ /* On Windows winpty handles CTRL-C, don't send a CTRL_C_EVENT.
* Use CTRL-BREAK to kill the job. */
- if (c == Ctrl_C)
- mch_signal_job(curbuf->b_term->tl_job, (char_u *)"int");
if (ctrl_break_was_pressed)
mch_signal_job(curbuf->b_term->tl_job, (char_u *)"kill");
#endif
@@ -1544,7 +1540,8 @@ term_channel_closed(channel_T *ch)
ch_log(NULL, "terminal job finished, opening window");
vim_snprintf(buf, sizeof(buf),
term->tl_opencmd == NULL
- ? "botright sbuf %d" : term->tl_opencmd, fnum);
+ ? "botright sbuf %d"
+ : (char *)term->tl_opencmd, fnum);
do_cmdline_cmd((char_u *)buf);
}
else
diff --git a/src/version.c b/src/version.c
index 8ca7d7022..3bd461af0 100644
--- a/src/version.c
+++ b/src/version.c
@@ -770,6 +770,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 917,
+/**/
916,
/**/
915,