Mercurial > vim
annotate src/register.c @ 32208:73c5881c1793 v9.0.1435
patch 9.0.1435: scrolling too many lines when 'wrap' and 'diff' are set
Commit: https://github.com/vim/vim/commit/38d867f041349e1400c2cce9cac06f59ae6ccbb1
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Apr 1 19:54:40 2023 +0100
patch 9.0.1435: scrolling too many lines when 'wrap' and 'diff' are set
Problem: Scrolling too many lines when 'wrap' and 'diff' are set.
Solution: Only scroll by screenlines for 'diff' when 'wrap' is not set.
(closes #12211)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 01 Apr 2023 21:00:04 +0200 |
parents | 7d94b1c0f292 |
children | 18dd2b5d008c |
rev | line source |
---|---|
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2 * |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3 * VIM - Vi IMproved by Bram Moolenaar |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4 * |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5 * Do ":help uganda" in Vim to read copying and usage conditions. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6 * Do ":help credits" in Vim to see a list of people who contributed. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
7 * See README.txt for an overview of the Vim source code. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
8 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
9 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
10 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
11 * register.c: functions for managing registers |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
12 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
13 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
14 #include "vim.h" |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
15 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
16 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
17 * Registers: |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
18 * 0 = unnamed register, for normal yanks and puts |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
19 * 1..9 = registers '1' to '9', for deletes |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
20 * 10..35 = registers 'a' to 'z' ('A' to 'Z' for appending) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
21 * 36 = delete register '-' |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
22 * 37 = Selection register '*'. Only if FEAT_CLIPBOARD defined |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
23 * 38 = Clipboard register '+'. Only if FEAT_CLIPBOARD and FEAT_X11 defined |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
24 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
25 static yankreg_T y_regs[NUM_REGISTERS]; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
26 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
27 static yankreg_T *y_current; // ptr to current yankreg |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
28 static int y_append; // TRUE when appending |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
29 static yankreg_T *y_previous = NULL; // ptr to last written yankreg |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
30 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
31 static int stuff_yank(int, char_u *); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
32 static void put_reedit_in_typebuf(int silent); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
33 static int put_in_typebuf(char_u *s, int esc, int colon, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
34 int silent); |
24866
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24794
diff
changeset
|
35 static int yank_copy_line(struct block_def *bd, long y_idx, int exclude_trailing_space); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
36 #ifdef FEAT_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
37 static void copy_yank_reg(yankreg_T *reg); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
38 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
39 static void dis_msg(char_u *p, int skip_esc); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
40 |
27018
268f6a3511df
patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
41 #if defined(FEAT_VIMINFO) || defined(PROTO) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
42 yankreg_T * |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
43 get_y_regs(void) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
44 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
45 return y_regs; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
46 } |
27018
268f6a3511df
patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
47 #endif |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
48 |
27018
268f6a3511df
patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
49 #if defined(FEAT_CLIPBOARD) || defined(PROTO) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
50 yankreg_T * |
19774
00a1b89256ea
patch 8.2.0443: clipboard code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
19524
diff
changeset
|
51 get_y_register(int reg) |
00a1b89256ea
patch 8.2.0443: clipboard code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
19524
diff
changeset
|
52 { |
00a1b89256ea
patch 8.2.0443: clipboard code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
19524
diff
changeset
|
53 return &y_regs[reg]; |
00a1b89256ea
patch 8.2.0443: clipboard code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
19524
diff
changeset
|
54 } |
27018
268f6a3511df
patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
55 #endif |
19774
00a1b89256ea
patch 8.2.0443: clipboard code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
19524
diff
changeset
|
56 |
00a1b89256ea
patch 8.2.0443: clipboard code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
19524
diff
changeset
|
57 yankreg_T * |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
58 get_y_current(void) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
59 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
60 return y_current; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
61 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
62 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
63 yankreg_T * |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
64 get_y_previous(void) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
65 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
66 return y_previous; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
67 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
68 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
69 void |
19774
00a1b89256ea
patch 8.2.0443: clipboard code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
19524
diff
changeset
|
70 set_y_current(yankreg_T *yreg) |
00a1b89256ea
patch 8.2.0443: clipboard code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
19524
diff
changeset
|
71 { |
00a1b89256ea
patch 8.2.0443: clipboard code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
19524
diff
changeset
|
72 y_current = yreg; |
00a1b89256ea
patch 8.2.0443: clipboard code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
19524
diff
changeset
|
73 } |
00a1b89256ea
patch 8.2.0443: clipboard code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
19524
diff
changeset
|
74 |
00a1b89256ea
patch 8.2.0443: clipboard code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
19524
diff
changeset
|
75 void |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
76 set_y_previous(yankreg_T *yreg) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
77 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
78 y_previous = yreg; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
79 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
80 |
25808
b1440083f0da
patch 8.2.3439: deleted lines go to wrong yank register
Bram Moolenaar <Bram@vim.org>
parents:
25380
diff
changeset
|
81 void |
b1440083f0da
patch 8.2.3439: deleted lines go to wrong yank register
Bram Moolenaar <Bram@vim.org>
parents:
25380
diff
changeset
|
82 reset_y_append(void) |
b1440083f0da
patch 8.2.3439: deleted lines go to wrong yank register
Bram Moolenaar <Bram@vim.org>
parents:
25380
diff
changeset
|
83 { |
b1440083f0da
patch 8.2.3439: deleted lines go to wrong yank register
Bram Moolenaar <Bram@vim.org>
parents:
25380
diff
changeset
|
84 y_append = FALSE; |
b1440083f0da
patch 8.2.3439: deleted lines go to wrong yank register
Bram Moolenaar <Bram@vim.org>
parents:
25380
diff
changeset
|
85 } |
b1440083f0da
patch 8.2.3439: deleted lines go to wrong yank register
Bram Moolenaar <Bram@vim.org>
parents:
25380
diff
changeset
|
86 |
b1440083f0da
patch 8.2.3439: deleted lines go to wrong yank register
Bram Moolenaar <Bram@vim.org>
parents:
25380
diff
changeset
|
87 |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
88 #if defined(FEAT_EVAL) || defined(PROTO) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
89 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
90 * Keep the last expression line here, for repeating. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
91 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
92 static char_u *expr_line = NULL; |
22732
4c21a3a47707
patch 8.2.1914: Vim9: cannot put line break in expression for '=' register
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
93 static exarg_T *expr_eap = NULL; |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
94 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
95 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
96 * Get an expression for the "\"=expr1" or "CTRL-R =expr1" |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
97 * Returns '=' when OK, NUL otherwise. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
98 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
99 int |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
100 get_expr_register(void) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
101 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
102 char_u *new_line; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
103 |
26804
34f1b7d6974a
patch 8.2.3930: getcmdline() argument has a misleading type
Bram Moolenaar <Bram@vim.org>
parents:
26439
diff
changeset
|
104 new_line = getcmdline('=', 0L, 0, 0); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
105 if (new_line == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
106 return NUL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
107 if (*new_line == NUL) // use previous line |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
108 vim_free(new_line); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
109 else |
22732
4c21a3a47707
patch 8.2.1914: Vim9: cannot put line break in expression for '=' register
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
110 set_expr_line(new_line, NULL); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
111 return '='; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
112 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
113 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
114 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
115 * Set the expression for the '=' register. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
116 * Argument must be an allocated string. |
22732
4c21a3a47707
patch 8.2.1914: Vim9: cannot put line break in expression for '=' register
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
117 * "eap" may be used if the next line needs to be checked when evaluating the |
4c21a3a47707
patch 8.2.1914: Vim9: cannot put line break in expression for '=' register
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
118 * expression. |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
119 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
120 void |
22732
4c21a3a47707
patch 8.2.1914: Vim9: cannot put line break in expression for '=' register
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
121 set_expr_line(char_u *new_line, exarg_T *eap) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
122 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
123 vim_free(expr_line); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
124 expr_line = new_line; |
22732
4c21a3a47707
patch 8.2.1914: Vim9: cannot put line break in expression for '=' register
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
125 expr_eap = eap; |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
126 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
127 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
128 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
129 * Get the result of the '=' register expression. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
130 * Returns a pointer to allocated memory, or NULL for failure. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
131 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
132 char_u * |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
133 get_expr_line(void) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
134 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
135 char_u *expr_copy; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
136 char_u *rv; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
137 static int nested = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
138 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
139 if (expr_line == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
140 return NULL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
141 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
142 // Make a copy of the expression, because evaluating it may cause it to be |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
143 // changed. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
144 expr_copy = vim_strsave(expr_line); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
145 if (expr_copy == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
146 return NULL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
147 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
148 // When we are invoked recursively limit the evaluation to 10 levels. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
149 // Then return the string as-is. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
150 if (nested >= 10) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
151 return expr_copy; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
152 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
153 ++nested; |
30598
37aa9fd2ed72
patch 9.0.0634: evaluating "expr" options has more overhead than needed
Bram Moolenaar <Bram@vim.org>
parents:
30005
diff
changeset
|
154 rv = eval_to_string_eap(expr_copy, TRUE, expr_eap, FALSE); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
155 --nested; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
156 vim_free(expr_copy); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
157 return rv; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
158 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
159 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
160 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
161 * Get the '=' register expression itself, without evaluating it. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
162 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
163 static char_u * |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
164 get_expr_line_src(void) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
165 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
166 if (expr_line == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
167 return NULL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
168 return vim_strsave(expr_line); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
169 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
170 #endif // FEAT_EVAL |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
171 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
172 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
173 * Check if 'regname' is a valid name of a yank register. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
174 * Note: There is no check for 0 (default register), caller should do this |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
175 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
176 int |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
177 valid_yank_reg( |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
178 int regname, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
179 int writing) // if TRUE check for writable registers |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
180 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
181 if ( (regname > 0 && ASCII_ISALNUM(regname)) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
182 || (!writing && vim_strchr((char_u *) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
183 #ifdef FEAT_EVAL |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
184 "/.%:=" |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
185 #else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
186 "/.%:" |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
187 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
188 , regname) != NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
189 || regname == '#' |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
190 || regname == '"' |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
191 || regname == '-' |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
192 || regname == '_' |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
193 #ifdef FEAT_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
194 || regname == '*' |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
195 || regname == '+' |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
196 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
197 #ifdef FEAT_DND |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
198 || (!writing && regname == '~') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
199 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
200 ) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
201 return TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
202 return FALSE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
203 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
204 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
205 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
206 * Set y_current and y_append, according to the value of "regname". |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
207 * Cannot handle the '_' register. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
208 * Must only be called with a valid register name! |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
209 * |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
210 * If regname is 0 and writing, use register 0 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
211 * If regname is 0 and reading, use previous register |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
212 * |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
213 * Return TRUE when the register should be inserted literally (selection or |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
214 * clipboard). |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
215 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
216 int |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
217 get_yank_register(int regname, int writing) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
218 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
219 int i; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
220 int ret = FALSE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
221 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
222 y_append = FALSE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
223 if ((regname == 0 || regname == '"') && !writing && y_previous != NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
224 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
225 y_current = y_previous; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
226 return ret; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
227 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
228 i = regname; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
229 if (VIM_ISDIGIT(i)) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
230 i -= '0'; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
231 else if (ASCII_ISLOWER(i)) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
232 i = CharOrdLow(i) + 10; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
233 else if (ASCII_ISUPPER(i)) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
234 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
235 i = CharOrdUp(i) + 10; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
236 y_append = TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
237 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
238 else if (regname == '-') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
239 i = DELETION_REGISTER; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
240 #ifdef FEAT_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
241 // When selection is not available, use register 0 instead of '*' |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
242 else if (clip_star.available && regname == '*') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
243 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
244 i = STAR_REGISTER; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
245 ret = TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
246 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
247 // When clipboard is not available, use register 0 instead of '+' |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
248 else if (clip_plus.available && regname == '+') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
249 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
250 i = PLUS_REGISTER; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
251 ret = TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
252 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
253 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
254 #ifdef FEAT_DND |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
255 else if (!writing && regname == '~') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
256 i = TILDE_REGISTER; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
257 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
258 else // not 0-9, a-z, A-Z or '-': use register 0 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
259 i = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
260 y_current = &(y_regs[i]); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
261 if (writing) // remember the register we write into for do_put() |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
262 y_previous = y_current; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
263 return ret; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
264 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
265 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
266 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
267 * Obtain the contents of a "normal" register. The register is made empty. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
268 * The returned pointer has allocated memory, use put_register() later. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
269 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
270 void * |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
271 get_register( |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
272 int name, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
273 int copy) // make a copy, if FALSE make register empty. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
274 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
275 yankreg_T *reg; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
276 int i; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
277 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
278 #ifdef FEAT_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
279 // When Visual area changed, may have to update selection. Obtain the |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
280 // selection too. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
281 if (name == '*' && clip_star.available) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
282 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
283 if (clip_isautosel_star()) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
284 clip_update_selection(&clip_star); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
285 may_get_selection(name); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
286 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
287 if (name == '+' && clip_plus.available) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
288 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
289 if (clip_isautosel_plus()) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
290 clip_update_selection(&clip_plus); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
291 may_get_selection(name); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
292 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
293 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
294 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
295 get_yank_register(name, 0); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
296 reg = ALLOC_ONE(yankreg_T); |
31778
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
297 if (reg == NULL) |
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
298 return (void *)NULL; |
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
299 |
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
300 *reg = *y_current; |
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
301 if (copy) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
302 { |
31778
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
303 // If we run out of memory some or all of the lines are empty. |
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
304 if (reg->y_size == 0) |
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
305 reg->y_array = NULL; |
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
306 else |
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
307 reg->y_array = ALLOC_MULT(char_u *, reg->y_size); |
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
308 if (reg->y_array != NULL) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
309 { |
31778
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
310 for (i = 0; i < reg->y_size; ++i) |
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
311 reg->y_array[i] = vim_strsave(y_current->y_array[i]); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
312 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
313 } |
31778
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
314 else |
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
315 y_current->y_array = NULL; |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
316 return (void *)reg; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
317 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
318 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
319 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
320 * Put "reg" into register "name". Free any previous contents and "reg". |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
321 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
322 void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
323 put_register(int name, void *reg) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
324 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
325 get_yank_register(name, 0); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
326 free_yank_all(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
327 *y_current = *(yankreg_T *)reg; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
328 vim_free(reg); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
329 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
330 #ifdef FEAT_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
331 // Send text written to clipboard register to the clipboard. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
332 may_set_selection(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
333 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
334 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
335 |
23021
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22732
diff
changeset
|
336 #if defined(FEAT_CLIPBOARD) || defined(PROTO) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
337 void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
338 free_register(void *reg) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
339 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
340 yankreg_T tmp; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
341 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
342 tmp = *y_current; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
343 *y_current = *(yankreg_T *)reg; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
344 free_yank_all(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
345 vim_free(reg); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
346 *y_current = tmp; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
347 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
348 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
349 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
350 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
351 * return TRUE if the current yank register has type MLINE |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
352 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
353 int |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
354 yank_register_mline(int regname) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
355 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
356 if (regname != 0 && !valid_yank_reg(regname, FALSE)) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
357 return FALSE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
358 if (regname == '_') // black hole is always empty |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
359 return FALSE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
360 get_yank_register(regname, FALSE); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
361 return (y_current->y_type == MLINE); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
362 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
363 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
364 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
365 * Start or stop recording into a yank register. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
366 * |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
367 * Return FAIL for failure, OK otherwise. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
368 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
369 int |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
370 do_record(int c) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
371 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
372 char_u *p; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
373 static int regname; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
374 yankreg_T *old_y_previous, *old_y_current; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
375 int retval; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
376 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
377 if (reg_recording == 0) // start recording |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
378 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
379 // registers 0-9, a-z and " are allowed |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
380 if (c < 0 || (!ASCII_ISALNUM(c) && c != '"')) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
381 retval = FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
382 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
383 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
384 reg_recording = c; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
385 showmode(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
386 regname = c; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
387 retval = OK; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
388 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
389 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
390 else // stop recording |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
391 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
392 // Get the recorded key hits. K_SPECIAL and CSI will be escaped, this |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
393 // needs to be removed again to put it in a register. exec_reg then |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
394 // adds the escaping back later. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
395 reg_recording = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
396 msg(""); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
397 p = get_recorded(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
398 if (p == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
399 retval = FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
400 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
401 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
402 // Remove escaping for CSI and K_SPECIAL in multi-byte chars. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
403 vim_unescape_csi(p); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
404 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
405 // We don't want to change the default register here, so save and |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
406 // restore the current register name. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
407 old_y_previous = y_previous; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
408 old_y_current = y_current; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
409 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
410 retval = stuff_yank(regname, p); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
411 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
412 y_previous = old_y_previous; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
413 y_current = old_y_current; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
414 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
415 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
416 return retval; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
417 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
418 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
419 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
420 * Stuff string "p" into yank register "regname" as a single line (append if |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
421 * uppercase). "p" must have been alloced. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
422 * |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
423 * return FAIL for failure, OK otherwise |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
424 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
425 static int |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
426 stuff_yank(int regname, char_u *p) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
427 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
428 char_u *lp; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
429 char_u **pp; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
430 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
431 // check for read-only register |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
432 if (regname != 0 && !valid_yank_reg(regname, TRUE)) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
433 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
434 vim_free(p); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
435 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
436 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
437 if (regname == '_') // black hole: don't do anything |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
438 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
439 vim_free(p); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
440 return OK; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
441 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
442 get_yank_register(regname, TRUE); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
443 if (y_append && y_current->y_array != NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
444 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
445 pp = &(y_current->y_array[y_current->y_size - 1]); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
446 lp = alloc(STRLEN(*pp) + STRLEN(p) + 1); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
447 if (lp == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
448 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
449 vim_free(p); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
450 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
451 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
452 STRCPY(lp, *pp); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
453 STRCAT(lp, p); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
454 vim_free(p); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
455 vim_free(*pp); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
456 *pp = lp; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
457 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
458 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
459 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
460 free_yank_all(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
461 if ((y_current->y_array = ALLOC_ONE(char_u *)) == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
462 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
463 vim_free(p); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
464 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
465 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
466 y_current->y_array[0] = p; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
467 y_current->y_size = 1; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
468 y_current->y_type = MCHAR; // used to be MLINE, why? |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
469 #ifdef FEAT_VIMINFO |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
470 y_current->y_time_set = vim_time(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
471 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
472 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
473 return OK; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
474 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
475 |
24946
dc3d45d9a4a8
patch 8.2.3010: not enough testing for viminfo code
Bram Moolenaar <Bram@vim.org>
parents:
24866
diff
changeset
|
476 /* |
dc3d45d9a4a8
patch 8.2.3010: not enough testing for viminfo code
Bram Moolenaar <Bram@vim.org>
parents:
24866
diff
changeset
|
477 * Last executed register (@ command) |
dc3d45d9a4a8
patch 8.2.3010: not enough testing for viminfo code
Bram Moolenaar <Bram@vim.org>
parents:
24866
diff
changeset
|
478 */ |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
479 static int execreg_lastc = NUL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
480 |
27018
268f6a3511df
patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
481 #if defined(FEAT_VIMINFO) || defined(PROTO) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
482 int |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
483 get_execreg_lastc(void) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
484 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
485 return execreg_lastc; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
486 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
487 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
488 void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
489 set_execreg_lastc(int lastc) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
490 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
491 execreg_lastc = lastc; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
492 } |
27018
268f6a3511df
patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
493 #endif |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
494 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
495 /* |
20891
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
496 * When executing a register as a series of ex-commands, if the |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
497 * line-continuation character is used for a line, then join it with one or |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
498 * more previous lines. Note that lines are processed backwards starting from |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
499 * the last line in the register. |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
500 * |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
501 * Arguments: |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
502 * lines - list of lines in the register |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
503 * idx - index of the line starting with \ or "\. Join this line with all the |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
504 * immediate predecessor lines that start with a \ and the first line |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
505 * that doesn't start with a \. Lines that start with a comment "\ |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
506 * character are ignored. |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
507 * |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
508 * Returns the concatenated line. The index of the line that should be |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
509 * processed next is returned in idx. |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
510 */ |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
511 static char_u * |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
512 execreg_line_continuation(char_u **lines, long *idx) |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
513 { |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
514 garray_T ga; |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
515 long i = *idx; |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
516 char_u *p; |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
517 int cmd_start; |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
518 int cmd_end = i; |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
519 int j; |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
520 char_u *str; |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
521 |
27028
c9474ae175f4
patch 8.2.4043: using int for second argument of ga_init2()
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
522 ga_init2(&ga, sizeof(char_u), 400); |
20891
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
523 |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
524 // search backwards to find the first line of this command. |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
525 // Any line not starting with \ or "\ is the start of the |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
526 // command. |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
527 while (--i > 0) |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
528 { |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
529 p = skipwhite(lines[i]); |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
530 if (*p != '\\' && (p[0] != '"' || p[1] != '\\' || p[2] != ' ')) |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
531 break; |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
532 } |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
533 cmd_start = i; |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
534 |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
535 // join all the lines |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
536 ga_concat(&ga, lines[cmd_start]); |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
537 for (j = cmd_start + 1; j <= cmd_end; j++) |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
538 { |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
539 p = skipwhite(lines[j]); |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
540 if (*p == '\\') |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
541 { |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
542 // Adjust the growsize to the current length to |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
543 // speed up concatenating many lines. |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
544 if (ga.ga_len > 400) |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
545 { |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
546 if (ga.ga_len > 8000) |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
547 ga.ga_growsize = 8000; |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
548 else |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
549 ga.ga_growsize = ga.ga_len; |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
550 } |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
551 ga_concat(&ga, p + 1); |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
552 } |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
553 } |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
554 ga_append(&ga, NUL); |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
555 str = vim_strsave(ga.ga_data); |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
556 ga_clear(&ga); |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
557 |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
558 *idx = i; |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
559 return str; |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
560 } |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
561 |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
562 /* |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
563 * Execute a yank register: copy it into the stuff buffer. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
564 * |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
565 * Return FAIL for failure, OK otherwise. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
566 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
567 int |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
568 do_execreg( |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
569 int regname, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
570 int colon, // insert ':' before each line |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
571 int addcr, // always add '\n' to end of line |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
572 int silent) // set "silent" flag in typeahead buffer |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
573 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
574 long i; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
575 char_u *p; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
576 int retval = OK; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
577 int remap; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
578 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
579 // repeat previous one |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
580 if (regname == '@') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
581 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
582 if (execreg_lastc == NUL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
583 { |
26958
d92e0d85923f
patch 8.2.4008: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26913
diff
changeset
|
584 emsg(_(e_no_previously_used_register)); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
585 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
586 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
587 regname = execreg_lastc; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
588 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
589 // check for valid regname |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
590 if (regname == '%' || regname == '#' || !valid_yank_reg(regname, FALSE)) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
591 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
592 emsg_invreg(regname); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
593 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
594 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
595 execreg_lastc = regname; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
596 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
597 #ifdef FEAT_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
598 regname = may_get_selection(regname); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
599 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
600 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
601 // black hole: don't stuff anything |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
602 if (regname == '_') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
603 return OK; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
604 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
605 // use last command line |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
606 if (regname == ':') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
607 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
608 if (last_cmdline == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
609 { |
25306
078edc1821bf
patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25070
diff
changeset
|
610 emsg(_(e_no_previous_command_line)); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
611 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
612 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
613 // don't keep the cmdline containing @: |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
614 VIM_CLEAR(new_last_cmdline); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
615 // Escape all control characters with a CTRL-V |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
616 p = vim_strsave_escaped_ext(last_cmdline, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
617 (char_u *)"\001\002\003\004\005\006\007" |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
618 "\010\011\012\013\014\015\016\017" |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
619 "\020\021\022\023\024\025\026\027" |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
620 "\030\031\032\033\034\035\036\037", |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
621 Ctrl_V, FALSE); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
622 if (p != NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
623 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
624 // When in Visual mode "'<,'>" will be prepended to the command. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
625 // Remove it when it's already there. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
626 if (VIsual_active && STRNCMP(p, "'<,'>", 5) == 0) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
627 retval = put_in_typebuf(p + 5, TRUE, TRUE, silent); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
628 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
629 retval = put_in_typebuf(p, TRUE, TRUE, silent); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
630 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
631 vim_free(p); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
632 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
633 #ifdef FEAT_EVAL |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
634 else if (regname == '=') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
635 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
636 p = get_expr_line(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
637 if (p == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
638 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
639 retval = put_in_typebuf(p, TRUE, colon, silent); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
640 vim_free(p); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
641 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
642 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
643 else if (regname == '.') // use last inserted text |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
644 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
645 p = get_last_insert_save(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
646 if (p == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
647 { |
25306
078edc1821bf
patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25070
diff
changeset
|
648 emsg(_(e_no_inserted_text_yet)); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
649 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
650 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
651 retval = put_in_typebuf(p, FALSE, colon, silent); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
652 vim_free(p); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
653 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
654 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
655 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
656 get_yank_register(regname, FALSE); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
657 if (y_current->y_array == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
658 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
659 |
19195
2ef19eed524a
patch 8.2.0156: various typos in source files and tests
Bram Moolenaar <Bram@vim.org>
parents:
18838
diff
changeset
|
660 // Disallow remapping for ":@r". |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
661 remap = colon ? REMAP_NONE : REMAP_YES; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
662 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
663 // Insert lines into typeahead buffer, from last one to first one. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
664 put_reedit_in_typebuf(silent); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
665 for (i = y_current->y_size; --i >= 0; ) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
666 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
667 char_u *escaped; |
20891
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
668 char_u *str; |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
669 int free_str = FALSE; |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
670 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
671 // insert NL between lines and after last line if type is MLINE |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
672 if (y_current->y_type == MLINE || i < y_current->y_size - 1 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
673 || addcr) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
674 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
675 if (ins_typebuf((char_u *)"\n", remap, 0, TRUE, silent) == FAIL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
676 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
677 } |
20891
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
678 |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
679 // Handle line-continuation for :@<register> |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
680 str = y_current->y_array[i]; |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
681 if (colon && i > 0) |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
682 { |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
683 p = skipwhite(str); |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
684 if (*p == '\\' || (p[0] == '"' && p[1] == '\\' && p[2] == ' ')) |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
685 { |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
686 str = execreg_line_continuation(y_current->y_array, &i); |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
687 if (str == NULL) |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
688 return FAIL; |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
689 free_str = TRUE; |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
690 } |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
691 } |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
692 escaped = vim_strsave_escape_csi(str); |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
693 if (free_str) |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
694 vim_free(str); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
695 if (escaped == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
696 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
697 retval = ins_typebuf(escaped, remap, 0, TRUE, silent); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
698 vim_free(escaped); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
699 if (retval == FAIL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
700 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
701 if (colon && ins_typebuf((char_u *)":", remap, 0, TRUE, silent) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
702 == FAIL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
703 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
704 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
705 reg_executing = regname == 0 ? '"' : regname; // disable "q" command |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
706 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
707 return retval; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
708 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
709 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
710 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
711 * If "restart_edit" is not zero, put it in the typeahead buffer, so that it's |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
712 * used only after other typeahead has been processed. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
713 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
714 static void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
715 put_reedit_in_typebuf(int silent) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
716 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
717 char_u buf[3]; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
718 |
31778
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
719 if (restart_edit == NUL) |
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
720 return; |
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
721 |
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
722 if (restart_edit == 'V') |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
723 { |
31778
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
724 buf[0] = 'g'; |
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
725 buf[1] = 'R'; |
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
726 buf[2] = NUL; |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
727 } |
31778
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
728 else |
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
729 { |
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
730 buf[0] = restart_edit == 'I' ? 'i' : restart_edit; |
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
731 buf[1] = NUL; |
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
732 } |
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
733 if (ins_typebuf(buf, REMAP_NONE, 0, TRUE, silent) == OK) |
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
734 restart_edit = NUL; |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
735 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
736 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
737 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
738 * Insert register contents "s" into the typeahead buffer, so that it will be |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
739 * executed again. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
740 * When "esc" is TRUE it is to be taken literally: Escape CSI characters and |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
741 * no remapping. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
742 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
743 static int |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
744 put_in_typebuf( |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
745 char_u *s, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
746 int esc, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
747 int colon, // add ':' before the line |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
748 int silent) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
749 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
750 int retval = OK; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
751 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
752 put_reedit_in_typebuf(silent); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
753 if (colon) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
754 retval = ins_typebuf((char_u *)"\n", REMAP_NONE, 0, TRUE, silent); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
755 if (retval == OK) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
756 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
757 char_u *p; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
758 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
759 if (esc) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
760 p = vim_strsave_escape_csi(s); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
761 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
762 p = s; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
763 if (p == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
764 retval = FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
765 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
766 retval = ins_typebuf(p, esc ? REMAP_NONE : REMAP_YES, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
767 0, TRUE, silent); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
768 if (esc) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
769 vim_free(p); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
770 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
771 if (colon && retval == OK) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
772 retval = ins_typebuf((char_u *)":", REMAP_NONE, 0, TRUE, silent); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
773 return retval; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
774 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
775 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
776 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
777 * Insert a yank register: copy it into the Read buffer. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
778 * Used by CTRL-R command and middle mouse button in insert mode. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
779 * |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
780 * return FAIL for failure, OK otherwise |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
781 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
782 int |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
783 insert_reg( |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
784 int regname, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
785 int literally_arg) // insert literally, not as if typed |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
786 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
787 long i; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
788 int retval = OK; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
789 char_u *arg; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
790 int allocated; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
791 int literally = literally_arg; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
792 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
793 // It is possible to get into an endless loop by having CTRL-R a in |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
794 // register a and then, in insert mode, doing CTRL-R a. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
795 // If you hit CTRL-C, the loop will be broken here. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
796 ui_breakcheck(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
797 if (got_int) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
798 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
799 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
800 // check for valid regname |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
801 if (regname != NUL && !valid_yank_reg(regname, FALSE)) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
802 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
803 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
804 #ifdef FEAT_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
805 regname = may_get_selection(regname); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
806 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
807 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
808 if (regname == '.') // insert last inserted text |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
809 retval = stuff_inserted(NUL, 1L, TRUE); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
810 else if (get_spec_reg(regname, &arg, &allocated, TRUE)) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
811 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
812 if (arg == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
813 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
814 stuffescaped(arg, literally); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
815 if (allocated) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
816 vim_free(arg); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
817 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
818 else // name or number register |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
819 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
820 if (get_yank_register(regname, FALSE)) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
821 literally = TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
822 if (y_current->y_array == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
823 retval = FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
824 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
825 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
826 for (i = 0; i < y_current->y_size; ++i) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
827 { |
23287
f2a70fca3485
patch 8.2.2189: cannot repeat a command that uses the small delete register
Bram Moolenaar <Bram@vim.org>
parents:
23021
diff
changeset
|
828 if (regname == '-') |
f2a70fca3485
patch 8.2.2189: cannot repeat a command that uses the small delete register
Bram Moolenaar <Bram@vim.org>
parents:
23021
diff
changeset
|
829 { |
f2a70fca3485
patch 8.2.2189: cannot repeat a command that uses the small delete register
Bram Moolenaar <Bram@vim.org>
parents:
23021
diff
changeset
|
830 AppendCharToRedobuff(Ctrl_R); |
f2a70fca3485
patch 8.2.2189: cannot repeat a command that uses the small delete register
Bram Moolenaar <Bram@vim.org>
parents:
23021
diff
changeset
|
831 AppendCharToRedobuff(regname); |
f2a70fca3485
patch 8.2.2189: cannot repeat a command that uses the small delete register
Bram Moolenaar <Bram@vim.org>
parents:
23021
diff
changeset
|
832 do_put(regname, NULL, BACKWARD, 1L, PUT_CURSEND); |
f2a70fca3485
patch 8.2.2189: cannot repeat a command that uses the small delete register
Bram Moolenaar <Bram@vim.org>
parents:
23021
diff
changeset
|
833 } |
f2a70fca3485
patch 8.2.2189: cannot repeat a command that uses the small delete register
Bram Moolenaar <Bram@vim.org>
parents:
23021
diff
changeset
|
834 else |
f2a70fca3485
patch 8.2.2189: cannot repeat a command that uses the small delete register
Bram Moolenaar <Bram@vim.org>
parents:
23021
diff
changeset
|
835 stuffescaped(y_current->y_array[i], literally); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
836 // Insert a newline between lines and after last line if |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
837 // y_type is MLINE. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
838 if (y_current->y_type == MLINE || i < y_current->y_size - 1) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
839 stuffcharReadbuff('\n'); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
840 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
841 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
842 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
843 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
844 return retval; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
845 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
846 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
847 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
848 * If "regname" is a special register, return TRUE and store a pointer to its |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
849 * value in "argp". |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
850 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
851 int |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
852 get_spec_reg( |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
853 int regname, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
854 char_u **argp, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
855 int *allocated, // return: TRUE when value was allocated |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
856 int errmsg) // give error message when failing |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
857 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
858 int cnt; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
859 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
860 *argp = NULL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
861 *allocated = FALSE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
862 switch (regname) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
863 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
864 case '%': // file name |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
865 if (errmsg) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
866 check_fname(); // will give emsg if not set |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
867 *argp = curbuf->b_fname; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
868 return TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
869 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
870 case '#': // alternate file name |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
871 *argp = getaltfname(errmsg); // may give emsg if not set |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
872 return TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
873 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
874 #ifdef FEAT_EVAL |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
875 case '=': // result of expression |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
876 *argp = get_expr_line(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
877 *allocated = TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
878 return TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
879 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
880 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
881 case ':': // last command line |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
882 if (last_cmdline == NULL && errmsg) |
25306
078edc1821bf
patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25070
diff
changeset
|
883 emsg(_(e_no_previous_command_line)); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
884 *argp = last_cmdline; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
885 return TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
886 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
887 case '/': // last search-pattern |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
888 if (last_search_pat() == NULL && errmsg) |
25306
078edc1821bf
patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25070
diff
changeset
|
889 emsg(_(e_no_previous_regular_expression)); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
890 *argp = last_search_pat(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
891 return TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
892 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
893 case '.': // last inserted text |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
894 *argp = get_last_insert_save(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
895 *allocated = TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
896 if (*argp == NULL && errmsg) |
25306
078edc1821bf
patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25070
diff
changeset
|
897 emsg(_(e_no_inserted_text_yet)); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
898 return TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
899 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
900 case Ctrl_F: // Filename under cursor |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
901 case Ctrl_P: // Path under cursor, expand via "path" |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
902 if (!errmsg) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
903 return FALSE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
904 *argp = file_name_at_cursor(FNAME_MESS | FNAME_HYP |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
905 | (regname == Ctrl_P ? FNAME_EXP : 0), 1L, NULL); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
906 *allocated = TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
907 return TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
908 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
909 case Ctrl_W: // word under cursor |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
910 case Ctrl_A: // WORD (mnemonic All) under cursor |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
911 if (!errmsg) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
912 return FALSE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
913 cnt = find_ident_under_cursor(argp, regname == Ctrl_W |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
914 ? (FIND_IDENT|FIND_STRING) : FIND_STRING); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
915 *argp = cnt ? vim_strnsave(*argp, cnt) : NULL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
916 *allocated = TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
917 return TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
918 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
919 case Ctrl_L: // Line under cursor |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
920 if (!errmsg) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
921 return FALSE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
922 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
923 *argp = ml_get_buf(curwin->w_buffer, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
924 curwin->w_cursor.lnum, FALSE); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
925 return TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
926 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
927 case '_': // black hole: always empty |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
928 *argp = (char_u *)""; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
929 return TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
930 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
931 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
932 return FALSE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
933 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
934 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
935 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
936 * Paste a yank register into the command line. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
937 * Only for non-special registers. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
938 * Used by CTRL-R command in command-line mode |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
939 * insert_reg() can't be used here, because special characters from the |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
940 * register contents will be interpreted as commands. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
941 * |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
942 * return FAIL for failure, OK otherwise |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
943 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
944 int |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
945 cmdline_paste_reg( |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
946 int regname, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
947 int literally_arg, // Insert text literally instead of "as typed" |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
948 int remcr) // don't add CR characters |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
949 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
950 long i; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
951 int literally = literally_arg; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
952 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
953 if (get_yank_register(regname, FALSE)) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
954 literally = TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
955 if (y_current->y_array == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
956 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
957 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
958 for (i = 0; i < y_current->y_size; ++i) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
959 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
960 cmdline_paste_str(y_current->y_array[i], literally); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
961 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
962 // Insert ^M between lines and after last line if type is MLINE. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
963 // Don't do this when "remcr" is TRUE. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
964 if ((y_current->y_type == MLINE || i < y_current->y_size - 1) && !remcr) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
965 cmdline_paste_str((char_u *)"\r", literally); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
966 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
967 // Check for CTRL-C, in case someone tries to paste a few thousand |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
968 // lines and gets bored. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
969 ui_breakcheck(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
970 if (got_int) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
971 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
972 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
973 return OK; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
974 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
975 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
976 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
977 * Shift the delete registers: "9 is cleared, "8 becomes "9, etc. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
978 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
979 void |
32009
4545f58c8490
patch 9.0.1336: functions without arguments are not always declared properly
Bram Moolenaar <Bram@vim.org>
parents:
31778
diff
changeset
|
980 shift_delete_registers(void) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
981 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
982 int n; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
983 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
984 y_current = &y_regs[9]; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
985 free_yank_all(); // free register nine |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
986 for (n = 9; n > 1; --n) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
987 y_regs[n] = y_regs[n - 1]; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
988 y_current = &y_regs[1]; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
989 if (!y_append) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
990 y_previous = y_current; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
991 y_regs[1].y_array = NULL; // set register one to empty |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
992 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
993 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
994 #if defined(FEAT_EVAL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
995 void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
996 yank_do_autocmd(oparg_T *oap, yankreg_T *reg) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
997 { |
26155
f2392648af3e
patch 8.2.3609: internal error when ModeChanged is triggered recursively
Bram Moolenaar <Bram@vim.org>
parents:
26137
diff
changeset
|
998 static int recursive = FALSE; |
f2392648af3e
patch 8.2.3609: internal error when ModeChanged is triggered recursively
Bram Moolenaar <Bram@vim.org>
parents:
26137
diff
changeset
|
999 dict_T *v_event; |
f2392648af3e
patch 8.2.3609: internal error when ModeChanged is triggered recursively
Bram Moolenaar <Bram@vim.org>
parents:
26137
diff
changeset
|
1000 list_T *list; |
f2392648af3e
patch 8.2.3609: internal error when ModeChanged is triggered recursively
Bram Moolenaar <Bram@vim.org>
parents:
26137
diff
changeset
|
1001 int n; |
f2392648af3e
patch 8.2.3609: internal error when ModeChanged is triggered recursively
Bram Moolenaar <Bram@vim.org>
parents:
26137
diff
changeset
|
1002 char_u buf[NUMBUFLEN + 2]; |
f2392648af3e
patch 8.2.3609: internal error when ModeChanged is triggered recursively
Bram Moolenaar <Bram@vim.org>
parents:
26137
diff
changeset
|
1003 long reglen = 0; |
f2392648af3e
patch 8.2.3609: internal error when ModeChanged is triggered recursively
Bram Moolenaar <Bram@vim.org>
parents:
26137
diff
changeset
|
1004 save_v_event_T save_v_event; |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1005 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1006 if (recursive) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1007 return; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1008 |
26155
f2392648af3e
patch 8.2.3609: internal error when ModeChanged is triggered recursively
Bram Moolenaar <Bram@vim.org>
parents:
26137
diff
changeset
|
1009 v_event = get_v_event(&save_v_event); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1010 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1011 list = list_alloc(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1012 if (list == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1013 return; |
28384
21e96d9b66c0
patch 8.2.4717: for TextYankPost v:event does not contain all information
Bram Moolenaar <Bram@vim.org>
parents:
28247
diff
changeset
|
1014 |
21e96d9b66c0
patch 8.2.4717: for TextYankPost v:event does not contain all information
Bram Moolenaar <Bram@vim.org>
parents:
28247
diff
changeset
|
1015 // yanked text contents |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1016 for (n = 0; n < reg->y_size; n++) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1017 list_append_string(list, reg->y_array[n], -1); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1018 list->lv_lock = VAR_FIXED; |
21068
ac493e63b192
patch 8.2.1085: Coverity complains about ignoring dict_add() return value
Bram Moolenaar <Bram@vim.org>
parents:
20996
diff
changeset
|
1019 (void)dict_add_list(v_event, "regcontents", list); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1020 |
28384
21e96d9b66c0
patch 8.2.4717: for TextYankPost v:event does not contain all information
Bram Moolenaar <Bram@vim.org>
parents:
28247
diff
changeset
|
1021 // register name or empty string for unnamed operation |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1022 buf[0] = (char_u)oap->regname; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1023 buf[1] = NUL; |
21068
ac493e63b192
patch 8.2.1085: Coverity complains about ignoring dict_add() return value
Bram Moolenaar <Bram@vim.org>
parents:
20996
diff
changeset
|
1024 (void)dict_add_string(v_event, "regname", buf); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1025 |
28384
21e96d9b66c0
patch 8.2.4717: for TextYankPost v:event does not contain all information
Bram Moolenaar <Bram@vim.org>
parents:
28247
diff
changeset
|
1026 // motion type: inclusive or exclusive |
21e96d9b66c0
patch 8.2.4717: for TextYankPost v:event does not contain all information
Bram Moolenaar <Bram@vim.org>
parents:
28247
diff
changeset
|
1027 (void)dict_add_bool(v_event, "inclusive", oap->inclusive); |
21e96d9b66c0
patch 8.2.4717: for TextYankPost v:event does not contain all information
Bram Moolenaar <Bram@vim.org>
parents:
28247
diff
changeset
|
1028 |
21e96d9b66c0
patch 8.2.4717: for TextYankPost v:event does not contain all information
Bram Moolenaar <Bram@vim.org>
parents:
28247
diff
changeset
|
1029 // kind of operation (yank, delete, change) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1030 buf[0] = get_op_char(oap->op_type); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1031 buf[1] = get_extra_op_char(oap->op_type); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1032 buf[2] = NUL; |
21068
ac493e63b192
patch 8.2.1085: Coverity complains about ignoring dict_add() return value
Bram Moolenaar <Bram@vim.org>
parents:
20996
diff
changeset
|
1033 (void)dict_add_string(v_event, "operator", buf); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1034 |
28384
21e96d9b66c0
patch 8.2.4717: for TextYankPost v:event does not contain all information
Bram Moolenaar <Bram@vim.org>
parents:
28247
diff
changeset
|
1035 // register type |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1036 buf[0] = NUL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1037 buf[1] = NUL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1038 switch (get_reg_type(oap->regname, ®len)) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1039 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1040 case MLINE: buf[0] = 'V'; break; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1041 case MCHAR: buf[0] = 'v'; break; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1042 case MBLOCK: |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1043 vim_snprintf((char *)buf, sizeof(buf), "%c%ld", Ctrl_V, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1044 reglen + 1); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1045 break; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1046 } |
21068
ac493e63b192
patch 8.2.1085: Coverity complains about ignoring dict_add() return value
Bram Moolenaar <Bram@vim.org>
parents:
20996
diff
changeset
|
1047 (void)dict_add_string(v_event, "regtype", buf); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1048 |
28384
21e96d9b66c0
patch 8.2.4717: for TextYankPost v:event does not contain all information
Bram Moolenaar <Bram@vim.org>
parents:
28247
diff
changeset
|
1049 // selection type - visual or not |
21068
ac493e63b192
patch 8.2.1085: Coverity complains about ignoring dict_add() return value
Bram Moolenaar <Bram@vim.org>
parents:
20996
diff
changeset
|
1050 (void)dict_add_bool(v_event, "visual", oap->is_VIsual); |
20824
b8ca32dcfabb
patch 8.2.0964: TextYankPost does not provide info about Visual selection
Bram Moolenaar <Bram@vim.org>
parents:
20743
diff
changeset
|
1051 |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1052 // Lock the dictionary and its keys |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1053 dict_set_items_ro(v_event); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1054 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1055 recursive = TRUE; |
29014
45c182c4f7e9
patch 8.2.5029: "textlock" is always zero
Bram Moolenaar <Bram@vim.org>
parents:
28988
diff
changeset
|
1056 textlock++; |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1057 apply_autocmds(EVENT_TEXTYANKPOST, NULL, NULL, FALSE, curbuf); |
29014
45c182c4f7e9
patch 8.2.5029: "textlock" is always zero
Bram Moolenaar <Bram@vim.org>
parents:
28988
diff
changeset
|
1058 textlock--; |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1059 recursive = FALSE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1060 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1061 // Empty the dictionary, v:event is still valid |
26155
f2392648af3e
patch 8.2.3609: internal error when ModeChanged is triggered recursively
Bram Moolenaar <Bram@vim.org>
parents:
26137
diff
changeset
|
1062 restore_v_event(v_event, &save_v_event); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1063 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1064 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1065 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1066 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1067 * set all the yank registers to empty (called from main()) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1068 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1069 void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1070 init_yank(void) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1071 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1072 int i; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1073 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1074 for (i = 0; i < NUM_REGISTERS; ++i) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1075 y_regs[i].y_array = NULL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1076 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1077 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1078 #if defined(EXITFREE) || defined(PROTO) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1079 void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1080 clear_registers(void) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1081 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1082 int i; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1083 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1084 for (i = 0; i < NUM_REGISTERS; ++i) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1085 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1086 y_current = &y_regs[i]; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1087 if (y_current->y_array != NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1088 free_yank_all(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1089 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1090 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1091 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1092 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1093 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1094 * Free "n" lines from the current yank register. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1095 * Called for normal freeing and in case of error. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1096 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1097 static void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1098 free_yank(long n) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1099 { |
31778
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
1100 if (y_current->y_array == NULL) |
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
1101 return; |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1102 |
31778
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
1103 long i; |
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
1104 |
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
1105 for (i = n; --i >= 0; ) |
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
1106 vim_free(y_current->y_array[i]); |
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
1107 VIM_CLEAR(y_current->y_array); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1108 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1109 |
19774
00a1b89256ea
patch 8.2.0443: clipboard code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
19524
diff
changeset
|
1110 void |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1111 free_yank_all(void) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1112 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1113 free_yank(y_current->y_size); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1114 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1115 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1116 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1117 * Yank the text between "oap->start" and "oap->end" into a yank register. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1118 * If we are to append (uppercase register), we first yank into a new yank |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1119 * register and then concatenate the old and the new one (so we keep the old |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1120 * one in case of out-of-memory). |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1121 * |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1122 * Return FAIL for failure, OK otherwise. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1123 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1124 int |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1125 op_yank(oparg_T *oap, int deleting, int mess) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1126 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1127 long y_idx; // index in y_array[] |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1128 yankreg_T *curr; // copy of y_current |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1129 yankreg_T newreg; // new yank register when appending |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1130 char_u **new_ptr; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1131 linenr_T lnum; // current line number |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1132 long j; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1133 int yanktype = oap->motion_type; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1134 long yanklines = oap->line_count; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1135 linenr_T yankendlnum = oap->end.lnum; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1136 char_u *p; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1137 char_u *pnew; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1138 struct block_def bd; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1139 #if defined(FEAT_CLIPBOARD) && defined(FEAT_X11) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1140 int did_star = FALSE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1141 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1142 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1143 // check for read-only register |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1144 if (oap->regname != 0 && !valid_yank_reg(oap->regname, TRUE)) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1145 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1146 beep_flush(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1147 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1148 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1149 if (oap->regname == '_') // black hole: nothing to do |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1150 return OK; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1151 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1152 #ifdef FEAT_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1153 if (!clip_star.available && oap->regname == '*') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1154 oap->regname = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1155 else if (!clip_plus.available && oap->regname == '+') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1156 oap->regname = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1157 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1158 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1159 if (!deleting) // op_delete() already set y_current |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1160 get_yank_register(oap->regname, TRUE); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1161 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1162 curr = y_current; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1163 // append to existing contents |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1164 if (y_append && y_current->y_array != NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1165 y_current = &newreg; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1166 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1167 free_yank_all(); // free previously yanked lines |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1168 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1169 // If the cursor was in column 1 before and after the movement, and the |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1170 // operator is not inclusive, the yank is always linewise. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1171 if ( oap->motion_type == MCHAR |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1172 && oap->start.col == 0 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1173 && !oap->inclusive |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1174 && (!oap->is_VIsual || *p_sel == 'o') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1175 && !oap->block_mode |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1176 && oap->end.col == 0 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1177 && yanklines > 1) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1178 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1179 yanktype = MLINE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1180 --yankendlnum; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1181 --yanklines; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1182 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1183 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1184 y_current->y_size = yanklines; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1185 y_current->y_type = yanktype; // set the yank register type |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1186 y_current->y_width = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1187 y_current->y_array = lalloc_clear(sizeof(char_u *) * yanklines, TRUE); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1188 if (y_current->y_array == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1189 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1190 y_current = curr; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1191 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1192 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1193 #ifdef FEAT_VIMINFO |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1194 y_current->y_time_set = vim_time(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1195 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1196 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1197 y_idx = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1198 lnum = oap->start.lnum; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1199 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1200 if (oap->block_mode) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1201 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1202 // Visual block mode |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1203 y_current->y_type = MBLOCK; // set the yank register type |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1204 y_current->y_width = oap->end_vcol - oap->start_vcol; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1205 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1206 if (curwin->w_curswant == MAXCOL && y_current->y_width > 0) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1207 y_current->y_width--; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1208 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1209 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1210 for ( ; lnum <= yankendlnum; lnum++, y_idx++) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1211 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1212 switch (y_current->y_type) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1213 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1214 case MBLOCK: |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1215 block_prep(oap, &bd, lnum, FALSE); |
24866
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24794
diff
changeset
|
1216 if (yank_copy_line(&bd, y_idx, oap->excl_tr_ws) == FAIL) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1217 goto fail; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1218 break; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1219 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1220 case MLINE: |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1221 if ((y_current->y_array[y_idx] = |
24866
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24794
diff
changeset
|
1222 vim_strsave(ml_get(lnum))) == NULL) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1223 goto fail; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1224 break; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1225 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1226 case MCHAR: |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1227 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1228 colnr_T startcol = 0, endcol = MAXCOL; |
24866
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24794
diff
changeset
|
1229 int is_oneChar = FALSE; |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1230 colnr_T cs, ce; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1231 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1232 p = ml_get(lnum); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1233 bd.startspaces = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1234 bd.endspaces = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1235 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1236 if (lnum == oap->start.lnum) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1237 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1238 startcol = oap->start.col; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1239 if (virtual_op) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1240 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1241 getvcol(curwin, &oap->start, &cs, NULL, &ce); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1242 if (ce != cs && oap->start.coladd > 0) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1243 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1244 // Part of a tab selected -- but don't |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1245 // double-count it. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1246 bd.startspaces = (ce - cs + 1) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1247 - oap->start.coladd; |
32094
7d94b1c0f292
patch 9.0.1378: illegal memory access when using virtual editing
Bram Moolenaar <Bram@vim.org>
parents:
32090
diff
changeset
|
1248 if (bd.startspaces < 0) |
7d94b1c0f292
patch 9.0.1378: illegal memory access when using virtual editing
Bram Moolenaar <Bram@vim.org>
parents:
32090
diff
changeset
|
1249 bd.startspaces = 0; |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1250 startcol++; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1251 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1252 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1253 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1254 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1255 if (lnum == oap->end.lnum) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1256 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1257 endcol = oap->end.col; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1258 if (virtual_op) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1259 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1260 getvcol(curwin, &oap->end, &cs, NULL, &ce); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1261 if (p[endcol] == NUL || (cs + oap->end.coladd < ce |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1262 // Don't add space for double-wide |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1263 // char; endcol will be on last byte |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1264 // of multi-byte char. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1265 && (*mb_head_off)(p, p + endcol) == 0)) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1266 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1267 if (oap->start.lnum == oap->end.lnum |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1268 && oap->start.col == oap->end.col) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1269 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1270 // Special case: inside a single char |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1271 is_oneChar = TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1272 bd.startspaces = oap->end.coladd |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1273 - oap->start.coladd + oap->inclusive; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1274 endcol = startcol; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1275 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1276 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1277 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1278 bd.endspaces = oap->end.coladd |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1279 + oap->inclusive; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1280 endcol -= oap->inclusive; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1281 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1282 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1283 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1284 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1285 if (endcol == MAXCOL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1286 endcol = (colnr_T)STRLEN(p); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1287 if (startcol > endcol || is_oneChar) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1288 bd.textlen = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1289 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1290 bd.textlen = endcol - startcol + oap->inclusive; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1291 bd.textstart = p + startcol; |
24866
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24794
diff
changeset
|
1292 if (yank_copy_line(&bd, y_idx, FALSE) == FAIL) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1293 goto fail; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1294 break; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1295 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1296 // NOTREACHED |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1297 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1298 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1299 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1300 if (curr != y_current) // append the new block to the old block |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1301 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1302 new_ptr = ALLOC_MULT(char_u *, curr->y_size + y_current->y_size); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1303 if (new_ptr == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1304 goto fail; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1305 for (j = 0; j < curr->y_size; ++j) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1306 new_ptr[j] = curr->y_array[j]; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1307 vim_free(curr->y_array); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1308 curr->y_array = new_ptr; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1309 #ifdef FEAT_VIMINFO |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1310 curr->y_time_set = vim_time(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1311 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1312 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1313 if (yanktype == MLINE) // MLINE overrides MCHAR and MBLOCK |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1314 curr->y_type = MLINE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1315 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1316 // Concatenate the last line of the old block with the first line of |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1317 // the new block, unless being Vi compatible. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1318 if (curr->y_type == MCHAR && vim_strchr(p_cpo, CPO_REGAPPEND) == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1319 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1320 pnew = alloc(STRLEN(curr->y_array[curr->y_size - 1]) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1321 + STRLEN(y_current->y_array[0]) + 1); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1322 if (pnew == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1323 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1324 y_idx = y_current->y_size - 1; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1325 goto fail; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1326 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1327 STRCPY(pnew, curr->y_array[--j]); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1328 STRCAT(pnew, y_current->y_array[0]); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1329 vim_free(curr->y_array[j]); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1330 vim_free(y_current->y_array[0]); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1331 curr->y_array[j++] = pnew; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1332 y_idx = 1; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1333 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1334 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1335 y_idx = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1336 while (y_idx < y_current->y_size) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1337 curr->y_array[j++] = y_current->y_array[y_idx++]; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1338 curr->y_size = j; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1339 vim_free(y_current->y_array); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1340 y_current = curr; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1341 } |
28137
f825792fddb1
patch 8.2.4593: unnecessary call to redraw_later()
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
1342 |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1343 if (mess) // Display message about yank? |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1344 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1345 if (yanktype == MCHAR |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1346 && !oap->block_mode |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1347 && yanklines == 1) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1348 yanklines = 0; |
18498
9e6d5a4abb1c
patch 8.1.2243: typos in comments
Bram Moolenaar <Bram@vim.org>
parents:
18454
diff
changeset
|
1349 // Some versions of Vi use ">=" here, some don't... |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1350 if (yanklines > p_report) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1351 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1352 char namebuf[100]; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1353 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1354 if (oap->regname == NUL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1355 *namebuf = NUL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1356 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1357 vim_snprintf(namebuf, sizeof(namebuf), |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1358 _(" into \"%c"), oap->regname); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1359 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1360 // redisplay now, so message is not deleted |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1361 update_topline_redraw(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1362 if (oap->block_mode) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1363 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1364 smsg(NGETTEXT("block of %ld line yanked%s", |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1365 "block of %ld lines yanked%s", yanklines), |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1366 yanklines, namebuf); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1367 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1368 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1369 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1370 smsg(NGETTEXT("%ld line yanked%s", |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1371 "%ld lines yanked%s", yanklines), |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1372 yanklines, namebuf); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1373 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1374 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1375 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1376 |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22176
diff
changeset
|
1377 if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1378 { |
18619
788d76db02ac
patch 8.1.2302: :lockmarks does not work for '[ and ']
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1379 // Set "'[" and "']" marks. |
788d76db02ac
patch 8.1.2302: :lockmarks does not work for '[ and ']
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1380 curbuf->b_op_start = oap->start; |
788d76db02ac
patch 8.1.2302: :lockmarks does not work for '[ and ']
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1381 curbuf->b_op_end = oap->end; |
788d76db02ac
patch 8.1.2302: :lockmarks does not work for '[ and ']
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1382 if (yanktype == MLINE && !oap->block_mode) |
788d76db02ac
patch 8.1.2302: :lockmarks does not work for '[ and ']
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1383 { |
788d76db02ac
patch 8.1.2302: :lockmarks does not work for '[ and ']
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1384 curbuf->b_op_start.col = 0; |
788d76db02ac
patch 8.1.2302: :lockmarks does not work for '[ and ']
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1385 curbuf->b_op_end.col = MAXCOL; |
788d76db02ac
patch 8.1.2302: :lockmarks does not work for '[ and ']
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1386 } |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1387 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1388 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1389 #ifdef FEAT_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1390 // If we were yanking to the '*' register, send result to clipboard. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1391 // If no register was specified, and "unnamed" in 'clipboard', make a copy |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1392 // to the '*' register. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1393 if (clip_star.available |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1394 && (curr == &(y_regs[STAR_REGISTER]) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1395 || (!deleting && oap->regname == 0 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1396 && ((clip_unnamed | clip_unnamed_saved) & CLIP_UNNAMED)))) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1397 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1398 if (curr != &(y_regs[STAR_REGISTER])) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1399 // Copy the text from register 0 to the clipboard register. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1400 copy_yank_reg(&(y_regs[STAR_REGISTER])); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1401 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1402 clip_own_selection(&clip_star); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1403 clip_gen_set_selection(&clip_star); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1404 # ifdef FEAT_X11 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1405 did_star = TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1406 # endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1407 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1408 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1409 # ifdef FEAT_X11 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1410 // If we were yanking to the '+' register, send result to selection. |
24041
580ee78577e9
patch 8.2.2562: GUI: star register changed when 'clipboard is "unnamedplus"
Bram Moolenaar <Bram@vim.org>
parents:
23287
diff
changeset
|
1411 // Also copy to the '*' register, in case auto-select is off. But not when |
29473
1c688281673d
patch 9.0.0078: star register is unexpectedly changed when deleting
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
1412 // 'clipboard' has "unnamedplus" and not "unnamed"; and not when |
1c688281673d
patch 9.0.0078: star register is unexpectedly changed when deleting
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
1413 // deleting and both "unnamedplus" and "unnamed". |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1414 if (clip_plus.available |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1415 && (curr == &(y_regs[PLUS_REGISTER]) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1416 || (!deleting && oap->regname == 0 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1417 && ((clip_unnamed | clip_unnamed_saved) & |
24041
580ee78577e9
patch 8.2.2562: GUI: star register changed when 'clipboard is "unnamedplus"
Bram Moolenaar <Bram@vim.org>
parents:
23287
diff
changeset
|
1418 CLIP_UNNAMED_PLUS)))) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1419 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1420 if (curr != &(y_regs[PLUS_REGISTER])) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1421 // Copy the text from register 0 to the clipboard register. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1422 copy_yank_reg(&(y_regs[PLUS_REGISTER])); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1423 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1424 clip_own_selection(&clip_plus); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1425 clip_gen_set_selection(&clip_plus); |
24041
580ee78577e9
patch 8.2.2562: GUI: star register changed when 'clipboard is "unnamedplus"
Bram Moolenaar <Bram@vim.org>
parents:
23287
diff
changeset
|
1426 if (!clip_isautosel_star() |
580ee78577e9
patch 8.2.2562: GUI: star register changed when 'clipboard is "unnamedplus"
Bram Moolenaar <Bram@vim.org>
parents:
23287
diff
changeset
|
1427 && !clip_isautosel_plus() |
580ee78577e9
patch 8.2.2562: GUI: star register changed when 'clipboard is "unnamedplus"
Bram Moolenaar <Bram@vim.org>
parents:
23287
diff
changeset
|
1428 && !((clip_unnamed | clip_unnamed_saved) == CLIP_UNNAMED_PLUS) |
29473
1c688281673d
patch 9.0.0078: star register is unexpectedly changed when deleting
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
1429 && !(deleting && (clip_unnamed | clip_unnamed_saved) |
1c688281673d
patch 9.0.0078: star register is unexpectedly changed when deleting
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
1430 == (CLIP_UNNAMED | CLIP_UNNAMED_PLUS)) |
24041
580ee78577e9
patch 8.2.2562: GUI: star register changed when 'clipboard is "unnamedplus"
Bram Moolenaar <Bram@vim.org>
parents:
23287
diff
changeset
|
1431 && !did_star |
580ee78577e9
patch 8.2.2562: GUI: star register changed when 'clipboard is "unnamedplus"
Bram Moolenaar <Bram@vim.org>
parents:
23287
diff
changeset
|
1432 && curr == &(y_regs[PLUS_REGISTER])) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1433 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1434 copy_yank_reg(&(y_regs[STAR_REGISTER])); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1435 clip_own_selection(&clip_star); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1436 clip_gen_set_selection(&clip_star); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1437 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1438 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1439 # endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1440 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1441 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1442 #if defined(FEAT_EVAL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1443 if (!deleting && has_textyankpost()) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1444 yank_do_autocmd(oap, y_current); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1445 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1446 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1447 return OK; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1448 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1449 fail: // free the allocated lines |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1450 free_yank(y_idx + 1); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1451 y_current = curr; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1452 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1453 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1454 |
24866
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24794
diff
changeset
|
1455 /* |
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24794
diff
changeset
|
1456 * Copy a block range into a register. |
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24794
diff
changeset
|
1457 * If "exclude_trailing_space" is set, do not copy trailing whitespaces. |
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24794
diff
changeset
|
1458 */ |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1459 static int |
24866
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24794
diff
changeset
|
1460 yank_copy_line(struct block_def *bd, long y_idx, int exclude_trailing_space) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1461 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1462 char_u *pnew; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1463 |
25070
f397a21b3e4c
patch 8.2.3072: "zy" does not work well when "virtualedit' is "block"
Bram Moolenaar <Bram@vim.org>
parents:
24946
diff
changeset
|
1464 if (exclude_trailing_space) |
f397a21b3e4c
patch 8.2.3072: "zy" does not work well when "virtualedit' is "block"
Bram Moolenaar <Bram@vim.org>
parents:
24946
diff
changeset
|
1465 bd->endspaces = 0; |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1466 if ((pnew = alloc(bd->startspaces + bd->endspaces + bd->textlen + 1)) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1467 == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1468 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1469 y_current->y_array[y_idx] = pnew; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1470 vim_memset(pnew, ' ', (size_t)bd->startspaces); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1471 pnew += bd->startspaces; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1472 mch_memmove(pnew, bd->textstart, (size_t)bd->textlen); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1473 pnew += bd->textlen; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1474 vim_memset(pnew, ' ', (size_t)bd->endspaces); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1475 pnew += bd->endspaces; |
24866
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24794
diff
changeset
|
1476 if (exclude_trailing_space) |
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24794
diff
changeset
|
1477 { |
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24794
diff
changeset
|
1478 int s = bd->textlen + bd->endspaces; |
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24794
diff
changeset
|
1479 |
27382
123b0747fa10
patch 8.2.4219: reading before the start of the line
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
1480 while (s > 0 && VIM_ISWHITE(*(bd->textstart + s - 1))) |
24866
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24794
diff
changeset
|
1481 { |
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24794
diff
changeset
|
1482 s = s - (*mb_head_off)(bd->textstart, bd->textstart + s - 1) - 1; |
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24794
diff
changeset
|
1483 pnew--; |
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24794
diff
changeset
|
1484 } |
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24794
diff
changeset
|
1485 } |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1486 *pnew = NUL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1487 return OK; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1488 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1489 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1490 #ifdef FEAT_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1491 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1492 * Make a copy of the y_current register to register "reg". |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1493 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1494 static void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1495 copy_yank_reg(yankreg_T *reg) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1496 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1497 yankreg_T *curr = y_current; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1498 long j; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1499 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1500 y_current = reg; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1501 free_yank_all(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1502 *y_current = *curr; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1503 y_current->y_array = lalloc_clear( |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1504 sizeof(char_u *) * y_current->y_size, TRUE); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1505 if (y_current->y_array == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1506 y_current->y_size = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1507 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1508 for (j = 0; j < y_current->y_size; ++j) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1509 if ((y_current->y_array[j] = vim_strsave(curr->y_array[j])) == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1510 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1511 free_yank(j); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1512 y_current->y_size = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1513 break; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1514 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1515 y_current = curr; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1516 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1517 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1518 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1519 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1520 * Put contents of register "regname" into the text. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1521 * Caller must check "regname" to be valid! |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1522 * "flags": PUT_FIXINDENT make indent look nice |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1523 * PUT_CURSEND leave cursor after end of new text |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1524 * PUT_LINE force linewise put (":put") |
24752
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24041
diff
changeset
|
1525 * PUT_BLOCK_INNER in block mode, do not add trailing spaces |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1526 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1527 void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1528 do_put( |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1529 int regname, |
22176
6941d3205be9
patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
21923
diff
changeset
|
1530 char_u *expr_result, // result for regname "=" when compiled |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1531 int dir, // BACKWARD for 'P', FORWARD for 'p' |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1532 long count, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1533 int flags) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1534 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1535 char_u *ptr; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1536 char_u *newp, *oldp; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1537 int yanklen; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1538 int totlen = 0; // init for gcc |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1539 linenr_T lnum; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1540 colnr_T col; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1541 long i; // index in y_array[] |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1542 int y_type; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1543 long y_size; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1544 int oldlen; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1545 long y_width = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1546 colnr_T vcol; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1547 int delcount; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1548 int incr = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1549 long j; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1550 struct block_def bd; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1551 char_u **y_array = NULL; |
26380
ac0e63cbf00b
patch 8.2.3721: using memory freed by losing the clipboard selection
Bram Moolenaar <Bram@vim.org>
parents:
26294
diff
changeset
|
1552 yankreg_T *y_current_used = NULL; |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1553 long nr_lines = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1554 pos_T new_cursor; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1555 int indent; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1556 int orig_indent = 0; // init for gcc |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1557 int indent_diff = 0; // init for gcc |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1558 int first_indent = TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1559 int lendiff = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1560 pos_T old_pos; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1561 char_u *insert_string = NULL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1562 int allocated = FALSE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1563 long cnt; |
18619
788d76db02ac
patch 8.1.2302: :lockmarks does not work for '[ and ']
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1564 pos_T orig_start = curbuf->b_op_start; |
788d76db02ac
patch 8.1.2302: :lockmarks does not work for '[ and ']
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1565 pos_T orig_end = curbuf->b_op_end; |
25380
ac88cd21ae88
patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
1566 unsigned int cur_ve_flags = get_ve_flags(); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1567 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1568 #ifdef FEAT_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1569 // Adjust register name for "unnamed" in 'clipboard'. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1570 adjust_clip_reg(®name); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1571 (void)may_get_selection(regname); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1572 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1573 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1574 if (flags & PUT_FIXINDENT) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1575 orig_indent = get_indent(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1576 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1577 curbuf->b_op_start = curwin->w_cursor; // default for '[ mark |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1578 curbuf->b_op_end = curwin->w_cursor; // default for '] mark |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1579 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1580 // Using inserted text works differently, because the register includes |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1581 // special characters (newlines, etc.). |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1582 if (regname == '.') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1583 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1584 if (VIsual_active) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1585 stuffcharReadbuff(VIsual_mode); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1586 (void)stuff_inserted((dir == FORWARD ? (count == -1 ? 'o' : 'a') : |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1587 (count == -1 ? 'O' : 'i')), count, FALSE); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1588 // Putting the text is done later, so can't really move the cursor to |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1589 // the next character. Use "l" to simulate it. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1590 if ((flags & PUT_CURSEND) && gchar_cursor() != NUL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1591 stuffcharReadbuff('l'); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1592 return; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1593 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1594 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1595 // For special registers '%' (file name), '#' (alternate file name) and |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1596 // ':' (last command line), etc. we have to create a fake yank register. |
22176
6941d3205be9
patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
21923
diff
changeset
|
1597 // For compiled code "expr_result" holds the expression result. |
6941d3205be9
patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
21923
diff
changeset
|
1598 if (regname == '=' && expr_result != NULL) |
6941d3205be9
patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
21923
diff
changeset
|
1599 insert_string = expr_result; |
6941d3205be9
patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
21923
diff
changeset
|
1600 else if (get_spec_reg(regname, &insert_string, &allocated, TRUE) |
6941d3205be9
patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
21923
diff
changeset
|
1601 && insert_string == NULL) |
6941d3205be9
patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
21923
diff
changeset
|
1602 return; |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1603 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1604 // Autocommands may be executed when saving lines for undo. This might |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1605 // make "y_array" invalid, so we start undo now to avoid that. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1606 if (u_save(curwin->w_cursor.lnum, curwin->w_cursor.lnum + 1) == FAIL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1607 goto end; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1608 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1609 if (insert_string != NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1610 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1611 y_type = MCHAR; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1612 #ifdef FEAT_EVAL |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1613 if (regname == '=') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1614 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1615 // For the = register we need to split the string at NL |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1616 // characters. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1617 // Loop twice: count the number of lines and save them. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1618 for (;;) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1619 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1620 y_size = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1621 ptr = insert_string; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1622 while (ptr != NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1623 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1624 if (y_array != NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1625 y_array[y_size] = ptr; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1626 ++y_size; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1627 ptr = vim_strchr(ptr, '\n'); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1628 if (ptr != NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1629 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1630 if (y_array != NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1631 *ptr = NUL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1632 ++ptr; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1633 // A trailing '\n' makes the register linewise. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1634 if (*ptr == NUL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1635 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1636 y_type = MLINE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1637 break; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1638 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1639 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1640 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1641 if (y_array != NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1642 break; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1643 y_array = ALLOC_MULT(char_u *, y_size); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1644 if (y_array == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1645 goto end; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1646 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1647 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1648 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1649 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1650 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1651 y_size = 1; // use fake one-line yank register |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1652 y_array = &insert_string; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1653 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1654 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1655 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1656 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1657 get_yank_register(regname, FALSE); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1658 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1659 y_type = y_current->y_type; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1660 y_width = y_current->y_width; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1661 y_size = y_current->y_size; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1662 y_array = y_current->y_array; |
26380
ac0e63cbf00b
patch 8.2.3721: using memory freed by losing the clipboard selection
Bram Moolenaar <Bram@vim.org>
parents:
26294
diff
changeset
|
1663 y_current_used = y_current; |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1664 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1665 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1666 if (y_type == MLINE) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1667 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1668 if (flags & PUT_LINE_SPLIT) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1669 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1670 char_u *p; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1671 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1672 // "p" or "P" in Visual mode: split the lines to put the text in |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1673 // between. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1674 if (u_save_cursor() == FAIL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1675 goto end; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1676 p = ml_get_cursor(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1677 if (dir == FORWARD && *p != NUL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1678 MB_PTR_ADV(p); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1679 ptr = vim_strsave(p); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1680 if (ptr == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1681 goto end; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1682 ml_append(curwin->w_cursor.lnum, ptr, (colnr_T)0, FALSE); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1683 vim_free(ptr); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1684 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1685 oldp = ml_get_curline(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1686 p = oldp + curwin->w_cursor.col; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1687 if (dir == FORWARD && *p != NUL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1688 MB_PTR_ADV(p); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1689 ptr = vim_strnsave(oldp, p - oldp); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1690 if (ptr == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1691 goto end; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1692 ml_replace(curwin->w_cursor.lnum, ptr, FALSE); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1693 ++nr_lines; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1694 dir = FORWARD; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1695 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1696 if (flags & PUT_LINE_FORWARD) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1697 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1698 // Must be "p" for a Visual block, put lines below the block. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1699 curwin->w_cursor = curbuf->b_visual.vi_end; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1700 dir = FORWARD; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1701 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1702 curbuf->b_op_start = curwin->w_cursor; // default for '[ mark |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1703 curbuf->b_op_end = curwin->w_cursor; // default for '] mark |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1704 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1705 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1706 if (flags & PUT_LINE) // :put command or "p" in Visual line mode. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1707 y_type = MLINE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1708 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1709 if (y_size == 0 || y_array == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1710 { |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26804
diff
changeset
|
1711 semsg(_(e_nothing_in_register_str), |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1712 regname == 0 ? (char_u *)"\"" : transchar(regname)); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1713 goto end; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1714 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1715 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1716 if (y_type == MBLOCK) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1717 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1718 lnum = curwin->w_cursor.lnum + y_size + 1; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1719 if (lnum > curbuf->b_ml.ml_line_count) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1720 lnum = curbuf->b_ml.ml_line_count + 1; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1721 if (u_save(curwin->w_cursor.lnum - 1, lnum) == FAIL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1722 goto end; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1723 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1724 else if (y_type == MLINE) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1725 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1726 lnum = curwin->w_cursor.lnum; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1727 #ifdef FEAT_FOLDING |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1728 // Correct line number for closed fold. Don't move the cursor yet, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1729 // u_save() uses it. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1730 if (dir == BACKWARD) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1731 (void)hasFolding(lnum, &lnum, NULL); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1732 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1733 (void)hasFolding(lnum, NULL, &lnum); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1734 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1735 if (dir == FORWARD) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1736 ++lnum; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1737 // In an empty buffer the empty line is going to be replaced, include |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1738 // it in the saved lines. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1739 if ((BUFEMPTY() ? u_save(0, 2) : u_save(lnum - 1, lnum)) == FAIL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1740 goto end; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1741 #ifdef FEAT_FOLDING |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1742 if (dir == FORWARD) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1743 curwin->w_cursor.lnum = lnum - 1; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1744 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1745 curwin->w_cursor.lnum = lnum; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1746 curbuf->b_op_start = curwin->w_cursor; // for mark_adjust() |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1747 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1748 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1749 else if (u_save_cursor() == FAIL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1750 goto end; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1751 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1752 yanklen = (int)STRLEN(y_array[0]); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1753 |
25380
ac88cd21ae88
patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
1754 if (cur_ve_flags == VE_ALL && y_type == MCHAR) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1755 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1756 if (gchar_cursor() == TAB) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1757 { |
18771
50fde4e20790
patch 8.1.2375: no suffucient testing for registers
Bram Moolenaar <Bram@vim.org>
parents:
18619
diff
changeset
|
1758 int viscol = getviscol(); |
50fde4e20790
patch 8.1.2375: no suffucient testing for registers
Bram Moolenaar <Bram@vim.org>
parents:
18619
diff
changeset
|
1759 int ts = curbuf->b_p_ts; |
50fde4e20790
patch 8.1.2375: no suffucient testing for registers
Bram Moolenaar <Bram@vim.org>
parents:
18619
diff
changeset
|
1760 |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1761 // Don't need to insert spaces when "p" on the last position of a |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1762 // tab or "P" on the first position. |
18771
50fde4e20790
patch 8.1.2375: no suffucient testing for registers
Bram Moolenaar <Bram@vim.org>
parents:
18619
diff
changeset
|
1763 if (dir == FORWARD ? |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1764 #ifdef FEAT_VARTABS |
18771
50fde4e20790
patch 8.1.2375: no suffucient testing for registers
Bram Moolenaar <Bram@vim.org>
parents:
18619
diff
changeset
|
1765 tabstop_padding(viscol, ts, curbuf->b_p_vts_array) != 1 |
50fde4e20790
patch 8.1.2375: no suffucient testing for registers
Bram Moolenaar <Bram@vim.org>
parents:
18619
diff
changeset
|
1766 #else |
50fde4e20790
patch 8.1.2375: no suffucient testing for registers
Bram Moolenaar <Bram@vim.org>
parents:
18619
diff
changeset
|
1767 ts - (viscol % ts) != 1 |
50fde4e20790
patch 8.1.2375: no suffucient testing for registers
Bram Moolenaar <Bram@vim.org>
parents:
18619
diff
changeset
|
1768 #endif |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1769 : curwin->w_cursor.coladd > 0) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1770 coladvance_force(viscol); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1771 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1772 curwin->w_cursor.coladd = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1773 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1774 else if (curwin->w_cursor.coladd > 0 || gchar_cursor() == NUL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1775 coladvance_force(getviscol() + (dir == FORWARD)); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1776 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1777 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1778 lnum = curwin->w_cursor.lnum; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1779 col = curwin->w_cursor.col; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1780 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1781 // Block mode |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1782 if (y_type == MBLOCK) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1783 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1784 int c = gchar_cursor(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1785 colnr_T endcol2 = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1786 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1787 if (dir == FORWARD && c != NUL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1788 { |
25380
ac88cd21ae88
patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
1789 if (cur_ve_flags == VE_ALL) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1790 getvcol(curwin, &curwin->w_cursor, &col, NULL, &endcol2); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1791 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1792 getvcol(curwin, &curwin->w_cursor, NULL, NULL, &col); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1793 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1794 if (has_mbyte) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1795 // move to start of next multi-byte character |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1796 curwin->w_cursor.col += (*mb_ptr2len)(ml_get_cursor()); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1797 else |
25380
ac88cd21ae88
patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
1798 if (c != TAB || cur_ve_flags != VE_ALL) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1799 ++curwin->w_cursor.col; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1800 ++col; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1801 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1802 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1803 getvcol(curwin, &curwin->w_cursor, &col, NULL, &endcol2); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1804 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1805 col += curwin->w_cursor.coladd; |
25380
ac88cd21ae88
patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
1806 if (cur_ve_flags == VE_ALL |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1807 && (curwin->w_cursor.coladd > 0 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1808 || endcol2 == curwin->w_cursor.col)) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1809 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1810 if (dir == FORWARD && c == NUL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1811 ++col; |
21238
136b33ce8216
patch 8.2.1170: cursor off by one with block paste while 'virtualedit' "all"
Bram Moolenaar <Bram@vim.org>
parents:
21068
diff
changeset
|
1812 if (dir != FORWARD && c != NUL && curwin->w_cursor.coladd > 0) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1813 ++curwin->w_cursor.col; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1814 if (c == TAB) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1815 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1816 if (dir == BACKWARD && curwin->w_cursor.col) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1817 curwin->w_cursor.col--; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1818 if (dir == FORWARD && col - 1 == endcol2) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1819 curwin->w_cursor.col++; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1820 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1821 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1822 curwin->w_cursor.coladd = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1823 bd.textcol = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1824 for (i = 0; i < y_size; ++i) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1825 { |
29451
057c26b5c33a
patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents:
29336
diff
changeset
|
1826 int spaces = 0; |
057c26b5c33a
patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents:
29336
diff
changeset
|
1827 char shortline; |
057c26b5c33a
patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents:
29336
diff
changeset
|
1828 chartabsize_T cts; |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1829 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1830 bd.startspaces = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1831 bd.endspaces = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1832 vcol = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1833 delcount = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1834 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1835 // add a new line |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1836 if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1837 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1838 if (ml_append(curbuf->b_ml.ml_line_count, (char_u *)"", |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1839 (colnr_T)1, FALSE) == FAIL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1840 break; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1841 ++nr_lines; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1842 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1843 // get the old line and advance to the position to insert at |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1844 oldp = ml_get_curline(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1845 oldlen = (int)STRLEN(oldp); |
29451
057c26b5c33a
patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents:
29336
diff
changeset
|
1846 init_chartabsize_arg(&cts, curwin, curwin->w_cursor.lnum, 0, |
057c26b5c33a
patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents:
29336
diff
changeset
|
1847 oldp, oldp); |
057c26b5c33a
patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents:
29336
diff
changeset
|
1848 |
057c26b5c33a
patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents:
29336
diff
changeset
|
1849 while (cts.cts_vcol < col && *cts.cts_ptr != NUL) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1850 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1851 // Count a tab for what it's worth (if list mode not on) |
29451
057c26b5c33a
patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents:
29336
diff
changeset
|
1852 incr = lbr_chartabsize_adv(&cts); |
057c26b5c33a
patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents:
29336
diff
changeset
|
1853 cts.cts_vcol += incr; |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1854 } |
29451
057c26b5c33a
patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents:
29336
diff
changeset
|
1855 vcol = cts.cts_vcol; |
057c26b5c33a
patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents:
29336
diff
changeset
|
1856 ptr = cts.cts_ptr; |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1857 bd.textcol = (colnr_T)(ptr - oldp); |
29451
057c26b5c33a
patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents:
29336
diff
changeset
|
1858 clear_chartabsize_arg(&cts); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1859 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1860 shortline = (vcol < col) || (vcol == col && !*ptr) ; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1861 |
30986
360f286b5869
patch 9.0.0828: various typos
Bram Moolenaar <Bram@vim.org>
parents:
30861
diff
changeset
|
1862 if (vcol < col) // line too short, pad with spaces |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1863 bd.startspaces = col - vcol; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1864 else if (vcol > col) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1865 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1866 bd.endspaces = vcol - col; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1867 bd.startspaces = incr - bd.endspaces; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1868 --bd.textcol; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1869 delcount = 1; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1870 if (has_mbyte) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1871 bd.textcol -= (*mb_head_off)(oldp, oldp + bd.textcol); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1872 if (oldp[bd.textcol] != TAB) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1873 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1874 // Only a Tab can be split into spaces. Other |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1875 // characters will have to be moved to after the |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1876 // block, causing misalignment. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1877 delcount = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1878 bd.endspaces = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1879 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1880 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1881 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1882 yanklen = (int)STRLEN(y_array[i]); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1883 |
24752
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24041
diff
changeset
|
1884 if ((flags & PUT_BLOCK_INNER) == 0) |
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24041
diff
changeset
|
1885 { |
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24041
diff
changeset
|
1886 // calculate number of spaces required to fill right side of |
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24041
diff
changeset
|
1887 // block |
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24041
diff
changeset
|
1888 spaces = y_width + 1; |
29451
057c26b5c33a
patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents:
29336
diff
changeset
|
1889 init_chartabsize_arg(&cts, curwin, 0, 0, |
057c26b5c33a
patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents:
29336
diff
changeset
|
1890 y_array[i], y_array[i]); |
24752
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24041
diff
changeset
|
1891 for (j = 0; j < yanklen; j++) |
29451
057c26b5c33a
patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents:
29336
diff
changeset
|
1892 { |
057c26b5c33a
patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents:
29336
diff
changeset
|
1893 spaces -= lbr_chartabsize(&cts); |
057c26b5c33a
patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents:
29336
diff
changeset
|
1894 ++cts.cts_ptr; |
057c26b5c33a
patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents:
29336
diff
changeset
|
1895 cts.cts_vcol = 0; |
057c26b5c33a
patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents:
29336
diff
changeset
|
1896 } |
057c26b5c33a
patch 9.0.0067: cannot show virtual text
Bram Moolenaar <Bram@vim.org>
parents:
29336
diff
changeset
|
1897 clear_chartabsize_arg(&cts); |
24752
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24041
diff
changeset
|
1898 if (spaces < 0) |
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24041
diff
changeset
|
1899 spaces = 0; |
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24041
diff
changeset
|
1900 } |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1901 |
26137
14a55d1520f2
patch 8.2.3601: check for overflow in put count does not work well
Bram Moolenaar <Bram@vim.org>
parents:
26083
diff
changeset
|
1902 // Insert the new text. |
14a55d1520f2
patch 8.2.3601: check for overflow in put count does not work well
Bram Moolenaar <Bram@vim.org>
parents:
26083
diff
changeset
|
1903 // First check for multiplication overflow. |
14a55d1520f2
patch 8.2.3601: check for overflow in put count does not work well
Bram Moolenaar <Bram@vim.org>
parents:
26083
diff
changeset
|
1904 if (yanklen + spaces != 0 |
14a55d1520f2
patch 8.2.3601: check for overflow in put count does not work well
Bram Moolenaar <Bram@vim.org>
parents:
26083
diff
changeset
|
1905 && count > ((INT_MAX - (bd.startspaces + bd.endspaces)) |
14a55d1520f2
patch 8.2.3601: check for overflow in put count does not work well
Bram Moolenaar <Bram@vim.org>
parents:
26083
diff
changeset
|
1906 / (yanklen + spaces))) |
14a55d1520f2
patch 8.2.3601: check for overflow in put count does not work well
Bram Moolenaar <Bram@vim.org>
parents:
26083
diff
changeset
|
1907 { |
14a55d1520f2
patch 8.2.3601: check for overflow in put count does not work well
Bram Moolenaar <Bram@vim.org>
parents:
26083
diff
changeset
|
1908 emsg(_(e_resulting_text_too_long)); |
14a55d1520f2
patch 8.2.3601: check for overflow in put count does not work well
Bram Moolenaar <Bram@vim.org>
parents:
26083
diff
changeset
|
1909 break; |
14a55d1520f2
patch 8.2.3601: check for overflow in put count does not work well
Bram Moolenaar <Bram@vim.org>
parents:
26083
diff
changeset
|
1910 } |
14a55d1520f2
patch 8.2.3601: check for overflow in put count does not work well
Bram Moolenaar <Bram@vim.org>
parents:
26083
diff
changeset
|
1911 |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1912 totlen = count * (yanklen + spaces) + bd.startspaces + bd.endspaces; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1913 newp = alloc(totlen + oldlen + 1); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1914 if (newp == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1915 break; |
26137
14a55d1520f2
patch 8.2.3601: check for overflow in put count does not work well
Bram Moolenaar <Bram@vim.org>
parents:
26083
diff
changeset
|
1916 |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1917 // copy part up to cursor to new line |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1918 ptr = newp; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1919 mch_memmove(ptr, oldp, (size_t)bd.textcol); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1920 ptr += bd.textcol; |
26137
14a55d1520f2
patch 8.2.3601: check for overflow in put count does not work well
Bram Moolenaar <Bram@vim.org>
parents:
26083
diff
changeset
|
1921 |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1922 // may insert some spaces before the new text |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1923 vim_memset(ptr, ' ', (size_t)bd.startspaces); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1924 ptr += bd.startspaces; |
26137
14a55d1520f2
patch 8.2.3601: check for overflow in put count does not work well
Bram Moolenaar <Bram@vim.org>
parents:
26083
diff
changeset
|
1925 |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1926 // insert the new text |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1927 for (j = 0; j < count; ++j) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1928 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1929 mch_memmove(ptr, y_array[i], (size_t)yanklen); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1930 ptr += yanklen; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1931 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1932 // insert block's trailing spaces only if there's text behind |
32090
327f8a3e0040
patch 9.0.1376: accessing invalid memory with put in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents:
32009
diff
changeset
|
1933 if ((j < count - 1 || !shortline) && spaces > 0) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1934 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1935 vim_memset(ptr, ' ', (size_t)spaces); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1936 ptr += spaces; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1937 } |
29336
575bc8eaa593
patch 9.0.0011: reading beyond the end of the line with put command
Bram Moolenaar <Bram@vim.org>
parents:
29014
diff
changeset
|
1938 else |
575bc8eaa593
patch 9.0.0011: reading beyond the end of the line with put command
Bram Moolenaar <Bram@vim.org>
parents:
29014
diff
changeset
|
1939 totlen -= spaces; // didn't use these spaces |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1940 } |
26137
14a55d1520f2
patch 8.2.3601: check for overflow in put count does not work well
Bram Moolenaar <Bram@vim.org>
parents:
26083
diff
changeset
|
1941 |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1942 // may insert some spaces after the new text |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1943 vim_memset(ptr, ' ', (size_t)bd.endspaces); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1944 ptr += bd.endspaces; |
26137
14a55d1520f2
patch 8.2.3601: check for overflow in put count does not work well
Bram Moolenaar <Bram@vim.org>
parents:
26083
diff
changeset
|
1945 |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1946 // move the text after the cursor to the end of the line. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1947 mch_memmove(ptr, oldp + bd.textcol + delcount, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1948 (size_t)(oldlen - bd.textcol - delcount + 1)); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1949 ml_replace(curwin->w_cursor.lnum, newp, FALSE); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1950 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1951 ++curwin->w_cursor.lnum; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1952 if (i == 0) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1953 curwin->w_cursor.col += bd.startspaces; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1954 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1955 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1956 changed_lines(lnum, 0, curwin->w_cursor.lnum, nr_lines); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1957 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1958 // Set '[ mark. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1959 curbuf->b_op_start = curwin->w_cursor; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1960 curbuf->b_op_start.lnum = lnum; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1961 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1962 // adjust '] mark |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1963 curbuf->b_op_end.lnum = curwin->w_cursor.lnum - 1; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1964 curbuf->b_op_end.col = bd.textcol + totlen - 1; |
30861
c33f094d20c1
patch 9.0.0765: with a Visual block a put command column may go negative
Bram Moolenaar <Bram@vim.org>
parents:
30598
diff
changeset
|
1965 if (curbuf->b_op_end.col < 0) |
c33f094d20c1
patch 9.0.0765: with a Visual block a put command column may go negative
Bram Moolenaar <Bram@vim.org>
parents:
30598
diff
changeset
|
1966 curbuf->b_op_end.col = 0; |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1967 curbuf->b_op_end.coladd = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1968 if (flags & PUT_CURSEND) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1969 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1970 colnr_T len; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1971 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1972 curwin->w_cursor = curbuf->b_op_end; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1973 curwin->w_cursor.col++; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1974 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1975 // in Insert mode we might be after the NUL, correct for that |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1976 len = (colnr_T)STRLEN(ml_get_curline()); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1977 if (curwin->w_cursor.col > len) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1978 curwin->w_cursor.col = len; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1979 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1980 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1981 curwin->w_cursor.lnum = lnum; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1982 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1983 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1984 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1985 // Character or Line mode |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1986 if (y_type == MCHAR) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1987 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1988 // if type is MCHAR, FORWARD is the same as BACKWARD on the next |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1989 // char |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1990 if (dir == FORWARD && gchar_cursor() != NUL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1991 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1992 if (has_mbyte) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1993 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1994 int bytelen = (*mb_ptr2len)(ml_get_cursor()); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1995 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1996 // put it on the next of the multi-byte character. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1997 col += bytelen; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1998 if (yanklen) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1999 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2000 curwin->w_cursor.col += bytelen; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2001 curbuf->b_op_end.col += bytelen; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2002 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2003 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2004 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2005 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2006 ++col; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2007 if (yanklen) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2008 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2009 ++curwin->w_cursor.col; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2010 ++curbuf->b_op_end.col; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2011 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2012 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2013 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2014 curbuf->b_op_start = curwin->w_cursor; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2015 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2016 // Line mode: BACKWARD is the same as FORWARD on the previous line |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2017 else if (dir == BACKWARD) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2018 --lnum; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2019 new_cursor = curwin->w_cursor; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2020 |
21923
2626306efe44
patch 8.2.1511: putting a string in Visual block mode ignores multi-byte
Bram Moolenaar <Bram@vim.org>
parents:
21238
diff
changeset
|
2021 // simple case: insert into one line at a time |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2022 if (y_type == MCHAR && y_size == 1) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2023 { |
21923
2626306efe44
patch 8.2.1511: putting a string in Visual block mode ignores multi-byte
Bram Moolenaar <Bram@vim.org>
parents:
21238
diff
changeset
|
2024 linenr_T end_lnum = 0; // init for gcc |
2626306efe44
patch 8.2.1511: putting a string in Visual block mode ignores multi-byte
Bram Moolenaar <Bram@vim.org>
parents:
21238
diff
changeset
|
2025 linenr_T start_lnum = lnum; |
26292
b79f122c6bd8
patch 8.2.3677: after a put the '] mark is on the last byte
Bram Moolenaar <Bram@vim.org>
parents:
26155
diff
changeset
|
2026 int first_byte_off = 0; |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2027 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2028 if (VIsual_active) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2029 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2030 end_lnum = curbuf->b_visual.vi_end.lnum; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2031 if (end_lnum < curbuf->b_visual.vi_start.lnum) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2032 end_lnum = curbuf->b_visual.vi_start.lnum; |
21923
2626306efe44
patch 8.2.1511: putting a string in Visual block mode ignores multi-byte
Bram Moolenaar <Bram@vim.org>
parents:
21238
diff
changeset
|
2033 if (end_lnum > start_lnum) |
2626306efe44
patch 8.2.1511: putting a string in Visual block mode ignores multi-byte
Bram Moolenaar <Bram@vim.org>
parents:
21238
diff
changeset
|
2034 { |
2626306efe44
patch 8.2.1511: putting a string in Visual block mode ignores multi-byte
Bram Moolenaar <Bram@vim.org>
parents:
21238
diff
changeset
|
2035 pos_T pos; |
2626306efe44
patch 8.2.1511: putting a string in Visual block mode ignores multi-byte
Bram Moolenaar <Bram@vim.org>
parents:
21238
diff
changeset
|
2036 |
2626306efe44
patch 8.2.1511: putting a string in Visual block mode ignores multi-byte
Bram Moolenaar <Bram@vim.org>
parents:
21238
diff
changeset
|
2037 // "col" is valid for the first line, in following lines |
2626306efe44
patch 8.2.1511: putting a string in Visual block mode ignores multi-byte
Bram Moolenaar <Bram@vim.org>
parents:
21238
diff
changeset
|
2038 // the virtual column needs to be used. Matters for |
2626306efe44
patch 8.2.1511: putting a string in Visual block mode ignores multi-byte
Bram Moolenaar <Bram@vim.org>
parents:
21238
diff
changeset
|
2039 // multi-byte characters. |
2626306efe44
patch 8.2.1511: putting a string in Visual block mode ignores multi-byte
Bram Moolenaar <Bram@vim.org>
parents:
21238
diff
changeset
|
2040 pos.lnum = lnum; |
2626306efe44
patch 8.2.1511: putting a string in Visual block mode ignores multi-byte
Bram Moolenaar <Bram@vim.org>
parents:
21238
diff
changeset
|
2041 pos.col = col; |
2626306efe44
patch 8.2.1511: putting a string in Visual block mode ignores multi-byte
Bram Moolenaar <Bram@vim.org>
parents:
21238
diff
changeset
|
2042 pos.coladd = 0; |
2626306efe44
patch 8.2.1511: putting a string in Visual block mode ignores multi-byte
Bram Moolenaar <Bram@vim.org>
parents:
21238
diff
changeset
|
2043 getvcol(curwin, &pos, NULL, &vcol, NULL); |
2626306efe44
patch 8.2.1511: putting a string in Visual block mode ignores multi-byte
Bram Moolenaar <Bram@vim.org>
parents:
21238
diff
changeset
|
2044 } |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2045 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2046 |
26137
14a55d1520f2
patch 8.2.3601: check for overflow in put count does not work well
Bram Moolenaar <Bram@vim.org>
parents:
26083
diff
changeset
|
2047 if (count == 0 || yanklen == 0) |
14a55d1520f2
patch 8.2.3601: check for overflow in put count does not work well
Bram Moolenaar <Bram@vim.org>
parents:
26083
diff
changeset
|
2048 { |
14a55d1520f2
patch 8.2.3601: check for overflow in put count does not work well
Bram Moolenaar <Bram@vim.org>
parents:
26083
diff
changeset
|
2049 if (VIsual_active) |
14a55d1520f2
patch 8.2.3601: check for overflow in put count does not work well
Bram Moolenaar <Bram@vim.org>
parents:
26083
diff
changeset
|
2050 lnum = end_lnum; |
14a55d1520f2
patch 8.2.3601: check for overflow in put count does not work well
Bram Moolenaar <Bram@vim.org>
parents:
26083
diff
changeset
|
2051 } |
14a55d1520f2
patch 8.2.3601: check for overflow in put count does not work well
Bram Moolenaar <Bram@vim.org>
parents:
26083
diff
changeset
|
2052 else if (count > INT_MAX / yanklen) |
14a55d1520f2
patch 8.2.3601: check for overflow in put count does not work well
Bram Moolenaar <Bram@vim.org>
parents:
26083
diff
changeset
|
2053 // multiplication overflow |
14a55d1520f2
patch 8.2.3601: check for overflow in put count does not work well
Bram Moolenaar <Bram@vim.org>
parents:
26083
diff
changeset
|
2054 emsg(_(e_resulting_text_too_long)); |
14a55d1520f2
patch 8.2.3601: check for overflow in put count does not work well
Bram Moolenaar <Bram@vim.org>
parents:
26083
diff
changeset
|
2055 else |
14a55d1520f2
patch 8.2.3601: check for overflow in put count does not work well
Bram Moolenaar <Bram@vim.org>
parents:
26083
diff
changeset
|
2056 { |
26083
a677aa897843
patch 8.2.3575: overflow check still fails when sizeof(int) == sizeof(long)
Bram Moolenaar <Bram@vim.org>
parents:
26081
diff
changeset
|
2057 totlen = count * yanklen; |
26137
14a55d1520f2
patch 8.2.3601: check for overflow in put count does not work well
Bram Moolenaar <Bram@vim.org>
parents:
26083
diff
changeset
|
2058 do { |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2059 oldp = ml_get(lnum); |
26137
14a55d1520f2
patch 8.2.3601: check for overflow in put count does not work well
Bram Moolenaar <Bram@vim.org>
parents:
26083
diff
changeset
|
2060 oldlen = (int)STRLEN(oldp); |
21923
2626306efe44
patch 8.2.1511: putting a string in Visual block mode ignores multi-byte
Bram Moolenaar <Bram@vim.org>
parents:
21238
diff
changeset
|
2061 if (lnum > start_lnum) |
2626306efe44
patch 8.2.1511: putting a string in Visual block mode ignores multi-byte
Bram Moolenaar <Bram@vim.org>
parents:
21238
diff
changeset
|
2062 { |
2626306efe44
patch 8.2.1511: putting a string in Visual block mode ignores multi-byte
Bram Moolenaar <Bram@vim.org>
parents:
21238
diff
changeset
|
2063 pos_T pos; |
2626306efe44
patch 8.2.1511: putting a string in Visual block mode ignores multi-byte
Bram Moolenaar <Bram@vim.org>
parents:
21238
diff
changeset
|
2064 |
2626306efe44
patch 8.2.1511: putting a string in Visual block mode ignores multi-byte
Bram Moolenaar <Bram@vim.org>
parents:
21238
diff
changeset
|
2065 pos.lnum = lnum; |
2626306efe44
patch 8.2.1511: putting a string in Visual block mode ignores multi-byte
Bram Moolenaar <Bram@vim.org>
parents:
21238
diff
changeset
|
2066 if (getvpos(&pos, vcol) == OK) |
2626306efe44
patch 8.2.1511: putting a string in Visual block mode ignores multi-byte
Bram Moolenaar <Bram@vim.org>
parents:
21238
diff
changeset
|
2067 col = pos.col; |
2626306efe44
patch 8.2.1511: putting a string in Visual block mode ignores multi-byte
Bram Moolenaar <Bram@vim.org>
parents:
21238
diff
changeset
|
2068 else |
2626306efe44
patch 8.2.1511: putting a string in Visual block mode ignores multi-byte
Bram Moolenaar <Bram@vim.org>
parents:
21238
diff
changeset
|
2069 col = MAXCOL; |
2626306efe44
patch 8.2.1511: putting a string in Visual block mode ignores multi-byte
Bram Moolenaar <Bram@vim.org>
parents:
21238
diff
changeset
|
2070 } |
26137
14a55d1520f2
patch 8.2.3601: check for overflow in put count does not work well
Bram Moolenaar <Bram@vim.org>
parents:
26083
diff
changeset
|
2071 if (VIsual_active && col > oldlen) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2072 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2073 lnum++; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2074 continue; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2075 } |
26137
14a55d1520f2
patch 8.2.3601: check for overflow in put count does not work well
Bram Moolenaar <Bram@vim.org>
parents:
26083
diff
changeset
|
2076 newp = alloc(totlen + oldlen + 1); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2077 if (newp == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2078 goto end; // alloc() gave an error message |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2079 mch_memmove(newp, oldp, (size_t)col); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2080 ptr = newp + col; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2081 for (i = 0; i < count; ++i) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2082 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2083 mch_memmove(ptr, y_array[0], (size_t)yanklen); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2084 ptr += yanklen; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2085 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2086 STRMOVE(ptr, oldp + col); |
29647
d564107db756
patch 9.0.0164: using freed memory with put command
Bram Moolenaar <Bram@vim.org>
parents:
29645
diff
changeset
|
2087 |
d564107db756
patch 9.0.0164: using freed memory with put command
Bram Moolenaar <Bram@vim.org>
parents:
29645
diff
changeset
|
2088 // compute the byte offset for the last character |
d564107db756
patch 9.0.0164: using freed memory with put command
Bram Moolenaar <Bram@vim.org>
parents:
29645
diff
changeset
|
2089 first_byte_off = mb_head_off(newp, ptr - 1); |
d564107db756
patch 9.0.0164: using freed memory with put command
Bram Moolenaar <Bram@vim.org>
parents:
29645
diff
changeset
|
2090 |
d564107db756
patch 9.0.0164: using freed memory with put command
Bram Moolenaar <Bram@vim.org>
parents:
29645
diff
changeset
|
2091 // Note: this may free "newp" |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2092 ml_replace(lnum, newp, FALSE); |
26292
b79f122c6bd8
patch 8.2.3677: after a put the '] mark is on the last byte
Bram Moolenaar <Bram@vim.org>
parents:
26155
diff
changeset
|
2093 |
29645
9cd050914eb6
patch 9.0.0163: text property not adjusted for text inserted with "p"
Bram Moolenaar <Bram@vim.org>
parents:
29554
diff
changeset
|
2094 inserted_bytes(lnum, col, totlen); |
9cd050914eb6
patch 9.0.0163: text property not adjusted for text inserted with "p"
Bram Moolenaar <Bram@vim.org>
parents:
29554
diff
changeset
|
2095 |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2096 // Place cursor on last putted char. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2097 if (lnum == curwin->w_cursor.lnum) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2098 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2099 // make sure curwin->w_virtcol is updated |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2100 changed_cline_bef_curs(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2101 curwin->w_cursor.col += (colnr_T)(totlen - 1); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2102 } |
26137
14a55d1520f2
patch 8.2.3601: check for overflow in put count does not work well
Bram Moolenaar <Bram@vim.org>
parents:
26083
diff
changeset
|
2103 if (VIsual_active) |
14a55d1520f2
patch 8.2.3601: check for overflow in put count does not work well
Bram Moolenaar <Bram@vim.org>
parents:
26083
diff
changeset
|
2104 lnum++; |
14a55d1520f2
patch 8.2.3601: check for overflow in put count does not work well
Bram Moolenaar <Bram@vim.org>
parents:
26083
diff
changeset
|
2105 } while (VIsual_active && lnum <= end_lnum); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2106 |
26137
14a55d1520f2
patch 8.2.3601: check for overflow in put count does not work well
Bram Moolenaar <Bram@vim.org>
parents:
26083
diff
changeset
|
2107 if (VIsual_active) // reset lnum to the last visual line |
14a55d1520f2
patch 8.2.3601: check for overflow in put count does not work well
Bram Moolenaar <Bram@vim.org>
parents:
26083
diff
changeset
|
2108 lnum--; |
14a55d1520f2
patch 8.2.3601: check for overflow in put count does not work well
Bram Moolenaar <Bram@vim.org>
parents:
26083
diff
changeset
|
2109 } |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2110 |
26292
b79f122c6bd8
patch 8.2.3677: after a put the '] mark is on the last byte
Bram Moolenaar <Bram@vim.org>
parents:
26155
diff
changeset
|
2111 // put '] at the first byte of the last character |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2112 curbuf->b_op_end = curwin->w_cursor; |
26292
b79f122c6bd8
patch 8.2.3677: after a put the '] mark is on the last byte
Bram Moolenaar <Bram@vim.org>
parents:
26155
diff
changeset
|
2113 curbuf->b_op_end.col -= first_byte_off; |
b79f122c6bd8
patch 8.2.3677: after a put the '] mark is on the last byte
Bram Moolenaar <Bram@vim.org>
parents:
26155
diff
changeset
|
2114 |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2115 // For "CTRL-O p" in Insert mode, put cursor after last char |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2116 if (totlen && (restart_edit != 0 || (flags & PUT_CURSEND))) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2117 ++curwin->w_cursor.col; |
26292
b79f122c6bd8
patch 8.2.3677: after a put the '] mark is on the last byte
Bram Moolenaar <Bram@vim.org>
parents:
26155
diff
changeset
|
2118 else |
b79f122c6bd8
patch 8.2.3677: after a put the '] mark is on the last byte
Bram Moolenaar <Bram@vim.org>
parents:
26155
diff
changeset
|
2119 curwin->w_cursor.col -= first_byte_off; |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2120 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2121 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2122 { |
25840
8ff483b86d9b
patch 8.2.3454: using a count with "gp" leave cursor in wrong position
Bram Moolenaar <Bram@vim.org>
parents:
25808
diff
changeset
|
2123 linenr_T new_lnum = new_cursor.lnum; |
26294
ba835881a79e
patch 8.2.3678: illegal memory access
Bram Moolenaar <Bram@vim.org>
parents:
26292
diff
changeset
|
2124 size_t len; |
25840
8ff483b86d9b
patch 8.2.3454: using a count with "gp" leave cursor in wrong position
Bram Moolenaar <Bram@vim.org>
parents:
25808
diff
changeset
|
2125 |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2126 // Insert at least one line. When y_type is MCHAR, break the first |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2127 // line in two. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2128 for (cnt = 1; cnt <= count; ++cnt) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2129 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2130 i = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2131 if (y_type == MCHAR) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2132 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2133 // Split the current line in two at the insert position. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2134 // First insert y_array[size - 1] in front of second line. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2135 // Then append y_array[0] to first line. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2136 lnum = new_cursor.lnum; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2137 ptr = ml_get(lnum) + col; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2138 totlen = (int)STRLEN(y_array[y_size - 1]); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2139 newp = alloc(STRLEN(ptr) + totlen + 1); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2140 if (newp == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2141 goto error; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2142 STRCPY(newp, y_array[y_size - 1]); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2143 STRCAT(newp, ptr); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2144 // insert second line |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2145 ml_append(lnum, newp, (colnr_T)0, FALSE); |
25840
8ff483b86d9b
patch 8.2.3454: using a count with "gp" leave cursor in wrong position
Bram Moolenaar <Bram@vim.org>
parents:
25808
diff
changeset
|
2146 ++new_lnum; |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2147 vim_free(newp); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2148 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2149 oldp = ml_get(lnum); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2150 newp = alloc(col + yanklen + 1); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2151 if (newp == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2152 goto error; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2153 // copy first part of line |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2154 mch_memmove(newp, oldp, (size_t)col); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2155 // append to first line |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2156 mch_memmove(newp + col, y_array[0], (size_t)(yanklen + 1)); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2157 ml_replace(lnum, newp, FALSE); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2158 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2159 curwin->w_cursor.lnum = lnum; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2160 i = 1; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2161 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2162 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2163 for (; i < y_size; ++i) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2164 { |
25840
8ff483b86d9b
patch 8.2.3454: using a count with "gp" leave cursor in wrong position
Bram Moolenaar <Bram@vim.org>
parents:
25808
diff
changeset
|
2165 if (y_type != MCHAR || i < y_size - 1) |
8ff483b86d9b
patch 8.2.3454: using a count with "gp" leave cursor in wrong position
Bram Moolenaar <Bram@vim.org>
parents:
25808
diff
changeset
|
2166 { |
8ff483b86d9b
patch 8.2.3454: using a count with "gp" leave cursor in wrong position
Bram Moolenaar <Bram@vim.org>
parents:
25808
diff
changeset
|
2167 if (ml_append(lnum, y_array[i], (colnr_T)0, FALSE) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2168 == FAIL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2169 goto error; |
25840
8ff483b86d9b
patch 8.2.3454: using a count with "gp" leave cursor in wrong position
Bram Moolenaar <Bram@vim.org>
parents:
25808
diff
changeset
|
2170 new_lnum++; |
8ff483b86d9b
patch 8.2.3454: using a count with "gp" leave cursor in wrong position
Bram Moolenaar <Bram@vim.org>
parents:
25808
diff
changeset
|
2171 } |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2172 lnum++; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2173 ++nr_lines; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2174 if (flags & PUT_FIXINDENT) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2175 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2176 old_pos = curwin->w_cursor; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2177 curwin->w_cursor.lnum = lnum; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2178 ptr = ml_get(lnum); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2179 if (cnt == count && i == y_size - 1) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2180 lendiff = (int)STRLEN(ptr); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2181 if (*ptr == '#' && preprocs_left()) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2182 indent = 0; // Leave # lines at start |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2183 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2184 if (*ptr == NUL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2185 indent = 0; // Ignore empty lines |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2186 else if (first_indent) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2187 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2188 indent_diff = orig_indent - get_indent(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2189 indent = orig_indent; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2190 first_indent = FALSE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2191 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2192 else if ((indent = get_indent() + indent_diff) < 0) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2193 indent = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2194 (void)set_indent(indent, 0); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2195 curwin->w_cursor = old_pos; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2196 // remember how many chars were removed |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2197 if (cnt == count && i == y_size - 1) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2198 lendiff -= (int)STRLEN(ml_get(lnum)); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2199 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2200 } |
25840
8ff483b86d9b
patch 8.2.3454: using a count with "gp" leave cursor in wrong position
Bram Moolenaar <Bram@vim.org>
parents:
25808
diff
changeset
|
2201 if (cnt == 1) |
8ff483b86d9b
patch 8.2.3454: using a count with "gp" leave cursor in wrong position
Bram Moolenaar <Bram@vim.org>
parents:
25808
diff
changeset
|
2202 new_lnum = lnum; |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2203 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2204 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2205 error: |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2206 // Adjust marks. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2207 if (y_type == MLINE) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2208 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2209 curbuf->b_op_start.col = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2210 if (dir == FORWARD) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2211 curbuf->b_op_start.lnum++; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2212 } |
31762
b53ab3c3e0c9
patch 9.0.1213: adding a line below the last one does not expand fold
Bram Moolenaar <Bram@vim.org>
parents:
30986
diff
changeset
|
2213 mark_adjust(curbuf->b_op_start.lnum + (y_type == MCHAR), |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2214 (linenr_T)MAXLNUM, nr_lines, 0L); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2215 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2216 // note changed text for displaying and folding |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2217 if (y_type == MCHAR) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2218 changed_lines(curwin->w_cursor.lnum, col, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2219 curwin->w_cursor.lnum + 1, nr_lines); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2220 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2221 changed_lines(curbuf->b_op_start.lnum, 0, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2222 curbuf->b_op_start.lnum, nr_lines); |
26380
ac0e63cbf00b
patch 8.2.3721: using memory freed by losing the clipboard selection
Bram Moolenaar <Bram@vim.org>
parents:
26294
diff
changeset
|
2223 if (y_current_used != NULL && (y_current_used != y_current |
ac0e63cbf00b
patch 8.2.3721: using memory freed by losing the clipboard selection
Bram Moolenaar <Bram@vim.org>
parents:
26294
diff
changeset
|
2224 || y_current->y_array != y_array)) |
ac0e63cbf00b
patch 8.2.3721: using memory freed by losing the clipboard selection
Bram Moolenaar <Bram@vim.org>
parents:
26294
diff
changeset
|
2225 { |
ac0e63cbf00b
patch 8.2.3721: using memory freed by losing the clipboard selection
Bram Moolenaar <Bram@vim.org>
parents:
26294
diff
changeset
|
2226 // Something invoked through changed_lines() has changed the |
ac0e63cbf00b
patch 8.2.3721: using memory freed by losing the clipboard selection
Bram Moolenaar <Bram@vim.org>
parents:
26294
diff
changeset
|
2227 // yank buffer, e.g. a GUI clipboard callback. |
ac0e63cbf00b
patch 8.2.3721: using memory freed by losing the clipboard selection
Bram Moolenaar <Bram@vim.org>
parents:
26294
diff
changeset
|
2228 emsg(_(e_yank_register_changed_while_using_it)); |
ac0e63cbf00b
patch 8.2.3721: using memory freed by losing the clipboard selection
Bram Moolenaar <Bram@vim.org>
parents:
26294
diff
changeset
|
2229 goto end; |
ac0e63cbf00b
patch 8.2.3721: using memory freed by losing the clipboard selection
Bram Moolenaar <Bram@vim.org>
parents:
26294
diff
changeset
|
2230 } |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2231 |
26292
b79f122c6bd8
patch 8.2.3677: after a put the '] mark is on the last byte
Bram Moolenaar <Bram@vim.org>
parents:
26155
diff
changeset
|
2232 // Put the '] mark on the first byte of the last inserted character. |
b79f122c6bd8
patch 8.2.3677: after a put the '] mark is on the last byte
Bram Moolenaar <Bram@vim.org>
parents:
26155
diff
changeset
|
2233 // Correct the length for change in indent. |
26012
b863efc63397
patch 8.2.3540: the mark '] is wrong after put with a count
Bram Moolenaar <Bram@vim.org>
parents:
25917
diff
changeset
|
2234 curbuf->b_op_end.lnum = new_lnum; |
26294
ba835881a79e
patch 8.2.3678: illegal memory access
Bram Moolenaar <Bram@vim.org>
parents:
26292
diff
changeset
|
2235 len = STRLEN(y_array[y_size - 1]); |
ba835881a79e
patch 8.2.3678: illegal memory access
Bram Moolenaar <Bram@vim.org>
parents:
26292
diff
changeset
|
2236 col = (colnr_T)len - lendiff; |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2237 if (col > 1) |
28988
e6f486df5cc9
patch 8.2.5016: access before start of text with a put command
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
2238 { |
e6f486df5cc9
patch 8.2.5016: access before start of text with a put command
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
2239 curbuf->b_op_end.col = col - 1; |
e6f486df5cc9
patch 8.2.5016: access before start of text with a put command
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
2240 if (len > 0) |
e6f486df5cc9
patch 8.2.5016: access before start of text with a put command
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
2241 curbuf->b_op_end.col -= mb_head_off(y_array[y_size - 1], |
26294
ba835881a79e
patch 8.2.3678: illegal memory access
Bram Moolenaar <Bram@vim.org>
parents:
26292
diff
changeset
|
2242 y_array[y_size - 1] + len - 1); |
28988
e6f486df5cc9
patch 8.2.5016: access before start of text with a put command
Bram Moolenaar <Bram@vim.org>
parents:
28942
diff
changeset
|
2243 } |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2244 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2245 curbuf->b_op_end.col = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2246 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2247 if (flags & PUT_CURSLINE) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2248 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2249 // ":put": put cursor on last inserted line |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2250 curwin->w_cursor.lnum = lnum; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2251 beginline(BL_WHITE | BL_FIX); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2252 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2253 else if (flags & PUT_CURSEND) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2254 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2255 // put cursor after inserted text |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2256 if (y_type == MLINE) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2257 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2258 if (lnum >= curbuf->b_ml.ml_line_count) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2259 curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2260 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2261 curwin->w_cursor.lnum = lnum + 1; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2262 curwin->w_cursor.col = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2263 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2264 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2265 { |
25840
8ff483b86d9b
patch 8.2.3454: using a count with "gp" leave cursor in wrong position
Bram Moolenaar <Bram@vim.org>
parents:
25808
diff
changeset
|
2266 curwin->w_cursor.lnum = new_lnum; |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2267 curwin->w_cursor.col = col; |
25842
196f75cf6983
patch 8.2.3455: using a count with "gp" leaves '] in wrong position
Bram Moolenaar <Bram@vim.org>
parents:
25840
diff
changeset
|
2268 curbuf->b_op_end = curwin->w_cursor; |
196f75cf6983
patch 8.2.3455: using a count with "gp" leaves '] in wrong position
Bram Moolenaar <Bram@vim.org>
parents:
25840
diff
changeset
|
2269 if (col > 1) |
196f75cf6983
patch 8.2.3455: using a count with "gp" leaves '] in wrong position
Bram Moolenaar <Bram@vim.org>
parents:
25840
diff
changeset
|
2270 curbuf->b_op_end.col = col - 1; |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2271 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2272 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2273 else if (y_type == MLINE) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2274 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2275 // put cursor on first non-blank in first inserted line |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2276 curwin->w_cursor.col = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2277 if (dir == FORWARD) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2278 ++curwin->w_cursor.lnum; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2279 beginline(BL_WHITE | BL_FIX); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2280 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2281 else // put cursor on first inserted character |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2282 curwin->w_cursor = new_cursor; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2283 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2284 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2285 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2286 msgmore(nr_lines); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2287 curwin->w_set_curswant = TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2288 |
32090
327f8a3e0040
patch 9.0.1376: accessing invalid memory with put in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents:
32009
diff
changeset
|
2289 // Make sure the cursor is not after the NUL. |
327f8a3e0040
patch 9.0.1376: accessing invalid memory with put in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents:
32009
diff
changeset
|
2290 int len = (int)STRLEN(ml_get_curline()); |
327f8a3e0040
patch 9.0.1376: accessing invalid memory with put in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents:
32009
diff
changeset
|
2291 if (curwin->w_cursor.col > len) |
327f8a3e0040
patch 9.0.1376: accessing invalid memory with put in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents:
32009
diff
changeset
|
2292 { |
327f8a3e0040
patch 9.0.1376: accessing invalid memory with put in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents:
32009
diff
changeset
|
2293 if (cur_ve_flags == VE_ALL) |
327f8a3e0040
patch 9.0.1376: accessing invalid memory with put in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents:
32009
diff
changeset
|
2294 curwin->w_cursor.coladd = curwin->w_cursor.col - len; |
327f8a3e0040
patch 9.0.1376: accessing invalid memory with put in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents:
32009
diff
changeset
|
2295 curwin->w_cursor.col = len; |
327f8a3e0040
patch 9.0.1376: accessing invalid memory with put in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents:
32009
diff
changeset
|
2296 } |
327f8a3e0040
patch 9.0.1376: accessing invalid memory with put in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents:
32009
diff
changeset
|
2297 |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2298 end: |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22176
diff
changeset
|
2299 if (cmdmod.cmod_flags & CMOD_LOCKMARKS) |
18619
788d76db02ac
patch 8.1.2302: :lockmarks does not work for '[ and ']
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2300 { |
788d76db02ac
patch 8.1.2302: :lockmarks does not work for '[ and ']
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2301 curbuf->b_op_start = orig_start; |
788d76db02ac
patch 8.1.2302: :lockmarks does not work for '[ and ']
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2302 curbuf->b_op_end = orig_end; |
788d76db02ac
patch 8.1.2302: :lockmarks does not work for '[ and ']
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2303 } |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2304 if (allocated) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2305 vim_free(insert_string); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2306 if (regname == '=') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2307 vim_free(y_array); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2308 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2309 VIsual_active = FALSE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2310 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2311 // If the cursor is past the end of the line put it at the end. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2312 adjust_cursor_eol(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2313 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2314 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2315 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2316 * Return the character name of the register with the given number. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2317 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2318 int |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2319 get_register_name(int num) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2320 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2321 if (num == -1) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2322 return '"'; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2323 else if (num < 10) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2324 return num + '0'; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2325 else if (num == DELETION_REGISTER) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2326 return '-'; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2327 #ifdef FEAT_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2328 else if (num == STAR_REGISTER) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2329 return '*'; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2330 else if (num == PLUS_REGISTER) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2331 return '+'; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2332 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2333 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2334 return num + 'a' - 10; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2335 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2336 |
27018
268f6a3511df
patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
2337 #if defined(FEAT_EVAL) || defined(PROTO) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2338 /* |
20743
a672feb8fc4f
patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2339 * Return the index of the register "" points to. |
a672feb8fc4f
patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2340 */ |
a672feb8fc4f
patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2341 int |
32009
4545f58c8490
patch 9.0.1336: functions without arguments are not always declared properly
Bram Moolenaar <Bram@vim.org>
parents:
31778
diff
changeset
|
2342 get_unname_register(void) |
20743
a672feb8fc4f
patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2343 { |
a672feb8fc4f
patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2344 return y_previous == NULL ? -1 : y_previous - &y_regs[0]; |
a672feb8fc4f
patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2345 } |
27018
268f6a3511df
patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
2346 #endif |
20743
a672feb8fc4f
patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2347 |
a672feb8fc4f
patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2348 /* |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2349 * ":dis" and ":registers": Display the contents of the yank registers. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2350 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2351 void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2352 ex_display(exarg_T *eap) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2353 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2354 int i, n; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2355 long j; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2356 char_u *p; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2357 yankreg_T *yb; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2358 int name; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2359 int attr; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2360 char_u *arg = eap->arg; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2361 int clen; |
18454
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2362 int type; |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2363 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2364 if (arg != NULL && *arg == NUL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2365 arg = NULL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2366 attr = HL_ATTR(HLF_8); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2367 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2368 // Highlight title |
18436
6ec1bfb4690b
patch 8.1.2212: cannot see the selection type in :reg output
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2369 msg_puts_title(_("\nType Name Content")); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2370 for (i = -1; i < NUM_REGISTERS && !got_int; ++i) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2371 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2372 name = get_register_name(i); |
18436
6ec1bfb4690b
patch 8.1.2212: cannot see the selection type in :reg output
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2373 switch (get_reg_type(name, NULL)) |
6ec1bfb4690b
patch 8.1.2212: cannot see the selection type in :reg output
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2374 { |
18454
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2375 case MLINE: type = 'l'; break; |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2376 case MCHAR: type = 'c'; break; |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2377 default: type = 'b'; break; |
18436
6ec1bfb4690b
patch 8.1.2212: cannot see the selection type in :reg output
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2378 } |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2379 if (arg != NULL && vim_strchr(arg, name) == NULL |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2380 #ifdef ONE_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2381 // Star register and plus register contain the same thing. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2382 && (name != '*' || vim_strchr(arg, '+') == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2383 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2384 ) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2385 continue; // did not ask for this register |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2386 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2387 #ifdef FEAT_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2388 // Adjust register name for "unnamed" in 'clipboard'. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2389 // When it's a clipboard register, fill it with the current contents |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2390 // of the clipboard. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2391 adjust_clip_reg(&name); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2392 (void)may_get_selection(name); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2393 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2394 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2395 if (i == -1) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2396 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2397 if (y_previous != NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2398 yb = y_previous; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2399 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2400 yb = &(y_regs[0]); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2401 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2402 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2403 yb = &(y_regs[i]); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2404 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2405 #ifdef FEAT_EVAL |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2406 if (name == MB_TOLOWER(redir_reg) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2407 || (redir_reg == '"' && yb == y_previous)) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2408 continue; // do not list register being written to, the |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2409 // pointer can be freed |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2410 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2411 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2412 if (yb->y_array != NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2413 { |
18454
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2414 int do_show = FALSE; |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2415 |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2416 for (j = 0; !do_show && j < yb->y_size; ++j) |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2417 do_show = !message_filtered(yb->y_array[j]); |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2418 |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2419 if (do_show || yb->y_size == 0) |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2420 { |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2421 msg_putchar('\n'); |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2422 msg_puts(" "); |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2423 msg_putchar(type); |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2424 msg_puts(" "); |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2425 msg_putchar('"'); |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2426 msg_putchar(name); |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2427 msg_puts(" "); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2428 |
18454
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2429 n = (int)Columns - 11; |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2430 for (j = 0; j < yb->y_size && n > 1; ++j) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2431 { |
18454
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2432 if (j) |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2433 { |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2434 msg_puts_attr("^J", attr); |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2435 n -= 2; |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2436 } |
28247
f70015784777
patch 8.2.4649: various formatting problems
Bram Moolenaar <Bram@vim.org>
parents:
28137
diff
changeset
|
2437 for (p = yb->y_array[j]; |
f70015784777
patch 8.2.4649: various formatting problems
Bram Moolenaar <Bram@vim.org>
parents:
28137
diff
changeset
|
2438 *p != NUL && (n -= ptr2cells(p)) >= 0; ++p) |
18454
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2439 { |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2440 clen = (*mb_ptr2len)(p); |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2441 msg_outtrans_len(p, clen); |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2442 p += clen - 1; |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2443 } |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2444 } |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2445 if (n > 1 && yb->y_type == MLINE) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2446 msg_puts_attr("^J", attr); |
18454
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2447 out_flush(); // show one line at a time |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2448 } |
18454
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2449 ui_breakcheck(); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2450 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2451 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2452 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2453 // display last inserted text |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2454 if ((p = get_last_insert()) != NULL |
18454
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2455 && (arg == NULL || vim_strchr(arg, '.') != NULL) && !got_int |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2456 && !message_filtered(p)) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2457 { |
18436
6ec1bfb4690b
patch 8.1.2212: cannot see the selection type in :reg output
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2458 msg_puts("\n c \". "); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2459 dis_msg(p, TRUE); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2460 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2461 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2462 // display last command line |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2463 if (last_cmdline != NULL && (arg == NULL || vim_strchr(arg, ':') != NULL) |
18454
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2464 && !got_int && !message_filtered(last_cmdline)) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2465 { |
18436
6ec1bfb4690b
patch 8.1.2212: cannot see the selection type in :reg output
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2466 msg_puts("\n c \": "); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2467 dis_msg(last_cmdline, FALSE); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2468 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2469 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2470 // display current file name |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2471 if (curbuf->b_fname != NULL |
18454
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2472 && (arg == NULL || vim_strchr(arg, '%') != NULL) && !got_int |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2473 && !message_filtered(curbuf->b_fname)) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2474 { |
18436
6ec1bfb4690b
patch 8.1.2212: cannot see the selection type in :reg output
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2475 msg_puts("\n c \"% "); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2476 dis_msg(curbuf->b_fname, FALSE); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2477 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2478 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2479 // display alternate file name |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2480 if ((arg == NULL || vim_strchr(arg, '%') != NULL) && !got_int) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2481 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2482 char_u *fname; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2483 linenr_T dummy; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2484 |
18454
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2485 if (buflist_name_nr(0, &fname, &dummy) != FAIL |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2486 && !message_filtered(fname)) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2487 { |
18436
6ec1bfb4690b
patch 8.1.2212: cannot see the selection type in :reg output
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2488 msg_puts("\n c \"# "); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2489 dis_msg(fname, FALSE); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2490 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2491 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2492 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2493 // display last search pattern |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2494 if (last_search_pat() != NULL |
18454
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2495 && (arg == NULL || vim_strchr(arg, '/') != NULL) && !got_int |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2496 && !message_filtered(last_search_pat())) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2497 { |
18436
6ec1bfb4690b
patch 8.1.2212: cannot see the selection type in :reg output
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2498 msg_puts("\n c \"/ "); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2499 dis_msg(last_search_pat(), FALSE); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2500 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2501 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2502 #ifdef FEAT_EVAL |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2503 // display last used expression |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2504 if (expr_line != NULL && (arg == NULL || vim_strchr(arg, '=') != NULL) |
18454
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2505 && !got_int && !message_filtered(expr_line)) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2506 { |
18436
6ec1bfb4690b
patch 8.1.2212: cannot see the selection type in :reg output
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2507 msg_puts("\n c \"= "); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2508 dis_msg(expr_line, FALSE); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2509 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2510 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2511 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2512 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2513 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2514 * display a string for do_dis() |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2515 * truncate at end of screen line |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2516 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2517 static void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2518 dis_msg( |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2519 char_u *p, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2520 int skip_esc) // if TRUE, ignore trailing ESC |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2521 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2522 int n; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2523 int l; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2524 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2525 n = (int)Columns - 6; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2526 while (*p != NUL |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2527 && !(*p == ESC && skip_esc && *(p + 1) == NUL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2528 && (n -= ptr2cells(p)) >= 0) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2529 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2530 if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2531 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2532 msg_outtrans_len(p, l); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2533 p += l; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2534 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2535 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2536 msg_outtrans_len(p++, 1); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2537 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2538 ui_breakcheck(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2539 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2540 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2541 #if defined(FEAT_DND) || defined(PROTO) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2542 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2543 * Replace the contents of the '~' register with str. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2544 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2545 void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2546 dnd_yank_drag_data(char_u *str, long len) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2547 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2548 yankreg_T *curr; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2549 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2550 curr = y_current; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2551 y_current = &y_regs[TILDE_REGISTER]; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2552 free_yank_all(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2553 str_to_reg(y_current, MCHAR, str, len, 0L, FALSE); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2554 y_current = curr; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2555 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2556 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2557 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2558 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2559 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2560 * Return the type of a register. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2561 * Used for getregtype() |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2562 * Returns MAUTO for error. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2563 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2564 char_u |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2565 get_reg_type(int regname, long *reglen) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2566 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2567 switch (regname) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2568 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2569 case '%': // file name |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2570 case '#': // alternate file name |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2571 case '=': // expression |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2572 case ':': // last command line |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2573 case '/': // last search-pattern |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2574 case '.': // last inserted text |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2575 case Ctrl_F: // Filename under cursor |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2576 case Ctrl_P: // Path under cursor, expand via "path" |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2577 case Ctrl_W: // word under cursor |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2578 case Ctrl_A: // WORD (mnemonic All) under cursor |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2579 case '_': // black hole: always empty |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2580 return MCHAR; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2581 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2582 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2583 # ifdef FEAT_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2584 regname = may_get_selection(regname); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2585 # endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2586 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2587 if (regname != NUL && !valid_yank_reg(regname, FALSE)) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2588 return MAUTO; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2589 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2590 get_yank_register(regname, FALSE); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2591 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2592 if (y_current->y_array != NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2593 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2594 if (reglen != NULL && y_current->y_type == MBLOCK) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2595 *reglen = y_current->y_width; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2596 return y_current->y_type; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2597 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2598 return MAUTO; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2599 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2600 |
18436
6ec1bfb4690b
patch 8.1.2212: cannot see the selection type in :reg output
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2601 #if defined(FEAT_EVAL) || defined(PROTO) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2602 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2603 * When "flags" has GREG_LIST return a list with text "s". |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2604 * Otherwise just return "s". |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2605 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2606 static char_u * |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2607 getreg_wrap_one_line(char_u *s, int flags) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2608 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2609 if (flags & GREG_LIST) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2610 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2611 list_T *list = list_alloc(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2612 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2613 if (list != NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2614 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2615 if (list_append_string(list, NULL, -1) == FAIL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2616 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2617 list_free(list); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2618 return NULL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2619 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2620 list->lv_first->li_tv.vval.v_string = s; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2621 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2622 return (char_u *)list; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2623 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2624 return s; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2625 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2626 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2627 /* |
19524
4a6a412e4565
patch 8.2.0319: file missing in distribution, comments outdated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2628 * Return the contents of a register as a single allocated string or as a list. |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2629 * Used for "@r" in expressions and for getreg(). |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2630 * Returns NULL for error. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2631 * Flags: |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2632 * GREG_NO_EXPR Do not allow expression register |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2633 * GREG_EXPR_SRC For the expression register: return expression itself, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2634 * not the result of its evaluation. |
19524
4a6a412e4565
patch 8.2.0319: file missing in distribution, comments outdated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2635 * GREG_LIST Return a list of lines instead of a single string. |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2636 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2637 char_u * |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2638 get_reg_contents(int regname, int flags) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2639 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2640 long i; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2641 char_u *retval; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2642 int allocated; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2643 long len; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2644 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2645 // Don't allow using an expression register inside an expression |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2646 if (regname == '=') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2647 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2648 if (flags & GREG_NO_EXPR) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2649 return NULL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2650 if (flags & GREG_EXPR_SRC) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2651 return getreg_wrap_one_line(get_expr_line_src(), flags); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2652 return getreg_wrap_one_line(get_expr_line(), flags); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2653 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2654 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2655 if (regname == '@') // "@@" is used for unnamed register |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2656 regname = '"'; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2657 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2658 // check for valid regname |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2659 if (regname != NUL && !valid_yank_reg(regname, FALSE)) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2660 return NULL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2661 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2662 # ifdef FEAT_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2663 regname = may_get_selection(regname); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2664 # endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2665 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2666 if (get_spec_reg(regname, &retval, &allocated, FALSE)) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2667 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2668 if (retval == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2669 return NULL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2670 if (allocated) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2671 return getreg_wrap_one_line(retval, flags); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2672 return getreg_wrap_one_line(vim_strsave(retval), flags); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2673 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2674 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2675 get_yank_register(regname, FALSE); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2676 if (y_current->y_array == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2677 return NULL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2678 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2679 if (flags & GREG_LIST) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2680 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2681 list_T *list = list_alloc(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2682 int error = FALSE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2683 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2684 if (list == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2685 return NULL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2686 for (i = 0; i < y_current->y_size; ++i) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2687 if (list_append_string(list, y_current->y_array[i], -1) == FAIL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2688 error = TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2689 if (error) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2690 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2691 list_free(list); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2692 return NULL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2693 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2694 return (char_u *)list; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2695 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2696 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2697 // Compute length of resulting string. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2698 len = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2699 for (i = 0; i < y_current->y_size; ++i) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2700 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2701 len += (long)STRLEN(y_current->y_array[i]); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2702 // Insert a newline between lines and after last line if |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2703 // y_type is MLINE. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2704 if (y_current->y_type == MLINE || i < y_current->y_size - 1) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2705 ++len; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2706 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2707 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2708 retval = alloc(len + 1); |
31778
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
2709 if (retval == NULL) |
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
2710 return NULL; |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2711 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2712 // Copy the lines of the yank register into the string. |
31778
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
2713 len = 0; |
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
2714 for (i = 0; i < y_current->y_size; ++i) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2715 { |
31778
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
2716 STRCPY(retval + len, y_current->y_array[i]); |
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
2717 len += (long)STRLEN(retval + len); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2718 |
31778
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
2719 // Insert a NL between lines and after the last line if y_type is |
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
2720 // MLINE. |
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
2721 if (y_current->y_type == MLINE || i < y_current->y_size - 1) |
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
2722 retval[len++] = '\n'; |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2723 } |
31778
579c846086eb
patch 9.0.1221: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31762
diff
changeset
|
2724 retval[len] = NUL; |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2725 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2726 return retval; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2727 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2728 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2729 static int |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2730 init_write_reg( |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2731 int name, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2732 yankreg_T **old_y_previous, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2733 yankreg_T **old_y_current, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2734 int must_append, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2735 int *yank_type UNUSED) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2736 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2737 if (!valid_yank_reg(name, TRUE)) // check for valid reg name |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2738 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2739 emsg_invreg(name); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2740 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2741 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2742 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2743 // Don't want to change the current (unnamed) register |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2744 *old_y_previous = y_previous; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2745 *old_y_current = y_current; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2746 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2747 get_yank_register(name, TRUE); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2748 if (!y_append && !must_append) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2749 free_yank_all(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2750 return OK; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2751 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2752 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2753 static void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2754 finish_write_reg( |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2755 int name, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2756 yankreg_T *old_y_previous, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2757 yankreg_T *old_y_current) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2758 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2759 # ifdef FEAT_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2760 // Send text of clipboard register to the clipboard. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2761 may_set_selection(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2762 # endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2763 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2764 // ':let @" = "val"' should change the meaning of the "" register |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2765 if (name != '"') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2766 y_previous = old_y_previous; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2767 y_current = old_y_current; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2768 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2769 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2770 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2771 * Store string "str" in register "name". |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2772 * "maxlen" is the maximum number of bytes to use, -1 for all bytes. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2773 * If "must_append" is TRUE, always append to the register. Otherwise append |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2774 * if "name" is an uppercase letter. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2775 * Note: "maxlen" and "must_append" don't work for the "/" register. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2776 * Careful: 'str' is modified, you may have to use a copy! |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2777 * If "str" ends in '\n' or '\r', use linewise, otherwise use characterwise. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2778 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2779 void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2780 write_reg_contents( |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2781 int name, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2782 char_u *str, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2783 int maxlen, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2784 int must_append) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2785 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2786 write_reg_contents_ex(name, str, maxlen, must_append, MAUTO, 0L); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2787 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2788 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2789 void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2790 write_reg_contents_lst( |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2791 int name, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2792 char_u **strings, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2793 int maxlen UNUSED, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2794 int must_append, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2795 int yank_type, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2796 long block_len) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2797 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2798 yankreg_T *old_y_previous, *old_y_current; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2799 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2800 if (name == '/' || name == '=') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2801 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2802 char_u *s; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2803 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2804 if (strings[0] == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2805 s = (char_u *)""; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2806 else if (strings[1] != NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2807 { |
26966
ac75c145f0a9
patch 8.2.4012: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26958
diff
changeset
|
2808 emsg(_(e_search_pattern_and_expression_register_may_not_contain_two_or_more_lines)); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2809 return; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2810 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2811 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2812 s = strings[0]; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2813 write_reg_contents_ex(name, s, -1, must_append, yank_type, block_len); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2814 return; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2815 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2816 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2817 if (name == '_') // black hole: nothing to do |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2818 return; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2819 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2820 if (init_write_reg(name, &old_y_previous, &old_y_current, must_append, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2821 &yank_type) == FAIL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2822 return; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2823 |
25070
f397a21b3e4c
patch 8.2.3072: "zy" does not work well when "virtualedit' is "block"
Bram Moolenaar <Bram@vim.org>
parents:
24946
diff
changeset
|
2824 str_to_reg(y_current, yank_type, (char_u *)strings, -1, block_len, TRUE); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2825 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2826 finish_write_reg(name, old_y_previous, old_y_current); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2827 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2828 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2829 void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2830 write_reg_contents_ex( |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2831 int name, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2832 char_u *str, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2833 int maxlen, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2834 int must_append, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2835 int yank_type, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2836 long block_len) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2837 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2838 yankreg_T *old_y_previous, *old_y_current; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2839 long len; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2840 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2841 if (maxlen >= 0) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2842 len = maxlen; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2843 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2844 len = (long)STRLEN(str); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2845 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2846 // Special case: '/' search pattern |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2847 if (name == '/') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2848 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2849 set_last_search_pat(str, RE_SEARCH, TRUE, TRUE); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2850 return; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2851 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2852 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2853 if (name == '#') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2854 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2855 buf_T *buf; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2856 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2857 if (VIM_ISDIGIT(*str)) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2858 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2859 int num = atoi((char *)str); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2860 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2861 buf = buflist_findnr(num); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2862 if (buf == NULL) |
26439
b18f3b0f317c
patch 8.2.3750: error messages are everywhere
Bram Moolenaar <Bram@vim.org>
parents:
26382
diff
changeset
|
2863 semsg(_(e_buffer_nr_does_not_exist), (long)num); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2864 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2865 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2866 buf = buflist_findnr(buflist_findpat(str, str + STRLEN(str), |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2867 TRUE, FALSE, FALSE)); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2868 if (buf == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2869 return; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2870 curwin->w_alt_fnum = buf->b_fnum; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2871 return; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2872 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2873 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2874 if (name == '=') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2875 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2876 char_u *p, *s; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2877 |
20830
9064044fd4f6
patch 8.2.0967: unnecessary type casts for vim_strnsave()
Bram Moolenaar <Bram@vim.org>
parents:
20824
diff
changeset
|
2878 p = vim_strnsave(str, len); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2879 if (p == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2880 return; |
18838
8dabdfc7c799
patch 8.1.2406: leaking memory in test_paste and test_registers
Bram Moolenaar <Bram@vim.org>
parents:
18771
diff
changeset
|
2881 if (must_append && expr_line != NULL) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2882 { |
18838
8dabdfc7c799
patch 8.1.2406: leaking memory in test_paste and test_registers
Bram Moolenaar <Bram@vim.org>
parents:
18771
diff
changeset
|
2883 s = concat_str(expr_line, p); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2884 vim_free(p); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2885 p = s; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2886 } |
22732
4c21a3a47707
patch 8.2.1914: Vim9: cannot put line break in expression for '=' register
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
2887 set_expr_line(p, NULL); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2888 return; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2889 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2890 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2891 if (name == '_') // black hole: nothing to do |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2892 return; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2893 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2894 if (init_write_reg(name, &old_y_previous, &old_y_current, must_append, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2895 &yank_type) == FAIL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2896 return; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2897 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2898 str_to_reg(y_current, yank_type, str, len, block_len, FALSE); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2899 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2900 finish_write_reg(name, old_y_previous, old_y_current); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2901 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2902 #endif // FEAT_EVAL |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2903 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2904 #if defined(FEAT_CLIPBOARD) || defined(FEAT_EVAL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2905 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2906 * Put a string into a register. When the register is not empty, the string |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2907 * is appended. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2908 */ |
19774
00a1b89256ea
patch 8.2.0443: clipboard code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
19524
diff
changeset
|
2909 void |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2910 str_to_reg( |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2911 yankreg_T *y_ptr, // pointer to yank register |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2912 int yank_type, // MCHAR, MLINE, MBLOCK, MAUTO |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2913 char_u *str, // string to put in register |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2914 long len, // length of string |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2915 long blocklen, // width of Visual block |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2916 int str_list) // TRUE if str is char_u ** |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2917 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2918 int type; // MCHAR, MLINE or MBLOCK |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2919 int lnum; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2920 long start; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2921 long i; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2922 int extra; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2923 int newlines; // number of lines added |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2924 int extraline = 0; // extra line at the end |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2925 int append = FALSE; // append to last line in register |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2926 char_u *s; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2927 char_u **ss; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2928 char_u **pp; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2929 long maxlen; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2930 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2931 if (y_ptr->y_array == NULL) // NULL means empty register |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2932 y_ptr->y_size = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2933 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2934 if (yank_type == MAUTO) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2935 type = ((str_list || (len > 0 && (str[len - 1] == NL |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2936 || str[len - 1] == CAR))) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2937 ? MLINE : MCHAR); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2938 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2939 type = yank_type; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2940 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2941 // Count the number of lines within the string |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2942 newlines = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2943 if (str_list) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2944 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2945 for (ss = (char_u **) str; *ss != NULL; ++ss) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2946 ++newlines; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2947 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2948 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2949 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2950 for (i = 0; i < len; i++) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2951 if (str[i] == '\n') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2952 ++newlines; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2953 if (type == MCHAR || len == 0 || str[len - 1] != '\n') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2954 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2955 extraline = 1; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2956 ++newlines; // count extra newline at the end |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2957 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2958 if (y_ptr->y_size > 0 && y_ptr->y_type == MCHAR) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2959 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2960 append = TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2961 --newlines; // uncount newline when appending first line |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2962 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2963 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2964 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2965 // Without any lines make the register empty. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2966 if (y_ptr->y_size + newlines == 0) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2967 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2968 VIM_CLEAR(y_ptr->y_array); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2969 return; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2970 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2971 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2972 // Allocate an array to hold the pointers to the new register lines. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2973 // If the register was not empty, move the existing lines to the new array. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2974 pp = lalloc_clear((y_ptr->y_size + newlines) * sizeof(char_u *), TRUE); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2975 if (pp == NULL) // out of memory |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2976 return; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2977 for (lnum = 0; lnum < y_ptr->y_size; ++lnum) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2978 pp[lnum] = y_ptr->y_array[lnum]; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2979 vim_free(y_ptr->y_array); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2980 y_ptr->y_array = pp; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2981 maxlen = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2982 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2983 // Find the end of each line and save it into the array. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2984 if (str_list) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2985 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2986 for (ss = (char_u **) str; *ss != NULL; ++ss, ++lnum) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2987 { |
24794
fd245e5d4585
patch 8.2.2935: calculating register width is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
24792
diff
changeset
|
2988 pp[lnum] = vim_strsave(*ss); |
fd245e5d4585
patch 8.2.2935: calculating register width is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
24792
diff
changeset
|
2989 if (type == MBLOCK) |
fd245e5d4585
patch 8.2.2935: calculating register width is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
24792
diff
changeset
|
2990 { |
fd245e5d4585
patch 8.2.2935: calculating register width is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
24792
diff
changeset
|
2991 int charlen = mb_string2cells(*ss, -1); |
fd245e5d4585
patch 8.2.2935: calculating register width is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
24792
diff
changeset
|
2992 |
fd245e5d4585
patch 8.2.2935: calculating register width is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
24792
diff
changeset
|
2993 if (charlen > maxlen) |
fd245e5d4585
patch 8.2.2935: calculating register width is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
24792
diff
changeset
|
2994 maxlen = charlen; |
fd245e5d4585
patch 8.2.2935: calculating register width is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
24792
diff
changeset
|
2995 } |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2996 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2997 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2998 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2999 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3000 for (start = 0; start < len + extraline; start += i + 1) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3001 { |
24794
fd245e5d4585
patch 8.2.2935: calculating register width is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
24792
diff
changeset
|
3002 int charlen = 0; |
fd245e5d4585
patch 8.2.2935: calculating register width is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
24792
diff
changeset
|
3003 |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3004 for (i = start; i < len; ++i) // find the end of the line |
24792
91c42289cbe1
patch 8.2.2934: ASAN error when using text from the clipboard
Bram Moolenaar <Bram@vim.org>
parents:
24790
diff
changeset
|
3005 { |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3006 if (str[i] == '\n') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3007 break; |
24794
fd245e5d4585
patch 8.2.2935: calculating register width is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
24792
diff
changeset
|
3008 if (type == MBLOCK) |
fd245e5d4585
patch 8.2.2935: calculating register width is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
24792
diff
changeset
|
3009 charlen += mb_ptr2cells_len(str + i, len - i); |
24792
91c42289cbe1
patch 8.2.2934: ASAN error when using text from the clipboard
Bram Moolenaar <Bram@vim.org>
parents:
24790
diff
changeset
|
3010 } |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3011 i -= start; // i is now length of line |
24790
14b86681e6e6
patch 8.2.2933: when 'clipboard' is "unnamed" zp does not work correctly
Bram Moolenaar <Bram@vim.org>
parents:
24752
diff
changeset
|
3012 if (charlen > maxlen) |
14b86681e6e6
patch 8.2.2933: when 'clipboard' is "unnamed" zp does not work correctly
Bram Moolenaar <Bram@vim.org>
parents:
24752
diff
changeset
|
3013 maxlen = charlen; |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3014 if (append) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3015 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3016 --lnum; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3017 extra = (int)STRLEN(y_ptr->y_array[lnum]); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3018 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3019 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3020 extra = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3021 s = alloc(i + extra + 1); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3022 if (s == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3023 break; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3024 if (extra) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3025 mch_memmove(s, y_ptr->y_array[lnum], (size_t)extra); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3026 if (append) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3027 vim_free(y_ptr->y_array[lnum]); |
24792
91c42289cbe1
patch 8.2.2934: ASAN error when using text from the clipboard
Bram Moolenaar <Bram@vim.org>
parents:
24790
diff
changeset
|
3028 if (i > 0) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3029 mch_memmove(s + extra, str + start, (size_t)i); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3030 extra += i; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3031 s[extra] = NUL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3032 y_ptr->y_array[lnum++] = s; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3033 while (--extra >= 0) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3034 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3035 if (*s == NUL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3036 *s = '\n'; // replace NUL with newline |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3037 ++s; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3038 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3039 append = FALSE; // only first line is appended |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3040 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3041 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3042 y_ptr->y_type = type; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3043 y_ptr->y_size = lnum; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3044 if (type == MBLOCK) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3045 y_ptr->y_width = (blocklen < 0 ? maxlen - 1 : blocklen); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3046 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3047 y_ptr->y_width = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3048 # ifdef FEAT_VIMINFO |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3049 y_ptr->y_time_set = vim_time(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3050 # endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3051 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3052 #endif // FEAT_CLIPBOARD || FEAT_EVAL || PROTO |