0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

patch 8.0.0960: job in terminal does not get CTRL-C

Problem:    Job in terminal does not get CTRL-C, we send a SIGINT instead.
Solution:   Don't call may_send_sigint() on CTRL-C.  Make CTRL-W CTRL-C end
            the job.
This commit is contained in:
Bram Moolenaar 2017-08-18 22:57:06 +02:00
parent f66a2cda2c
commit 8e539c51c3
3 changed files with 31 additions and 8 deletions

View File

@ -52,6 +52,7 @@ Special in the terminal window: *CTRL-W_.* *CTRL-W_N*
CTRL-W " {reg} paste register {reg} *CTRL-W_quote* CTRL-W " {reg} paste register {reg} *CTRL-W_quote*
Also works with the = register to insert the result of Also works with the = register to insert the result of
evaluating an expression. evaluating an expression.
CTRL-W CTRL-C ends the job, see below |t_CTRL-W_CTRL-C|
See option 'termkey' for specifying another key instead of CTRL-W that See option 'termkey' for specifying another key instead of CTRL-W that
will work like CTRL-W. However, typing 'termkey' twice sends 'termkey' to will work like CTRL-W. However, typing 'termkey' twice sends 'termkey' to
@ -62,16 +63,29 @@ the job. For example:
'termkey' . send a CTRL-W to the job in the terminal 'termkey' . send a CTRL-W to the job in the terminal
'termkey' N go to terminal Normal mode, see below 'termkey' N go to terminal Normal mode, see below
'termkey' CTRL-N same as CTRL-W N 'termkey' CTRL-N same as CTRL-W N
'termkey' CTRL-C same as |t_CTRL-W_CTRL-C|
*t_CTRL-\_CTRL-N* *t_CTRL-\_CTRL-N*
The special key combination CTRL-\ CTRL-N can be used to switch to Normal The special key combination CTRL-\ CTRL-N can be used to switch to Normal
mode, just like this works in any other mode. mode, just like this works in any other mode.
*t_CTRL-W_CTRL-C*
CTRL-W CTRL-C can be typed to forcefully end the job. On MS-Windows a
CTRL-BREAK will also kill the job.
If you type CTRL-C the effect depends on what the pty has been configured to
do. For simple commands this causes a SIGINT to be sent to the job, which
would end it. Other commands may ignore the SIGINT or handle the CTRL-C
themselves (like Vim does).
Size ~ Size and color ~
See option 'termsize' for controlling the size of the terminal window. See option 'termsize' for controlling the size of the terminal window.
(TODO: scrolling when the terminal is larger than the window) (TODO: scrolling when the terminal is larger than the window)
The terminal uses the 'background' option to decide whether the terminal
window will start with a white or black background. The job running in the
terminal can change the colors.
Syntax ~ Syntax ~
@ -115,8 +129,8 @@ Syntax ~
If you want to use more options use the |term_start()| If you want to use more options use the |term_start()|
function. function.
When the buffer associated with the terminal is wiped out the job is killed, When the buffer associated with the terminal is unloaded or wiped out the job
similar to calling `job_stop(job, "kill")` is killed, similar to calling `job_stop(job, "kill")`
By default the 'bufhidden' option of the buffer will be set to "hide". By default the 'bufhidden' option of the buffer will be set to "hide".
So long as the job is running: If the window is closed the buffer becomes So long as the job is running: If the window is closed the buffer becomes
@ -130,7 +144,7 @@ done, use options like this: >
Note that the window will open at an unexpected moment, this will interrupt Note that the window will open at an unexpected moment, this will interrupt
what you are doing. what you are doing.
*E947* *E947* *E948*
So long as the job is running, the buffer is considered modified and Vim So long as the job is running, the buffer is considered modified and Vim
cannot be quit easily, see |abandon|. cannot be quit easily, see |abandon|.
@ -187,6 +201,8 @@ In Terminal-Normal mode the statusline and window title show "(Terminal)". If
the job ends while in Terminal-Normal mode this changes to the job ends while in Terminal-Normal mode this changes to
"(Terminal-finished)". "(Terminal-finished)".
It is not possible to enter Insert mode from Terminal-Job mode.
Unix ~ Unix ~
@ -226,7 +242,10 @@ You can download them from the following page:
https://github.com/rprichard/winpty https://github.com/rprichard/winpty
Just put the files somewhere in your PATH. Just put the files somewhere in your PATH. You can set the 'winptydll' option
to point to the right file, if needed. If you have both the 32-bit and 64-bit
version, rename to winpty32.dll and winpty64.dll to match the way Vim was
build.
============================================================================== ==============================================================================
2. Remote testing *terminal-testing* 2. Remote testing *terminal-testing*

View File

@ -1367,9 +1367,6 @@ terminal_loop(void)
if (c == K_IGNORE) if (c == K_IGNORE)
continue; continue;
#ifdef UNIX
may_send_sigint(c, curbuf->b_term->tl_job->jv_pid, 0);
#endif
#ifdef WIN3264 #ifdef WIN3264
/* On Windows winpty handles CTRL-C, don't send a CTRL_C_EVENT. /* On Windows winpty handles CTRL-C, don't send a CTRL_C_EVENT.
* Use CTRL-BREAK to kill the job. */ * Use CTRL-BREAK to kill the job. */
@ -1405,6 +1402,11 @@ terminal_loop(void)
/* Send both keys to the terminal. */ /* Send both keys to the terminal. */
send_keys_to_term(curbuf->b_term, prev_c, TRUE); send_keys_to_term(curbuf->b_term, prev_c, TRUE);
} }
else if (c == Ctrl_C)
{
/* "CTRL-W CTRL-C" or 'termkey' CTRL-C: end the job */
mch_signal_job(curbuf->b_term->tl_job, (char_u *)"kill");
}
else if (termkey == 0 && c == '.') else if (termkey == 0 && c == '.')
{ {
/* "CTRL-W .": send CTRL-W to the job */ /* "CTRL-W .": send CTRL-W to the job */

View File

@ -769,6 +769,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
960,
/**/ /**/
959, 959,
/**/ /**/