Mercurial > vim
annotate src/register.c @ 25038:efdb9608cc11 v8.2.3056
patch 8.2.3056: Vim9: using default value in lambda gives confusing error
Commit: https://github.com/vim/vim/commit/14ded11fcad77ebf41032ec80a95d516ca9acb1c
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jun 26 19:25:49 2021 +0200
patch 8.2.3056: Vim9: using default value in lambda gives confusing error
Problem: Vim9: using default value in lambda gives confusing error.
Solution: Pass "default_args" on the first pass to get the arguments.
(closes #8455)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 26 Jun 2021 19:30:03 +0200 |
parents | dc3d45d9a4a8 |
children | f397a21b3e4c |
rev | line source |
---|---|
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2 * |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3 * VIM - Vi IMproved by Bram Moolenaar |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4 * |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5 * Do ":help uganda" in Vim to read copying and usage conditions. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6 * Do ":help credits" in Vim to see a list of people who contributed. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
7 * See README.txt for an overview of the Vim source code. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
8 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
9 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
10 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
11 * register.c: functions for managing registers |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
12 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
13 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
14 #include "vim.h" |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
15 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
16 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
17 * Registers: |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
18 * 0 = unnamed register, for normal yanks and puts |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
19 * 1..9 = registers '1' to '9', for deletes |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
20 * 10..35 = registers 'a' to 'z' ('A' to 'Z' for appending) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
21 * 36 = delete register '-' |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
22 * 37 = Selection register '*'. Only if FEAT_CLIPBOARD defined |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
23 * 38 = Clipboard register '+'. Only if FEAT_CLIPBOARD and FEAT_X11 defined |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
24 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
25 static yankreg_T y_regs[NUM_REGISTERS]; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
26 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
27 static yankreg_T *y_current; // ptr to current yankreg |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
28 static int y_append; // TRUE when appending |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
29 static yankreg_T *y_previous = NULL; // ptr to last written yankreg |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
30 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
31 static int stuff_yank(int, char_u *); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
32 static void put_reedit_in_typebuf(int silent); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
33 static int put_in_typebuf(char_u *s, int esc, int colon, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
34 int silent); |
24866
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24794
diff
changeset
|
35 static int yank_copy_line(struct block_def *bd, long y_idx, int exclude_trailing_space); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
36 #ifdef FEAT_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
37 static void copy_yank_reg(yankreg_T *reg); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
38 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
39 static void dis_msg(char_u *p, int skip_esc); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
40 |
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 |
24946
dc3d45d9a4a8
patch 8.2.3010: not enough testing for viminfo code
Bram Moolenaar <Bram@vim.org>
parents:
24866
diff
changeset
|
465 /* |
dc3d45d9a4a8
patch 8.2.3010: not enough testing for viminfo code
Bram Moolenaar <Bram@vim.org>
parents:
24866
diff
changeset
|
466 * Last executed register (@ command) |
dc3d45d9a4a8
patch 8.2.3010: not enough testing for viminfo code
Bram Moolenaar <Bram@vim.org>
parents:
24866
diff
changeset
|
467 */ |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
468 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
|
469 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
470 int |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
471 get_execreg_lastc(void) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
472 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
473 return execreg_lastc; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
474 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
475 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
476 void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
477 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
|
478 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
479 execreg_lastc = lastc; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
480 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
481 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
482 /* |
20891
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
483 * 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
|
484 * 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
|
485 * 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
|
486 * 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
|
487 * |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
488 * Arguments: |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
489 * 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
|
490 * 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
|
491 * 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
|
492 * 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
|
493 * character are ignored. |
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 * 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
|
496 * 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
|
497 */ |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
498 static char_u * |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
499 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
|
500 { |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
501 garray_T ga; |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
502 long i = *idx; |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
503 char_u *p; |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
504 int cmd_start; |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
505 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
|
506 int j; |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
507 char_u *str; |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
508 |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
509 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
|
510 |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
511 // 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
|
512 // 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
|
513 // command. |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
514 while (--i > 0) |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
515 { |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
516 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
|
517 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
|
518 break; |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
519 } |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
520 cmd_start = i; |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
521 |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
522 // 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
|
523 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
|
524 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
|
525 { |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
526 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
|
527 if (*p == '\\') |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
528 { |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
529 // 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
|
530 // 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
|
531 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
|
532 { |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
533 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
|
534 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
|
535 else |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
536 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
|
537 } |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
538 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
|
539 } |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
540 } |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
541 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
|
542 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
|
543 ga_clear(&ga); |
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 *idx = i; |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
546 return str; |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
547 } |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
548 |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
549 /* |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
550 * 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
|
551 * |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
552 * 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
|
553 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
554 int |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
555 do_execreg( |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
556 int regname, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
557 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
|
558 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
|
559 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
|
560 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
561 long i; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
562 char_u *p; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
563 int retval = OK; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
564 int remap; |
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 // repeat previous one |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
567 if (regname == '@') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
568 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
569 if (execreg_lastc == NUL) |
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 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
|
572 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
573 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
574 regname = execreg_lastc; |
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 // check for valid regname |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
577 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
|
578 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
579 emsg_invreg(regname); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
580 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
581 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
582 execreg_lastc = regname; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
583 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
584 #ifdef FEAT_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
585 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
|
586 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
587 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
588 // 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
|
589 if (regname == '_') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
590 return OK; |
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 // use last command line |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
593 if (regname == ':') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
594 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
595 if (last_cmdline == NULL) |
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 emsg(_(e_nolastcmd)); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
598 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
599 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
600 // 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
|
601 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
|
602 // 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
|
603 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
|
604 (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
|
605 "\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
|
606 "\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
|
607 "\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
|
608 Ctrl_V, FALSE); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
609 if (p != NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
610 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
611 // 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
|
612 // 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
|
613 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
|
614 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
|
615 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
616 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
|
617 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
618 vim_free(p); |
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 #ifdef FEAT_EVAL |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
621 else if (regname == '=') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
622 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
623 p = get_expr_line(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
624 if (p == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
625 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
626 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
|
627 vim_free(p); |
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 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
630 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
|
631 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
632 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
|
633 if (p == NULL) |
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 emsg(_(e_noinstext)); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
636 return FAIL; |
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 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
|
639 vim_free(p); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
640 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
641 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
642 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
643 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
|
644 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
|
645 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
646 |
19195
2ef19eed524a
patch 8.2.0156: various typos in source files and tests
Bram Moolenaar <Bram@vim.org>
parents:
18838
diff
changeset
|
647 // 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
|
648 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
|
649 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
650 // 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
|
651 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
|
652 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
|
653 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
654 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
|
655 char_u *str; |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
656 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
|
657 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
658 // 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
|
659 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
|
660 || addcr) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
661 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
662 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
|
663 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
664 } |
20891
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
665 |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
666 // 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
|
667 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
|
668 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
|
669 { |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
670 p = skipwhite(str); |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
671 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
|
672 { |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
673 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
|
674 if (str == NULL) |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
675 return FAIL; |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
676 free_str = TRUE; |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
677 } |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
678 } |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
679 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
|
680 if (free_str) |
4bdc07beeadb
patch 8.2.0997: cannot execute a register containing line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
681 vim_free(str); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
682 if (escaped == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
683 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
684 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
|
685 vim_free(escaped); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
686 if (retval == 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 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
|
689 == FAIL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
690 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
691 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
692 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
|
693 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
694 return retval; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
695 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
696 |
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 * 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
|
699 * 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
|
700 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
701 static void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
702 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
|
703 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
704 char_u buf[3]; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
705 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
706 if (restart_edit != NUL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
707 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
708 if (restart_edit == 'V') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
709 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
710 buf[0] = 'g'; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
711 buf[1] = 'R'; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
712 buf[2] = NUL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
713 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
714 else |
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 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
|
717 buf[1] = 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 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
|
720 restart_edit = NUL; |
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 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
723 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
724 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
725 * 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
|
726 * executed again. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
727 * 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
|
728 * no remapping. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
729 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
730 static int |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
731 put_in_typebuf( |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
732 char_u *s, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
733 int esc, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
734 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
|
735 int silent) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
736 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
737 int retval = OK; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
738 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
739 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
|
740 if (colon) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
741 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
|
742 if (retval == OK) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
743 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
744 char_u *p; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
745 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
746 if (esc) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
747 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
|
748 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
749 p = s; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
750 if (p == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
751 retval = FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
752 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
753 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
|
754 0, TRUE, silent); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
755 if (esc) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
756 vim_free(p); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
757 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
758 if (colon && retval == OK) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
759 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
|
760 return retval; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
761 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
762 |
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 * 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
|
765 * 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
|
766 * |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
767 * 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
|
768 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
769 int |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
770 insert_reg( |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
771 int regname, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
772 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
|
773 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
774 long i; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
775 int retval = OK; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
776 char_u *arg; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
777 int allocated; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
778 int literally = literally_arg; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
779 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
780 // 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
|
781 // 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
|
782 // 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
|
783 ui_breakcheck(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
784 if (got_int) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
785 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
786 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
787 // check for valid regname |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
788 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
|
789 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
790 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
791 #ifdef FEAT_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
792 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
|
793 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
794 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
795 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
|
796 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
|
797 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
|
798 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
799 if (arg == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
800 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
801 stuffescaped(arg, literally); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
802 if (allocated) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
803 vim_free(arg); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
804 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
805 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
|
806 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
807 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
|
808 literally = TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
809 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
|
810 retval = FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
811 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
812 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
813 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
|
814 { |
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
|
815 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
|
816 { |
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 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
|
818 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
|
819 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
|
820 } |
f2a70fca3485
patch 8.2.2189: cannot repeat a command that uses the small delete register
Bram Moolenaar <Bram@vim.org>
parents:
23021
diff
changeset
|
821 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
|
822 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
|
823 // 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
|
824 // y_type is MLINE. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
825 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
|
826 stuffcharReadbuff('\n'); |
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 } |
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 return retval; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
832 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
833 |
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 * 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
|
836 * value in "argp". |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
837 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
838 int |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
839 get_spec_reg( |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
840 int regname, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
841 char_u **argp, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
842 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
|
843 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
|
844 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
845 int cnt; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
846 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
847 *argp = NULL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
848 *allocated = FALSE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
849 switch (regname) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
850 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
851 case '%': // file name |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
852 if (errmsg) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
853 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
|
854 *argp = curbuf->b_fname; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
855 return TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
856 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
857 case '#': // alternate file name |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
858 *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
|
859 return TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
860 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
861 #ifdef FEAT_EVAL |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
862 case '=': // result of expression |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
863 *argp = get_expr_line(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
864 *allocated = TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
865 return TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
866 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
867 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
868 case ':': // last command line |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
869 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
|
870 emsg(_(e_nolastcmd)); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
871 *argp = last_cmdline; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
872 return TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
873 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
874 case '/': // last search-pattern |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
875 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
|
876 emsg(_(e_noprevre)); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
877 *argp = last_search_pat(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
878 return TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
879 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
880 case '.': // last inserted text |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
881 *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
|
882 *allocated = TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
883 if (*argp == NULL && errmsg) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
884 emsg(_(e_noinstext)); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
885 return TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
886 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
887 #ifdef FEAT_SEARCHPATH |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
888 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
|
889 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
|
890 if (!errmsg) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
891 return FALSE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
892 *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
|
893 | (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
|
894 *allocated = TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
895 return TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
896 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
897 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
898 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
|
899 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
|
900 if (!errmsg) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
901 return FALSE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
902 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
|
903 ? (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
|
904 *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
|
905 *allocated = TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
906 return TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
907 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
908 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
|
909 if (!errmsg) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
910 return FALSE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
911 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
912 *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
|
913 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
|
914 return TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
915 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
916 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
|
917 *argp = (char_u *)""; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
918 return TRUE; |
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 return FALSE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
922 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
923 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
924 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
925 * 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
|
926 * 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
|
927 * 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
|
928 * 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
|
929 * 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
|
930 * |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
931 * 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
|
932 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
933 int |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
934 cmdline_paste_reg( |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
935 int regname, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
936 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
|
937 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
|
938 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
939 long i; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
940 int literally = literally_arg; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
941 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
942 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
|
943 literally = TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
944 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
|
945 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
946 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
947 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
|
948 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
949 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
|
950 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
951 // 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
|
952 // 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
|
953 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
|
954 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
|
955 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
956 // 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
|
957 // lines and gets bored. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
958 ui_breakcheck(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
959 if (got_int) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
960 return FAIL; |
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 return OK; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
963 } |
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 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
966 * 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
|
967 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
968 void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
969 shift_delete_registers() |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
970 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
971 int n; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
972 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
973 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
|
974 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
|
975 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
|
976 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
|
977 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
|
978 if (!y_append) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
979 y_previous = y_current; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
980 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
|
981 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
982 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
983 #if defined(FEAT_EVAL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
984 void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
985 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
|
986 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
987 static int recursive = FALSE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
988 dict_T *v_event; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
989 list_T *list; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
990 int n; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
991 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
|
992 long reglen = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
993 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
994 if (recursive) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
995 return; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
996 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
997 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
|
998 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
999 list = list_alloc(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1000 if (list == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1001 return; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1002 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
|
1003 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
|
1004 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
|
1005 (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
|
1006 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1007 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
|
1008 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
|
1009 (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
|
1010 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1011 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
|
1012 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
|
1013 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
|
1014 (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
|
1015 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1016 buf[0] = NUL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1017 buf[1] = NUL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1018 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
|
1019 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1020 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
|
1021 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
|
1022 case MBLOCK: |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1023 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
|
1024 reglen + 1); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1025 break; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1026 } |
21068
ac493e63b192
patch 8.2.1085: Coverity complains about ignoring dict_add() return value
Bram Moolenaar <Bram@vim.org>
parents:
20996
diff
changeset
|
1027 (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
|
1028 |
21068
ac493e63b192
patch 8.2.1085: Coverity complains about ignoring dict_add() return value
Bram Moolenaar <Bram@vim.org>
parents:
20996
diff
changeset
|
1029 (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
|
1030 |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1031 // 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
|
1032 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
|
1033 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1034 recursive = TRUE; |
20229
06a1dd50463e
patch 8.2.0670: cannot change window when evaluating 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
19774
diff
changeset
|
1035 textwinlock++; |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1036 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
|
1037 textwinlock--; |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1038 recursive = FALSE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1039 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1040 // 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
|
1041 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
|
1042 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
|
1043 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1044 #endif |
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 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1047 * 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
|
1048 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1049 void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1050 init_yank(void) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1051 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1052 int i; |
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 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
|
1055 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
|
1056 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1057 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1058 #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
|
1059 void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1060 clear_registers(void) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1061 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1062 int i; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1063 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1064 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
|
1065 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1066 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
|
1067 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
|
1068 free_yank_all(); |
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 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1072 |
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 * 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
|
1075 * 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
|
1076 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1077 static void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1078 free_yank(long n) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1079 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1080 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
|
1081 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1082 long i; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1083 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1084 for (i = n; --i >= 0; ) |
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 #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
|
1087 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
|
1088 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1089 // 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
|
1090 // 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
|
1091 ++no_wait_return; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1092 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
|
1093 --no_wait_return; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1094 msg_didout = FALSE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1095 msg_col = 0; |
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 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1098 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
|
1099 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1100 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
|
1101 #ifdef AMIGA |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1102 if (n >= 1000) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1103 msg(""); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1104 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1105 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1106 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1107 |
19774
00a1b89256ea
patch 8.2.0443: clipboard code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
19524
diff
changeset
|
1108 void |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1109 free_yank_all(void) |
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 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
|
1112 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1113 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1114 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1115 * 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
|
1116 * 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
|
1117 * 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
|
1118 * 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
|
1119 * |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1120 * 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
|
1121 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1122 int |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1123 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
|
1124 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1125 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
|
1126 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
|
1127 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
|
1128 char_u **new_ptr; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1129 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
|
1130 long j; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1131 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
|
1132 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
|
1133 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
|
1134 char_u *p; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1135 char_u *pnew; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1136 struct block_def bd; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1137 #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
|
1138 int did_star = FALSE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1139 #endif |
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 // 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
|
1142 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
|
1143 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1144 beep_flush(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1145 return FAIL; |
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 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
|
1148 return OK; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1149 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1150 #ifdef FEAT_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1151 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
|
1152 oap->regname = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1153 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
|
1154 oap->regname = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1155 #endif |
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 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
|
1158 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
|
1159 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1160 curr = y_current; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1161 // append to existing contents |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1162 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
|
1163 y_current = &newreg; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1164 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1165 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
|
1166 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1167 // 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
|
1168 // 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
|
1169 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
|
1170 && oap->start.col == 0 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1171 && !oap->inclusive |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1172 && (!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
|
1173 && !oap->block_mode |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1174 && oap->end.col == 0 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1175 && yanklines > 1) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1176 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1177 yanktype = MLINE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1178 --yankendlnum; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1179 --yanklines; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1180 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1181 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1182 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
|
1183 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
|
1184 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
|
1185 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
|
1186 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
|
1187 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1188 y_current = curr; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1189 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1190 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1191 #ifdef FEAT_VIMINFO |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1192 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
|
1193 #endif |
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 y_idx = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1196 lnum = oap->start.lnum; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1197 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1198 if (oap->block_mode) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1199 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1200 // Visual block mode |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1201 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
|
1202 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
|
1203 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1204 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
|
1205 y_current->y_width--; |
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 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1208 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
|
1209 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1210 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
|
1211 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1212 case MBLOCK: |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1213 block_prep(oap, &bd, lnum, FALSE); |
24866
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24794
diff
changeset
|
1214 if (yank_copy_line(&bd, y_idx, oap->excl_tr_ws) == FAIL) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1215 goto fail; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1216 break; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1217 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1218 case MLINE: |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1219 if ((y_current->y_array[y_idx] = |
24866
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24794
diff
changeset
|
1220 vim_strsave(ml_get(lnum))) == NULL) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1221 goto fail; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1222 break; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1223 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1224 case MCHAR: |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1225 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1226 colnr_T startcol = 0, endcol = MAXCOL; |
24866
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24794
diff
changeset
|
1227 int is_oneChar = FALSE; |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1228 colnr_T cs, ce; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1229 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1230 p = ml_get(lnum); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1231 bd.startspaces = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1232 bd.endspaces = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1233 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1234 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
|
1235 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1236 startcol = oap->start.col; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1237 if (virtual_op) |
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 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
|
1240 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
|
1241 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1242 // 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
|
1243 // double-count it. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1244 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
|
1245 - oap->start.coladd; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1246 startcol++; |
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 } |
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 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1251 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
|
1252 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1253 endcol = oap->end.col; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1254 if (virtual_op) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1255 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1256 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
|
1257 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
|
1258 // 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
|
1259 // 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
|
1260 // of multi-byte char. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1261 && (*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
|
1262 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1263 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
|
1264 && 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
|
1265 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1266 // 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
|
1267 is_oneChar = TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1268 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
|
1269 - 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
|
1270 endcol = startcol; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1271 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1272 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1273 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1274 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
|
1275 + oap->inclusive; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1276 endcol -= oap->inclusive; |
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 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1279 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1280 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1281 if (endcol == MAXCOL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1282 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
|
1283 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
|
1284 bd.textlen = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1285 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1286 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
|
1287 bd.textstart = p + startcol; |
24866
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24794
diff
changeset
|
1288 if (yank_copy_line(&bd, y_idx, FALSE) == FAIL) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1289 goto fail; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1290 break; |
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 // NOTREACHED |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1293 } |
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 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1296 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
|
1297 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1298 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
|
1299 if (new_ptr == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1300 goto fail; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1301 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
|
1302 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
|
1303 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
|
1304 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
|
1305 #ifdef FEAT_VIMINFO |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1306 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
|
1307 #endif |
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 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
|
1310 curr->y_type = MLINE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1311 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1312 // 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
|
1313 // 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
|
1314 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
|
1315 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1316 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
|
1317 + 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
|
1318 if (pnew == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1319 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1320 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
|
1321 goto fail; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1322 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1323 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
|
1324 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
|
1325 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
|
1326 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
|
1327 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
|
1328 y_idx = 1; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1329 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1330 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1331 y_idx = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1332 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
|
1333 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
|
1334 curr->y_size = j; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1335 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
|
1336 y_current = curr; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1337 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1338 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
|
1339 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
|
1340 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
|
1341 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1342 if (yanktype == MCHAR |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1343 && !oap->block_mode |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1344 && yanklines == 1) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1345 yanklines = 0; |
18498
9e6d5a4abb1c
patch 8.1.2243: typos in comments
Bram Moolenaar <Bram@vim.org>
parents:
18454
diff
changeset
|
1346 // 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
|
1347 if (yanklines > p_report) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1348 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1349 char namebuf[100]; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1350 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1351 if (oap->regname == NUL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1352 *namebuf = NUL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1353 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1354 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
|
1355 _(" into \"%c"), oap->regname); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1356 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1357 // 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
|
1358 update_topline_redraw(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1359 if (oap->block_mode) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1360 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1361 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
|
1362 "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
|
1363 yanklines, namebuf); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1364 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1365 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1366 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1367 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
|
1368 "%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
|
1369 yanklines, namebuf); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1370 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1371 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1372 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1373 |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22176
diff
changeset
|
1374 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
|
1375 { |
18619
788d76db02ac
patch 8.1.2302: :lockmarks does not work for '[ and ']
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1376 // Set "'[" and "']" marks. |
788d76db02ac
patch 8.1.2302: :lockmarks does not work for '[ and ']
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1377 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
|
1378 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
|
1379 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
|
1380 { |
788d76db02ac
patch 8.1.2302: :lockmarks does not work for '[ and ']
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1381 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
|
1382 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
|
1383 } |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1384 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1385 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1386 #ifdef FEAT_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1387 // 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
|
1388 // 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
|
1389 // to the '*' register. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1390 if (clip_star.available |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1391 && (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
|
1392 || (!deleting && oap->regname == 0 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1393 && ((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
|
1394 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1395 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
|
1396 // 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
|
1397 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
|
1398 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1399 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
|
1400 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
|
1401 # ifdef FEAT_X11 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1402 did_star = TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1403 # endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1404 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1405 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1406 # ifdef FEAT_X11 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1407 // If we were yanking to the '+' register, send result to selection. |
24041
580ee78577e9
patch 8.2.2562: GUI: star register changed when 'clipboard is "unnamedplus"
Bram Moolenaar <Bram@vim.org>
parents:
23287
diff
changeset
|
1408 // Also copy to the '*' register, in case auto-select is off. But not when |
580ee78577e9
patch 8.2.2562: GUI: star register changed when 'clipboard is "unnamedplus"
Bram Moolenaar <Bram@vim.org>
parents:
23287
diff
changeset
|
1409 // 'clipboard' has "unnamedplus" and not "unnamed". |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1410 if (clip_plus.available |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1411 && (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
|
1412 || (!deleting && oap->regname == 0 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1413 && ((clip_unnamed | clip_unnamed_saved) & |
24041
580ee78577e9
patch 8.2.2562: GUI: star register changed when 'clipboard is "unnamedplus"
Bram Moolenaar <Bram@vim.org>
parents:
23287
diff
changeset
|
1414 CLIP_UNNAMED_PLUS)))) |
18164
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 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
|
1417 // 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
|
1418 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
|
1419 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1420 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
|
1421 clip_gen_set_selection(&clip_plus); |
24041
580ee78577e9
patch 8.2.2562: GUI: star register changed when 'clipboard is "unnamedplus"
Bram Moolenaar <Bram@vim.org>
parents:
23287
diff
changeset
|
1422 if (!clip_isautosel_star() |
580ee78577e9
patch 8.2.2562: GUI: star register changed when 'clipboard is "unnamedplus"
Bram Moolenaar <Bram@vim.org>
parents:
23287
diff
changeset
|
1423 && !clip_isautosel_plus() |
580ee78577e9
patch 8.2.2562: GUI: star register changed when 'clipboard is "unnamedplus"
Bram Moolenaar <Bram@vim.org>
parents:
23287
diff
changeset
|
1424 && !((clip_unnamed | clip_unnamed_saved) == CLIP_UNNAMED_PLUS) |
580ee78577e9
patch 8.2.2562: GUI: star register changed when 'clipboard is "unnamedplus"
Bram Moolenaar <Bram@vim.org>
parents:
23287
diff
changeset
|
1425 && !did_star |
580ee78577e9
patch 8.2.2562: GUI: star register changed when 'clipboard is "unnamedplus"
Bram Moolenaar <Bram@vim.org>
parents:
23287
diff
changeset
|
1426 && curr == &(y_regs[PLUS_REGISTER])) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1427 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1428 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
|
1429 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
|
1430 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
|
1431 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1432 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1433 # endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1434 #endif |
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 #if defined(FEAT_EVAL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1437 if (!deleting && has_textyankpost()) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1438 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
|
1439 #endif |
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 return OK; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1442 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1443 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
|
1444 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
|
1445 y_current = curr; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1446 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1447 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1448 |
24866
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24794
diff
changeset
|
1449 /* |
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24794
diff
changeset
|
1450 * Copy a block range into a register. |
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24794
diff
changeset
|
1451 * If "exclude_trailing_space" is set, do not copy trailing whitespaces. |
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24794
diff
changeset
|
1452 */ |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1453 static int |
24866
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24794
diff
changeset
|
1454 yank_copy_line(struct block_def *bd, long y_idx, int exclude_trailing_space) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1455 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1456 char_u *pnew; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1457 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1458 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
|
1459 == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1460 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1461 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
|
1462 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
|
1463 pnew += bd->startspaces; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1464 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
|
1465 pnew += bd->textlen; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1466 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
|
1467 pnew += bd->endspaces; |
24866
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24794
diff
changeset
|
1468 if (exclude_trailing_space) |
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24794
diff
changeset
|
1469 { |
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24794
diff
changeset
|
1470 int s = bd->textlen + bd->endspaces; |
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24794
diff
changeset
|
1471 |
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24794
diff
changeset
|
1472 while (VIM_ISWHITE(*(bd->textstart + s - 1)) && s > 0) |
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24794
diff
changeset
|
1473 { |
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24794
diff
changeset
|
1474 s = s - (*mb_head_off)(bd->textstart, bd->textstart + s - 1) - 1; |
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24794
diff
changeset
|
1475 pnew--; |
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24794
diff
changeset
|
1476 } |
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24794
diff
changeset
|
1477 } |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1478 *pnew = NUL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1479 return OK; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1480 } |
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 #ifdef FEAT_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1483 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1484 * 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
|
1485 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1486 static void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1487 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
|
1488 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1489 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
|
1490 long j; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1491 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1492 y_current = reg; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1493 free_yank_all(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1494 *y_current = *curr; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1495 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
|
1496 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
|
1497 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
|
1498 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
|
1499 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1500 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
|
1501 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
|
1502 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1503 free_yank(j); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1504 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
|
1505 break; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1506 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1507 y_current = curr; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1508 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1509 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1510 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1511 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1512 * 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
|
1513 * 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
|
1514 * "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
|
1515 * 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
|
1516 * PUT_LINE force linewise put (":put") |
24752
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24041
diff
changeset
|
1517 * PUT_BLOCK_INNER in block mode, do not add trailing spaces |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1518 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1519 void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1520 do_put( |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1521 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
|
1522 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
|
1523 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
|
1524 long count, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1525 int flags) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1526 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1527 char_u *ptr; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1528 char_u *newp, *oldp; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1529 int yanklen; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1530 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
|
1531 linenr_T lnum; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1532 colnr_T col; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1533 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
|
1534 int y_type; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1535 long y_size; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1536 int oldlen; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1537 long y_width = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1538 colnr_T vcol; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1539 int delcount; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1540 int incr = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1541 long j; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1542 struct block_def bd; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1543 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
|
1544 long nr_lines = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1545 pos_T new_cursor; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1546 int indent; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1547 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
|
1548 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
|
1549 int first_indent = TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1550 int lendiff = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1551 pos_T old_pos; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1552 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
|
1553 int allocated = FALSE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1554 long cnt; |
18619
788d76db02ac
patch 8.1.2302: :lockmarks does not work for '[ and ']
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1555 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
|
1556 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
|
1557 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1558 #ifdef FEAT_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1559 // 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
|
1560 adjust_clip_reg(®name); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1561 (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
|
1562 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1563 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1564 if (flags & PUT_FIXINDENT) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1565 orig_indent = get_indent(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1566 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1567 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
|
1568 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
|
1569 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1570 // 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
|
1571 // special characters (newlines, etc.). |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1572 if (regname == '.') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1573 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1574 if (VIsual_active) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1575 stuffcharReadbuff(VIsual_mode); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1576 (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
|
1577 (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
|
1578 // 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
|
1579 // 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
|
1580 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
|
1581 stuffcharReadbuff('l'); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1582 return; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1583 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1584 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1585 // 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
|
1586 // ':' (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
|
1587 // 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
|
1588 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
|
1589 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
|
1590 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
|
1591 && 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
|
1592 return; |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1593 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1594 // 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
|
1595 // 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
|
1596 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
|
1597 goto end; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1598 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1599 if (insert_string != NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1600 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1601 y_type = MCHAR; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1602 #ifdef FEAT_EVAL |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1603 if (regname == '=') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1604 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1605 // 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
|
1606 // characters. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1607 // 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
|
1608 for (;;) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1609 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1610 y_size = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1611 ptr = insert_string; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1612 while (ptr != NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1613 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1614 if (y_array != NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1615 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
|
1616 ++y_size; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1617 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
|
1618 if (ptr != NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1619 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1620 if (y_array != NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1621 *ptr = NUL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1622 ++ptr; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1623 // 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
|
1624 if (*ptr == NUL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1625 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1626 y_type = MLINE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1627 break; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1628 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1629 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1630 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1631 if (y_array != NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1632 break; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1633 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
|
1634 if (y_array == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1635 goto end; |
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 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1638 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1639 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1640 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1641 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
|
1642 y_array = &insert_string; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1643 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1644 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1645 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1646 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1647 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
|
1648 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1649 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
|
1650 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
|
1651 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
|
1652 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
|
1653 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1654 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1655 if (y_type == MLINE) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1656 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1657 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
|
1658 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1659 char_u *p; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1660 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1661 // "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
|
1662 // between. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1663 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
|
1664 goto end; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1665 p = ml_get_cursor(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1666 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
|
1667 MB_PTR_ADV(p); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1668 ptr = vim_strsave(p); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1669 if (ptr == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1670 goto end; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1671 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
|
1672 vim_free(ptr); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1673 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1674 oldp = ml_get_curline(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1675 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
|
1676 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
|
1677 MB_PTR_ADV(p); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1678 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
|
1679 if (ptr == NULL) |
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 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
|
1682 ++nr_lines; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1683 dir = FORWARD; |
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 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
|
1686 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1687 // 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
|
1688 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
|
1689 dir = FORWARD; |
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 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
|
1692 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
|
1693 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1694 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1695 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
|
1696 y_type = MLINE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1697 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1698 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
|
1699 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1700 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
|
1701 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
|
1702 goto end; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1703 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1704 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1705 if (y_type == MBLOCK) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1706 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1707 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
|
1708 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
|
1709 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
|
1710 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
|
1711 goto end; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1712 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1713 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
|
1714 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1715 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
|
1716 #ifdef FEAT_FOLDING |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1717 // 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
|
1718 // u_save() uses it. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1719 if (dir == BACKWARD) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1720 (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
|
1721 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1722 (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
|
1723 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1724 if (dir == FORWARD) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1725 ++lnum; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1726 // 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
|
1727 // 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
|
1728 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
|
1729 goto end; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1730 #ifdef FEAT_FOLDING |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1731 if (dir == FORWARD) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1732 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
|
1733 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1734 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
|
1735 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
|
1736 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1737 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1738 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
|
1739 goto end; |
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 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
|
1742 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1743 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
|
1744 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1745 if (gchar_cursor() == TAB) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1746 { |
18771
50fde4e20790
patch 8.1.2375: no suffucient testing for registers
Bram Moolenaar <Bram@vim.org>
parents:
18619
diff
changeset
|
1747 int viscol = getviscol(); |
50fde4e20790
patch 8.1.2375: no suffucient testing for registers
Bram Moolenaar <Bram@vim.org>
parents:
18619
diff
changeset
|
1748 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
|
1749 |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1750 // 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
|
1751 // 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
|
1752 if (dir == FORWARD ? |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1753 #ifdef FEAT_VARTABS |
18771
50fde4e20790
patch 8.1.2375: no suffucient testing for registers
Bram Moolenaar <Bram@vim.org>
parents:
18619
diff
changeset
|
1754 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
|
1755 #else |
50fde4e20790
patch 8.1.2375: no suffucient testing for registers
Bram Moolenaar <Bram@vim.org>
parents:
18619
diff
changeset
|
1756 ts - (viscol % ts) != 1 |
50fde4e20790
patch 8.1.2375: no suffucient testing for registers
Bram Moolenaar <Bram@vim.org>
parents:
18619
diff
changeset
|
1757 #endif |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1758 : 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
|
1759 coladvance_force(viscol); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1760 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1761 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
|
1762 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1763 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
|
1764 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
|
1765 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1766 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1767 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
|
1768 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
|
1769 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1770 // Block mode |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1771 if (y_type == MBLOCK) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1772 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1773 int c = gchar_cursor(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1774 colnr_T endcol2 = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1775 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1776 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
|
1777 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1778 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
|
1779 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
|
1780 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1781 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
|
1782 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1783 if (has_mbyte) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1784 // 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
|
1785 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
|
1786 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1787 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
|
1788 ++curwin->w_cursor.col; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1789 ++col; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1790 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1791 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1792 getvcol(curwin, &curwin->w_cursor, &col, NULL, &endcol2); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1793 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1794 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
|
1795 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
|
1796 && (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
|
1797 || 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
|
1798 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1799 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
|
1800 ++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
|
1801 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
|
1802 ++curwin->w_cursor.col; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1803 if (c == TAB) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1804 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1805 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
|
1806 curwin->w_cursor.col--; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1807 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
|
1808 curwin->w_cursor.col++; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1809 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1810 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1811 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
|
1812 bd.textcol = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1813 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
|
1814 { |
24752
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24041
diff
changeset
|
1815 int spaces = 0; |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1816 char shortline; |
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.startspaces = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1819 bd.endspaces = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1820 vcol = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1821 delcount = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1822 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1823 // add a new line |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1824 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
|
1825 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1826 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
|
1827 (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
|
1828 break; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1829 ++nr_lines; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1830 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1831 // 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
|
1832 oldp = ml_get_curline(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1833 oldlen = (int)STRLEN(oldp); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1834 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
|
1835 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1836 // 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
|
1837 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
|
1838 vcol += incr; |
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 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
|
1841 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1842 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
|
1843 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1844 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
|
1845 bd.startspaces = col - vcol; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1846 else if (vcol > col) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1847 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1848 bd.endspaces = vcol - col; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1849 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
|
1850 --bd.textcol; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1851 delcount = 1; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1852 if (has_mbyte) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1853 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
|
1854 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
|
1855 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1856 // 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
|
1857 // 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
|
1858 // block, causing misalignment. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1859 delcount = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1860 bd.endspaces = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1861 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1862 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1863 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1864 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
|
1865 |
24752
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24041
diff
changeset
|
1866 if ((flags & PUT_BLOCK_INNER) == 0) |
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24041
diff
changeset
|
1867 { |
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24041
diff
changeset
|
1868 // calculate number of spaces required to fill right side of |
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24041
diff
changeset
|
1869 // block |
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24041
diff
changeset
|
1870 spaces = y_width + 1; |
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24041
diff
changeset
|
1871 for (j = 0; j < yanklen; j++) |
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24041
diff
changeset
|
1872 spaces -= lbr_chartabsize(NULL, &y_array[i][j], 0); |
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24041
diff
changeset
|
1873 if (spaces < 0) |
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24041
diff
changeset
|
1874 spaces = 0; |
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24041
diff
changeset
|
1875 } |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1876 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1877 // insert the new text |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1878 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
|
1879 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
|
1880 if (newp == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1881 break; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1882 // 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
|
1883 ptr = newp; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1884 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
|
1885 ptr += bd.textcol; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1886 // 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
|
1887 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
|
1888 ptr += bd.startspaces; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1889 // insert the new text |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1890 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
|
1891 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1892 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
|
1893 ptr += yanklen; |
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 // 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
|
1896 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
|
1897 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1898 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
|
1899 ptr += spaces; |
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 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1902 // 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
|
1903 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
|
1904 ptr += bd.endspaces; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1905 // 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
|
1906 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
|
1907 (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
|
1908 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
|
1909 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1910 ++curwin->w_cursor.lnum; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1911 if (i == 0) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1912 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
|
1913 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1914 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1915 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
|
1916 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1917 // Set '[ mark. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1918 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
|
1919 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
|
1920 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1921 // adjust '] mark |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1922 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
|
1923 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
|
1924 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
|
1925 if (flags & PUT_CURSEND) |
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 colnr_T len; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1928 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1929 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
|
1930 curwin->w_cursor.col++; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1931 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1932 // 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
|
1933 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
|
1934 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
|
1935 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
|
1936 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1937 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1938 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
|
1939 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1940 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1941 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1942 // Character or Line mode |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1943 if (y_type == MCHAR) |
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 // 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
|
1946 // char |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1947 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
|
1948 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1949 if (has_mbyte) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1950 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1951 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
|
1952 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1953 // 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
|
1954 col += bytelen; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1955 if (yanklen) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1956 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1957 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
|
1958 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
|
1959 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1960 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1961 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1962 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1963 ++col; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1964 if (yanklen) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1965 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1966 ++curwin->w_cursor.col; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1967 ++curbuf->b_op_end.col; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1968 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1969 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1970 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1971 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
|
1972 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1973 // 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
|
1974 else if (dir == BACKWARD) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1975 --lnum; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1976 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
|
1977 |
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
|
1978 // 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
|
1979 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
|
1980 { |
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
|
1981 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
|
1982 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
|
1983 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1984 if (VIsual_active) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1985 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1986 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
|
1987 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
|
1988 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
|
1989 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
|
1990 { |
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 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
|
1992 |
2626306efe44
patch 8.2.1511: putting a string in Visual block mode ignores multi-byte
Bram Moolenaar <Bram@vim.org>
parents:
21238
diff
changeset
|
1993 // "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
|
1994 // 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
|
1995 // 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
|
1996 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
|
1997 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
|
1998 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
|
1999 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
|
2000 } |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2001 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2002 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2003 do { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2004 totlen = count * yanklen; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2005 if (totlen > 0) |
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 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
|
2008 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
|
2009 { |
2626306efe44
patch 8.2.1511: putting a string in Visual block mode ignores multi-byte
Bram Moolenaar <Bram@vim.org>
parents:
21238
diff
changeset
|
2010 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
|
2011 |
2626306efe44
patch 8.2.1511: putting a string in Visual block mode ignores multi-byte
Bram Moolenaar <Bram@vim.org>
parents:
21238
diff
changeset
|
2012 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
|
2013 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
|
2014 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
|
2015 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
|
2016 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
|
2017 } |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2018 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
|
2019 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2020 lnum++; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2021 continue; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2022 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2023 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
|
2024 if (newp == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2025 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
|
2026 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
|
2027 ptr = newp + col; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2028 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
|
2029 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2030 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
|
2031 ptr += yanklen; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2032 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2033 STRMOVE(ptr, oldp + col); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2034 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
|
2035 // 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
|
2036 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
|
2037 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2038 // 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
|
2039 changed_cline_bef_curs(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2040 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
|
2041 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2042 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2043 if (VIsual_active) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2044 lnum++; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2045 } 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
|
2046 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2047 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
|
2048 lnum--; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2049 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2050 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
|
2051 // 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
|
2052 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
|
2053 ++curwin->w_cursor.col; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2054 changed_bytes(lnum, col); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2055 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2056 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2057 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2058 // 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
|
2059 // line in two. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2060 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
|
2061 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2062 i = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2063 if (y_type == MCHAR) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2064 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2065 // 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
|
2066 // 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
|
2067 // 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
|
2068 lnum = new_cursor.lnum; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2069 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
|
2070 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
|
2071 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
|
2072 if (newp == NULL) |
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 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
|
2075 STRCAT(newp, ptr); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2076 // insert second line |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2077 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
|
2078 vim_free(newp); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2079 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2080 oldp = ml_get(lnum); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2081 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
|
2082 if (newp == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2083 goto error; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2084 // 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
|
2085 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
|
2086 // append to first line |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2087 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
|
2088 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
|
2089 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2090 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
|
2091 i = 1; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2092 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2093 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2094 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
|
2095 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2096 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
|
2097 && 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
|
2098 == FAIL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2099 goto error; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2100 lnum++; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2101 ++nr_lines; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2102 if (flags & PUT_FIXINDENT) |
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 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
|
2105 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
|
2106 ptr = ml_get(lnum); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2107 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
|
2108 lendiff = (int)STRLEN(ptr); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2109 #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
|
2110 if (*ptr == '#' && preprocs_left()) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2111 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
|
2112 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2113 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2114 if (*ptr == NUL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2115 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
|
2116 else if (first_indent) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2117 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2118 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
|
2119 indent = orig_indent; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2120 first_indent = FALSE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2121 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2122 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
|
2123 indent = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2124 (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
|
2125 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
|
2126 // 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
|
2127 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
|
2128 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
|
2129 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2130 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2131 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2132 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2133 error: |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2134 // Adjust marks. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2135 if (y_type == MLINE) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2136 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2137 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
|
2138 if (dir == FORWARD) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2139 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
|
2140 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2141 // 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
|
2142 // 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
|
2143 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
|
2144 < 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
|
2145 #ifdef FEAT_DIFF |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2146 || curwin->w_p_diff |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2147 #endif |
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 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
|
2150 (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
|
2151 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2152 // 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
|
2153 if (y_type == MCHAR) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2154 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
|
2155 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
|
2156 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2157 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
|
2158 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
|
2159 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2160 // 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
|
2161 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
|
2162 // 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
|
2163 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
|
2164 if (col > 1) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2165 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
|
2166 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2167 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
|
2168 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2169 if (flags & PUT_CURSLINE) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2170 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2171 // ":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
|
2172 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
|
2173 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
|
2174 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2175 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
|
2176 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2177 // 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
|
2178 if (y_type == MLINE) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2179 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2180 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
|
2181 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
|
2182 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2183 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
|
2184 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
|
2185 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2186 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2187 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2188 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
|
2189 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
|
2190 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2191 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2192 else if (y_type == MLINE) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2193 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2194 // 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
|
2195 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
|
2196 if (dir == FORWARD) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2197 ++curwin->w_cursor.lnum; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2198 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
|
2199 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2200 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
|
2201 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
|
2202 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2203 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2204 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2205 msgmore(nr_lines); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2206 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
|
2207 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2208 end: |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22176
diff
changeset
|
2209 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
|
2210 { |
788d76db02ac
patch 8.1.2302: :lockmarks does not work for '[ and ']
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2211 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
|
2212 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
|
2213 } |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2214 if (allocated) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2215 vim_free(insert_string); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2216 if (regname == '=') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2217 vim_free(y_array); |
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 VIsual_active = FALSE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2220 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2221 // 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
|
2222 adjust_cursor_eol(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2223 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2224 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2225 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2226 * 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
|
2227 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2228 int |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2229 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
|
2230 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2231 if (num == -1) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2232 return '"'; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2233 else if (num < 10) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2234 return num + '0'; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2235 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
|
2236 return '-'; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2237 #ifdef FEAT_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2238 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
|
2239 return '*'; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2240 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
|
2241 return '+'; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2242 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2243 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2244 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2245 #ifdef EBCDIC |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2246 int i; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2247 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2248 // EBCDIC is really braindead ... |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2249 i = 'a' + (num - 10); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2250 if (i > 'i') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2251 i += 7; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2252 if (i > 'r') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2253 i += 8; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2254 return i; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2255 #else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2256 return num + 'a' - 10; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2257 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2258 } |
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 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2261 /* |
20743
a672feb8fc4f
patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2262 * 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
|
2263 */ |
a672feb8fc4f
patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2264 int |
a672feb8fc4f
patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2265 get_unname_register() |
a672feb8fc4f
patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2266 { |
a672feb8fc4f
patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2267 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
|
2268 } |
a672feb8fc4f
patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2269 |
a672feb8fc4f
patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2270 /* |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2271 * ":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
|
2272 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2273 void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2274 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
|
2275 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2276 int i, n; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2277 long j; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2278 char_u *p; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2279 yankreg_T *yb; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2280 int name; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2281 int attr; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2282 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
|
2283 int clen; |
18454
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2284 int type; |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2285 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2286 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
|
2287 arg = NULL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2288 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
|
2289 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2290 // 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
|
2291 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
|
2292 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
|
2293 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2294 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
|
2295 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
|
2296 { |
18454
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2297 case MLINE: type = 'l'; break; |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2298 case MCHAR: type = 'c'; break; |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2299 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
|
2300 } |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2301 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
|
2302 #ifdef ONE_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2303 // 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
|
2304 && (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
|
2305 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2306 ) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2307 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
|
2308 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2309 #ifdef FEAT_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2310 // 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
|
2311 // 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
|
2312 // of the clipboard. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2313 adjust_clip_reg(&name); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2314 (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
|
2315 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2316 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2317 if (i == -1) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2318 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2319 if (y_previous != NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2320 yb = y_previous; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2321 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2322 yb = &(y_regs[0]); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2323 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2324 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2325 yb = &(y_regs[i]); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2326 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2327 #ifdef FEAT_EVAL |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2328 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
|
2329 || (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
|
2330 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
|
2331 // pointer can be freed |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2332 #endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2333 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2334 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
|
2335 { |
18454
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2336 int do_show = FALSE; |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2337 |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2338 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
|
2339 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
|
2340 |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2341 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
|
2342 { |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2343 msg_putchar('\n'); |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2344 msg_puts(" "); |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2345 msg_putchar(type); |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2346 msg_puts(" "); |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2347 msg_putchar('"'); |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2348 msg_putchar(name); |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2349 msg_puts(" "); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2350 |
18454
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2351 n = (int)Columns - 11; |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2352 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
|
2353 { |
18454
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2354 if (j) |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2355 { |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2356 msg_puts_attr("^J", attr); |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2357 n -= 2; |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2358 } |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2359 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
|
2360 ++p) |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2361 { |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2362 clen = (*mb_ptr2len)(p); |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2363 msg_outtrans_len(p, clen); |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2364 p += clen - 1; |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2365 } |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2366 } |
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2367 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
|
2368 msg_puts_attr("^J", attr); |
18454
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2369 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
|
2370 } |
18454
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2371 ui_breakcheck(); |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2372 } |
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 last inserted text |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2376 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
|
2377 && (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
|
2378 && !message_filtered(p)) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2379 { |
18436
6ec1bfb4690b
patch 8.1.2212: cannot see the selection type in :reg output
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2380 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
|
2381 dis_msg(p, TRUE); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2382 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2383 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2384 // display last command line |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2385 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
|
2386 && !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
|
2387 { |
18436
6ec1bfb4690b
patch 8.1.2212: cannot see the selection type in :reg output
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2388 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
|
2389 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
|
2390 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2391 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2392 // display current file name |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2393 if (curbuf->b_fname != NULL |
18454
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2394 && (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
|
2395 && !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
|
2396 { |
18436
6ec1bfb4690b
patch 8.1.2212: cannot see the selection type in :reg output
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2397 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
|
2398 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
|
2399 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2400 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2401 // display alternate file name |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2402 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
|
2403 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2404 char_u *fname; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2405 linenr_T dummy; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2406 |
18454
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2407 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
|
2408 && !message_filtered(fname)) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2409 { |
18436
6ec1bfb4690b
patch 8.1.2212: cannot see the selection type in :reg output
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2410 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
|
2411 dis_msg(fname, FALSE); |
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 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2414 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2415 // display last search pattern |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2416 if (last_search_pat() != NULL |
18454
b912277e3877
patch 8.1.2221: cannot filter :disp output
Bram Moolenaar <Bram@vim.org>
parents:
18436
diff
changeset
|
2417 && (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
|
2418 && !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
|
2419 { |
18436
6ec1bfb4690b
patch 8.1.2212: cannot see the selection type in :reg output
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2420 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
|
2421 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
|
2422 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2423 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2424 #ifdef FEAT_EVAL |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2425 // display last used expression |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2426 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
|
2427 && !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
|
2428 { |
18436
6ec1bfb4690b
patch 8.1.2212: cannot see the selection type in :reg output
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2429 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
|
2430 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
|
2431 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2432 #endif |
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 |
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 * 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
|
2437 * 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
|
2438 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2439 static void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2440 dis_msg( |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2441 char_u *p, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2442 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
|
2443 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2444 int n; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2445 int l; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2446 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2447 n = (int)Columns - 6; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2448 while (*p != NUL |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2449 && !(*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
|
2450 && (n -= ptr2cells(p)) >= 0) |
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 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
|
2453 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2454 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
|
2455 p += l; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2456 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2457 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2458 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
|
2459 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2460 ui_breakcheck(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2461 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2462 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2463 #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
|
2464 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2465 * 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
|
2466 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2467 void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2468 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
|
2469 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2470 yankreg_T *curr; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2471 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2472 curr = y_current; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2473 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
|
2474 free_yank_all(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2475 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
|
2476 y_current = curr; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2477 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2478 #endif |
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 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2482 * 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
|
2483 * Used for getregtype() |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2484 * Returns MAUTO for error. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2485 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2486 char_u |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2487 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
|
2488 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2489 switch (regname) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2490 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2491 case '%': // file name |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2492 case '#': // alternate file name |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2493 case '=': // expression |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2494 case ':': // last command line |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2495 case '/': // last search-pattern |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2496 case '.': // last inserted text |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2497 # ifdef FEAT_SEARCHPATH |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2498 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
|
2499 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
|
2500 # endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2501 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
|
2502 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
|
2503 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
|
2504 return MCHAR; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2505 } |
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 # ifdef FEAT_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2508 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
|
2509 # endif |
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 (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
|
2512 return MAUTO; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2513 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2514 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
|
2515 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2516 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
|
2517 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2518 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
|
2519 *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
|
2520 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
|
2521 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2522 return MAUTO; |
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 |
18436
6ec1bfb4690b
patch 8.1.2212: cannot see the selection type in :reg output
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2525 #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
|
2526 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2527 * 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
|
2528 * Otherwise just return "s". |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2529 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2530 static char_u * |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2531 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
|
2532 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2533 if (flags & GREG_LIST) |
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 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
|
2536 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2537 if (list != NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2538 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2539 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
|
2540 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2541 list_free(list); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2542 return NULL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2543 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2544 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
|
2545 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2546 return (char_u *)list; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2547 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2548 return s; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2549 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2550 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2551 /* |
19524
4a6a412e4565
patch 8.2.0319: file missing in distribution, comments outdated
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
2552 * 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
|
2553 * 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
|
2554 * Returns NULL for error. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2555 * Flags: |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2556 * 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
|
2557 * 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
|
2558 * 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
|
2559 * 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
|
2560 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2561 char_u * |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2562 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
|
2563 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2564 long i; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2565 char_u *retval; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2566 int allocated; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2567 long len; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2568 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2569 // 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
|
2570 if (regname == '=') |
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 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
|
2573 return NULL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2574 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
|
2575 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
|
2576 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
|
2577 } |
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 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
|
2580 regname = '"'; |
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 // check for valid regname |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2583 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
|
2584 return NULL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2585 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2586 # ifdef FEAT_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2587 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
|
2588 # endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2589 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2590 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
|
2591 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2592 if (retval == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2593 return NULL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2594 if (allocated) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2595 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
|
2596 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
|
2597 } |
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 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
|
2600 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
|
2601 return NULL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2602 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2603 if (flags & GREG_LIST) |
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 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
|
2606 int error = FALSE; |
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 if (list == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2609 return NULL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2610 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
|
2611 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
|
2612 error = TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2613 if (error) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2614 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2615 list_free(list); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2616 return NULL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2617 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2618 return (char_u *)list; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2619 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2620 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2621 // 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
|
2622 len = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2623 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
|
2624 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2625 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
|
2626 // 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
|
2627 // y_type is MLINE. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2628 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
|
2629 ++len; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2630 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2631 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2632 retval = alloc(len + 1); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2633 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2634 // 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
|
2635 if (retval != NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2636 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2637 len = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2638 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
|
2639 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2640 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
|
2641 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
|
2642 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2643 // 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
|
2644 // MLINE. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2645 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
|
2646 retval[len++] = '\n'; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2647 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2648 retval[len] = NUL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2649 } |
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 return retval; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2652 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2653 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2654 static int |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2655 init_write_reg( |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2656 int name, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2657 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
|
2658 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
|
2659 int must_append, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2660 int *yank_type UNUSED) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2661 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2662 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
|
2663 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2664 emsg_invreg(name); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2665 return FAIL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2666 } |
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 // 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
|
2669 *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
|
2670 *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
|
2671 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2672 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
|
2673 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
|
2674 free_yank_all(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2675 return OK; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2676 } |
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 static void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2679 finish_write_reg( |
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 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
|
2682 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
|
2683 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2684 # ifdef FEAT_CLIPBOARD |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2685 // 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
|
2686 may_set_selection(); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2687 # endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2688 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2689 // ':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
|
2690 if (name != '"') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2691 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
|
2692 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
|
2693 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2694 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2695 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2696 * 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
|
2697 * "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
|
2698 * 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
|
2699 * 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
|
2700 * 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
|
2701 * 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
|
2702 * 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
|
2703 */ |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2704 void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2705 write_reg_contents( |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2706 int name, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2707 char_u *str, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2708 int maxlen, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2709 int must_append) |
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 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
|
2712 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2713 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2714 void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2715 write_reg_contents_lst( |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2716 int name, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2717 char_u **strings, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2718 int maxlen UNUSED, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2719 int must_append, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2720 int yank_type, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2721 long block_len) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2722 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2723 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
|
2724 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2725 if (name == '/' || name == '=') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2726 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2727 char_u *s; |
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 if (strings[0] == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2730 s = (char_u *)""; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2731 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
|
2732 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2733 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
|
2734 "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
|
2735 return; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2736 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2737 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2738 s = strings[0]; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2739 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
|
2740 return; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2741 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2742 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2743 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
|
2744 return; |
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 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
|
2747 &yank_type) == FAIL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2748 return; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2749 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2750 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
|
2751 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2752 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
|
2753 } |
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 void |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2756 write_reg_contents_ex( |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2757 int name, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2758 char_u *str, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2759 int maxlen, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2760 int must_append, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2761 int yank_type, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2762 long block_len) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2763 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2764 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
|
2765 long len; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2766 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2767 if (maxlen >= 0) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2768 len = maxlen; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2769 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2770 len = (long)STRLEN(str); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2771 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2772 // Special case: '/' search pattern |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2773 if (name == '/') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2774 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2775 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
|
2776 return; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2777 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2778 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2779 if (name == '#') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2780 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2781 buf_T *buf; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2782 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2783 if (VIM_ISDIGIT(*str)) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2784 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2785 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
|
2786 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2787 buf = buflist_findnr(num); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2788 if (buf == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2789 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
|
2790 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2791 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2792 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
|
2793 TRUE, FALSE, FALSE)); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2794 if (buf == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2795 return; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2796 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
|
2797 return; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2798 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2799 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2800 if (name == '=') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2801 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2802 char_u *p, *s; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2803 |
20830
9064044fd4f6
patch 8.2.0967: unnecessary type casts for vim_strnsave()
Bram Moolenaar <Bram@vim.org>
parents:
20824
diff
changeset
|
2804 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
|
2805 if (p == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2806 return; |
18838
8dabdfc7c799
patch 8.1.2406: leaking memory in test_paste and test_registers
Bram Moolenaar <Bram@vim.org>
parents:
18771
diff
changeset
|
2807 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
|
2808 { |
18838
8dabdfc7c799
patch 8.1.2406: leaking memory in test_paste and test_registers
Bram Moolenaar <Bram@vim.org>
parents:
18771
diff
changeset
|
2809 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
|
2810 vim_free(p); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2811 p = s; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2812 } |
22732
4c21a3a47707
patch 8.2.1914: Vim9: cannot put line break in expression for '=' register
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
2813 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
|
2814 return; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2815 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2816 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2817 if (name == '_') // black hole: nothing to do |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2818 return; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2819 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2820 if (init_write_reg(name, &old_y_previous, &old_y_current, must_append, |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2821 &yank_type) == FAIL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2822 return; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2823 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2824 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
|
2825 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2826 finish_write_reg(name, old_y_previous, old_y_current); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2827 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2828 #endif // FEAT_EVAL |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2829 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2830 #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
|
2831 /* |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2832 * 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
|
2833 * is appended. |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2834 */ |
19774
00a1b89256ea
patch 8.2.0443: clipboard code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
19524
diff
changeset
|
2835 void |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2836 str_to_reg( |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2837 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
|
2838 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
|
2839 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
|
2840 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
|
2841 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
|
2842 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
|
2843 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2844 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
|
2845 int lnum; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2846 long start; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2847 long i; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2848 int extra; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2849 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
|
2850 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
|
2851 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
|
2852 char_u *s; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2853 char_u **ss; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2854 char_u **pp; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2855 long maxlen; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2856 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2857 if (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
|
2858 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
|
2859 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2860 if (yank_type == MAUTO) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2861 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
|
2862 || str[len - 1] == CAR))) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2863 ? MLINE : MCHAR); |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2864 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2865 type = yank_type; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2866 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2867 // 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
|
2868 newlines = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2869 if (str_list) |
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 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
|
2872 ++newlines; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2873 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2874 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2875 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2876 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
|
2877 if (str[i] == '\n') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2878 ++newlines; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2879 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
|
2880 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2881 extraline = 1; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2882 ++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
|
2883 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2884 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
|
2885 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2886 append = TRUE; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2887 --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
|
2888 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2889 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2890 |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2891 // 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
|
2892 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
|
2893 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2894 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
|
2895 return; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2896 } |
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 // 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
|
2899 // 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
|
2900 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
|
2901 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
|
2902 return; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2903 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
|
2904 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
|
2905 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
|
2906 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
|
2907 maxlen = 0; |
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 // 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
|
2910 if (str_list) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2911 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2912 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
|
2913 { |
24794
fd245e5d4585
patch 8.2.2935: calculating register width is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
24792
diff
changeset
|
2914 pp[lnum] = vim_strsave(*ss); |
fd245e5d4585
patch 8.2.2935: calculating register width is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
24792
diff
changeset
|
2915 if (type == MBLOCK) |
fd245e5d4585
patch 8.2.2935: calculating register width is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
24792
diff
changeset
|
2916 { |
fd245e5d4585
patch 8.2.2935: calculating register width is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
24792
diff
changeset
|
2917 int charlen = mb_string2cells(*ss, -1); |
fd245e5d4585
patch 8.2.2935: calculating register width is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
24792
diff
changeset
|
2918 |
fd245e5d4585
patch 8.2.2935: calculating register width is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
24792
diff
changeset
|
2919 if (charlen > maxlen) |
fd245e5d4585
patch 8.2.2935: calculating register width is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
24792
diff
changeset
|
2920 maxlen = charlen; |
fd245e5d4585
patch 8.2.2935: calculating register width is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
24792
diff
changeset
|
2921 } |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2922 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2923 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2924 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2925 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2926 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
|
2927 { |
24794
fd245e5d4585
patch 8.2.2935: calculating register width is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
24792
diff
changeset
|
2928 int charlen = 0; |
fd245e5d4585
patch 8.2.2935: calculating register width is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
24792
diff
changeset
|
2929 |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2930 for (i = start; i < len; ++i) // find the end of the line |
24792
91c42289cbe1
patch 8.2.2934: ASAN error when using text from the clipboard
Bram Moolenaar <Bram@vim.org>
parents:
24790
diff
changeset
|
2931 { |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2932 if (str[i] == '\n') |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2933 break; |
24794
fd245e5d4585
patch 8.2.2935: calculating register width is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
24792
diff
changeset
|
2934 if (type == MBLOCK) |
fd245e5d4585
patch 8.2.2935: calculating register width is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
24792
diff
changeset
|
2935 charlen += mb_ptr2cells_len(str + i, len - i); |
24792
91c42289cbe1
patch 8.2.2934: ASAN error when using text from the clipboard
Bram Moolenaar <Bram@vim.org>
parents:
24790
diff
changeset
|
2936 } |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2937 i -= start; // i is now length of line |
24790
14b86681e6e6
patch 8.2.2933: when 'clipboard' is "unnamed" zp does not work correctly
Bram Moolenaar <Bram@vim.org>
parents:
24752
diff
changeset
|
2938 if (charlen > maxlen) |
14b86681e6e6
patch 8.2.2933: when 'clipboard' is "unnamed" zp does not work correctly
Bram Moolenaar <Bram@vim.org>
parents:
24752
diff
changeset
|
2939 maxlen = charlen; |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2940 if (append) |
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 --lnum; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2943 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
|
2944 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2945 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2946 extra = 0; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2947 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
|
2948 if (s == NULL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2949 break; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2950 if (extra) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2951 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
|
2952 if (append) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2953 vim_free(y_ptr->y_array[lnum]); |
24792
91c42289cbe1
patch 8.2.2934: ASAN error when using text from the clipboard
Bram Moolenaar <Bram@vim.org>
parents:
24790
diff
changeset
|
2954 if (i > 0) |
18164
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2955 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
|
2956 extra += i; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2957 s[extra] = NUL; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2958 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
|
2959 while (--extra >= 0) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2960 { |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2961 if (*s == NUL) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2962 *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
|
2963 ++s; |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2964 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2965 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
|
2966 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2967 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2968 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
|
2969 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
|
2970 if (type == MBLOCK) |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2971 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
|
2972 else |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2973 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
|
2974 # ifdef FEAT_VIMINFO |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2975 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
|
2976 # endif |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2977 } |
f57481564f2c
patch 8.1.2077: the ops.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2978 #endif // FEAT_CLIPBOARD || FEAT_EVAL || PROTO |