Mercurial > vim
annotate src/register.c @ 23648:b7d3c79075c5 v8.2.2366
patch 8.2.2366: when using ":sleep" the cursor is always displayed
Commit: https://github.com/vim/vim/commit/e2edc2ed4a9a229870b1e1811b0ecf045b84e429
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jan 16 20:21:23 2021 +0100
patch 8.2.2366: when using ":sleep" the cursor is always displayed
Problem: When using ":sleep" the cursor is always displayed.
Solution: Do not display the cursor when using ":sleep!". (Jeremy Lerner,
closes #7688)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 16 Jan 2021 20:30:04 +0100 |
parents | f2a70fca3485 |
children | 580ee78577e9 |
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); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
35 static int yank_copy_line(struct block_def *bd, long y_idx); |
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 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
41 yankreg_T * |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
42 get_y_regs(void) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
43 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
44 return y_regs; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
45 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
46 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
47 yankreg_T * |
19774
00a1b89256ea
patch 8.2.0443: clipboard code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
19524
diff
changeset
|
48 get_y_register(int reg) |
00a1b89256ea
patch 8.2.0443: clipboard code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
19524
diff
changeset
|
49 { |
00a1b89256ea
patch 8.2.0443: clipboard code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
19524
diff
changeset
|
50 return &y_regs[reg]; |
00a1b89256ea
patch 8.2.0443: clipboard code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
19524
diff
changeset
|
51 } |
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 yankreg_T * |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
54 get_y_current(void) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
55 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
56 return y_current; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
57 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
58 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
59 yankreg_T * |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
60 get_y_previous(void) |
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 return y_previous; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
63 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
64 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
65 void |
19774
00a1b89256ea
patch 8.2.0443: clipboard code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
19524
diff
changeset
|
66 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
|
67 { |
00a1b89256ea
patch 8.2.0443: clipboard code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
19524
diff
changeset
|
68 y_current = yreg; |
00a1b89256ea
patch 8.2.0443: clipboard code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
19524
diff
changeset
|
69 } |
00a1b89256ea
patch 8.2.0443: clipboard code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
19524
diff
changeset
|
70 |
00a1b89256ea
patch 8.2.0443: clipboard code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
19524
diff
changeset
|
71 void |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
72 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
|
73 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
74 y_previous = yreg; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
75 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
76 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
77 #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
|
78 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
79 * 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
|
80 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
81 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
|
82 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
|
83 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
84 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
85 * 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
|
86 * 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
|
87 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
88 int |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
89 get_expr_register(void) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
90 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
91 char_u *new_line; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
92 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
93 new_line = getcmdline('=', 0L, 0, TRUE); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
94 if (new_line == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
95 return NUL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
96 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
|
97 vim_free(new_line); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
98 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
|
99 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
|
100 return '='; |
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 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
103 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
104 * 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
|
105 * 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
|
106 * "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
|
107 * expression. |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
108 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
109 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
|
110 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
|
111 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
112 vim_free(expr_line); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
113 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
|
114 expr_eap = eap; |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
115 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
116 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
117 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
118 * 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
|
119 * 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
|
120 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
121 char_u * |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
122 get_expr_line(void) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
123 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
124 char_u *expr_copy; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
125 char_u *rv; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
126 static int nested = 0; |
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 if (expr_line == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
129 return NULL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
130 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
131 // 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
|
132 // changed. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
133 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
|
134 if (expr_copy == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
135 return NULL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
136 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
137 // 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
|
138 // 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
|
139 if (nested >= 10) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
140 return expr_copy; |
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 ++nested; |
22732
4c21a3a47707
patch 8.2.1914: Vim9: cannot put line break in expression for '=' register
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
143 rv = eval_to_string_eap(expr_copy, TRUE, expr_eap); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
144 --nested; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
145 vim_free(expr_copy); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
146 return rv; |
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 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
149 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
150 * 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
|
151 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
152 static char_u * |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
153 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
|
154 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
155 if (expr_line == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
156 return NULL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
157 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
|
158 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
159 #endif // FEAT_EVAL |
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 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
162 * 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
|
163 * 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
|
164 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
165 int |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
166 valid_yank_reg( |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
167 int regname, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
168 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
|
169 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
170 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
|
171 || (!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
|
172 #ifdef FEAT_EVAL |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
173 "/.%:=" |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
174 #else |
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 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
177 , regname) != NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
178 || regname == '#' |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
179 || regname == '"' |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
180 || regname == '-' |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
181 || regname == '_' |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
182 #ifdef FEAT_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
183 || regname == '*' |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
184 || regname == '+' |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
185 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
186 #ifdef FEAT_DND |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
187 || (!writing && regname == '~') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
188 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
189 ) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
190 return TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
191 return FALSE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
192 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
193 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
194 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
195 * 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
|
196 * Cannot handle the '_' register. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
197 * 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
|
198 * |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
199 * 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
|
200 * 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
|
201 * |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
202 * 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
|
203 * clipboard). |
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 int |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
206 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
|
207 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
208 int i; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
209 int ret = FALSE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
210 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
211 y_append = FALSE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
212 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
|
213 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
214 y_current = y_previous; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
215 return ret; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
216 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
217 i = regname; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
218 if (VIM_ISDIGIT(i)) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
219 i -= '0'; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
220 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
|
221 i = CharOrdLow(i) + 10; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
222 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
|
223 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
224 i = CharOrdUp(i) + 10; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
225 y_append = TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
226 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
227 else if (regname == '-') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
228 i = DELETION_REGISTER; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
229 #ifdef FEAT_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
230 // 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
|
231 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
|
232 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
233 i = STAR_REGISTER; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
234 ret = TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
235 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
236 // 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
|
237 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
|
238 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
239 i = PLUS_REGISTER; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
240 ret = TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
241 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
242 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
243 #ifdef FEAT_DND |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
244 else if (!writing && regname == '~') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
245 i = TILDE_REGISTER; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
246 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
247 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
|
248 i = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
249 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
|
250 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
|
251 y_previous = y_current; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
252 return ret; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
253 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
254 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
255 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
256 * 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
|
257 * 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
|
258 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
259 void * |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
260 get_register( |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
261 int name, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
262 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
|
263 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
264 yankreg_T *reg; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
265 int i; |
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 #ifdef FEAT_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
268 // 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
|
269 // selection too. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
270 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
|
271 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
272 if (clip_isautosel_star()) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
273 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
|
274 may_get_selection(name); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
275 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
276 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
|
277 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
278 if (clip_isautosel_plus()) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
279 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
|
280 may_get_selection(name); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
281 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
282 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
283 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
284 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
|
285 reg = ALLOC_ONE(yankreg_T); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
286 if (reg != NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
287 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
288 *reg = *y_current; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
289 if (copy) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
290 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
291 // If we run out of memory some or all of the lines are empty. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
292 if (reg->y_size == 0) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
293 reg->y_array = NULL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
294 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
295 reg->y_array = ALLOC_MULT(char_u *, reg->y_size); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
296 if (reg->y_array != NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
297 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
298 for (i = 0; i < reg->y_size; ++i) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
299 reg->y_array[i] = vim_strsave(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
|
300 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
301 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
302 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
303 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
|
304 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
305 return (void *)reg; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
306 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
307 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
308 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
309 * 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
|
310 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
311 void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
312 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
|
313 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
314 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
|
315 free_yank_all(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
316 *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
|
317 vim_free(reg); |
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 #ifdef FEAT_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
320 // 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
|
321 may_set_selection(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
322 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
323 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
324 |
23021
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22732
diff
changeset
|
325 #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
|
326 void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
327 free_register(void *reg) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
328 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
329 yankreg_T tmp; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
330 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
331 tmp = *y_current; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
332 *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
|
333 free_yank_all(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
334 vim_free(reg); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
335 *y_current = tmp; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
336 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
337 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
338 |
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 * 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
|
341 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
342 int |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
343 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
|
344 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
345 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
|
346 return FALSE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
347 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
|
348 return FALSE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
349 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
|
350 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
|
351 } |
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 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
354 * 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
|
355 * |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
356 * 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
|
357 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
358 int |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
359 do_record(int c) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
360 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
361 char_u *p; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
362 static int regname; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
363 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
|
364 int retval; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
365 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
366 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
|
367 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
368 // 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
|
369 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
|
370 retval = FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
371 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
372 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
373 reg_recording = c; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
374 showmode(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
375 regname = c; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
376 retval = OK; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
377 } |
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 else // stop recording |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
380 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
381 // 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
|
382 // 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
|
383 // 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
|
384 reg_recording = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
385 msg(""); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
386 p = get_recorded(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
387 if (p == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
388 retval = FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
389 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
390 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
391 // 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
|
392 vim_unescape_csi(p); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
393 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
394 // 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
|
395 // 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
|
396 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
|
397 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
|
398 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
399 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
|
400 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
401 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
|
402 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
|
403 } |
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 return retval; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
406 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
407 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
408 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
409 * 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
|
410 * 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
|
411 * |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
412 * 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
|
413 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
414 static int |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
415 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
|
416 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
417 char_u *lp; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
418 char_u **pp; |
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 // 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
|
421 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
|
422 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
423 vim_free(p); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
424 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
425 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
426 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
|
427 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
428 vim_free(p); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
429 return OK; |
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 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
|
432 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
|
433 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
434 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
|
435 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
|
436 if (lp == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
437 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
438 vim_free(p); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
439 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
440 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
441 STRCPY(lp, *pp); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
442 STRCAT(lp, p); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
443 vim_free(p); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
444 vim_free(*pp); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
445 *pp = lp; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
446 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
447 else |
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 free_yank_all(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
450 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
|
451 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
452 vim_free(p); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
453 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
454 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
455 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
|
456 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
|
457 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
|
458 #ifdef FEAT_VIMINFO |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
459 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
|
460 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
461 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
462 return OK; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
463 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
464 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
465 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
|
466 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
467 int |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
468 get_execreg_lastc(void) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
469 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
470 return execreg_lastc; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
471 } |
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 void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
474 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
|
475 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
476 execreg_lastc = lastc; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
477 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
478 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
479 /* |
20891
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
480 * 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
|
481 * 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
|
482 * 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
|
483 * 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
|
484 * |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
485 * Arguments: |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
486 * 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
|
487 * 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
|
488 * 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
|
489 * 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
|
490 * character are ignored. |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
491 * |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
492 * 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
|
493 * 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
|
494 */ |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
495 static char_u * |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
496 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
|
497 { |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
498 garray_T ga; |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
499 long i = *idx; |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
500 char_u *p; |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
501 int cmd_start; |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
502 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
|
503 int j; |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
504 char_u *str; |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
505 |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
506 ga_init2(&ga, (int)sizeof(char_u), 400); |
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 // 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
|
509 // 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
|
510 // command. |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
511 while (--i > 0) |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
512 { |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
513 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
|
514 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
|
515 break; |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
516 } |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
517 cmd_start = i; |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
518 |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
519 // 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
|
520 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
|
521 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
|
522 { |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
523 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
|
524 if (*p == '\\') |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
525 { |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
526 // 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
|
527 // 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
|
528 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
|
529 { |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
530 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
|
531 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
|
532 else |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
533 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
|
534 } |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
535 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
|
536 } |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
537 } |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
538 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
|
539 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
|
540 ga_clear(&ga); |
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 *idx = i; |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
543 return str; |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
544 } |
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 /* |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
547 * 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
|
548 * |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
549 * 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
|
550 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
551 int |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
552 do_execreg( |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
553 int regname, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
554 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
|
555 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
|
556 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
|
557 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
558 long i; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
559 char_u *p; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
560 int retval = OK; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
561 int remap; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
562 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
563 // repeat previous one |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
564 if (regname == '@') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
565 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
566 if (execreg_lastc == NUL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
567 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
568 emsg(_("E748: No previously used register")); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
569 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
570 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
571 regname = execreg_lastc; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
572 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
573 // check for valid regname |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
574 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
|
575 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
576 emsg_invreg(regname); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
577 return FAIL; |
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 execreg_lastc = regname; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
580 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
581 #ifdef FEAT_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
582 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
|
583 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
584 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
585 // 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
|
586 if (regname == '_') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
587 return OK; |
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 // use last command line |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
590 if (regname == ':') |
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 if (last_cmdline == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
593 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
594 emsg(_(e_nolastcmd)); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
595 return FAIL; |
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 // 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
|
598 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
|
599 // 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
|
600 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
|
601 (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
|
602 "\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
|
603 "\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
|
604 "\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
|
605 Ctrl_V, FALSE); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
606 if (p != NULL) |
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 // 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
|
609 // 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
|
610 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
|
611 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
|
612 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
613 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
|
614 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
615 vim_free(p); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
616 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
617 #ifdef FEAT_EVAL |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
618 else if (regname == '=') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
619 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
620 p = get_expr_line(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
621 if (p == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
622 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
623 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
|
624 vim_free(p); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
625 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
626 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
627 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
|
628 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
629 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
|
630 if (p == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
631 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
632 emsg(_(e_noinstext)); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
633 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
634 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
635 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
|
636 vim_free(p); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
637 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
638 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
639 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
640 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
|
641 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
|
642 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
643 |
19195
2ef19eed524a
patch 8.2.0156: various typos in source files and tests
Bram Moolenaar <Bram@vim.org>
parents:
18838
diff
changeset
|
644 // 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
|
645 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
|
646 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
647 // 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
|
648 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
|
649 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
|
650 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
651 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
|
652 char_u *str; |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
653 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
|
654 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
655 // 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
|
656 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
|
657 || addcr) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
658 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
659 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
|
660 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
661 } |
20891
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
662 |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
663 // 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
|
664 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
|
665 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
|
666 { |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
667 p = skipwhite(str); |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
668 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
|
669 { |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
670 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
|
671 if (str == NULL) |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
672 return FAIL; |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
673 free_str = TRUE; |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
674 } |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
675 } |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
676 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
|
677 if (free_str) |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
678 vim_free(str); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
679 if (escaped == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
680 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
681 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
|
682 vim_free(escaped); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
683 if (retval == FAIL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
684 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
685 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
|
686 == FAIL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
687 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
688 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
689 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
|
690 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
691 return retval; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
692 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
693 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
694 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
695 * 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
|
696 * 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
|
697 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
698 static void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
699 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
|
700 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
701 char_u buf[3]; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
702 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
703 if (restart_edit != NUL) |
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 if (restart_edit == 'V') |
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 buf[0] = 'g'; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
708 buf[1] = 'R'; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
709 buf[2] = NUL; |
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 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
712 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
713 buf[0] = restart_edit == 'I' ? 'i' : restart_edit; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
714 buf[1] = NUL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
715 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
716 if (ins_typebuf(buf, REMAP_NONE, 0, TRUE, silent) == OK) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
717 restart_edit = NUL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
718 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
719 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
720 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
721 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
722 * 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
|
723 * executed again. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
724 * 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
|
725 * no remapping. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
726 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
727 static int |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
728 put_in_typebuf( |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
729 char_u *s, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
730 int esc, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
731 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
|
732 int silent) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
733 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
734 int retval = OK; |
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 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
|
737 if (colon) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
738 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
|
739 if (retval == OK) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
740 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
741 char_u *p; |
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 if (esc) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
744 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
|
745 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
746 p = s; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
747 if (p == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
748 retval = FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
749 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
750 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
|
751 0, TRUE, silent); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
752 if (esc) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
753 vim_free(p); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
754 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
755 if (colon && retval == OK) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
756 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
|
757 return retval; |
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 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
760 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
761 * 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
|
762 * 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
|
763 * |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
764 * 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
|
765 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
766 int |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
767 insert_reg( |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
768 int regname, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
769 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
|
770 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
771 long i; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
772 int retval = OK; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
773 char_u *arg; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
774 int allocated; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
775 int literally = literally_arg; |
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 // 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
|
778 // 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
|
779 // 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
|
780 ui_breakcheck(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
781 if (got_int) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
782 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
783 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
784 // check for valid regname |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
785 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
|
786 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
787 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
788 #ifdef FEAT_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
789 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
|
790 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
791 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
792 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
|
793 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
|
794 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
|
795 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
796 if (arg == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
797 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
798 stuffescaped(arg, literally); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
799 if (allocated) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
800 vim_free(arg); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
801 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
802 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
|
803 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
804 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
|
805 literally = TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
806 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
|
807 retval = FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
808 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
809 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
810 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
|
811 { |
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
|
812 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
|
813 { |
f2a70fca3485
patch 8.2.2189: cannot repeat a command that uses the small delete register
Bram Moolenaar <Bram@vim.org>
parents:
23021
diff
changeset
|
814 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
|
815 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
|
816 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
|
817 } |
f2a70fca3485
patch 8.2.2189: cannot repeat a command that uses the small delete register
Bram Moolenaar <Bram@vim.org>
parents:
23021
diff
changeset
|
818 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
|
819 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
|
820 // 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
|
821 // y_type is MLINE. |
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_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
|
823 stuffcharReadbuff('\n'); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
824 } |
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 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
827 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
828 return retval; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
829 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
830 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
831 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
832 * 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
|
833 * value in "argp". |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
834 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
835 int |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
836 get_spec_reg( |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
837 int regname, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
838 char_u **argp, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
839 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
|
840 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
|
841 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
842 int cnt; |
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 *argp = NULL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
845 *allocated = FALSE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
846 switch (regname) |
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 case '%': // file name |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
849 if (errmsg) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
850 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
|
851 *argp = curbuf->b_fname; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
852 return TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
853 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
854 case '#': // alternate file name |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
855 *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
|
856 return TRUE; |
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 #ifdef FEAT_EVAL |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
859 case '=': // result of expression |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
860 *argp = get_expr_line(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
861 *allocated = TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
862 return TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
863 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
864 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
865 case ':': // last command line |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
866 if (last_cmdline == NULL && errmsg) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
867 emsg(_(e_nolastcmd)); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
868 *argp = last_cmdline; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
869 return TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
870 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
871 case '/': // last search-pattern |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
872 if (last_search_pat() == NULL && errmsg) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
873 emsg(_(e_noprevre)); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
874 *argp = last_search_pat(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
875 return TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
876 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
877 case '.': // last inserted text |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
878 *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
|
879 *allocated = TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
880 if (*argp == NULL && errmsg) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
881 emsg(_(e_noinstext)); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
882 return TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
883 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
884 #ifdef FEAT_SEARCHPATH |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
885 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
|
886 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
|
887 if (!errmsg) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
888 return FALSE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
889 *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
|
890 | (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
|
891 *allocated = TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
892 return TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
893 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
894 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
895 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
|
896 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
|
897 if (!errmsg) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
898 return FALSE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
899 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
|
900 ? (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
|
901 *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
|
902 *allocated = TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
903 return TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
904 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
905 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
|
906 if (!errmsg) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
907 return FALSE; |
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 *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
|
910 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
|
911 return TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
912 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
913 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
|
914 *argp = (char_u *)""; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
915 return TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
916 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
917 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
918 return FALSE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
919 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
920 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
921 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
922 * 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
|
923 * 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
|
924 * 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
|
925 * 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
|
926 * 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
|
927 * |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
928 * 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
|
929 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
930 int |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
931 cmdline_paste_reg( |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
932 int regname, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
933 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
|
934 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
|
935 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
936 long i; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
937 int literally = literally_arg; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
938 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
939 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
|
940 literally = TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
941 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
|
942 return FAIL; |
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 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
|
945 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
946 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
|
947 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
948 // 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
|
949 // 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
|
950 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
|
951 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
|
952 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
953 // 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
|
954 // lines and gets bored. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
955 ui_breakcheck(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
956 if (got_int) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
957 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
958 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
959 return OK; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
960 } |
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 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
963 * 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
|
964 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
965 void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
966 shift_delete_registers() |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
967 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
968 int n; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
969 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
970 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
|
971 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
|
972 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
|
973 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
|
974 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
|
975 if (!y_append) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
976 y_previous = y_current; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
977 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
|
978 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
979 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
980 #if defined(FEAT_EVAL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
981 void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
982 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
|
983 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
984 static int recursive = FALSE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
985 dict_T *v_event; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
986 list_T *list; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
987 int n; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
988 char_u buf[NUMBUFLEN + 2]; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
989 long reglen = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
990 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
991 if (recursive) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
992 return; |
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 v_event = get_vim_var_dict(VV_EVENT); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
995 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
996 list = list_alloc(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
997 if (list == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
998 return; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
999 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
|
1000 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
|
1001 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
|
1002 (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
|
1003 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1004 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
|
1005 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
|
1006 (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
|
1007 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1008 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
|
1009 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
|
1010 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
|
1011 (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
|
1012 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1013 buf[0] = NUL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1014 buf[1] = NUL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1015 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
|
1016 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1017 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
|
1018 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
|
1019 case MBLOCK: |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1020 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
|
1021 reglen + 1); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1022 break; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1023 } |
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, "regtype", buf); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1025 |
21068
ac493e63b192
patch 8.2.1085: Coverity complains about ignoring dict_add() return value
Bram Moolenaar <Bram@vim.org>
parents:
20996
diff
changeset
|
1026 (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
|
1027 |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1028 // 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
|
1029 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
|
1030 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1031 recursive = TRUE; |
20229
06a1dd50463e
patch 8.2.0670: cannot change window when evaluating 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
19774
diff
changeset
|
1032 textwinlock++; |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1033 apply_autocmds(EVENT_TEXTYANKPOST, NULL, NULL, FALSE, curbuf); |
20229
06a1dd50463e
patch 8.2.0670: cannot change window when evaluating 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
19774
diff
changeset
|
1034 textwinlock--; |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1035 recursive = FALSE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1036 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1037 // Empty the dictionary, v:event is still valid |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1038 dict_free_contents(v_event); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1039 hash_init(&v_event->dv_hashtab); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1040 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1041 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1042 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1043 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1044 * 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
|
1045 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1046 void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1047 init_yank(void) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1048 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1049 int i; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1050 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1051 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
|
1052 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
|
1053 } |
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 #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
|
1056 void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1057 clear_registers(void) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1058 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1059 int i; |
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 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
|
1062 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1063 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
|
1064 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
|
1065 free_yank_all(); |
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 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1068 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1069 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1070 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1071 * 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
|
1072 * 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
|
1073 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1074 static void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1075 free_yank(long n) |
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 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
|
1078 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1079 long i; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1080 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1081 for (i = n; --i >= 0; ) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1082 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1083 #ifdef AMIGA // only for very slow machines |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1084 if ((i & 1023) == 1023) // this may take a while |
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 // This message should never cause a hit-return message. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1087 // Overwrite this message with any next message. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1088 ++no_wait_return; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1089 smsg(_("freeing %ld lines"), i + 1); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1090 --no_wait_return; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1091 msg_didout = FALSE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1092 msg_col = 0; |
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 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1095 vim_free(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
|
1096 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1097 VIM_CLEAR(y_current->y_array); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1098 #ifdef AMIGA |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1099 if (n >= 1000) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1100 msg(""); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1101 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1102 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1103 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1104 |
19774
00a1b89256ea
patch 8.2.0443: clipboard code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
19524
diff
changeset
|
1105 void |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1106 free_yank_all(void) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1107 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1108 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
|
1109 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1110 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1111 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1112 * 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
|
1113 * 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
|
1114 * 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
|
1115 * 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
|
1116 * |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1117 * 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
|
1118 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1119 int |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1120 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
|
1121 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1122 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
|
1123 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
|
1124 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
|
1125 char_u **new_ptr; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1126 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
|
1127 long j; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1128 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
|
1129 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
|
1130 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
|
1131 char_u *p; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1132 char_u *pnew; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1133 struct block_def bd; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1134 #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
|
1135 int did_star = FALSE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1136 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1137 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1138 // 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
|
1139 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
|
1140 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1141 beep_flush(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1142 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1143 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1144 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
|
1145 return OK; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1146 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1147 #ifdef FEAT_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1148 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
|
1149 oap->regname = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1150 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
|
1151 oap->regname = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1152 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1153 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1154 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
|
1155 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
|
1156 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1157 curr = y_current; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1158 // append to existing contents |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1159 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
|
1160 y_current = &newreg; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1161 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1162 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
|
1163 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1164 // 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
|
1165 // 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
|
1166 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
|
1167 && oap->start.col == 0 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1168 && !oap->inclusive |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1169 && (!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
|
1170 && !oap->block_mode |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1171 && oap->end.col == 0 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1172 && yanklines > 1) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1173 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1174 yanktype = MLINE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1175 --yankendlnum; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1176 --yanklines; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1177 } |
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 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
|
1180 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
|
1181 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
|
1182 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
|
1183 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
|
1184 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1185 y_current = curr; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1186 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1187 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1188 #ifdef FEAT_VIMINFO |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1189 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
|
1190 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1191 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1192 y_idx = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1193 lnum = oap->start.lnum; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1194 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1195 if (oap->block_mode) |
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 // Visual block mode |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1198 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
|
1199 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
|
1200 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1201 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
|
1202 y_current->y_width--; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1203 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1204 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1205 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
|
1206 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1207 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
|
1208 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1209 case MBLOCK: |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1210 block_prep(oap, &bd, lnum, FALSE); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1211 if (yank_copy_line(&bd, y_idx) == FAIL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1212 goto fail; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1213 break; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1214 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1215 case MLINE: |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1216 if ((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
|
1217 vim_strsave(ml_get(lnum))) == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1218 goto fail; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1219 break; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1220 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1221 case MCHAR: |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1222 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1223 colnr_T startcol = 0, endcol = MAXCOL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1224 int is_oneChar = FALSE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1225 colnr_T cs, ce; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1226 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1227 p = ml_get(lnum); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1228 bd.startspaces = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1229 bd.endspaces = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1230 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1231 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
|
1232 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1233 startcol = oap->start.col; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1234 if (virtual_op) |
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 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
|
1237 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
|
1238 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1239 // 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
|
1240 // double-count it. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1241 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
|
1242 - oap->start.coladd; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1243 startcol++; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1244 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1245 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1246 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1247 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1248 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
|
1249 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1250 endcol = oap->end.col; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1251 if (virtual_op) |
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 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
|
1254 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
|
1255 // 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
|
1256 // 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
|
1257 // of multi-byte char. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1258 && (*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
|
1259 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1260 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
|
1261 && 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
|
1262 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1263 // 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
|
1264 is_oneChar = TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1265 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
|
1266 - 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
|
1267 endcol = startcol; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1268 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1269 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1270 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1271 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
|
1272 + oap->inclusive; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1273 endcol -= oap->inclusive; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1274 } |
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 } |
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 if (endcol == MAXCOL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1279 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
|
1280 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
|
1281 bd.textlen = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1282 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1283 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
|
1284 bd.textstart = p + startcol; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1285 if (yank_copy_line(&bd, y_idx) == FAIL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1286 goto fail; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1287 break; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1288 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1289 // NOTREACHED |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1290 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1291 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1292 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1293 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
|
1294 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1295 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
|
1296 if (new_ptr == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1297 goto fail; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1298 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
|
1299 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
|
1300 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
|
1301 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
|
1302 #ifdef FEAT_VIMINFO |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1303 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
|
1304 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1305 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1306 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
|
1307 curr->y_type = MLINE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1308 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1309 // 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
|
1310 // 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
|
1311 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
|
1312 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1313 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
|
1314 + 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
|
1315 if (pnew == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1316 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1317 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
|
1318 goto fail; |
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 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
|
1321 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
|
1322 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
|
1323 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
|
1324 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
|
1325 y_idx = 1; |
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 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1328 y_idx = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1329 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
|
1330 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
|
1331 curr->y_size = j; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1332 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
|
1333 y_current = curr; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1334 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1335 if (curwin->w_p_rnu) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1336 redraw_later(SOME_VALID); // cursor moved to start |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1337 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
|
1338 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1339 if (yanktype == MCHAR |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1340 && !oap->block_mode |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1341 && yanklines == 1) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1342 yanklines = 0; |
18498
9e6d5a4abb1c
patch 8.1.2243: typos in comments
Bram Moolenaar <Bram@vim.org>
parents:
18454
diff
changeset
|
1343 // 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
|
1344 if (yanklines > p_report) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1345 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1346 char namebuf[100]; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1347 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1348 if (oap->regname == NUL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1349 *namebuf = NUL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1350 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1351 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
|
1352 _(" into \"%c"), oap->regname); |
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 // 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
|
1355 update_topline_redraw(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1356 if (oap->block_mode) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1357 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1358 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
|
1359 "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
|
1360 yanklines, namebuf); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1361 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1362 else |
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("%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 "%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 } |
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 |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22176
diff
changeset
|
1371 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
|
1372 { |
18619
788d76db02ac
patch 8.1.2302: :lockmarks does not work for '[ and ']
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1373 // Set "'[" and "']" marks. |
788d76db02ac
patch 8.1.2302: :lockmarks does not work for '[ and ']
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1374 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
|
1375 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
|
1376 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
|
1377 { |
788d76db02ac
patch 8.1.2302: :lockmarks does not work for '[ and ']
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1378 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
|
1379 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
|
1380 } |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1381 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1382 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1383 #ifdef FEAT_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1384 // 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
|
1385 // 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
|
1386 // to the '*' register. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1387 if (clip_star.available |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1388 && (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
|
1389 || (!deleting && oap->regname == 0 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1390 && ((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
|
1391 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1392 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
|
1393 // 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
|
1394 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
|
1395 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1396 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
|
1397 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
|
1398 # ifdef FEAT_X11 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1399 did_star = TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1400 # endif |
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 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1403 # ifdef FEAT_X11 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1404 // If we were yanking to the '+' register, send result to selection. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1405 // Also copy to the '*' register, in case auto-select is off. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1406 if (clip_plus.available |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1407 && (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
|
1408 || (!deleting && oap->regname == 0 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1409 && ((clip_unnamed | clip_unnamed_saved) & |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1410 CLIP_UNNAMED_PLUS)))) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1411 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1412 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
|
1413 // 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
|
1414 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
|
1415 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1416 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
|
1417 clip_gen_set_selection(&clip_plus); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1418 if (!clip_isautosel_star() && !clip_isautosel_plus() |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1419 && !did_star && 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
|
1420 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1421 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
|
1422 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
|
1423 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
|
1424 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1425 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1426 # endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1427 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1428 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1429 #if defined(FEAT_EVAL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1430 if (!deleting && has_textyankpost()) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1431 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
|
1432 #endif |
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 return OK; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1435 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1436 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
|
1437 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
|
1438 y_current = curr; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1439 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1440 } |
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 static int |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1443 yank_copy_line(struct block_def *bd, long y_idx) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1444 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1445 char_u *pnew; |
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 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
|
1448 == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1449 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1450 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
|
1451 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
|
1452 pnew += bd->startspaces; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1453 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
|
1454 pnew += bd->textlen; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1455 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
|
1456 pnew += bd->endspaces; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1457 *pnew = NUL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1458 return OK; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1459 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1460 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1461 #ifdef FEAT_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1462 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1463 * 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
|
1464 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1465 static void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1466 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
|
1467 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1468 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
|
1469 long j; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1470 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1471 y_current = reg; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1472 free_yank_all(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1473 *y_current = *curr; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1474 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
|
1475 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
|
1476 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
|
1477 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
|
1478 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1479 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
|
1480 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
|
1481 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1482 free_yank(j); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1483 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
|
1484 break; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1485 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1486 y_current = curr; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1487 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1488 #endif |
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 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1491 * 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
|
1492 * 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
|
1493 * "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
|
1494 * 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
|
1495 * PUT_LINE force linewise put (":put") |
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 void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1498 do_put( |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1499 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
|
1500 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
|
1501 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
|
1502 long count, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1503 int flags) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1504 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1505 char_u *ptr; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1506 char_u *newp, *oldp; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1507 int yanklen; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1508 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
|
1509 linenr_T lnum; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1510 colnr_T col; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1511 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
|
1512 int y_type; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1513 long y_size; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1514 int oldlen; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1515 long y_width = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1516 colnr_T vcol; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1517 int delcount; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1518 int incr = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1519 long j; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1520 struct block_def bd; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1521 char_u **y_array = NULL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1522 long nr_lines = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1523 pos_T new_cursor; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1524 int indent; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1525 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
|
1526 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
|
1527 int first_indent = TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1528 int lendiff = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1529 pos_T old_pos; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1530 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
|
1531 int allocated = FALSE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1532 long cnt; |
18619
788d76db02ac
patch 8.1.2302: :lockmarks does not work for '[ and ']
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1533 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
|
1534 pos_T orig_end = curbuf->b_op_end; |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1535 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1536 #ifdef FEAT_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1537 // 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
|
1538 adjust_clip_reg(®name); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1539 (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
|
1540 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1541 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1542 if (flags & PUT_FIXINDENT) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1543 orig_indent = get_indent(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1544 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1545 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
|
1546 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
|
1547 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1548 // 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
|
1549 // special characters (newlines, etc.). |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1550 if (regname == '.') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1551 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1552 if (VIsual_active) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1553 stuffcharReadbuff(VIsual_mode); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1554 (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
|
1555 (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
|
1556 // 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
|
1557 // 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
|
1558 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
|
1559 stuffcharReadbuff('l'); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1560 return; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1561 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1562 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1563 // 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
|
1564 // ':' (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
|
1565 // 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
|
1566 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
|
1567 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
|
1568 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
|
1569 && 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
|
1570 return; |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1571 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1572 // 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
|
1573 // 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
|
1574 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
|
1575 goto end; |
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 if (insert_string != NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1578 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1579 y_type = MCHAR; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1580 #ifdef FEAT_EVAL |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1581 if (regname == '=') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1582 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1583 // 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
|
1584 // characters. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1585 // 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
|
1586 for (;;) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1587 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1588 y_size = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1589 ptr = insert_string; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1590 while (ptr != NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1591 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1592 if (y_array != NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1593 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
|
1594 ++y_size; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1595 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
|
1596 if (ptr != NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1597 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1598 if (y_array != NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1599 *ptr = NUL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1600 ++ptr; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1601 // 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
|
1602 if (*ptr == NUL) |
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 y_type = MLINE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1605 break; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1606 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1607 } |
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 (y_array != NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1610 break; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1611 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
|
1612 if (y_array == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1613 goto end; |
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 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1616 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1617 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1618 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1619 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
|
1620 y_array = &insert_string; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1621 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1622 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1623 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1624 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1625 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
|
1626 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1627 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
|
1628 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
|
1629 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
|
1630 y_array = y_current->y_array; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1631 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1632 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1633 if (y_type == MLINE) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1634 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1635 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
|
1636 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1637 char_u *p; |
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 // "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
|
1640 // between. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1641 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
|
1642 goto end; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1643 p = ml_get_cursor(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1644 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
|
1645 MB_PTR_ADV(p); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1646 ptr = vim_strsave(p); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1647 if (ptr == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1648 goto end; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1649 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
|
1650 vim_free(ptr); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1651 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1652 oldp = ml_get_curline(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1653 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
|
1654 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
|
1655 MB_PTR_ADV(p); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1656 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
|
1657 if (ptr == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1658 goto end; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1659 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
|
1660 ++nr_lines; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1661 dir = FORWARD; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1662 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1663 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
|
1664 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1665 // 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
|
1666 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
|
1667 dir = FORWARD; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1668 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1669 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
|
1670 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
|
1671 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1672 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1673 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
|
1674 y_type = MLINE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1675 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1676 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
|
1677 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1678 semsg(_("E353: Nothing in register %s"), |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1679 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
|
1680 goto end; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1681 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1682 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1683 if (y_type == MBLOCK) |
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 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
|
1686 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
|
1687 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
|
1688 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
|
1689 goto end; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1690 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1691 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
|
1692 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1693 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
|
1694 #ifdef FEAT_FOLDING |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1695 // 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
|
1696 // u_save() uses it. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1697 if (dir == BACKWARD) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1698 (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
|
1699 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1700 (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
|
1701 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1702 if (dir == FORWARD) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1703 ++lnum; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1704 // 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
|
1705 // 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
|
1706 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
|
1707 goto end; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1708 #ifdef FEAT_FOLDING |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1709 if (dir == FORWARD) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1710 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
|
1711 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1712 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
|
1713 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
|
1714 #endif |
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 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
|
1717 goto end; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1718 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1719 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
|
1720 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1721 if (ve_flags == VE_ALL && y_type == MCHAR) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1722 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1723 if (gchar_cursor() == TAB) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1724 { |
18771
50fde4e20790
patch 8.1.2375: no suffucient testing for registers
Bram Moolenaar <Bram@vim.org>
parents:
18619
diff
changeset
|
1725 int viscol = getviscol(); |
50fde4e20790
patch 8.1.2375: no suffucient testing for registers
Bram Moolenaar <Bram@vim.org>
parents:
18619
diff
changeset
|
1726 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
|
1727 |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1728 // 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
|
1729 // 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
|
1730 if (dir == FORWARD ? |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1731 #ifdef FEAT_VARTABS |
18771
50fde4e20790
patch 8.1.2375: no suffucient testing for registers
Bram Moolenaar <Bram@vim.org>
parents:
18619
diff
changeset
|
1732 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
|
1733 #else |
50fde4e20790
patch 8.1.2375: no suffucient testing for registers
Bram Moolenaar <Bram@vim.org>
parents:
18619
diff
changeset
|
1734 ts - (viscol % ts) != 1 |
50fde4e20790
patch 8.1.2375: no suffucient testing for registers
Bram Moolenaar <Bram@vim.org>
parents:
18619
diff
changeset
|
1735 #endif |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1736 : 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
|
1737 coladvance_force(viscol); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1738 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1739 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
|
1740 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1741 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
|
1742 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
|
1743 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1744 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1745 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
|
1746 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
|
1747 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1748 // Block mode |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1749 if (y_type == MBLOCK) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1750 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1751 int c = gchar_cursor(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1752 colnr_T endcol2 = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1753 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1754 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
|
1755 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1756 if (ve_flags == VE_ALL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1757 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
|
1758 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1759 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
|
1760 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1761 if (has_mbyte) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1762 // 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
|
1763 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
|
1764 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1765 if (c != TAB || ve_flags != VE_ALL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1766 ++curwin->w_cursor.col; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1767 ++col; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1768 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1769 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1770 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
|
1771 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1772 col += curwin->w_cursor.coladd; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1773 if (ve_flags == VE_ALL |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1774 && (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
|
1775 || 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
|
1776 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1777 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
|
1778 ++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
|
1779 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
|
1780 ++curwin->w_cursor.col; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1781 if (c == TAB) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1782 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1783 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
|
1784 curwin->w_cursor.col--; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1785 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
|
1786 curwin->w_cursor.col++; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1787 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1788 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1789 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
|
1790 bd.textcol = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1791 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
|
1792 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1793 int spaces; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1794 char shortline; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1795 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1796 bd.startspaces = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1797 bd.endspaces = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1798 vcol = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1799 delcount = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1800 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1801 // add a new line |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1802 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
|
1803 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1804 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
|
1805 (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
|
1806 break; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1807 ++nr_lines; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1808 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1809 // 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
|
1810 oldp = ml_get_curline(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1811 oldlen = (int)STRLEN(oldp); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1812 for (ptr = oldp; vcol < col && *ptr; ) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1813 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1814 // Count a tab for what it's worth (if list mode not on) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1815 incr = lbr_chartabsize_adv(oldp, &ptr, (colnr_T)vcol); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1816 vcol += incr; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1817 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1818 bd.textcol = (colnr_T)(ptr - oldp); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1819 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1820 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
|
1821 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1822 if (vcol < col) // line too short, padd with spaces |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1823 bd.startspaces = col - vcol; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1824 else if (vcol > col) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1825 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1826 bd.endspaces = vcol - col; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1827 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
|
1828 --bd.textcol; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1829 delcount = 1; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1830 if (has_mbyte) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1831 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
|
1832 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
|
1833 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1834 // 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
|
1835 // 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
|
1836 // block, causing misalignment. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1837 delcount = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1838 bd.endspaces = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1839 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1840 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1841 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1842 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
|
1843 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1844 // calculate number of spaces required to fill right side of block |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1845 spaces = y_width + 1; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1846 for (j = 0; j < yanklen; j++) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1847 spaces -= lbr_chartabsize(NULL, &y_array[i][j], 0); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1848 if (spaces < 0) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1849 spaces = 0; |
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 // insert the new text |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1852 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
|
1853 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
|
1854 if (newp == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1855 break; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1856 // 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
|
1857 ptr = newp; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1858 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
|
1859 ptr += bd.textcol; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1860 // 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
|
1861 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
|
1862 ptr += bd.startspaces; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1863 // insert the new text |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1864 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
|
1865 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1866 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
|
1867 ptr += yanklen; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1868 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1869 // insert block's trailing spaces only if there's text behind |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1870 if ((j < count - 1 || !shortline) && spaces) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1871 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1872 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
|
1873 ptr += spaces; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1874 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1875 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1876 // 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
|
1877 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
|
1878 ptr += bd.endspaces; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1879 // 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
|
1880 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
|
1881 (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
|
1882 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
|
1883 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1884 ++curwin->w_cursor.lnum; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1885 if (i == 0) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1886 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
|
1887 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1888 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1889 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
|
1890 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1891 // Set '[ mark. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1892 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
|
1893 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
|
1894 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1895 // adjust '] mark |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1896 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
|
1897 curbuf->b_op_end.col = bd.textcol + totlen - 1; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1898 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
|
1899 if (flags & PUT_CURSEND) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1900 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1901 colnr_T len; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1902 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1903 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
|
1904 curwin->w_cursor.col++; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1905 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1906 // 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
|
1907 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
|
1908 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
|
1909 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
|
1910 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1911 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1912 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
|
1913 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1914 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1915 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1916 // Character or Line mode |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1917 if (y_type == MCHAR) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1918 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1919 // 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
|
1920 // char |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1921 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
|
1922 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1923 if (has_mbyte) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1924 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1925 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
|
1926 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1927 // 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
|
1928 col += bytelen; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1929 if (yanklen) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1930 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1931 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
|
1932 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
|
1933 } |
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 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1936 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1937 ++col; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1938 if (yanklen) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1939 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1940 ++curwin->w_cursor.col; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1941 ++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
|
1942 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1943 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1944 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1945 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
|
1946 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1947 // 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
|
1948 else if (dir == BACKWARD) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1949 --lnum; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1950 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
|
1951 |
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
|
1952 // 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
|
1953 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
|
1954 { |
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
|
1955 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
|
1956 linenr_T start_lnum = lnum; |
18164
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 if (VIsual_active) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1959 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1960 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
|
1961 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
|
1962 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
|
1963 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
|
1964 { |
2626306efe44
patch 8.2.1511: putting a string in Visual block mode ignores multi-byte
Bram Moolenaar <Bram@vim.org>
parents:
21238
diff
changeset
|
1965 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
|
1966 |
2626306efe44
patch 8.2.1511: putting a string in Visual block mode ignores multi-byte
Bram Moolenaar <Bram@vim.org>
parents:
21238
diff
changeset
|
1967 // "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
|
1968 // 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
|
1969 // 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
|
1970 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
|
1971 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
|
1972 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
|
1973 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
|
1974 } |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1975 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1976 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1977 do { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1978 totlen = count * yanklen; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1979 if (totlen > 0) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1980 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1981 oldp = ml_get(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
|
1982 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
|
1983 { |
2626306efe44
patch 8.2.1511: putting a string in Visual block mode ignores multi-byte
Bram Moolenaar <Bram@vim.org>
parents:
21238
diff
changeset
|
1984 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
|
1985 |
2626306efe44
patch 8.2.1511: putting a string in Visual block mode ignores multi-byte
Bram Moolenaar <Bram@vim.org>
parents:
21238
diff
changeset
|
1986 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
|
1987 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
|
1988 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
|
1989 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
|
1990 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
|
1991 } |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1992 if (VIsual_active && col > (int)STRLEN(oldp)) |
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 lnum++; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1995 continue; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1996 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1997 newp = alloc(STRLEN(oldp) + totlen + 1); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1998 if (newp == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1999 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
|
2000 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
|
2001 ptr = newp + col; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2002 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
|
2003 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2004 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
|
2005 ptr += yanklen; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2006 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2007 STRMOVE(ptr, oldp + col); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2008 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
|
2009 // 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
|
2010 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
|
2011 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2012 // 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
|
2013 changed_cline_bef_curs(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2014 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
|
2015 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2016 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2017 if (VIsual_active) |
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 } while (VIsual_active && lnum <= end_lnum); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2020 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2021 if (VIsual_active) // reset lnum to the last visual line |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2022 lnum--; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2023 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2024 curbuf->b_op_end = curwin->w_cursor; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2025 // 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
|
2026 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
|
2027 ++curwin->w_cursor.col; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2028 changed_bytes(lnum, col); |
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 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2031 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2032 // 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
|
2033 // line in two. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2034 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
|
2035 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2036 i = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2037 if (y_type == MCHAR) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2038 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2039 // 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
|
2040 // 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
|
2041 // 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
|
2042 lnum = new_cursor.lnum; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2043 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
|
2044 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
|
2045 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
|
2046 if (newp == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2047 goto error; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2048 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
|
2049 STRCAT(newp, ptr); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2050 // insert second line |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2051 ml_append(lnum, newp, (colnr_T)0, FALSE); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2052 vim_free(newp); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2053 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2054 oldp = ml_get(lnum); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2055 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
|
2056 if (newp == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2057 goto error; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2058 // 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
|
2059 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
|
2060 // append to first line |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2061 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
|
2062 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
|
2063 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2064 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
|
2065 i = 1; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2066 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2067 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2068 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
|
2069 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2070 if ((y_type != MCHAR || i < y_size - 1) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2071 && ml_append(lnum, y_array[i], (colnr_T)0, FALSE) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2072 == FAIL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2073 goto error; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2074 lnum++; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2075 ++nr_lines; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2076 if (flags & PUT_FIXINDENT) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2077 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2078 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
|
2079 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
|
2080 ptr = ml_get(lnum); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2081 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
|
2082 lendiff = (int)STRLEN(ptr); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2083 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2084 if (*ptr == '#' && preprocs_left()) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2085 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
|
2086 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2087 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2088 if (*ptr == NUL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2089 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
|
2090 else if (first_indent) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2091 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2092 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
|
2093 indent = orig_indent; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2094 first_indent = FALSE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2095 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2096 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
|
2097 indent = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2098 (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
|
2099 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
|
2100 // 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
|
2101 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
|
2102 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
|
2103 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2104 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2105 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2106 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2107 error: |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2108 // Adjust marks. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2109 if (y_type == MLINE) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2110 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2111 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
|
2112 if (dir == FORWARD) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2113 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
|
2114 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2115 // Skip mark_adjust when adding lines after the last one, there |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2116 // can't be marks there. But still needed in diff mode. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2117 if (curbuf->b_op_start.lnum + (y_type == MCHAR) - 1 + nr_lines |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2118 < 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
|
2119 #ifdef FEAT_DIFF |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2120 || curwin->w_p_diff |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2121 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2122 ) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2123 mark_adjust(curbuf->b_op_start.lnum + (y_type == MCHAR), |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2124 (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
|
2125 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2126 // 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
|
2127 if (y_type == MCHAR) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2128 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
|
2129 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
|
2130 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2131 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
|
2132 curbuf->b_op_start.lnum, nr_lines); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2133 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2134 // put '] mark at last inserted character |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2135 curbuf->b_op_end.lnum = lnum; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2136 // correct length for change in indent |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2137 col = (colnr_T)STRLEN(y_array[y_size - 1]) - lendiff; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2138 if (col > 1) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2139 curbuf->b_op_end.col = col - 1; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2140 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2141 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
|
2142 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2143 if (flags & PUT_CURSLINE) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2144 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2145 // ":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
|
2146 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
|
2147 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
|
2148 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2149 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
|
2150 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2151 // 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
|
2152 if (y_type == MLINE) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2153 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2154 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
|
2155 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
|
2156 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2157 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
|
2158 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
|
2159 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2160 else |
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 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
|
2163 curwin->w_cursor.col = col; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2164 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2165 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2166 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
|
2167 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2168 // 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
|
2169 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
|
2170 if (dir == FORWARD) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2171 ++curwin->w_cursor.lnum; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2172 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
|
2173 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2174 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
|
2175 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
|
2176 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2177 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2178 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2179 msgmore(nr_lines); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2180 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
|
2181 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2182 end: |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22176
diff
changeset
|
2183 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
|
2184 { |
788d76db02ac
patch 8.1.2302: :lockmarks does not work for '[ and ']
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2185 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
|
2186 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
|
2187 } |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2188 if (allocated) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2189 vim_free(insert_string); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2190 if (regname == '=') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2191 vim_free(y_array); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2192 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2193 VIsual_active = FALSE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2194 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2195 // 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
|
2196 adjust_cursor_eol(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2197 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2198 |
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 * 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
|
2201 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2202 int |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2203 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
|
2204 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2205 if (num == -1) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2206 return '"'; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2207 else if (num < 10) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2208 return num + '0'; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2209 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
|
2210 return '-'; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2211 #ifdef FEAT_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2212 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
|
2213 return '*'; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2214 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
|
2215 return '+'; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2216 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2217 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2218 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2219 #ifdef EBCDIC |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2220 int i; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2221 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2222 // EBCDIC is really braindead ... |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2223 i = 'a' + (num - 10); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2224 if (i > 'i') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2225 i += 7; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2226 if (i > 'r') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2227 i += 8; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2228 return i; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2229 #else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2230 return num + 'a' - 10; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2231 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2232 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2233 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2234 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2235 /* |
20743
a672feb8fc4f
patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2236 * 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
|
2237 */ |
a672feb8fc4f
patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2238 int |
a672feb8fc4f
patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2239 get_unname_register() |
a672feb8fc4f
patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2240 { |
a672feb8fc4f
patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2241 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
|
2242 } |
a672feb8fc4f
patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2243 |
a672feb8fc4f
patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2244 /* |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2245 * ":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
|
2246 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2247 void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2248 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
|
2249 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2250 int i, n; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2251 long j; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2252 char_u *p; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2253 yankreg_T *yb; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2254 int name; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2255 int attr; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2256 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
|
2257 int clen; |
18454
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2258 int type; |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2259 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2260 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
|
2261 arg = NULL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2262 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
|
2263 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2264 // 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
|
2265 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
|
2266 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
|
2267 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2268 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
|
2269 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
|
2270 { |
18454
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2271 case MLINE: type = 'l'; break; |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2272 case MCHAR: type = 'c'; break; |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2273 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
|
2274 } |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2275 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
|
2276 #ifdef ONE_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2277 // 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
|
2278 && (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
|
2279 #endif |
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 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
|
2282 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2283 #ifdef FEAT_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2284 // 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
|
2285 // 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
|
2286 // of the clipboard. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2287 adjust_clip_reg(&name); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2288 (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
|
2289 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2290 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2291 if (i == -1) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2292 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2293 if (y_previous != NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2294 yb = y_previous; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2295 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2296 yb = &(y_regs[0]); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2297 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2298 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2299 yb = &(y_regs[i]); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2300 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2301 #ifdef FEAT_EVAL |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2302 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
|
2303 || (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
|
2304 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
|
2305 // pointer can be freed |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2306 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2307 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2308 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
|
2309 { |
18454
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2310 int do_show = FALSE; |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2311 |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2312 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
|
2313 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
|
2314 |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2315 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
|
2316 { |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2317 msg_putchar('\n'); |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2318 msg_puts(" "); |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2319 msg_putchar(type); |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2320 msg_puts(" "); |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2321 msg_putchar('"'); |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2322 msg_putchar(name); |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2323 msg_puts(" "); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2324 |
18454
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2325 n = (int)Columns - 11; |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2326 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
|
2327 { |
18454
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2328 if (j) |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2329 { |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2330 msg_puts_attr("^J", attr); |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2331 n -= 2; |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2332 } |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2333 for (p = yb->y_array[j]; *p && (n -= ptr2cells(p)) >= 0; |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2334 ++p) |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2335 { |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2336 clen = (*mb_ptr2len)(p); |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2337 msg_outtrans_len(p, clen); |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2338 p += clen - 1; |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2339 } |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2340 } |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2341 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
|
2342 msg_puts_attr("^J", attr); |
18454
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2343 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
|
2344 } |
18454
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2345 ui_breakcheck(); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2346 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2347 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2348 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2349 // display last inserted text |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2350 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
|
2351 && (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
|
2352 && !message_filtered(p)) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2353 { |
18436
6ec1bfb4690b
patch 8.1.2212: cannot see the selection type in :reg output
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2354 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
|
2355 dis_msg(p, TRUE); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2356 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2357 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2358 // display last command line |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2359 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
|
2360 && !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
|
2361 { |
18436
6ec1bfb4690b
patch 8.1.2212: cannot see the selection type in :reg output
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2362 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
|
2363 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
|
2364 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2365 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2366 // display current file name |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2367 if (curbuf->b_fname != NULL |
18454
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2368 && (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
|
2369 && !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
|
2370 { |
18436
6ec1bfb4690b
patch 8.1.2212: cannot see the selection type in :reg output
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2371 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
|
2372 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
|
2373 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2374 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2375 // display alternate file name |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2376 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
|
2377 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2378 char_u *fname; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2379 linenr_T dummy; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2380 |
18454
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2381 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
|
2382 && !message_filtered(fname)) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2383 { |
18436
6ec1bfb4690b
patch 8.1.2212: cannot see the selection type in :reg output
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2384 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
|
2385 dis_msg(fname, FALSE); |
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 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2388 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2389 // display last search pattern |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2390 if (last_search_pat() != NULL |
18454
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2391 && (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
|
2392 && !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
|
2393 { |
18436
6ec1bfb4690b
patch 8.1.2212: cannot see the selection type in :reg output
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2394 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
|
2395 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
|
2396 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2397 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2398 #ifdef FEAT_EVAL |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2399 // display last used expression |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2400 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
|
2401 && !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
|
2402 { |
18436
6ec1bfb4690b
patch 8.1.2212: cannot see the selection type in :reg output
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2403 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
|
2404 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
|
2405 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2406 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2407 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2408 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2409 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2410 * 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
|
2411 * 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
|
2412 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2413 static void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2414 dis_msg( |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2415 char_u *p, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2416 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
|
2417 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2418 int n; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2419 int l; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2420 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2421 n = (int)Columns - 6; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2422 while (*p != NUL |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2423 && !(*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
|
2424 && (n -= ptr2cells(p)) >= 0) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2425 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2426 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
|
2427 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2428 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
|
2429 p += l; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2430 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2431 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2432 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
|
2433 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2434 ui_breakcheck(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2435 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2436 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2437 #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
|
2438 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2439 * 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
|
2440 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2441 void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2442 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
|
2443 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2444 yankreg_T *curr; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2445 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2446 curr = y_current; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2447 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
|
2448 free_yank_all(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2449 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
|
2450 y_current = curr; |
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 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2453 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2454 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2455 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2456 * 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
|
2457 * Used for getregtype() |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2458 * Returns MAUTO for error. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2459 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2460 char_u |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2461 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
|
2462 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2463 switch (regname) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2464 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2465 case '%': // file name |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2466 case '#': // alternate file name |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2467 case '=': // expression |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2468 case ':': // last command line |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2469 case '/': // last search-pattern |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2470 case '.': // last inserted text |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2471 # ifdef FEAT_SEARCHPATH |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2472 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
|
2473 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
|
2474 # endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2475 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
|
2476 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
|
2477 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
|
2478 return MCHAR; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2479 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2480 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2481 # ifdef FEAT_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2482 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
|
2483 # endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2484 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2485 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
|
2486 return MAUTO; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2487 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2488 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
|
2489 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2490 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
|
2491 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2492 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
|
2493 *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
|
2494 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
|
2495 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2496 return MAUTO; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2497 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2498 |
18436
6ec1bfb4690b
patch 8.1.2212: cannot see the selection type in :reg output
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2499 #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
|
2500 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2501 * 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
|
2502 * Otherwise just return "s". |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2503 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2504 static char_u * |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2505 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
|
2506 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2507 if (flags & GREG_LIST) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2508 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2509 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
|
2510 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2511 if (list != NULL) |
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 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
|
2514 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2515 list_free(list); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2516 return NULL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2517 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2518 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
|
2519 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2520 return (char_u *)list; |
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 return s; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2523 } |
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 /* |
19524
4a6a412e4565
patch 8.2.0319: file missing in distribution, comments outdated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2526 * 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
|
2527 * 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
|
2528 * Returns NULL for error. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2529 * Flags: |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2530 * 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
|
2531 * 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
|
2532 * 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
|
2533 * 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
|
2534 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2535 char_u * |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2536 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
|
2537 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2538 long i; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2539 char_u *retval; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2540 int allocated; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2541 long len; |
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 // 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
|
2544 if (regname == '=') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2545 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2546 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
|
2547 return NULL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2548 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
|
2549 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
|
2550 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
|
2551 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2552 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2553 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
|
2554 regname = '"'; |
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 // check for valid regname |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2557 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
|
2558 return NULL; |
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 # ifdef FEAT_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2561 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
|
2562 # endif |
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 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
|
2565 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2566 if (retval == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2567 return NULL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2568 if (allocated) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2569 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
|
2570 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
|
2571 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2572 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2573 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
|
2574 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
|
2575 return NULL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2576 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2577 if (flags & GREG_LIST) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2578 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2579 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
|
2580 int error = FALSE; |
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 if (list == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2583 return NULL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2584 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
|
2585 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
|
2586 error = TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2587 if (error) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2588 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2589 list_free(list); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2590 return NULL; |
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 return (char_u *)list; |
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 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2595 // 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
|
2596 len = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2597 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
|
2598 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2599 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
|
2600 // 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
|
2601 // y_type is MLINE. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2602 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
|
2603 ++len; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2604 } |
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 retval = alloc(len + 1); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2607 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2608 // Copy the lines of the yank register into the string. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2609 if (retval != NULL) |
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 len = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2612 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
|
2613 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2614 STRCPY(retval + len, 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
|
2615 len += (long)STRLEN(retval + len); |
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 // Insert a NL between lines and after the last line if y_type is |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2618 // MLINE. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2619 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
|
2620 retval[len++] = '\n'; |
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 retval[len] = NUL; |
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 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2625 return retval; |
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 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2628 static int |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2629 init_write_reg( |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2630 int name, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2631 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
|
2632 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
|
2633 int must_append, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2634 int *yank_type UNUSED) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2635 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2636 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
|
2637 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2638 emsg_invreg(name); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2639 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2640 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2641 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2642 // 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
|
2643 *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
|
2644 *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
|
2645 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2646 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
|
2647 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
|
2648 free_yank_all(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2649 return OK; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2650 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2651 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2652 static void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2653 finish_write_reg( |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2654 int name, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2655 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
|
2656 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
|
2657 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2658 # ifdef FEAT_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2659 // 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
|
2660 may_set_selection(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2661 # endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2662 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2663 // ':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
|
2664 if (name != '"') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2665 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
|
2666 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
|
2667 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2668 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2669 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2670 * 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
|
2671 * "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
|
2672 * 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
|
2673 * 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
|
2674 * 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
|
2675 * 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
|
2676 * 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
|
2677 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2678 void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2679 write_reg_contents( |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2680 int name, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2681 char_u *str, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2682 int maxlen, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2683 int must_append) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2684 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2685 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
|
2686 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2687 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2688 void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2689 write_reg_contents_lst( |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2690 int name, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2691 char_u **strings, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2692 int maxlen UNUSED, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2693 int must_append, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2694 int yank_type, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2695 long block_len) |
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 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
|
2698 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2699 if (name == '/' || name == '=') |
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 char_u *s; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2702 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2703 if (strings[0] == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2704 s = (char_u *)""; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2705 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
|
2706 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2707 emsg(_("E883: search pattern and expression register may not " |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2708 "contain two or more lines")); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2709 return; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2710 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2711 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2712 s = strings[0]; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2713 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
|
2714 return; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2715 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2716 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2717 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
|
2718 return; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2719 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2720 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
|
2721 &yank_type) == FAIL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2722 return; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2723 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2724 str_to_reg(y_current, yank_type, (char_u *) strings, -1, block_len, TRUE); |
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 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
|
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 void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2730 write_reg_contents_ex( |
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 char_u *str, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2733 int maxlen, |
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, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2736 long block_len) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2737 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2738 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
|
2739 long len; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2740 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2741 if (maxlen >= 0) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2742 len = maxlen; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2743 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2744 len = (long)STRLEN(str); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2745 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2746 // Special case: '/' search pattern |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2747 if (name == '/') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2748 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2749 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
|
2750 return; |
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 if (name == '#') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2754 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2755 buf_T *buf; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2756 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2757 if (VIM_ISDIGIT(*str)) |
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 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
|
2760 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2761 buf = buflist_findnr(num); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2762 if (buf == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2763 semsg(_(e_nobufnr), (long)num); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2764 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2765 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2766 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
|
2767 TRUE, FALSE, FALSE)); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2768 if (buf == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2769 return; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2770 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
|
2771 return; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2772 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2773 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2774 if (name == '=') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2775 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2776 char_u *p, *s; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2777 |
20830
9064044fd4f6
patch 8.2.0967: unnecessary type casts for vim_strnsave()
Bram Moolenaar <Bram@vim.org>
parents:
20824
diff
changeset
|
2778 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
|
2779 if (p == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2780 return; |
18838
8dabdfc7c799
patch 8.1.2406: leaking memory in test_paste and test_registers
Bram Moolenaar <Bram@vim.org>
parents:
18771
diff
changeset
|
2781 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
|
2782 { |
18838
8dabdfc7c799
patch 8.1.2406: leaking memory in test_paste and test_registers
Bram Moolenaar <Bram@vim.org>
parents:
18771
diff
changeset
|
2783 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
|
2784 vim_free(p); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2785 p = s; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2786 } |
22732
4c21a3a47707
patch 8.2.1914: Vim9: cannot put line break in expression for '=' register
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
2787 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
|
2788 return; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2789 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2790 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2791 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
|
2792 return; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2793 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2794 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
|
2795 &yank_type) == FAIL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2796 return; |
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 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
|
2799 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2800 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
|
2801 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2802 #endif // FEAT_EVAL |
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 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
|
2805 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2806 * 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
|
2807 * is appended. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2808 */ |
19774
00a1b89256ea
patch 8.2.0443: clipboard code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
19524
diff
changeset
|
2809 void |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2810 str_to_reg( |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2811 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
|
2812 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
|
2813 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
|
2814 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
|
2815 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
|
2816 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
|
2817 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2818 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
|
2819 int lnum; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2820 long start; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2821 long i; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2822 int extra; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2823 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
|
2824 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
|
2825 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
|
2826 char_u *s; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2827 char_u **ss; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2828 char_u **pp; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2829 long maxlen; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2830 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2831 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
|
2832 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
|
2833 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2834 if (yank_type == MAUTO) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2835 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
|
2836 || str[len - 1] == CAR))) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2837 ? MLINE : MCHAR); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2838 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2839 type = yank_type; |
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 // 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
|
2842 newlines = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2843 if (str_list) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2844 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2845 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
|
2846 ++newlines; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2847 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2848 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2849 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2850 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
|
2851 if (str[i] == '\n') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2852 ++newlines; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2853 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
|
2854 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2855 extraline = 1; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2856 ++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
|
2857 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2858 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
|
2859 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2860 append = TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2861 --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
|
2862 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2863 } |
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 // 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
|
2866 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
|
2867 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2868 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
|
2869 return; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2870 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2871 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2872 // 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
|
2873 // 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
|
2874 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
|
2875 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
|
2876 return; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2877 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
|
2878 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
|
2879 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
|
2880 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
|
2881 maxlen = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2882 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2883 // 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
|
2884 if (str_list) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2885 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2886 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
|
2887 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2888 i = (long)STRLEN(*ss); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2889 pp[lnum] = vim_strnsave(*ss, i); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2890 if (i > maxlen) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2891 maxlen = i; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2892 } |
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 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2895 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2896 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
|
2897 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2898 for (i = start; i < len; ++i) // find 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
|
2899 if (str[i] == '\n') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2900 break; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2901 i -= start; // i is now length of line |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2902 if (i > maxlen) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2903 maxlen = i; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2904 if (append) |
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 --lnum; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2907 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
|
2908 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2909 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2910 extra = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2911 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
|
2912 if (s == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2913 break; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2914 if (extra) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2915 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
|
2916 if (append) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2917 vim_free(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
|
2918 if (i) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2919 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
|
2920 extra += i; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2921 s[extra] = NUL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2922 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
|
2923 while (--extra >= 0) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2924 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2925 if (*s == NUL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2926 *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
|
2927 ++s; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2928 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2929 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
|
2930 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2931 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2932 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
|
2933 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
|
2934 if (type == MBLOCK) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2935 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
|
2936 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2937 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
|
2938 # ifdef FEAT_VIMINFO |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2939 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
|
2940 # endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2941 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2942 #endif // FEAT_CLIPBOARD || FEAT_EVAL || PROTO |