summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.0020
blob: 3685bee38bff5da300ca3dc3c3c33045cfb88197 (plain)
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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0020
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.0020
Problem:    Cannot tell whether a register is being used for executing or
            recording.
Solution:   Add reg_executing() and reg_recording(). (Hirohito Higashi,
            closes #2745)  Rename the global variables for consistency.  Store
            the register name in reg_executing.
Files:	    runtime/doc/eval.txt, runtime/doc/usr_41.txt, src/evalfunc.c,
            src/testdir/test_functions.vim, src/getchar.c, src/normal.c,
            src/ops.c, src/globals.h, src/edit.c, src/fileio.c, src/message.c,
            src/screen.c


*** ../vim-8.1.0019/runtime/doc/eval.txt	2018-05-17 15:06:48.000000000 +0200
--- runtime/doc/eval.txt	2018-05-22 20:25:41.869831935 +0200
***************
*** 2302,2307 ****
--- 2302,2309 ----
  				List	items from {expr} to {max}
  readfile({fname} [, {binary} [, {max}]])
  				List	get list of lines from file {fname}
+ reg_executing()			Number	get the executing register name
+ reg_recording()			String	get the recording register name
  reltime([{start} [, {end}]])	List	get time value
  reltimefloat({time})		Float	turn the time value into a Float
  reltimestr({time})		String	turn time value into a String
***************
*** 6558,6563 ****
--- 6562,6576 ----
  		the result is an empty list.
  		Also see |writefile()|.
  
+ reg_executing()						*reg_executing()*
+ 		Returns the single letter name of the register being executed.
+ 		Returns an empty string when no register is being executed.
+ 		See |@|.
+ 
+ reg_recording()						*reg_recording()*
+ 		Returns the single letter name of the register being recorded.
+ 		Returns an empty string string when not recording.  See |q|.
+ 
  reltime([{start} [, {end}]])				*reltime()*
  		Return an item that represents a time value.  The format of
  		the item depends on the system.  It can be passed to
*** ../vim-8.1.0019/runtime/doc/usr_41.txt	2018-05-17 13:42:03.000000000 +0200
--- runtime/doc/usr_41.txt	2018-05-22 20:26:30.025880034 +0200
***************
*** 1018,1023 ****
--- 1018,1025 ----
  	getreg()		get contents of a register
  	getregtype()		get type of a register
  	setreg()		set contents and type of a register
+ 	reg_executing()		return the name of the register being executed
+ 	reg_recording()		return the name of the register being recorded
  
  	shiftwidth()		effective value of 'shiftwidth'
  
*** ../vim-8.1.0019/src/evalfunc.c	2018-05-21 13:28:40.320041589 +0200
--- src/evalfunc.c	2018-05-22 20:32:33.566027870 +0200
***************
*** 306,311 ****
--- 306,313 ----
  #endif
  static void f_range(typval_T *argvars, typval_T *rettv);
  static void f_readfile(typval_T *argvars, typval_T *rettv);
+ static void f_reg_executing(typval_T *argvars, typval_T *rettv);
+ static void f_reg_recording(typval_T *argvars, typval_T *rettv);
  static void f_reltime(typval_T *argvars, typval_T *rettv);
  #ifdef FEAT_FLOAT
  static void f_reltimefloat(typval_T *argvars, typval_T *rettv);
***************
*** 754,759 ****
--- 756,763 ----
  #endif
      {"range",		1, 3, f_range},
      {"readfile",	1, 3, f_readfile},
+     {"reg_executing",	0, 0, f_reg_executing},
+     {"reg_recording",	0, 0, f_reg_recording},
      {"reltime",		0, 2, f_reltime},
  #ifdef FEAT_FLOAT
      {"reltimefloat",	1, 1, f_reltimefloat},
***************
*** 8697,8702 ****
--- 8701,8734 ----
      fclose(fd);
  }
  
+     static void
+ return_register(int regname, typval_T *rettv)
+ {
+     char_u buf[2] = {0, 0};
+ 
+     buf[0] = (char_u)regname;
+     rettv->v_type = VAR_STRING;
+     rettv->vval.v_string = vim_strsave(buf);
+ }
+ 
+ /*
+  * "reg_executing()" function
+  */
+     static void
+ f_reg_executing(typval_T *argvars UNUSED, typval_T *rettv)
+ {
+     return_register(reg_executing, rettv);
+ }
+ 
+ /*
+  * "reg_recording()" function
+  */
+     static void
+ f_reg_recording(typval_T *argvars UNUSED, typval_T *rettv)
+ {
+     return_register(reg_recording, rettv);
+ }
+ 
  #if defined(FEAT_RELTIME)
  static int list2proftime(typval_T *arg, proftime_T *tm);
  
*** ../vim-8.1.0019/src/testdir/test_functions.vim	2018-05-20 14:11:07.125342749 +0200
--- src/testdir/test_functions.vim	2018-05-22 20:27:42.625937524 +0200
***************
*** 923,925 ****
--- 923,950 ----
    let chars = join(map(range(1, 0x20) + [0xa0], {n -> nr2char(n)}), '')
    call assert_equal("x", trim(chars . "x" . chars))
  endfunc
+ 
+ " Test for reg_recording() and reg_executing()
+ func Test_reg_executing_and_recording()
+   let s:reg_stat = ''
+   func s:save_reg_stat()
+     let s:reg_stat = reg_recording() . ':' . reg_executing()
+     return ''
+   endfunc
+ 
+   new
+   call s:save_reg_stat()
+   call assert_equal(':', s:reg_stat)
+   call feedkeys("qa\"=s:save_reg_stat()\<CR>pq", 'xt')
+   call assert_equal('a:', s:reg_stat)
+   call feedkeys("@a", 'xt')
+   call assert_equal(':a', s:reg_stat)
+   call feedkeys("qb@aq", 'xt')
+   call assert_equal('b:a', s:reg_stat)
+   call feedkeys("q\"\"=s:save_reg_stat()\<CR>pq", 'xt')
+   call assert_equal('":', s:reg_stat)
+ 
+   bwipe!
+   delfunc s:save_reg_stat
+   unlet s:reg_stat
+ endfunc
*** ../vim-8.1.0019/src/getchar.c	2018-05-13 18:25:53.000000000 +0200
--- src/getchar.c	2018-05-22 20:21:55.241805765 +0200
***************
*** 1244,1250 ****
      int		todo = len;
  
      /* remember how many chars were last recorded */
!     if (Recording)
  	last_recorded_len += len;
  
      buf[1] = NUL;
--- 1244,1250 ----
      int		todo = len;
  
      /* remember how many chars were last recorded */
!     if (reg_recording != 0)
  	last_recorded_len += len;
  
      buf[1] = NUL;
***************
*** 1254,1260 ****
  	c = *s++;
  	updatescript(c);
  
! 	if (Recording)
  	{
  	    buf[0] = c;
  	    add_buff(&recordbuff, buf, 1L);
--- 1254,1260 ----
  	c = *s++;
  	updatescript(c);
  
! 	if (reg_recording != 0)
  	{
  	    buf[0] = c;
  	    add_buff(&recordbuff, buf, 1L);
***************
*** 2007,2013 ****
      init_typebuf();
      start_stuff();
      if (advance && typebuf.tb_maplen == 0)
! 	Exec_reg = FALSE;
      do
      {
  /*
--- 2007,2013 ----
      init_typebuf();
      start_stuff();
      if (advance && typebuf.tb_maplen == 0)
! 	reg_executing = 0;
      do
      {
  /*
*** ../vim-8.1.0019/src/normal.c	2018-05-10 15:04:13.000000000 +0200
--- src/normal.c	2018-05-22 20:22:01.537798525 +0200
***************
*** 871,878 ****
  		|| (nv_cmds[idx].cmd_flags & NV_NCH_ALW) == NV_NCH_ALW
  		|| (ca.cmdchar == 'q'
  		    && oap->op_type == OP_NOP
! 		    && !Recording
! 		    && !Exec_reg)
  		|| ((ca.cmdchar == 'a' || ca.cmdchar == 'i')
  		    && (oap->op_type != OP_NOP || VIsual_active))))
      {
--- 871,878 ----
  		|| (nv_cmds[idx].cmd_flags & NV_NCH_ALW) == NV_NCH_ALW
  		|| (ca.cmdchar == 'q'
  		    && oap->op_type == OP_NOP
! 		    && reg_recording == 0
! 		    && reg_executing == 0)
  		|| ((ca.cmdchar == 'a' || ca.cmdchar == 'i')
  		    && (oap->op_type != OP_NOP || VIsual_active))))
      {
***************
*** 9324,9330 ****
  #endif
  	    /* (stop) recording into a named register, unless executing a
  	     * register */
! 	    if (!Exec_reg && do_record(cap->nchar) == FAIL)
  		clearopbeep(cap->oap);
      }
  }
--- 9324,9330 ----
  #endif
  	    /* (stop) recording into a named register, unless executing a
  	     * register */
! 	    if (reg_executing == 0 && do_record(cap->nchar) == FAIL)
  		clearopbeep(cap->oap);
      }
  }
*** ../vim-8.1.0019/src/ops.c	2018-05-01 19:10:26.000000000 +0200
--- src/ops.c	2018-05-22 20:22:13.973784219 +0200
***************
*** 1091,1104 ****
      yankreg_T	    *old_y_previous, *old_y_current;
      int		    retval;
  
!     if (Recording == FALSE)	    /* start recording */
      {
  	/* registers 0-9, a-z and " are allowed */
  	if (c < 0 || (!ASCII_ISALNUM(c) && c != '"'))
  	    retval = FAIL;
  	else
  	{
! 	    Recording = c;
  	    showmode();
  	    regname = c;
  	    retval = OK;
--- 1091,1104 ----
      yankreg_T	    *old_y_previous, *old_y_current;
      int		    retval;
  
!     if (reg_recording == 0)	    /* start recording */
      {
  	/* registers 0-9, a-z and " are allowed */
  	if (c < 0 || (!ASCII_ISALNUM(c) && c != '"'))
  	    retval = FAIL;
  	else
  	{
! 	    reg_recording = c;
  	    showmode();
  	    regname = c;
  	    retval = OK;
***************
*** 1111,1117 ****
  	 * needs to be removed again to put it in a register.  exec_reg then
  	 * adds the escaping back later.
  	 */
! 	Recording = FALSE;
  	MSG("");
  	p = get_recorded();
  	if (p == NULL)
--- 1111,1117 ----
  	 * needs to be removed again to put it in a register.  exec_reg then
  	 * adds the escaping back later.
  	 */
! 	reg_recording = 0;
  	MSG("");
  	p = get_recorded();
  	if (p == NULL)
***************
*** 1318,1324 ****
  								      == FAIL)
  		return FAIL;
  	}
! 	Exec_reg = TRUE;	/* disable the 'q' command */
      }
      return retval;
  }
--- 1318,1324 ----
  								      == FAIL)
  		return FAIL;
  	}
! 	reg_executing = regname == 0 ? '"' : regname; // disable "q" command
      }
      return retval;
  }
*** ../vim-8.1.0019/src/globals.h	2018-05-01 15:29:24.000000000 +0200
--- src/globals.h	2018-05-22 20:22:30.453765251 +0200
***************
*** 933,940 ****
  EXTERN int exmode_active INIT(= 0);	/* zero, EXMODE_NORMAL or EXMODE_VIM */
  EXTERN int ex_no_reprint INIT(= FALSE); /* no need to print after z or p */
  
! EXTERN int Recording INIT(= FALSE);	/* TRUE when recording into a reg. */
! EXTERN int Exec_reg INIT(= FALSE);	/* TRUE when executing a register */
  
  EXTERN int no_mapping INIT(= FALSE);	/* currently no mapping allowed */
  EXTERN int no_zero_mapping INIT(= 0);	/* mapping zero not allowed */
--- 933,940 ----
  EXTERN int exmode_active INIT(= 0);	/* zero, EXMODE_NORMAL or EXMODE_VIM */
  EXTERN int ex_no_reprint INIT(= FALSE); /* no need to print after z or p */
  
! EXTERN int reg_recording INIT(= 0);	/* register for recording  or zero */
! EXTERN int reg_executing INIT(= 0);	/* register being executed or zero */
  
  EXTERN int no_mapping INIT(= FALSE);	/* currently no mapping allowed */
  EXTERN int no_zero_mapping INIT(= 0);	/* mapping zero not allowed */
*** ../vim-8.1.0019/src/edit.c	2018-05-10 15:03:58.000000000 +0200
--- src/edit.c	2018-05-22 20:19:41.393959222 +0200
***************
*** 8698,8704 ****
       * When recording or for CTRL-O, need to display the new mode.
       * Otherwise remove the mode message.
       */
!     if (Recording || restart_edit != NUL)
  	showmode();
      else if (p_smd)
  	MSG("");
--- 8698,8704 ----
       * When recording or for CTRL-O, need to display the new mode.
       * Otherwise remove the mode message.
       */
!     if (reg_recording != 0 || restart_edit != NUL)
  	showmode();
      else if (p_smd)
  	MSG("");
*** ../vim-8.1.0019/src/fileio.c	2018-05-21 13:39:36.047906786 +0200
--- src/fileio.c	2018-05-22 20:19:50.201949153 +0200
***************
*** 9274,9280 ****
  
      if (!did_cursorhold
  	    && has_cursorhold()
! 	    && !Recording
  	    && typebuf.tb_len == 0
  #ifdef FEAT_INS_EXPAND
  	    && !ins_compl_active()
--- 9274,9280 ----
  
      if (!did_cursorhold
  	    && has_cursorhold()
! 	    && reg_recording == 0
  	    && typebuf.tb_len == 0
  #ifdef FEAT_INS_EXPAND
  	    && !ins_compl_active()
*** ../vim-8.1.0019/src/message.c	2018-04-29 12:18:04.000000000 +0200
--- src/message.c	2018-05-22 20:20:24.417909998 +0200
***************
*** 1025,1031 ****
      int		oldState;
      int		tmpState;
      int		had_got_int;
!     int		save_Recording;
      FILE	*save_scriptout;
  
      if (redraw == TRUE)
--- 1025,1031 ----
      int		oldState;
      int		tmpState;
      int		had_got_int;
!     int		save_reg_recording;
      FILE	*save_scriptout;
  
      if (redraw == TRUE)
***************
*** 1103,1118 ****
  	    /* Temporarily disable Recording. If Recording is active, the
  	     * character will be recorded later, since it will be added to the
  	     * typebuf after the loop */
! 	    save_Recording = Recording;
  	    save_scriptout = scriptout;
! 	    Recording = FALSE;
  	    scriptout = NULL;
  	    c = safe_vgetc();
  	    if (had_got_int && !global_busy)
  		got_int = FALSE;
  	    --no_mapping;
  	    --allow_keys;
! 	    Recording = save_Recording;
  	    scriptout = save_scriptout;
  
  #ifdef FEAT_CLIPBOARD
--- 1103,1118 ----
  	    /* Temporarily disable Recording. If Recording is active, the
  	     * character will be recorded later, since it will be added to the
  	     * typebuf after the loop */
! 	    save_reg_recording = reg_recording;
  	    save_scriptout = scriptout;
! 	    reg_recording = 0;
  	    scriptout = NULL;
  	    c = safe_vgetc();
  	    if (had_got_int && !global_busy)
  		got_int = FALSE;
  	    --no_mapping;
  	    --allow_keys;
! 	    reg_recording = save_reg_recording;
  	    scriptout = save_scriptout;
  
  #ifdef FEAT_CLIPBOARD
*** ../vim-8.1.0019/src/screen.c	2018-05-19 14:43:26.775509740 +0200
--- src/screen.c	2018-05-22 20:20:50.233880413 +0200
***************
*** 10255,10261 ****
  	    && ((State & INSERT)
  		|| restart_edit
  		|| VIsual_active));
!     if (do_mode || Recording)
      {
  	/*
  	 * Don't show mode right now, when not redrawing or inside a mapping.
--- 10255,10261 ----
  	    && ((State & INSERT)
  		|| restart_edit
  		|| VIsual_active));
!     if (do_mode || reg_recording != 0)
      {
  	/*
  	 * Don't show mode right now, when not redrawing or inside a mapping.
***************
*** 10414,10420 ****
  
  	    need_clear = TRUE;
  	}
! 	if (Recording
  #ifdef FEAT_INS_EXPAND
  		&& edit_submode == NULL	    /* otherwise it gets too long */
  #endif
--- 10414,10420 ----
  
  	    need_clear = TRUE;
  	}
! 	if (reg_recording != 0
  #ifdef FEAT_INS_EXPAND
  		&& edit_submode == NULL	    /* otherwise it gets too long */
  #endif
***************
*** 10489,10495 ****
      int save_msg_col = msg_col;
  
      msg_pos_mode();
!     if (Recording)
  	recording_mode(HL_ATTR(HLF_CM));
      msg_clr_eos();
  
--- 10489,10495 ----
      int save_msg_col = msg_col;
  
      msg_pos_mode();
!     if (reg_recording != 0)
  	recording_mode(HL_ATTR(HLF_CM));
      msg_clr_eos();
  
***************
*** 10504,10510 ****
      if (!shortmess(SHM_RECORDING))
      {
  	char_u s[4];
! 	sprintf((char *)s, " @%c", Recording);
  	MSG_PUTS_ATTR(s, attr);
      }
  }
--- 10504,10510 ----
      if (!shortmess(SHM_RECORDING))
      {
  	char_u s[4];
! 	sprintf((char *)s, " @%c", reg_recording);
  	MSG_PUTS_ATTR(s, attr);
      }
  }
*** ../vim-8.1.0019/src/version.c	2018-05-22 18:31:30.001365739 +0200
--- src/version.c	2018-05-22 20:33:34.882025227 +0200
***************
*** 763,764 ****
--- 763,766 ----
  {   /* Add new patch number below this line */
+ /**/
+     20,
  /**/

-- 
            |

Ceci n'est pas une pipe.

 /// 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    ///