diff src/evalfunc.c @ 14103:d053ec57d886 v8.1.0069

patch 8.1.0069: cannot handle pressing CTRL-C in a prompt buffer commit https://github.com/vim/vim/commit/0e5979a6d491f68c4a8c86fab489016919329a6b Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jun 17 19:36:33 2018 +0200 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().
author Christian Brabandt <cb@256bit.org>
date Sun, 17 Jun 2018 19:45:06 +0200
parents c97e9edfc6b4
children de75c249723d
line wrap: on
line diff
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -298,6 +298,7 @@ static void f_prevnonblank(typval_T *arg
 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},
@@ -8622,6 +8624,35 @@ f_prompt_setcallback(typval_T *argvars, 
 }
 
 /*
+ * "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
  */
     static void