Mercurial > vim
annotate src/mark.c @ 24108:0a5eba7e6660 v8.2.2595
patch 8.2.2595: setting 'winminheight' may cause 'lines' to change
Commit: https://github.com/vim/vim/commit/9e813b3dea94a8952b732a224fa31beba6e85973
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Mar 13 14:29:05 2021 +0100
patch 8.2.2595: setting 'winminheight' may cause 'lines' to change
Problem: Setting 'winminheight' may cause 'lines' to change.
Solution: Also take minimal height of other tabpages into account. (https://github.com/vim/vim/issues/7899)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 13 Mar 2021 14:30:03 +0100 |
parents | e949ad96ad7a |
children | 8f2262c72178 |
rev | line source |
---|---|
10042
4aead6a9b7a9
commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
7 | 2 * |
3 * VIM - Vi IMproved by Bram Moolenaar | |
4 * | |
5 * Do ":help uganda" in Vim to read copying and usage conditions. | |
6 * Do ":help credits" in Vim to see a list of people who contributed. | |
7 * See README.txt for an overview of the Vim source code. | |
8 */ | |
9 | |
10 /* | |
11 * mark.c: functions for setting marks and jumping to them | |
12 */ | |
13 | |
14 #include "vim.h" | |
15 | |
16 /* | |
17 * This file contains routines to maintain and manipulate marks. | |
18 */ | |
19 | |
20 /* | |
21 * If a named file mark's lnum is non-zero, it is valid. | |
22 * If a named file mark's fnum is non-zero, it is for an existing buffer, | |
23 * otherwise it is from .viminfo and namedfm[n].fname is the file name. | |
24 * There are marks 'A - 'Z (set by user) and '0 to '9 (set when writing | |
25 * viminfo). | |
26 */ | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
27 static xfmark_T namedfm[NMARKS + EXTRA_MARKS]; // marks with file nr |
7 | 28 |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17464
diff
changeset
|
29 static void fname2fnum(xfmark_T *fm); |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
5735
diff
changeset
|
30 static void fmarks_check_one(xfmark_T *fm, char_u *name, buf_T *buf); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
5735
diff
changeset
|
31 static char_u *mark_line(pos_T *mp, int lead_len); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
5735
diff
changeset
|
32 static void show_one_mark(int, char_u *, pos_T *, char_u *, int current); |
11140
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
33 static void mark_adjust_internal(linenr_T line1, linenr_T line2, long amount, |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
34 long amount_after, int adjust_folds); |
7 | 35 |
36 /* | |
706 | 37 * Set named mark "c" at current cursor position. |
7 | 38 * Returns OK on success, FAIL if bad name given. |
39 */ | |
40 int | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
41 setmark(int c) |
7 | 42 { |
706 | 43 return setmark_pos(c, &curwin->w_cursor, curbuf->b_fnum); |
44 } | |
45 | |
46 /* | |
47 * Set named mark "c" to position "pos". | |
48 * When "c" is upper case use file "fnum". | |
49 * Returns OK on success, FAIL if bad name given. | |
50 */ | |
51 int | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
52 setmark_pos(int c, pos_T *pos, int fnum) |
706 | 53 { |
7 | 54 int i; |
10730
44e9340dc604
patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents:
10285
diff
changeset
|
55 buf_T *buf; |
7 | 56 |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
57 // Check for a special key (may cause islower() to crash). |
7 | 58 if (c < 0) |
59 return FAIL; | |
60 | |
61 if (c == '\'' || c == '`') | |
62 { | |
706 | 63 if (pos == &curwin->w_cursor) |
64 { | |
65 setpcmark(); | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
66 // keep it even when the cursor doesn't move |
706 | 67 curwin->w_prev_pcmark = curwin->w_pcmark; |
68 } | |
69 else | |
70 curwin->w_pcmark = *pos; | |
7 | 71 return OK; |
72 } | |
73 | |
10730
44e9340dc604
patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents:
10285
diff
changeset
|
74 buf = buflist_findnr(fnum); |
44e9340dc604
patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents:
10285
diff
changeset
|
75 if (buf == NULL) |
44e9340dc604
patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents:
10285
diff
changeset
|
76 return FAIL; |
44e9340dc604
patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents:
10285
diff
changeset
|
77 |
1533 | 78 if (c == '"') |
79 { | |
10730
44e9340dc604
patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents:
10285
diff
changeset
|
80 buf->b_last_cursor = *pos; |
1533 | 81 return OK; |
82 } | |
83 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
84 // Allow setting '[ and '] for an autocommand that simulates reading a |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
85 // file. |
7 | 86 if (c == '[') |
87 { | |
10730
44e9340dc604
patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents:
10285
diff
changeset
|
88 buf->b_op_start = *pos; |
7 | 89 return OK; |
90 } | |
91 if (c == ']') | |
92 { | |
10730
44e9340dc604
patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents:
10285
diff
changeset
|
93 buf->b_op_end = *pos; |
7 | 94 return OK; |
95 } | |
96 | |
5265
cd971e951b06
updated for version 7.4b.009
Bram Moolenaar <bram@vim.org>
parents:
4092
diff
changeset
|
97 if (c == '<' || c == '>') |
3660 | 98 { |
5265
cd971e951b06
updated for version 7.4b.009
Bram Moolenaar <bram@vim.org>
parents:
4092
diff
changeset
|
99 if (c == '<') |
10730
44e9340dc604
patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents:
10285
diff
changeset
|
100 buf->b_visual.vi_start = *pos; |
5265
cd971e951b06
updated for version 7.4b.009
Bram Moolenaar <bram@vim.org>
parents:
4092
diff
changeset
|
101 else |
10730
44e9340dc604
patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents:
10285
diff
changeset
|
102 buf->b_visual.vi_end = *pos; |
44e9340dc604
patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents:
10285
diff
changeset
|
103 if (buf->b_visual.vi_mode == NUL) |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
104 // Visual_mode has not yet been set, use a sane default. |
10730
44e9340dc604
patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents:
10285
diff
changeset
|
105 buf->b_visual.vi_mode = 'v'; |
3660 | 106 return OK; |
107 } | |
108 | |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
109 if (ASCII_ISLOWER(c)) |
7 | 110 { |
111 i = c - 'a'; | |
10730
44e9340dc604
patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents:
10285
diff
changeset
|
112 buf->b_namedm[i] = *pos; |
7 | 113 return OK; |
114 } | |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
115 if (ASCII_ISUPPER(c) || VIM_ISDIGIT(c)) |
7 | 116 { |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
117 if (VIM_ISDIGIT(c)) |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
118 i = c - '0' + NMARKS; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
119 else |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
120 i = c - 'A'; |
706 | 121 namedfm[i].fmark.mark = *pos; |
122 namedfm[i].fmark.fnum = fnum; | |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
123 VIM_CLEAR(namedfm[i].fname); |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
124 #ifdef FEAT_VIMINFO |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
125 namedfm[i].time_set = vim_time(); |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
126 #endif |
7 | 127 return OK; |
128 } | |
129 return FAIL; | |
130 } | |
131 | |
132 /* | |
133 * Set the previous context mark to the current position and add it to the | |
134 * jump list. | |
135 */ | |
136 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
137 setpcmark(void) |
7 | 138 { |
139 #ifdef FEAT_JUMPLIST | |
140 int i; | |
141 xfmark_T *fm; | |
142 #endif | |
143 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
144 // for :global the mark is set only once |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
21403
diff
changeset
|
145 if (global_busy || listcmd_busy || (cmdmod.cmod_flags & CMOD_KEEPJUMPS)) |
7 | 146 return; |
147 | |
148 curwin->w_prev_pcmark = curwin->w_pcmark; | |
149 curwin->w_pcmark = curwin->w_cursor; | |
150 | |
151 #ifdef FEAT_JUMPLIST | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
152 // If jumplist is full: remove oldest entry |
7 | 153 if (++curwin->w_jumplistlen > JUMPLISTSIZE) |
154 { | |
155 curwin->w_jumplistlen = JUMPLISTSIZE; | |
156 vim_free(curwin->w_jumplist[0].fname); | |
157 for (i = 1; i < JUMPLISTSIZE; ++i) | |
158 curwin->w_jumplist[i - 1] = curwin->w_jumplist[i]; | |
159 } | |
160 curwin->w_jumplistidx = curwin->w_jumplistlen; | |
161 fm = &curwin->w_jumplist[curwin->w_jumplistlen - 1]; | |
162 | |
163 fm->fmark.mark = curwin->w_pcmark; | |
164 fm->fmark.fnum = curbuf->b_fnum; | |
165 fm->fname = NULL; | |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
166 # ifdef FEAT_VIMINFO |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
167 fm->time_set = vim_time(); |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
168 # endif |
7 | 169 #endif |
170 } | |
171 | |
172 /* | |
173 * To change context, call setpcmark(), then move the current position to | |
174 * where ever, then call checkpcmark(). This ensures that the previous | |
175 * context will only be changed if the cursor moved to a different line. | |
176 * If pcmark was deleted (with "dG") the previous mark is restored. | |
177 */ | |
178 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
179 checkpcmark(void) |
7 | 180 { |
181 if (curwin->w_prev_pcmark.lnum != 0 | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10730
diff
changeset
|
182 && (EQUAL_POS(curwin->w_pcmark, curwin->w_cursor) |
7 | 183 || curwin->w_pcmark.lnum == 0)) |
184 { | |
185 curwin->w_pcmark = curwin->w_prev_pcmark; | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
186 curwin->w_prev_pcmark.lnum = 0; // Show it has been checked |
7 | 187 } |
188 } | |
189 | |
190 #if defined(FEAT_JUMPLIST) || defined(PROTO) | |
191 /* | |
192 * move "count" positions in the jump list (count may be negative) | |
193 */ | |
194 pos_T * | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
195 movemark(int count) |
7 | 196 { |
197 pos_T *pos; | |
198 xfmark_T *jmp; | |
199 | |
13278
28ae299c6af0
patch 8.0.1513: the jumplist is not always properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
13248
diff
changeset
|
200 cleanup_jumplist(curwin, TRUE); |
7 | 201 |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
202 if (curwin->w_jumplistlen == 0) // nothing to jump to |
7 | 203 return (pos_T *)NULL; |
204 | |
205 for (;;) | |
206 { | |
207 if (curwin->w_jumplistidx + count < 0 | |
208 || curwin->w_jumplistidx + count >= curwin->w_jumplistlen) | |
209 return (pos_T *)NULL; | |
210 | |
211 /* | |
212 * if first CTRL-O or CTRL-I command after a jump, add cursor position | |
1188 | 213 * to list. Careful: If there are duplicates (CTRL-O immediately after |
7 | 214 * starting Vim on a file), another entry may have been removed. |
215 */ | |
216 if (curwin->w_jumplistidx == curwin->w_jumplistlen) | |
217 { | |
218 setpcmark(); | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
219 --curwin->w_jumplistidx; // skip the new entry |
7 | 220 if (curwin->w_jumplistidx + count < 0) |
221 return (pos_T *)NULL; | |
222 } | |
223 | |
224 curwin->w_jumplistidx += count; | |
225 | |
226 jmp = curwin->w_jumplist + curwin->w_jumplistidx; | |
227 if (jmp->fmark.fnum == 0) | |
228 fname2fnum(jmp); | |
229 if (jmp->fmark.fnum != curbuf->b_fnum) | |
230 { | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
231 // jump to other file |
7 | 232 if (buflist_findnr(jmp->fmark.fnum) == NULL) |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
233 { // Skip this one .. |
7 | 234 count += count < 0 ? -1 : 1; |
235 continue; | |
236 } | |
237 if (buflist_getfile(jmp->fmark.fnum, jmp->fmark.mark.lnum, | |
238 0, FALSE) == FAIL) | |
239 return (pos_T *)NULL; | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
240 // Set lnum again, autocommands my have changed it |
7 | 241 curwin->w_cursor = jmp->fmark.mark; |
242 pos = (pos_T *)-1; | |
243 } | |
244 else | |
245 pos = &(jmp->fmark.mark); | |
246 return pos; | |
247 } | |
248 } | |
249 | |
250 /* | |
251 * Move "count" positions in the changelist (count may be negative). | |
252 */ | |
253 pos_T * | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
254 movechangelist(int count) |
7 | 255 { |
256 int n; | |
257 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
258 if (curbuf->b_changelistlen == 0) // nothing to jump to |
7 | 259 return (pos_T *)NULL; |
260 | |
261 n = curwin->w_changelistidx; | |
262 if (n + count < 0) | |
263 { | |
264 if (n == 0) | |
265 return (pos_T *)NULL; | |
266 n = 0; | |
267 } | |
268 else if (n + count >= curbuf->b_changelistlen) | |
269 { | |
270 if (n == curbuf->b_changelistlen - 1) | |
271 return (pos_T *)NULL; | |
272 n = curbuf->b_changelistlen - 1; | |
273 } | |
274 else | |
275 n += count; | |
276 curwin->w_changelistidx = n; | |
277 return curbuf->b_changelist + n; | |
278 } | |
279 #endif | |
280 | |
281 /* | |
4043 | 282 * Find mark "c" in buffer pointed to by "buf". |
706 | 283 * If "changefile" is TRUE it's allowed to edit another file for '0, 'A, etc. |
284 * If "fnum" is not NULL store the fnum there for '0, 'A etc., don't edit | |
285 * another file. | |
7 | 286 * Returns: |
287 * - pointer to pos_T if found. lnum is 0 when mark not set, -1 when mark is | |
288 * in another file which can't be gotten. (caller needs to check lnum!) | |
289 * - NULL if there is no mark called 'c'. | |
290 * - -1 if mark is in other file and jumped there (only if changefile is TRUE) | |
291 */ | |
292 pos_T * | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
293 getmark_buf(buf_T *buf, int c, int changefile) |
4043 | 294 { |
295 return getmark_buf_fnum(buf, c, changefile, NULL); | |
296 } | |
297 | |
298 pos_T * | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
299 getmark(int c, int changefile) |
706 | 300 { |
4043 | 301 return getmark_buf_fnum(curbuf, c, changefile, NULL); |
706 | 302 } |
303 | |
304 pos_T * | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
305 getmark_buf_fnum( |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
306 buf_T *buf, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
307 int c, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
308 int changefile, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
309 int *fnum) |
7 | 310 { |
311 pos_T *posp; | |
312 pos_T *startp, *endp; | |
313 static pos_T pos_copy; | |
314 | |
315 posp = NULL; | |
316 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
317 // Check for special key, can't be a mark name and might cause islower() |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
318 // to crash. |
7 | 319 if (c < 0) |
320 return posp; | |
321 #ifndef EBCDIC | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
322 if (c > '~') // check for islower()/isupper() |
7 | 323 ; |
324 else | |
325 #endif | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
326 if (c == '\'' || c == '`') // previous context mark |
7 | 327 { |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
328 pos_copy = curwin->w_pcmark; // need to make a copy because |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
329 posp = &pos_copy; // w_pcmark may be changed soon |
7 | 330 } |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
331 else if (c == '"') // to pos when leaving buffer |
4043 | 332 posp = &(buf->b_last_cursor); |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
333 else if (c == '^') // to where Insert mode stopped |
4043 | 334 posp = &(buf->b_last_insert); |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
335 else if (c == '.') // to where last change was made |
4043 | 336 posp = &(buf->b_last_change); |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
337 else if (c == '[') // to start of previous operator |
4043 | 338 posp = &(buf->b_op_start); |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
339 else if (c == ']') // to end of previous operator |
4043 | 340 posp = &(buf->b_op_end); |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
341 else if (c == '{' || c == '}') // to previous/next paragraph |
7 | 342 { |
343 pos_T pos; | |
344 oparg_T oa; | |
345 int slcb = listcmd_busy; | |
346 | |
347 pos = curwin->w_cursor; | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
348 listcmd_busy = TRUE; // avoid that '' is changed |
503 | 349 if (findpar(&oa.inclusive, |
350 c == '}' ? FORWARD : BACKWARD, 1L, NUL, FALSE)) | |
7 | 351 { |
352 pos_copy = curwin->w_cursor; | |
353 posp = &pos_copy; | |
354 } | |
355 curwin->w_cursor = pos; | |
356 listcmd_busy = slcb; | |
357 } | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
358 else if (c == '(' || c == ')') // to previous/next sentence |
7 | 359 { |
360 pos_T pos; | |
361 int slcb = listcmd_busy; | |
362 | |
363 pos = curwin->w_cursor; | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
364 listcmd_busy = TRUE; // avoid that '' is changed |
7 | 365 if (findsent(c == ')' ? FORWARD : BACKWARD, 1L)) |
366 { | |
367 pos_copy = curwin->w_cursor; | |
368 posp = &pos_copy; | |
369 } | |
370 curwin->w_cursor = pos; | |
371 listcmd_busy = slcb; | |
372 } | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
373 else if (c == '<' || c == '>') // start/end of visual area |
7 | 374 { |
4043 | 375 startp = &buf->b_visual.vi_start; |
376 endp = &buf->b_visual.vi_end; | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10730
diff
changeset
|
377 if (((c == '<') == LT_POS(*startp, *endp) || endp->lnum == 0) |
10730
44e9340dc604
patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents:
10285
diff
changeset
|
378 && startp->lnum != 0) |
7 | 379 posp = startp; |
380 else | |
381 posp = endp; | |
382 /* | |
383 * For Visual line mode, set mark at begin or end of line | |
384 */ | |
4043 | 385 if (buf->b_visual.vi_mode == 'V') |
7 | 386 { |
387 pos_copy = *posp; | |
388 posp = &pos_copy; | |
389 if (c == '<') | |
390 pos_copy.col = 0; | |
391 else | |
392 pos_copy.col = MAXCOL; | |
393 pos_copy.coladd = 0; | |
394 } | |
395 } | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
396 else if (ASCII_ISLOWER(c)) // normal named mark |
7 | 397 { |
4043 | 398 posp = &(buf->b_namedm[c - 'a']); |
7 | 399 } |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
400 else if (ASCII_ISUPPER(c) || VIM_ISDIGIT(c)) // named file mark |
7 | 401 { |
402 if (VIM_ISDIGIT(c)) | |
403 c = c - '0' + NMARKS; | |
404 else | |
405 c -= 'A'; | |
406 posp = &(namedfm[c].fmark.mark); | |
407 | |
408 if (namedfm[c].fmark.fnum == 0) | |
409 fname2fnum(&namedfm[c]); | |
706 | 410 |
411 if (fnum != NULL) | |
412 *fnum = namedfm[c].fmark.fnum; | |
4043 | 413 else if (namedfm[c].fmark.fnum != buf->b_fnum) |
7 | 414 { |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
415 // mark is in another file |
7 | 416 posp = &pos_copy; |
417 | |
418 if (namedfm[c].fmark.mark.lnum != 0 | |
419 && changefile && namedfm[c].fmark.fnum) | |
420 { | |
421 if (buflist_getfile(namedfm[c].fmark.fnum, | |
422 (linenr_T)1, GETF_SETMARK, FALSE) == OK) | |
423 { | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
424 // Set the lnum now, autocommands could have changed it |
7 | 425 curwin->w_cursor = namedfm[c].fmark.mark; |
426 return (pos_T *)-1; | |
427 } | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
428 pos_copy.lnum = -1; // can't get file |
7 | 429 } |
430 else | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
431 pos_copy.lnum = 0; // mark exists, but is not valid in |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
432 // current buffer |
7 | 433 } |
434 } | |
435 | |
436 return posp; | |
437 } | |
438 | |
439 /* | |
440 * Search for the next named mark in the current file. | |
441 * | |
442 * Returns pointer to pos_T of the next mark or NULL if no mark is found. | |
443 */ | |
444 pos_T * | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
445 getnextmark( |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
446 pos_T *startpos, // where to start |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
447 int dir, // direction for search |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
448 int begin_line) |
7 | 449 { |
450 int i; | |
451 pos_T *result = NULL; | |
452 pos_T pos; | |
453 | |
454 pos = *startpos; | |
455 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
456 // When searching backward and leaving the cursor on the first non-blank, |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
457 // position must be in a previous line. |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
458 // When searching forward and leaving the cursor on the first non-blank, |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
459 // position must be in a next line. |
7 | 460 if (dir == BACKWARD && begin_line) |
461 pos.col = 0; | |
462 else if (dir == FORWARD && begin_line) | |
463 pos.col = MAXCOL; | |
464 | |
465 for (i = 0; i < NMARKS; i++) | |
466 { | |
467 if (curbuf->b_namedm[i].lnum > 0) | |
468 { | |
469 if (dir == FORWARD) | |
470 { | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10730
diff
changeset
|
471 if ((result == NULL || LT_POS(curbuf->b_namedm[i], *result)) |
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10730
diff
changeset
|
472 && LT_POS(pos, curbuf->b_namedm[i])) |
7 | 473 result = &curbuf->b_namedm[i]; |
474 } | |
475 else | |
476 { | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10730
diff
changeset
|
477 if ((result == NULL || LT_POS(*result, curbuf->b_namedm[i])) |
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10730
diff
changeset
|
478 && LT_POS(curbuf->b_namedm[i], pos)) |
7 | 479 result = &curbuf->b_namedm[i]; |
480 } | |
481 } | |
482 } | |
483 | |
484 return result; | |
485 } | |
486 | |
487 /* | |
488 * For an xtended filemark: set the fnum from the fname. | |
489 * This is used for marks obtained from the .viminfo file. It's postponed | |
490 * until the mark is used to avoid a long startup delay. | |
491 */ | |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17464
diff
changeset
|
492 static void |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
493 fname2fnum(xfmark_T *fm) |
7 | 494 { |
495 char_u *p; | |
496 | |
497 if (fm->fname != NULL) | |
498 { | |
499 /* | |
500 * First expand "~/" in the file name to the home directory. | |
1480 | 501 * Don't expand the whole name, it may contain other '~' chars. |
7 | 502 */ |
1480 | 503 if (fm->fname[0] == '~' && (fm->fname[1] == '/' |
504 #ifdef BACKSLASH_IN_FILENAME | |
505 || fm->fname[1] == '\\' | |
506 #endif | |
507 )) | |
508 { | |
509 int len; | |
510 | |
511 expand_env((char_u *)"~/", NameBuff, MAXPATHL); | |
1570 | 512 len = (int)STRLEN(NameBuff); |
1480 | 513 vim_strncpy(NameBuff + len, fm->fname + 2, MAXPATHL - len - 1); |
514 } | |
515 else | |
516 vim_strncpy(NameBuff, fm->fname, MAXPATHL - 1); | |
517 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
518 // Try to shorten the file name. |
7 | 519 mch_dirname(IObuff, IOSIZE); |
520 p = shorten_fname(NameBuff, IObuff); | |
521 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
522 // buflist_new() will call fmarks_check_names() |
7 | 523 (void)buflist_new(NameBuff, p, (linenr_T)1, 0); |
524 } | |
525 } | |
526 | |
527 /* | |
528 * Check all file marks for a name that matches the file name in buf. | |
529 * May replace the name with an fnum. | |
530 * Used for marks that come from the .viminfo file. | |
531 */ | |
532 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
533 fmarks_check_names(buf_T *buf) |
7 | 534 { |
535 char_u *name; | |
536 int i; | |
537 #ifdef FEAT_JUMPLIST | |
538 win_T *wp; | |
539 #endif | |
540 | |
541 if (buf->b_ffname == NULL) | |
542 return; | |
543 | |
544 name = home_replace_save(buf, buf->b_ffname); | |
545 if (name == NULL) | |
546 return; | |
547 | |
548 for (i = 0; i < NMARKS + EXTRA_MARKS; ++i) | |
549 fmarks_check_one(&namedfm[i], name, buf); | |
550 | |
551 #ifdef FEAT_JUMPLIST | |
552 FOR_ALL_WINDOWS(wp) | |
553 { | |
554 for (i = 0; i < wp->w_jumplistlen; ++i) | |
555 fmarks_check_one(&wp->w_jumplist[i], name, buf); | |
556 } | |
557 #endif | |
558 | |
559 vim_free(name); | |
560 } | |
561 | |
562 static void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
563 fmarks_check_one(xfmark_T *fm, char_u *name, buf_T *buf) |
7 | 564 { |
565 if (fm->fmark.fnum == 0 | |
566 && fm->fname != NULL | |
567 && fnamecmp(name, fm->fname) == 0) | |
568 { | |
569 fm->fmark.fnum = buf->b_fnum; | |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
570 VIM_CLEAR(fm->fname); |
7 | 571 } |
572 } | |
573 | |
574 /* | |
575 * Check a if a position from a mark is valid. | |
576 * Give and error message and return FAIL if not. | |
577 */ | |
578 int | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
579 check_mark(pos_T *pos) |
7 | 580 { |
581 if (pos == NULL) | |
582 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15326
diff
changeset
|
583 emsg(_(e_umark)); |
7 | 584 return FAIL; |
585 } | |
586 if (pos->lnum <= 0) | |
587 { | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
588 // lnum is negative if mark is in another file can can't get that |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
589 // file, error message already give then. |
7 | 590 if (pos->lnum == 0) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15326
diff
changeset
|
591 emsg(_(e_marknotset)); |
7 | 592 return FAIL; |
593 } | |
594 if (pos->lnum > curbuf->b_ml.ml_line_count) | |
595 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15326
diff
changeset
|
596 emsg(_(e_markinval)); |
7 | 597 return FAIL; |
598 } | |
599 return OK; | |
600 } | |
601 | |
602 /* | |
603 * clrallmarks() - clear all marks in the buffer 'buf' | |
604 * | |
605 * Used mainly when trashing the entire buffer during ":e" type commands | |
606 */ | |
607 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
608 clrallmarks(buf_T *buf) |
7 | 609 { |
610 static int i = -1; | |
611 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
612 if (i == -1) // first call ever: initialize |
7 | 613 for (i = 0; i < NMARKS + 1; i++) |
614 { | |
615 namedfm[i].fmark.mark.lnum = 0; | |
616 namedfm[i].fname = NULL; | |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
617 #ifdef FEAT_VIMINFO |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
618 namedfm[i].time_set = 0; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
619 #endif |
7 | 620 } |
621 | |
622 for (i = 0; i < NMARKS; i++) | |
623 buf->b_namedm[i].lnum = 0; | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
624 buf->b_op_start.lnum = 0; // start/end op mark cleared |
7 | 625 buf->b_op_end.lnum = 0; |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
626 buf->b_last_cursor.lnum = 1; // '" mark cleared |
7 | 627 buf->b_last_cursor.col = 0; |
628 buf->b_last_cursor.coladd = 0; | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
629 buf->b_last_insert.lnum = 0; // '^ mark cleared |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
630 buf->b_last_change.lnum = 0; // '. mark cleared |
7 | 631 #ifdef FEAT_JUMPLIST |
632 buf->b_changelistlen = 0; | |
633 #endif | |
634 } | |
635 | |
636 /* | |
637 * Get name of file from a filemark. | |
638 * When it's in the current buffer, return the text at the mark. | |
639 * Returns an allocated string. | |
640 */ | |
641 char_u * | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
642 fm_getname(fmark_T *fmark, int lead_len) |
7 | 643 { |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
644 if (fmark->fnum == curbuf->b_fnum) // current buffer |
7 | 645 return mark_line(&(fmark->mark), lead_len); |
646 return buflist_nr2name(fmark->fnum, FALSE, TRUE); | |
647 } | |
648 | |
649 /* | |
650 * Return the line at mark "mp". Truncate to fit in window. | |
651 * The returned string has been allocated. | |
652 */ | |
653 static char_u * | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
654 mark_line(pos_T *mp, int lead_len) |
7 | 655 { |
656 char_u *s, *p; | |
657 int len; | |
658 | |
659 if (mp->lnum == 0 || mp->lnum > curbuf->b_ml.ml_line_count) | |
660 return vim_strsave((char_u *)"-invalid-"); | |
14305
8a4c0ab88201
patch 8.1.0168: output of :marks is too short with multi-byte chars
Christian Brabandt <cb@256bit.org>
parents:
13278
diff
changeset
|
661 // Allow for up to 5 bytes per character. |
20830
9064044fd4f6
patch 8.2.0967: unnecessary type casts for vim_strnsave()
Bram Moolenaar <Bram@vim.org>
parents:
20635
diff
changeset
|
662 s = vim_strnsave(skipwhite(ml_get(mp->lnum)), Columns * 5); |
7 | 663 if (s == NULL) |
664 return NULL; | |
14305
8a4c0ab88201
patch 8.1.0168: output of :marks is too short with multi-byte chars
Christian Brabandt <cb@256bit.org>
parents:
13278
diff
changeset
|
665 // Truncate the line to fit it in the window. |
7 | 666 len = 0; |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11121
diff
changeset
|
667 for (p = s; *p != NUL; MB_PTR_ADV(p)) |
7 | 668 { |
669 len += ptr2cells(p); | |
670 if (len >= Columns - lead_len) | |
671 break; | |
672 } | |
673 *p = NUL; | |
674 return s; | |
675 } | |
676 | |
677 /* | |
678 * print the marks | |
679 */ | |
680 void | |
18126
f89e2e720b5b
patch 8.1.2058: function for ex command is named inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
681 ex_marks(exarg_T *eap) |
7 | 682 { |
683 char_u *arg = eap->arg; | |
684 int i; | |
685 char_u *name; | |
21403
d387121083a4
patch 8.2.1252: ":marks" may show '< and '> mixed up
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
686 pos_T *posp, *startp, *endp; |
7 | 687 |
688 if (arg != NULL && *arg == NUL) | |
689 arg = NULL; | |
690 | |
691 show_one_mark('\'', arg, &curwin->w_pcmark, NULL, TRUE); | |
692 for (i = 0; i < NMARKS; ++i) | |
693 show_one_mark(i + 'a', arg, &curbuf->b_namedm[i], NULL, TRUE); | |
694 for (i = 0; i < NMARKS + EXTRA_MARKS; ++i) | |
695 { | |
696 if (namedfm[i].fmark.fnum != 0) | |
697 name = fm_getname(&namedfm[i].fmark, 15); | |
698 else | |
699 name = namedfm[i].fname; | |
700 if (name != NULL) | |
701 { | |
702 show_one_mark(i >= NMARKS ? i - NMARKS + '0' : i + 'A', | |
703 arg, &namedfm[i].fmark.mark, name, | |
704 namedfm[i].fmark.fnum == curbuf->b_fnum); | |
705 if (namedfm[i].fmark.fnum != 0) | |
706 vim_free(name); | |
707 } | |
708 } | |
709 show_one_mark('"', arg, &curbuf->b_last_cursor, NULL, TRUE); | |
710 show_one_mark('[', arg, &curbuf->b_op_start, NULL, TRUE); | |
711 show_one_mark(']', arg, &curbuf->b_op_end, NULL, TRUE); | |
712 show_one_mark('^', arg, &curbuf->b_last_insert, NULL, TRUE); | |
713 show_one_mark('.', arg, &curbuf->b_last_change, NULL, TRUE); | |
21403
d387121083a4
patch 8.2.1252: ":marks" may show '< and '> mixed up
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
714 |
d387121083a4
patch 8.2.1252: ":marks" may show '< and '> mixed up
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
715 // Show the marks as where they will jump to. |
d387121083a4
patch 8.2.1252: ":marks" may show '< and '> mixed up
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
716 startp = &curbuf->b_visual.vi_start; |
d387121083a4
patch 8.2.1252: ":marks" may show '< and '> mixed up
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
717 endp = &curbuf->b_visual.vi_end; |
d387121083a4
patch 8.2.1252: ":marks" may show '< and '> mixed up
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
718 if ((LT_POS(*startp, *endp) || endp->lnum == 0) && startp->lnum != 0) |
d387121083a4
patch 8.2.1252: ":marks" may show '< and '> mixed up
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
719 posp = startp; |
d387121083a4
patch 8.2.1252: ":marks" may show '< and '> mixed up
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
720 else |
d387121083a4
patch 8.2.1252: ":marks" may show '< and '> mixed up
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
721 posp = endp; |
d387121083a4
patch 8.2.1252: ":marks" may show '< and '> mixed up
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
722 show_one_mark('<', arg, posp, NULL, TRUE); |
d387121083a4
patch 8.2.1252: ":marks" may show '< and '> mixed up
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
723 show_one_mark('>', arg, posp == startp ? endp : startp, NULL, TRUE); |
d387121083a4
patch 8.2.1252: ":marks" may show '< and '> mixed up
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
724 |
7 | 725 show_one_mark(-1, arg, NULL, NULL, FALSE); |
726 } | |
727 | |
728 static void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
729 show_one_mark( |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
730 int c, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
731 char_u *arg, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
732 pos_T *p, |
16433
9c206a78ec04
patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents:
15651
diff
changeset
|
733 char_u *name_arg, |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
734 int current) // in current file |
7 | 735 { |
736 static int did_title = FALSE; | |
737 int mustfree = FALSE; | |
16433
9c206a78ec04
patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents:
15651
diff
changeset
|
738 char_u *name = name_arg; |
7 | 739 |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
740 if (c == -1) // finish up |
7 | 741 { |
742 if (did_title) | |
743 did_title = FALSE; | |
744 else | |
745 { | |
746 if (arg == NULL) | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
747 msg(_("No marks set")); |
7 | 748 else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15326
diff
changeset
|
749 semsg(_("E283: No marks matching \"%s\""), arg); |
7 | 750 } |
751 } | |
16433
9c206a78ec04
patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents:
15651
diff
changeset
|
752 // don't output anything if 'q' typed at --more-- prompt |
7 | 753 else if (!got_int |
754 && (arg == NULL || vim_strchr(arg, c) != NULL) | |
755 && p->lnum != 0) | |
756 { | |
16433
9c206a78ec04
patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents:
15651
diff
changeset
|
757 if (name == NULL && current) |
7 | 758 { |
16433
9c206a78ec04
patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents:
15651
diff
changeset
|
759 name = mark_line(p, 15); |
9c206a78ec04
patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents:
15651
diff
changeset
|
760 mustfree = TRUE; |
7 | 761 } |
16433
9c206a78ec04
patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents:
15651
diff
changeset
|
762 if (!message_filtered(name)) |
7 | 763 { |
16433
9c206a78ec04
patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents:
15651
diff
changeset
|
764 if (!did_title) |
7 | 765 { |
16433
9c206a78ec04
patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents:
15651
diff
changeset
|
766 // Highlight title |
9c206a78ec04
patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents:
15651
diff
changeset
|
767 msg_puts_title(_("\nmark line col file/text")); |
9c206a78ec04
patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents:
15651
diff
changeset
|
768 did_title = TRUE; |
7 | 769 } |
16433
9c206a78ec04
patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents:
15651
diff
changeset
|
770 msg_putchar('\n'); |
9c206a78ec04
patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents:
15651
diff
changeset
|
771 if (!got_int) |
7 | 772 { |
16433
9c206a78ec04
patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents:
15651
diff
changeset
|
773 sprintf((char *)IObuff, " %c %6ld %4d ", c, p->lnum, p->col); |
9c206a78ec04
patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents:
15651
diff
changeset
|
774 msg_outtrans(IObuff); |
9c206a78ec04
patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents:
15651
diff
changeset
|
775 if (name != NULL) |
9c206a78ec04
patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents:
15651
diff
changeset
|
776 { |
9c206a78ec04
patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents:
15651
diff
changeset
|
777 msg_outtrans_attr(name, current ? HL_ATTR(HLF_D) : 0); |
9c206a78ec04
patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents:
15651
diff
changeset
|
778 } |
7 | 779 } |
16433
9c206a78ec04
patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents:
15651
diff
changeset
|
780 out_flush(); // show one line at a time |
7 | 781 } |
16433
9c206a78ec04
patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents:
15651
diff
changeset
|
782 if (mustfree) |
9c206a78ec04
patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents:
15651
diff
changeset
|
783 vim_free(name); |
7 | 784 } |
785 } | |
786 | |
24 | 787 /* |
788 * ":delmarks[!] [marks]" | |
789 */ | |
790 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
791 ex_delmarks(exarg_T *eap) |
24 | 792 { |
793 char_u *p; | |
794 int from, to; | |
795 int i; | |
796 int lower; | |
797 int digit; | |
798 int n; | |
799 | |
800 if (*eap->arg == NUL && eap->forceit) | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
801 // clear all marks |
24 | 802 clrallmarks(curbuf); |
803 else if (eap->forceit) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15326
diff
changeset
|
804 emsg(_(e_invarg)); |
24 | 805 else if (*eap->arg == NUL) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15326
diff
changeset
|
806 emsg(_(e_argreq)); |
24 | 807 else |
808 { | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
809 // clear specified marks only |
24 | 810 for (p = eap->arg; *p != NUL; ++p) |
811 { | |
812 lower = ASCII_ISLOWER(*p); | |
813 digit = VIM_ISDIGIT(*p); | |
814 if (lower || digit || ASCII_ISUPPER(*p)) | |
815 { | |
816 if (p[1] == '-') | |
817 { | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
818 // clear range of marks |
24 | 819 from = *p; |
820 to = p[2]; | |
821 if (!(lower ? ASCII_ISLOWER(p[2]) | |
822 : (digit ? VIM_ISDIGIT(p[2]) | |
823 : ASCII_ISUPPER(p[2]))) | |
824 || to < from) | |
825 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15326
diff
changeset
|
826 semsg(_(e_invarg2), p); |
24 | 827 return; |
828 } | |
829 p += 2; | |
830 } | |
831 else | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
832 // clear one lower case mark |
24 | 833 from = to = *p; |
834 | |
835 for (i = from; i <= to; ++i) | |
836 { | |
837 if (lower) | |
838 curbuf->b_namedm[i - 'a'].lnum = 0; | |
839 else | |
840 { | |
841 if (digit) | |
842 n = i - '0' + NMARKS; | |
843 else | |
844 n = i - 'A'; | |
845 namedfm[n].fmark.mark.lnum = 0; | |
18979
de2d1820215a
patch 8.2.0050: after deleting a file mark it is still in viminfo
Bram Moolenaar <Bram@vim.org>
parents:
18800
diff
changeset
|
846 namedfm[n].fmark.fnum = 0; |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
847 VIM_CLEAR(namedfm[n].fname); |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
848 #ifdef FEAT_VIMINFO |
18979
de2d1820215a
patch 8.2.0050: after deleting a file mark it is still in viminfo
Bram Moolenaar <Bram@vim.org>
parents:
18800
diff
changeset
|
849 namedfm[n].time_set = digit ? 0 : vim_time(); |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
850 #endif |
24 | 851 } |
852 } | |
853 } | |
854 else | |
855 switch (*p) | |
856 { | |
857 case '"': curbuf->b_last_cursor.lnum = 0; break; | |
858 case '^': curbuf->b_last_insert.lnum = 0; break; | |
859 case '.': curbuf->b_last_change.lnum = 0; break; | |
860 case '[': curbuf->b_op_start.lnum = 0; break; | |
861 case ']': curbuf->b_op_end.lnum = 0; break; | |
690 | 862 case '<': curbuf->b_visual.vi_start.lnum = 0; break; |
863 case '>': curbuf->b_visual.vi_end.lnum = 0; break; | |
24 | 864 case ' ': break; |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15326
diff
changeset
|
865 default: semsg(_(e_invarg2), p); |
24 | 866 return; |
867 } | |
868 } | |
869 } | |
870 } | |
871 | |
7 | 872 #if defined(FEAT_JUMPLIST) || defined(PROTO) |
873 /* | |
874 * print the jumplist | |
875 */ | |
876 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
877 ex_jumps(exarg_T *eap UNUSED) |
7 | 878 { |
879 int i; | |
880 char_u *name; | |
881 | |
13278
28ae299c6af0
patch 8.0.1513: the jumplist is not always properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
13248
diff
changeset
|
882 cleanup_jumplist(curwin, TRUE); |
13248
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
883 |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
884 // Highlight title |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
885 msg_puts_title(_("\n jump line col file/text")); |
7 | 886 for (i = 0; i < curwin->w_jumplistlen && !got_int; ++i) |
887 { | |
888 if (curwin->w_jumplist[i].fmark.mark.lnum != 0) | |
889 { | |
890 name = fm_getname(&curwin->w_jumplist[i].fmark, 16); | |
14968
c5ec5ddbe814
patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents:
14305
diff
changeset
|
891 |
c5ec5ddbe814
patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents:
14305
diff
changeset
|
892 // apply :filter /pat/ or file name not available |
c5ec5ddbe814
patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents:
14305
diff
changeset
|
893 if (name == NULL || message_filtered(name)) |
15651
dd4e6f077874
patch 8.1.0833: memory leak when jumps output is filtered
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
894 { |
dd4e6f077874
patch 8.1.0833: memory leak when jumps output is filtered
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
895 vim_free(name); |
7 | 896 continue; |
15651
dd4e6f077874
patch 8.1.0833: memory leak when jumps output is filtered
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
897 } |
7 | 898 |
899 msg_putchar('\n'); | |
900 if (got_int) | |
1702 | 901 { |
902 vim_free(name); | |
7 | 903 break; |
1702 | 904 } |
7 | 905 sprintf((char *)IObuff, "%c %2d %5ld %4d ", |
906 i == curwin->w_jumplistidx ? '>' : ' ', | |
907 i > curwin->w_jumplistidx ? i - curwin->w_jumplistidx | |
908 : curwin->w_jumplistidx - i, | |
909 curwin->w_jumplist[i].fmark.mark.lnum, | |
910 curwin->w_jumplist[i].fmark.mark.col); | |
911 msg_outtrans(IObuff); | |
912 msg_outtrans_attr(name, | |
913 curwin->w_jumplist[i].fmark.fnum == curbuf->b_fnum | |
11158
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
11140
diff
changeset
|
914 ? HL_ATTR(HLF_D) : 0); |
7 | 915 vim_free(name); |
916 ui_breakcheck(); | |
917 } | |
918 out_flush(); | |
919 } | |
920 if (curwin->w_jumplistidx == curwin->w_jumplistlen) | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
921 msg_puts("\n>"); |
7 | 922 } |
923 | |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
924 void |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
925 ex_clearjumps(exarg_T *eap UNUSED) |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
926 { |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
927 free_jumplist(curwin); |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
928 curwin->w_jumplistlen = 0; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
929 curwin->w_jumplistidx = 0; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
930 } |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
931 |
7 | 932 /* |
933 * print the changelist | |
934 */ | |
935 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
936 ex_changes(exarg_T *eap UNUSED) |
7 | 937 { |
938 int i; | |
939 char_u *name; | |
940 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
941 // Highlight title |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
942 msg_puts_title(_("\nchange line col text")); |
7 | 943 |
944 for (i = 0; i < curbuf->b_changelistlen && !got_int; ++i) | |
945 { | |
946 if (curbuf->b_changelist[i].lnum != 0) | |
947 { | |
948 msg_putchar('\n'); | |
949 if (got_int) | |
950 break; | |
951 sprintf((char *)IObuff, "%c %3d %5ld %4d ", | |
952 i == curwin->w_changelistidx ? '>' : ' ', | |
953 i > curwin->w_changelistidx ? i - curwin->w_changelistidx | |
954 : curwin->w_changelistidx - i, | |
955 (long)curbuf->b_changelist[i].lnum, | |
956 curbuf->b_changelist[i].col); | |
957 msg_outtrans(IObuff); | |
958 name = mark_line(&curbuf->b_changelist[i], 17); | |
959 if (name == NULL) | |
960 break; | |
11158
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
11140
diff
changeset
|
961 msg_outtrans_attr(name, HL_ATTR(HLF_D)); |
7 | 962 vim_free(name); |
963 ui_breakcheck(); | |
964 } | |
965 out_flush(); | |
966 } | |
967 if (curwin->w_changelistidx == curbuf->b_changelistlen) | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
968 msg_puts("\n>"); |
7 | 969 } |
970 #endif | |
971 | |
972 #define one_adjust(add) \ | |
973 { \ | |
974 lp = add; \ | |
975 if (*lp >= line1 && *lp <= line2) \ | |
976 { \ | |
977 if (amount == MAXLNUM) \ | |
978 *lp = 0; \ | |
979 else \ | |
980 *lp += amount; \ | |
981 } \ | |
982 else if (amount_after && *lp > line2) \ | |
983 *lp += amount_after; \ | |
984 } | |
985 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
986 // don't delete the line, just put at first deleted line |
7 | 987 #define one_adjust_nodel(add) \ |
988 { \ | |
989 lp = add; \ | |
990 if (*lp >= line1 && *lp <= line2) \ | |
991 { \ | |
992 if (amount == MAXLNUM) \ | |
993 *lp = line1; \ | |
994 else \ | |
995 *lp += amount; \ | |
996 } \ | |
997 else if (amount_after && *lp > line2) \ | |
998 *lp += amount_after; \ | |
999 } | |
1000 | |
1001 /* | |
1002 * Adjust marks between line1 and line2 (inclusive) to move 'amount' lines. | |
1003 * Must be called before changed_*(), appended_lines() or deleted_lines(). | |
1004 * May be called before or after changing the text. | |
1005 * When deleting lines line1 to line2, use an 'amount' of MAXLNUM: The marks | |
1006 * within this range are made invalid. | |
1007 * If 'amount_after' is non-zero adjust marks after line2. | |
1008 * Example: Delete lines 34 and 35: mark_adjust(34, 35, MAXLNUM, -2); | |
1009 * Example: Insert two lines below 55: mark_adjust(56, MAXLNUM, 2, 0); | |
1010 * or: mark_adjust(56, 55, MAXLNUM, 2); | |
1011 */ | |
1012 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1013 mark_adjust( |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1014 linenr_T line1, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1015 linenr_T line2, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1016 long amount, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1017 long amount_after) |
7 | 1018 { |
11140
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1019 mark_adjust_internal(line1, line2, amount, amount_after, TRUE); |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1020 } |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1021 |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1022 void |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1023 mark_adjust_nofold( |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1024 linenr_T line1, |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1025 linenr_T line2, |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1026 long amount, |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1027 long amount_after) |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1028 { |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1029 mark_adjust_internal(line1, line2, amount, amount_after, FALSE); |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1030 } |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1031 |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1032 static void |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1033 mark_adjust_internal( |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1034 linenr_T line1, |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1035 linenr_T line2, |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1036 long amount, |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1037 long amount_after, |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1038 int adjust_folds UNUSED) |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1039 { |
7 | 1040 int i; |
1041 int fnum = curbuf->b_fnum; | |
1042 linenr_T *lp; | |
1043 win_T *win; | |
1863 | 1044 tabpage_T *tab; |
15636
6f1c7e9a6393
patch 8.1.0826: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
1045 static pos_T initpos = {1, 0, 0}; |
7 | 1046 |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1047 if (line2 < line1 && amount_after == 0L) // nothing to do |
7 | 1048 return; |
1049 | |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
21403
diff
changeset
|
1050 if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) |
7 | 1051 { |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1052 // named marks, lower case and upper case |
7 | 1053 for (i = 0; i < NMARKS; i++) |
1054 { | |
1055 one_adjust(&(curbuf->b_namedm[i].lnum)); | |
1056 if (namedfm[i].fmark.fnum == fnum) | |
1057 one_adjust_nodel(&(namedfm[i].fmark.mark.lnum)); | |
1058 } | |
1059 for (i = NMARKS; i < NMARKS + EXTRA_MARKS; i++) | |
1060 { | |
1061 if (namedfm[i].fmark.fnum == fnum) | |
1062 one_adjust_nodel(&(namedfm[i].fmark.mark.lnum)); | |
1063 } | |
1064 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1065 // last Insert position |
7 | 1066 one_adjust(&(curbuf->b_last_insert.lnum)); |
1067 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1068 // last change position |
7 | 1069 one_adjust(&(curbuf->b_last_change.lnum)); |
1070 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1071 // last cursor position, if it was set |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10730
diff
changeset
|
1072 if (!EQUAL_POS(curbuf->b_last_cursor, initpos)) |
4092 | 1073 one_adjust(&(curbuf->b_last_cursor.lnum)); |
1074 | |
1075 | |
7 | 1076 #ifdef FEAT_JUMPLIST |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1077 // list of change positions |
7 | 1078 for (i = 0; i < curbuf->b_changelistlen; ++i) |
1079 one_adjust_nodel(&(curbuf->b_changelist[i].lnum)); | |
1080 #endif | |
1081 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1082 // Visual area |
690 | 1083 one_adjust_nodel(&(curbuf->b_visual.vi_start.lnum)); |
1084 one_adjust_nodel(&(curbuf->b_visual.vi_end.lnum)); | |
7 | 1085 |
1086 #ifdef FEAT_QUICKFIX | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1087 // quickfix marks |
643 | 1088 qf_mark_adjust(NULL, line1, line2, amount, amount_after); |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1089 // location lists |
1863 | 1090 FOR_ALL_TAB_WINDOWS(tab, win) |
643 | 1091 qf_mark_adjust(win, line1, line2, amount, amount_after); |
7 | 1092 #endif |
1093 | |
1094 #ifdef FEAT_SIGNS | |
1095 sign_mark_adjust(line1, line2, amount, amount_after); | |
1096 #endif | |
1097 } | |
1098 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1099 // previous context mark |
7 | 1100 one_adjust(&(curwin->w_pcmark.lnum)); |
1101 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1102 // previous pcmark |
7 | 1103 one_adjust(&(curwin->w_prev_pcmark.lnum)); |
1104 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1105 // saved cursor for formatting |
7 | 1106 if (saved_cursor.lnum != 0) |
1107 one_adjust_nodel(&(saved_cursor.lnum)); | |
1108 | |
1109 /* | |
1110 * Adjust items in all windows related to the current buffer. | |
1111 */ | |
1863 | 1112 FOR_ALL_TAB_WINDOWS(tab, win) |
7 | 1113 { |
1114 #ifdef FEAT_JUMPLIST | |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
21403
diff
changeset
|
1115 if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1116 // Marks in the jumplist. When deleting lines, this may create |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1117 // duplicate marks in the jumplist, they will be removed later. |
7 | 1118 for (i = 0; i < win->w_jumplistlen; ++i) |
1119 if (win->w_jumplist[i].fmark.fnum == fnum) | |
1120 one_adjust_nodel(&(win->w_jumplist[i].fmark.mark.lnum)); | |
1121 #endif | |
1122 | |
1123 if (win->w_buffer == curbuf) | |
1124 { | |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
21403
diff
changeset
|
1125 if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1126 // marks in the tag stack |
7 | 1127 for (i = 0; i < win->w_tagstacklen; i++) |
1128 if (win->w_tagstack[i].fmark.fnum == fnum) | |
1129 one_adjust_nodel(&(win->w_tagstack[i].fmark.mark.lnum)); | |
1130 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1131 // the displayed Visual area |
7 | 1132 if (win->w_old_cursor_lnum != 0) |
1133 { | |
1134 one_adjust_nodel(&(win->w_old_cursor_lnum)); | |
1135 one_adjust_nodel(&(win->w_old_visual_lnum)); | |
1136 } | |
1137 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1138 // topline and cursor position for windows with the same buffer |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1139 // other than the current window |
7 | 1140 if (win != curwin) |
1141 { | |
1142 if (win->w_topline >= line1 && win->w_topline <= line2) | |
1143 { | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1144 if (amount == MAXLNUM) // topline is deleted |
7 | 1145 { |
1146 if (line1 <= 1) | |
1147 win->w_topline = 1; | |
1148 else | |
1149 win->w_topline = line1 - 1; | |
1150 } | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1151 else // keep topline on the same line |
7 | 1152 win->w_topline += amount; |
1153 #ifdef FEAT_DIFF | |
1154 win->w_topfill = 0; | |
1155 #endif | |
1156 } | |
1157 else if (amount_after && win->w_topline > line2) | |
1158 { | |
1159 win->w_topline += amount_after; | |
1160 #ifdef FEAT_DIFF | |
1161 win->w_topfill = 0; | |
1162 #endif | |
1163 } | |
1164 if (win->w_cursor.lnum >= line1 && win->w_cursor.lnum <= line2) | |
1165 { | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1166 if (amount == MAXLNUM) // line with cursor is deleted |
7 | 1167 { |
1168 if (line1 <= 1) | |
1169 win->w_cursor.lnum = 1; | |
1170 else | |
1171 win->w_cursor.lnum = line1 - 1; | |
1172 win->w_cursor.col = 0; | |
1173 } | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1174 else // keep cursor on the same line |
7 | 1175 win->w_cursor.lnum += amount; |
1176 } | |
1177 else if (amount_after && win->w_cursor.lnum > line2) | |
1178 win->w_cursor.lnum += amount_after; | |
1179 } | |
1180 | |
1181 #ifdef FEAT_FOLDING | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1182 // adjust folds |
11140
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1183 if (adjust_folds) |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1184 foldMarkAdjust(win, line1, line2, amount, amount_after); |
7 | 1185 #endif |
1186 } | |
1187 } | |
1188 | |
1189 #ifdef FEAT_DIFF | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1190 // adjust diffs |
7 | 1191 diff_mark_adjust(line1, line2, amount, amount_after); |
1192 #endif | |
1193 } | |
1194 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1195 // This code is used often, needs to be fast. |
7 | 1196 #define col_adjust(pp) \ |
1197 { \ | |
1198 posp = pp; \ | |
1199 if (posp->lnum == lnum && posp->col >= mincol) \ | |
1200 { \ | |
1201 posp->lnum += lnum_amount; \ | |
1202 if (col_amount < 0 && posp->col <= (colnr_T)-col_amount) \ | |
1203 posp->col = 0; \ | |
15326
fe428bee74b3
patch 8.1.0671: cursor in the wrong column after auto-formatting
Bram Moolenaar <Bram@vim.org>
parents:
14968
diff
changeset
|
1204 else if (posp->col < spaces_removed) \ |
fe428bee74b3
patch 8.1.0671: cursor in the wrong column after auto-formatting
Bram Moolenaar <Bram@vim.org>
parents:
14968
diff
changeset
|
1205 posp->col = col_amount + spaces_removed; \ |
7 | 1206 else \ |
1207 posp->col += col_amount; \ | |
1208 } \ | |
1209 } | |
1210 | |
1211 /* | |
1212 * Adjust marks in line "lnum" at column "mincol" and further: add | |
1213 * "lnum_amount" to the line number and add "col_amount" to the column | |
1214 * position. | |
15326
fe428bee74b3
patch 8.1.0671: cursor in the wrong column after auto-formatting
Bram Moolenaar <Bram@vim.org>
parents:
14968
diff
changeset
|
1215 * "spaces_removed" is the number of spaces that were removed, matters when the |
fe428bee74b3
patch 8.1.0671: cursor in the wrong column after auto-formatting
Bram Moolenaar <Bram@vim.org>
parents:
14968
diff
changeset
|
1216 * cursor is inside them. |
7 | 1217 */ |
1218 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1219 mark_col_adjust( |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1220 linenr_T lnum, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1221 colnr_T mincol, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1222 long lnum_amount, |
15326
fe428bee74b3
patch 8.1.0671: cursor in the wrong column after auto-formatting
Bram Moolenaar <Bram@vim.org>
parents:
14968
diff
changeset
|
1223 long col_amount, |
fe428bee74b3
patch 8.1.0671: cursor in the wrong column after auto-formatting
Bram Moolenaar <Bram@vim.org>
parents:
14968
diff
changeset
|
1224 int spaces_removed) |
7 | 1225 { |
1226 int i; | |
1227 int fnum = curbuf->b_fnum; | |
1228 win_T *win; | |
1229 pos_T *posp; | |
1230 | |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
21403
diff
changeset
|
1231 if ((col_amount == 0L && lnum_amount == 0L) |
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
21403
diff
changeset
|
1232 || (cmdmod.cmod_flags & CMOD_LOCKMARKS)) |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1233 return; // nothing to do |
7 | 1234 |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1235 // named marks, lower case and upper case |
7 | 1236 for (i = 0; i < NMARKS; i++) |
1237 { | |
1238 col_adjust(&(curbuf->b_namedm[i])); | |
1239 if (namedfm[i].fmark.fnum == fnum) | |
1240 col_adjust(&(namedfm[i].fmark.mark)); | |
1241 } | |
1242 for (i = NMARKS; i < NMARKS + EXTRA_MARKS; i++) | |
1243 { | |
1244 if (namedfm[i].fmark.fnum == fnum) | |
1245 col_adjust(&(namedfm[i].fmark.mark)); | |
1246 } | |
1247 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1248 // last Insert position |
7 | 1249 col_adjust(&(curbuf->b_last_insert)); |
1250 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1251 // last change position |
7 | 1252 col_adjust(&(curbuf->b_last_change)); |
1253 | |
1254 #ifdef FEAT_JUMPLIST | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1255 // list of change positions |
7 | 1256 for (i = 0; i < curbuf->b_changelistlen; ++i) |
1257 col_adjust(&(curbuf->b_changelist[i])); | |
1258 #endif | |
1259 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1260 // Visual area |
690 | 1261 col_adjust(&(curbuf->b_visual.vi_start)); |
1262 col_adjust(&(curbuf->b_visual.vi_end)); | |
7 | 1263 |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1264 // previous context mark |
7 | 1265 col_adjust(&(curwin->w_pcmark)); |
1266 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1267 // previous pcmark |
7 | 1268 col_adjust(&(curwin->w_prev_pcmark)); |
1269 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1270 // saved cursor for formatting |
7 | 1271 col_adjust(&saved_cursor); |
1272 | |
1273 /* | |
1274 * Adjust items in all windows related to the current buffer. | |
1275 */ | |
1276 FOR_ALL_WINDOWS(win) | |
1277 { | |
1278 #ifdef FEAT_JUMPLIST | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1279 // marks in the jumplist |
7 | 1280 for (i = 0; i < win->w_jumplistlen; ++i) |
1281 if (win->w_jumplist[i].fmark.fnum == fnum) | |
1282 col_adjust(&(win->w_jumplist[i].fmark.mark)); | |
1283 #endif | |
1284 | |
1285 if (win->w_buffer == curbuf) | |
1286 { | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1287 // marks in the tag stack |
7 | 1288 for (i = 0; i < win->w_tagstacklen; i++) |
1289 if (win->w_tagstack[i].fmark.fnum == fnum) | |
1290 col_adjust(&(win->w_tagstack[i].fmark.mark)); | |
1291 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1292 // cursor position for other windows with the same buffer |
7 | 1293 if (win != curwin) |
1294 col_adjust(&win->w_cursor); | |
1295 } | |
1296 } | |
1297 } | |
1298 | |
1299 #ifdef FEAT_JUMPLIST | |
1300 /* | |
1301 * When deleting lines, this may create duplicate marks in the | |
13248
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1302 * jumplist. They will be removed here for the specified window. |
13278
28ae299c6af0
patch 8.0.1513: the jumplist is not always properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
13248
diff
changeset
|
1303 * When "loadfiles" is TRUE first ensure entries have the "fnum" field set |
28ae299c6af0
patch 8.0.1513: the jumplist is not always properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
13248
diff
changeset
|
1304 * (this may be a bit slow). |
7 | 1305 */ |
13248
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1306 void |
13278
28ae299c6af0
patch 8.0.1513: the jumplist is not always properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
13248
diff
changeset
|
1307 cleanup_jumplist(win_T *wp, int loadfiles) |
7 | 1308 { |
1309 int i; | |
1310 int from, to; | |
1311 | |
13278
28ae299c6af0
patch 8.0.1513: the jumplist is not always properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
13248
diff
changeset
|
1312 if (loadfiles) |
28ae299c6af0
patch 8.0.1513: the jumplist is not always properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
13248
diff
changeset
|
1313 { |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1314 // If specified, load all the files from the jump list. This is |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1315 // needed to properly clean up duplicate entries, but will take some |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1316 // time. |
13278
28ae299c6af0
patch 8.0.1513: the jumplist is not always properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
13248
diff
changeset
|
1317 for (i = 0; i < wp->w_jumplistlen; ++i) |
28ae299c6af0
patch 8.0.1513: the jumplist is not always properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
13248
diff
changeset
|
1318 { |
28ae299c6af0
patch 8.0.1513: the jumplist is not always properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
13248
diff
changeset
|
1319 if ((wp->w_jumplist[i].fmark.fnum == 0) && |
28ae299c6af0
patch 8.0.1513: the jumplist is not always properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
13248
diff
changeset
|
1320 (wp->w_jumplist[i].fmark.mark.lnum != 0)) |
28ae299c6af0
patch 8.0.1513: the jumplist is not always properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
13248
diff
changeset
|
1321 fname2fnum(&wp->w_jumplist[i]); |
28ae299c6af0
patch 8.0.1513: the jumplist is not always properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
13248
diff
changeset
|
1322 } |
28ae299c6af0
patch 8.0.1513: the jumplist is not always properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
13248
diff
changeset
|
1323 } |
28ae299c6af0
patch 8.0.1513: the jumplist is not always properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
13248
diff
changeset
|
1324 |
7 | 1325 to = 0; |
13248
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1326 for (from = 0; from < wp->w_jumplistlen; ++from) |
7 | 1327 { |
13248
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1328 if (wp->w_jumplistidx == from) |
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1329 wp->w_jumplistidx = to; |
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1330 for (i = from + 1; i < wp->w_jumplistlen; ++i) |
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1331 if (wp->w_jumplist[i].fmark.fnum |
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1332 == wp->w_jumplist[from].fmark.fnum |
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1333 && wp->w_jumplist[from].fmark.fnum != 0 |
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1334 && wp->w_jumplist[i].fmark.mark.lnum |
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1335 == wp->w_jumplist[from].fmark.mark.lnum) |
7 | 1336 break; |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1337 if (i >= wp->w_jumplistlen) // no duplicate |
13248
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1338 wp->w_jumplist[to++] = wp->w_jumplist[from]; |
7 | 1339 else |
13248
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1340 vim_free(wp->w_jumplist[from].fname); |
7 | 1341 } |
13248
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1342 if (wp->w_jumplistidx == wp->w_jumplistlen) |
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1343 wp->w_jumplistidx = to; |
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1344 wp->w_jumplistlen = to; |
7 | 1345 } |
1346 | |
1347 /* | |
1348 * Copy the jumplist from window "from" to window "to". | |
1349 */ | |
1350 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1351 copy_jumplist(win_T *from, win_T *to) |
7 | 1352 { |
1353 int i; | |
1354 | |
1355 for (i = 0; i < from->w_jumplistlen; ++i) | |
1356 { | |
1357 to->w_jumplist[i] = from->w_jumplist[i]; | |
1358 if (from->w_jumplist[i].fname != NULL) | |
1359 to->w_jumplist[i].fname = vim_strsave(from->w_jumplist[i].fname); | |
1360 } | |
1361 to->w_jumplistlen = from->w_jumplistlen; | |
1362 to->w_jumplistidx = from->w_jumplistidx; | |
1363 } | |
1364 | |
1365 /* | |
1366 * Free items in the jumplist of window "wp". | |
1367 */ | |
1368 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1369 free_jumplist(win_T *wp) |
7 | 1370 { |
1371 int i; | |
1372 | |
1373 for (i = 0; i < wp->w_jumplistlen; ++i) | |
1374 vim_free(wp->w_jumplist[i].fname); | |
1375 } | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1376 #endif // FEAT_JUMPLIST |
7 | 1377 |
1378 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1379 set_last_cursor(win_T *win) |
7 | 1380 { |
5417 | 1381 if (win->w_buffer != NULL) |
1382 win->w_buffer->b_last_cursor = win->w_cursor; | |
7 | 1383 } |
1384 | |
358 | 1385 #if defined(EXITFREE) || defined(PROTO) |
1386 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1387 free_all_marks(void) |
358 | 1388 { |
1389 int i; | |
1390 | |
1391 for (i = 0; i < NMARKS + EXTRA_MARKS; i++) | |
1392 if (namedfm[i].fmark.mark.lnum != 0) | |
1393 vim_free(namedfm[i].fname); | |
1394 } | |
1395 #endif | |
1396 | |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1397 /* |
17464
3e708b5c0509
patch 8.1.1730: wrong place for mark viminfo support
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1398 * Return a pointer to the named file marks. |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1399 */ |
17464
3e708b5c0509
patch 8.1.1730: wrong place for mark viminfo support
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1400 xfmark_T * |
3e708b5c0509
patch 8.1.1730: wrong place for mark viminfo support
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1401 get_namedfm(void) |
7 | 1402 { |
17464
3e708b5c0509
patch 8.1.1730: wrong place for mark viminfo support
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1403 return namedfm; |
7 | 1404 } |
20615
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1405 |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1406 #if defined(FEAT_EVAL) || defined(PROTO) |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1407 /* |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1408 * Add information about mark 'mname' to list 'l' |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1409 */ |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1410 static int |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1411 add_mark(list_T *l, char_u *mname, pos_T *pos, int bufnr, char_u *fname) |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1412 { |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1413 dict_T *d; |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1414 list_T *lpos; |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1415 |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1416 if (pos->lnum <= 0) |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1417 return OK; |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1418 |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1419 d = dict_alloc(); |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1420 if (d == NULL) |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1421 return FAIL; |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1422 |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1423 if (list_append_dict(l, d) == FAIL) |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1424 { |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1425 dict_unref(d); |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1426 return FAIL; |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1427 } |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1428 |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1429 lpos = list_alloc(); |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1430 if (lpos == NULL) |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1431 return FAIL; |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1432 |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1433 list_append_number(lpos, bufnr); |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1434 list_append_number(lpos, pos->lnum); |
20635
3e36a51ff152
patch 8.2.0871: cannot use getmarklist() as a method
Bram Moolenaar <Bram@vim.org>
parents:
20615
diff
changeset
|
1435 list_append_number(lpos, pos->col + 1); |
20615
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1436 list_append_number(lpos, pos->coladd); |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1437 |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1438 if (dict_add_string(d, "mark", mname) == FAIL |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1439 || dict_add_list(d, "pos", lpos) == FAIL |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1440 || (fname != NULL && dict_add_string(d, "file", fname) == FAIL)) |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1441 return FAIL; |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1442 |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1443 return OK; |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1444 } |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1445 |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1446 /* |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1447 * Get information about marks local to a buffer. |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1448 */ |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1449 static void |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1450 get_buf_local_marks(buf_T *buf, list_T *l) |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1451 { |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1452 char_u mname[3] = "' "; |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1453 int i; |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1454 |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1455 // Marks 'a' to 'z' |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1456 for (i = 0; i < NMARKS; ++i) |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1457 { |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1458 mname[1] = 'a' + i; |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1459 add_mark(l, mname, &buf->b_namedm[i], buf->b_fnum, NULL); |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1460 } |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1461 |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1462 // Mark '' is a window local mark and not a buffer local mark |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1463 add_mark(l, (char_u *)"''", &curwin->w_pcmark, curbuf->b_fnum, NULL); |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1464 |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1465 add_mark(l, (char_u *)"'\"", &buf->b_last_cursor, buf->b_fnum, NULL); |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1466 add_mark(l, (char_u *)"'[", &buf->b_op_start, buf->b_fnum, NULL); |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1467 add_mark(l, (char_u *)"']", &buf->b_op_end, buf->b_fnum, NULL); |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1468 add_mark(l, (char_u *)"'^", &buf->b_last_insert, buf->b_fnum, NULL); |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1469 add_mark(l, (char_u *)"'.", &buf->b_last_change, buf->b_fnum, NULL); |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1470 add_mark(l, (char_u *)"'<", &buf->b_visual.vi_start, buf->b_fnum, NULL); |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1471 add_mark(l, (char_u *)"'>", &buf->b_visual.vi_end, buf->b_fnum, NULL); |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1472 } |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1473 |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1474 /* |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1475 * Get information about global marks ('A' to 'Z' and '0' to '9') |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1476 */ |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1477 static void |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1478 get_global_marks(list_T *l) |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1479 { |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1480 char_u mname[3] = "' "; |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1481 int i; |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1482 char_u *name; |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1483 |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1484 // Marks 'A' to 'Z' and '0' to '9' |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1485 for (i = 0; i < NMARKS + EXTRA_MARKS; ++i) |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1486 { |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1487 if (namedfm[i].fmark.fnum != 0) |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1488 name = buflist_nr2name(namedfm[i].fmark.fnum, TRUE, TRUE); |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1489 else |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1490 name = namedfm[i].fname; |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1491 if (name != NULL) |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1492 { |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1493 mname[1] = i >= NMARKS ? i - NMARKS + '0' : i + 'A'; |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1494 add_mark(l, mname, &namedfm[i].fmark.mark, |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1495 namedfm[i].fmark.fnum, name); |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1496 if (namedfm[i].fmark.fnum != 0) |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1497 vim_free(name); |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1498 } |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1499 } |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1500 } |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1501 |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1502 /* |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1503 * getmarklist() function |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1504 */ |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1505 void |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1506 f_getmarklist(typval_T *argvars, typval_T *rettv) |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1507 { |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1508 buf_T *buf = NULL; |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1509 |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1510 if (rettv_list_alloc(rettv) != OK) |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1511 return; |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1512 |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1513 if (argvars[0].v_type == VAR_UNKNOWN) |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1514 { |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1515 get_global_marks(rettv->vval.v_list); |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1516 return; |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1517 } |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1518 |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1519 buf = tv_get_buf(&argvars[0], FALSE); |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1520 if (buf == NULL) |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1521 return; |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1522 |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1523 get_buf_local_marks(buf, rettv->vval.v_list); |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1524 } |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1525 #endif |