forked from aniani/vim
patch 8.1.0069: cannot handle pressing CTRL-C in a prompt buffer
Problem: Cannot handle pressing CTRL-C in a prompt buffer. Solution: Add prompt_setinterrupt().
This commit is contained in:
@@ -298,6 +298,7 @@ static void f_prevnonblank(typval_T *argvars, typval_T *rettv);
|
||||
static void f_printf(typval_T *argvars, typval_T *rettv);
|
||||
#ifdef FEAT_JOB_CHANNEL
|
||||
static void f_prompt_setcallback(typval_T *argvars, typval_T *rettv);
|
||||
static void f_prompt_setinterrupt(typval_T *argvars, typval_T *rettv);
|
||||
static void f_prompt_setprompt(typval_T *argvars, typval_T *rettv);
|
||||
#endif
|
||||
static void f_pumvisible(typval_T *argvars, typval_T *rettv);
|
||||
@@ -754,6 +755,7 @@ static struct fst
|
||||
{"printf", 1, 19, f_printf},
|
||||
#ifdef FEAT_JOB_CHANNEL
|
||||
{"prompt_setcallback", 2, 2, f_prompt_setcallback},
|
||||
{"prompt_setinterrupt", 2, 2, f_prompt_setinterrupt},
|
||||
{"prompt_setprompt", 2, 2, f_prompt_setprompt},
|
||||
#endif
|
||||
{"pumvisible", 0, 0, f_pumvisible},
|
||||
@@ -8621,6 +8623,35 @@ f_prompt_setcallback(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
buf->b_prompt_partial = partial;
|
||||
}
|
||||
|
||||
/*
|
||||
* "prompt_setinterrupt({buffer}, {callback})" function
|
||||
*/
|
||||
static void
|
||||
f_prompt_setinterrupt(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
{
|
||||
buf_T *buf;
|
||||
char_u *callback;
|
||||
partial_T *partial;
|
||||
|
||||
if (check_secure())
|
||||
return;
|
||||
buf = get_buf_tv(&argvars[0], FALSE);
|
||||
if (buf == NULL)
|
||||
return;
|
||||
|
||||
callback = get_callback(&argvars[1], &partial);
|
||||
if (callback == NULL)
|
||||
return;
|
||||
|
||||
free_callback(buf->b_prompt_interrupt, buf->b_prompt_int_partial);
|
||||
if (partial == NULL)
|
||||
buf->b_prompt_interrupt = vim_strsave(callback);
|
||||
else
|
||||
/* pointer into the partial */
|
||||
buf->b_prompt_interrupt = callback;
|
||||
buf->b_prompt_int_partial = partial;
|
||||
}
|
||||
|
||||
/*
|
||||
* "prompt_setprompt({buffer}, {text})" function
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user