1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
|
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0069
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------
Patch 8.1.0069
Problem: Cannot handle pressing CTRL-C in a prompt buffer.
Solution: Add prompt_setinterrupt().
Files: runtime/doc/eval.txt, src/edit.c, src/evalfunc.c, src/channel.c,
src/proto/channel.pro
*** ../vim-8.1.0068/runtime/doc/eval.txt 2018-06-07 18:17:42.274227515 +0200
--- runtime/doc/eval.txt 2018-06-17 18:12:12.760548966 +0200
***************
*** 2297,2304 ****
prevnonblank({lnum}) Number line nr of non-blank line <= {lnum}
printf({fmt}, {expr1}...) String format text
prompt_addtext({buf}, {expr}) none add text to a prompt buffer
- prompt_setprompt({buf}, {text}) none set prompt text
prompt_setcallback({buf}, {expr}) none set prompt callback function
pumvisible() Number whether popup menu is visible
pyeval({expr}) any evaluate |Python| expression
py3eval({expr}) any evaluate |python3| expression
--- 2297,2305 ----
prevnonblank({lnum}) Number line nr of non-blank line <= {lnum}
printf({fmt}, {expr1}...) String format text
prompt_addtext({buf}, {expr}) none add text to a prompt buffer
prompt_setcallback({buf}, {expr}) none set prompt callback function
+ prompt_setinterrupt({buf}, {text}) none set prompt interrupt function
+ prompt_setprompt({buf}, {text}) none set prompt text
pumvisible() Number whether popup menu is visible
pyeval({expr}) any evaluate |Python| expression
py3eval({expr}) any evaluate |python3| expression
***************
*** 6506,6522 ****
arguments an error is given. Up to 18 arguments can be used.
- prompt_setprompt({buf}, {text}) *prompt_setprompt()*
- Set prompt for buffer {buf} to {text}. You most likely want
- {text} to end in a space.
- The result is only visible if {buf} has 'buftype' set to
- "prompt". Example: >
- call prompt_setprompt(bufnr(''), 'command: ')
-
-
prompt_setcallback({buf}, {expr}) *prompt_setcallback()*
! Set prompt callback for buffer {buf} to {expr}. This has only
effect if {buf} has 'buftype' set to "prompt".
The callback is invoked when pressing Enter. The current
buffer will always be the prompt buffer. A new line for a
prompt is added before invoking the callback, thus the prompt
--- 6507,6517 ----
arguments an error is given. Up to 18 arguments can be used.
prompt_setcallback({buf}, {expr}) *prompt_setcallback()*
! Set prompt callback for buffer {buf} to {expr}. When {expr}
! is an empty string the callback is removed. This has only
effect if {buf} has 'buftype' set to "prompt".
+
The callback is invoked when pressing Enter. The current
buffer will always be the prompt buffer. A new line for a
prompt is added before invoking the callback, thus the prompt
***************
*** 6541,6546 ****
--- 6536,6557 ----
endif
endfunc
+ prompt_setinterrupt({buf}, {expr}) *prompt_setinterrupt()*
+ Set a callback for buffer {buf} to {expr}. When {expr} is an
+ empty string the callback is removed. This has only effect if
+ {buf} has 'buftype' set to "prompt".
+
+ This callback will be invoked when pressing CTRL-C in Insert
+ mode. Without setting a callback Vim will exit Insert mode,
+ as in any buffer.
+
+ prompt_setprompt({buf}, {text}) *prompt_setprompt()*
+ Set prompt for buffer {buf} to {text}. You most likely want
+ {text} to end in a space.
+ The result is only visible if {buf} has 'buftype' set to
+ "prompt". Example: >
+ call prompt_setprompt(bufnr(''), 'command: ')
+
pumvisible() *pumvisible()*
Returns non-zero when the popup menu is visible, zero
***************
*** 8563,8569 ****
instead of using 'termwinsize'
"term_cols" horizontal size to use for the terminal,
instead of using 'termwinsize'
! "vertical" split the window vertically
"curwin" use the current window, do not split the
window; fails if the current buffer
cannot be |abandon|ed
--- 8574,8582 ----
instead of using 'termwinsize'
"term_cols" horizontal size to use for the terminal,
instead of using 'termwinsize'
! "vertical" split the window vertically; note that
! other window position can be defined with
! command modifiers, such as |:belowright|.
"curwin" use the current window, do not split the
window; fails if the current buffer
cannot be |abandon|ed
***************
*** 9392,9402 ****
out if it works in the current console).
wildignore Compiled with 'wildignore' option.
wildmenu Compiled with 'wildmenu' option.
win32 Win32 version of Vim (MS-Windows 95 and later, 32 or
64 bits)
win32unix Win32 version of Vim, using Unix files (Cygwin)
win64 Win64 version of Vim (MS-Windows 64 bit).
! win95 Win32 version for MS-Windows 95/98/ME.
winaltkeys Compiled with 'winaltkeys' option.
windows Compiled with support for more than one window.
writebackup Compiled with 'writebackup' default on.
--- 9405,9416 ----
out if it works in the current console).
wildignore Compiled with 'wildignore' option.
wildmenu Compiled with 'wildmenu' option.
+ win16 old version for MS-Windows 3.1 (always False)
win32 Win32 version of Vim (MS-Windows 95 and later, 32 or
64 bits)
win32unix Win32 version of Vim, using Unix files (Cygwin)
win64 Win64 version of Vim (MS-Windows 64 bit).
! win95 Win32 version for MS-Windows 95/98/ME (always False)
winaltkeys Compiled with 'winaltkeys' option.
windows Compiled with support for more than one window.
writebackup Compiled with 'writebackup' default on.
*** ../vim-8.1.0068/src/edit.c 2018-06-17 16:23:29.337140663 +0200
--- src/edit.c 2018-06-17 19:32:54.656479224 +0200
***************
*** 1016,1021 ****
--- 1016,1034 ----
goto doESCkey;
}
#endif
+ #ifdef FEAT_JOB_CHANNEL
+ if (c == Ctrl_C && bt_prompt(curbuf))
+ {
+ if (invoke_prompt_interrupt())
+ {
+ if (!bt_prompt(curbuf))
+ // buffer changed to a non-prompt buffer, get out of
+ // Insert mode
+ goto doESCkey;
+ break;
+ }
+ }
+ #endif
#ifdef UNIX
do_intr:
*** ../vim-8.1.0068/src/evalfunc.c 2018-06-17 19:22:48.343603795 +0200
--- src/evalfunc.c 2018-06-17 19:16:21.949606435 +0200
***************
*** 298,303 ****
--- 298,304 ----
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,759 ****
--- 755,761 ----
{"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,8627 ****
--- 8624,8658 ----
}
/*
+ * "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
*** ../vim-8.1.0068/src/channel.c 2018-06-12 20:25:47.883923416 +0200
--- src/channel.c 2018-06-17 19:33:49.264186387 +0200
***************
*** 5856,5862 ****
curwin->w_cursor.lnum = lnum + 1;
curwin->w_cursor.col = 0;
! if (curbuf->b_prompt_callback == NULL)
return;
text = ml_get(lnum);
prompt = prompt_text();
--- 5856,5862 ----
curwin->w_cursor.lnum = lnum + 1;
curwin->w_cursor.col = 0;
! if (curbuf->b_prompt_callback == NULL || *curbuf->b_prompt_callback == NUL)
return;
text = ml_get(lnum);
prompt = prompt_text();
***************
*** 5874,5877 ****
--- 5874,5901 ----
clear_tv(&rettv);
}
+ /*
+ * Return TRUE when the interrupt callback was invoked.
+ */
+ int
+ invoke_prompt_interrupt(void)
+ {
+ typval_T rettv;
+ int dummy;
+ typval_T argv[1];
+
+ if (curbuf->b_prompt_interrupt == NULL
+ || *curbuf->b_prompt_interrupt == NUL)
+ return FALSE;
+ argv[0].v_type = VAR_UNKNOWN;
+
+ got_int = FALSE; // don't skip executing commands
+ call_func(curbuf->b_prompt_interrupt,
+ (int)STRLEN(curbuf->b_prompt_interrupt),
+ &rettv, 0, argv, NULL, 0L, 0L, &dummy, TRUE,
+ curbuf->b_prompt_int_partial, NULL);
+ clear_tv(&rettv);
+ return TRUE;
+ }
+
#endif /* FEAT_JOB_CHANNEL */
*** ../vim-8.1.0068/src/proto/channel.pro 2018-06-12 20:25:47.883923416 +0200
--- src/proto/channel.pro 2018-06-17 19:34:32.267954974 +0200
***************
*** 72,75 ****
--- 72,76 ----
void job_info_all(list_T *l);
int job_stop(job_T *job, typval_T *argvars, char *type);
void invoke_prompt_callback(void);
+ int invoke_prompt_interrupt(void);
/* vim: set ft=c : */
*** ../vim-8.1.0068/src/version.c 2018-06-17 19:22:48.343603795 +0200
--- src/version.c 2018-06-17 19:34:40.111912692 +0200
***************
*** 763,764 ****
--- 763,766 ----
{ /* Add new patch number below this line */
+ /**/
+ 69,
/**/
--
hundred-and-one symptoms of being an internet addict:
64. The remote to the T.V. is missing...and you don't even care.
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|