Mercurial > vim
annotate src/mark.c @ 5474:f6940759212d
Added tag v7-4-086 for changeset 60a5b7b82016
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Mon, 11 Nov 2013 04:25:53 +0100 |
parents | 2a72805a3038 |
children | 50dbef5e774a |
rev | line source |
---|---|
7 | 1 /* vi:set ts=8 sts=4 sw=4: |
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 */ | |
27 #define EXTRA_MARKS 10 /* marks 0-9 */ | |
28 static xfmark_T namedfm[NMARKS + EXTRA_MARKS]; /* marks with file nr */ | |
29 | |
30 static void fname2fnum __ARGS((xfmark_T *fm)); | |
31 static void fmarks_check_one __ARGS((xfmark_T *fm, char_u *name, buf_T *buf)); | |
32 static char_u *mark_line __ARGS((pos_T *mp, int lead_len)); | |
33 static void show_one_mark __ARGS((int, char_u *, pos_T *, char_u *, int current)); | |
34 #ifdef FEAT_JUMPLIST | |
35 static void cleanup_jumplist __ARGS((void)); | |
36 #endif | |
37 #ifdef FEAT_VIMINFO | |
38 static void write_one_filemark __ARGS((FILE *fp, xfmark_T *fm, int c1, int c2)); | |
39 #endif | |
40 | |
41 /* | |
706 | 42 * Set named mark "c" at current cursor position. |
7 | 43 * Returns OK on success, FAIL if bad name given. |
44 */ | |
45 int | |
46 setmark(c) | |
47 int c; | |
48 { | |
706 | 49 return setmark_pos(c, &curwin->w_cursor, curbuf->b_fnum); |
50 } | |
51 | |
52 /* | |
53 * Set named mark "c" to position "pos". | |
54 * When "c" is upper case use file "fnum". | |
55 * Returns OK on success, FAIL if bad name given. | |
56 */ | |
57 int | |
58 setmark_pos(c, pos, fnum) | |
59 int c; | |
60 pos_T *pos; | |
61 int fnum; | |
62 { | |
7 | 63 int i; |
64 | |
65 /* Check for a special key (may cause islower() to crash). */ | |
66 if (c < 0) | |
67 return FAIL; | |
68 | |
69 if (c == '\'' || c == '`') | |
70 { | |
706 | 71 if (pos == &curwin->w_cursor) |
72 { | |
73 setpcmark(); | |
74 /* keep it even when the cursor doesn't move */ | |
75 curwin->w_prev_pcmark = curwin->w_pcmark; | |
76 } | |
77 else | |
78 curwin->w_pcmark = *pos; | |
7 | 79 return OK; |
80 } | |
81 | |
1533 | 82 if (c == '"') |
83 { | |
84 curbuf->b_last_cursor = *pos; | |
85 return OK; | |
86 } | |
87 | |
7 | 88 /* Allow setting '[ and '] for an autocommand that simulates reading a |
89 * file. */ | |
90 if (c == '[') | |
91 { | |
706 | 92 curbuf->b_op_start = *pos; |
7 | 93 return OK; |
94 } | |
95 if (c == ']') | |
96 { | |
706 | 97 curbuf->b_op_end = *pos; |
7 | 98 return OK; |
99 } | |
100 | |
3660 | 101 #ifdef FEAT_VISUAL |
5265
cd971e951b06
updated for version 7.4b.009
Bram Moolenaar <bram@vim.org>
parents:
4092
diff
changeset
|
102 if (c == '<' || c == '>') |
3660 | 103 { |
5265
cd971e951b06
updated for version 7.4b.009
Bram Moolenaar <bram@vim.org>
parents:
4092
diff
changeset
|
104 if (c == '<') |
cd971e951b06
updated for version 7.4b.009
Bram Moolenaar <bram@vim.org>
parents:
4092
diff
changeset
|
105 curbuf->b_visual.vi_start = *pos; |
cd971e951b06
updated for version 7.4b.009
Bram Moolenaar <bram@vim.org>
parents:
4092
diff
changeset
|
106 else |
cd971e951b06
updated for version 7.4b.009
Bram Moolenaar <bram@vim.org>
parents:
4092
diff
changeset
|
107 curbuf->b_visual.vi_end = *pos; |
cd971e951b06
updated for version 7.4b.009
Bram Moolenaar <bram@vim.org>
parents:
4092
diff
changeset
|
108 if (curbuf->b_visual.vi_mode == NUL) |
cd971e951b06
updated for version 7.4b.009
Bram Moolenaar <bram@vim.org>
parents:
4092
diff
changeset
|
109 /* Visual_mode has not yet been set, use a sane default. */ |
cd971e951b06
updated for version 7.4b.009
Bram Moolenaar <bram@vim.org>
parents:
4092
diff
changeset
|
110 curbuf->b_visual.vi_mode = 'v'; |
3660 | 111 return OK; |
112 } | |
113 #endif | |
114 | |
7 | 115 #ifndef EBCDIC |
116 if (c > 'z') /* some islower() and isupper() cannot handle | |
117 characters above 127 */ | |
118 return FAIL; | |
119 #endif | |
120 if (islower(c)) | |
121 { | |
122 i = c - 'a'; | |
706 | 123 curbuf->b_namedm[i] = *pos; |
7 | 124 return OK; |
125 } | |
126 if (isupper(c)) | |
127 { | |
128 i = c - 'A'; | |
706 | 129 namedfm[i].fmark.mark = *pos; |
130 namedfm[i].fmark.fnum = fnum; | |
7 | 131 vim_free(namedfm[i].fname); |
132 namedfm[i].fname = NULL; | |
133 return OK; | |
134 } | |
135 return FAIL; | |
136 } | |
137 | |
138 /* | |
139 * Set the previous context mark to the current position and add it to the | |
140 * jump list. | |
141 */ | |
142 void | |
143 setpcmark() | |
144 { | |
145 #ifdef FEAT_JUMPLIST | |
146 int i; | |
147 xfmark_T *fm; | |
148 #endif | |
149 #ifdef JUMPLIST_ROTATE | |
150 xfmark_T tempmark; | |
151 #endif | |
152 | |
153 /* for :global the mark is set only once */ | |
154 if (global_busy || listcmd_busy || cmdmod.keepjumps) | |
155 return; | |
156 | |
157 curwin->w_prev_pcmark = curwin->w_pcmark; | |
158 curwin->w_pcmark = curwin->w_cursor; | |
159 | |
160 #ifdef FEAT_JUMPLIST | |
161 # ifdef JUMPLIST_ROTATE | |
162 /* | |
163 * If last used entry is not at the top, put it at the top by rotating | |
164 * the stack until it is (the newer entries will be at the bottom). | |
165 * Keep one entry (the last used one) at the top. | |
166 */ | |
167 if (curwin->w_jumplistidx < curwin->w_jumplistlen) | |
168 ++curwin->w_jumplistidx; | |
169 while (curwin->w_jumplistidx < curwin->w_jumplistlen) | |
170 { | |
171 tempmark = curwin->w_jumplist[curwin->w_jumplistlen - 1]; | |
172 for (i = curwin->w_jumplistlen - 1; i > 0; --i) | |
173 curwin->w_jumplist[i] = curwin->w_jumplist[i - 1]; | |
174 curwin->w_jumplist[0] = tempmark; | |
175 ++curwin->w_jumplistidx; | |
176 } | |
177 # endif | |
178 | |
179 /* If jumplist is full: remove oldest entry */ | |
180 if (++curwin->w_jumplistlen > JUMPLISTSIZE) | |
181 { | |
182 curwin->w_jumplistlen = JUMPLISTSIZE; | |
183 vim_free(curwin->w_jumplist[0].fname); | |
184 for (i = 1; i < JUMPLISTSIZE; ++i) | |
185 curwin->w_jumplist[i - 1] = curwin->w_jumplist[i]; | |
186 } | |
187 curwin->w_jumplistidx = curwin->w_jumplistlen; | |
188 fm = &curwin->w_jumplist[curwin->w_jumplistlen - 1]; | |
189 | |
190 fm->fmark.mark = curwin->w_pcmark; | |
191 fm->fmark.fnum = curbuf->b_fnum; | |
192 fm->fname = NULL; | |
193 #endif | |
194 } | |
195 | |
196 /* | |
197 * To change context, call setpcmark(), then move the current position to | |
198 * where ever, then call checkpcmark(). This ensures that the previous | |
199 * context will only be changed if the cursor moved to a different line. | |
200 * If pcmark was deleted (with "dG") the previous mark is restored. | |
201 */ | |
202 void | |
203 checkpcmark() | |
204 { | |
205 if (curwin->w_prev_pcmark.lnum != 0 | |
206 && (equalpos(curwin->w_pcmark, curwin->w_cursor) | |
207 || curwin->w_pcmark.lnum == 0)) | |
208 { | |
209 curwin->w_pcmark = curwin->w_prev_pcmark; | |
210 curwin->w_prev_pcmark.lnum = 0; /* Show it has been checked */ | |
211 } | |
212 } | |
213 | |
214 #if defined(FEAT_JUMPLIST) || defined(PROTO) | |
215 /* | |
216 * move "count" positions in the jump list (count may be negative) | |
217 */ | |
218 pos_T * | |
219 movemark(count) | |
220 int count; | |
221 { | |
222 pos_T *pos; | |
223 xfmark_T *jmp; | |
224 | |
225 cleanup_jumplist(); | |
226 | |
227 if (curwin->w_jumplistlen == 0) /* nothing to jump to */ | |
228 return (pos_T *)NULL; | |
229 | |
230 for (;;) | |
231 { | |
232 if (curwin->w_jumplistidx + count < 0 | |
233 || curwin->w_jumplistidx + count >= curwin->w_jumplistlen) | |
234 return (pos_T *)NULL; | |
235 | |
236 /* | |
237 * if first CTRL-O or CTRL-I command after a jump, add cursor position | |
1188 | 238 * to list. Careful: If there are duplicates (CTRL-O immediately after |
7 | 239 * starting Vim on a file), another entry may have been removed. |
240 */ | |
241 if (curwin->w_jumplistidx == curwin->w_jumplistlen) | |
242 { | |
243 setpcmark(); | |
244 --curwin->w_jumplistidx; /* skip the new entry */ | |
245 if (curwin->w_jumplistidx + count < 0) | |
246 return (pos_T *)NULL; | |
247 } | |
248 | |
249 curwin->w_jumplistidx += count; | |
250 | |
251 jmp = curwin->w_jumplist + curwin->w_jumplistidx; | |
252 if (jmp->fmark.fnum == 0) | |
253 fname2fnum(jmp); | |
254 if (jmp->fmark.fnum != curbuf->b_fnum) | |
255 { | |
256 /* jump to other file */ | |
257 if (buflist_findnr(jmp->fmark.fnum) == NULL) | |
258 { /* Skip this one .. */ | |
259 count += count < 0 ? -1 : 1; | |
260 continue; | |
261 } | |
262 if (buflist_getfile(jmp->fmark.fnum, jmp->fmark.mark.lnum, | |
263 0, FALSE) == FAIL) | |
264 return (pos_T *)NULL; | |
265 /* Set lnum again, autocommands my have changed it */ | |
266 curwin->w_cursor = jmp->fmark.mark; | |
267 pos = (pos_T *)-1; | |
268 } | |
269 else | |
270 pos = &(jmp->fmark.mark); | |
271 return pos; | |
272 } | |
273 } | |
274 | |
275 /* | |
276 * Move "count" positions in the changelist (count may be negative). | |
277 */ | |
278 pos_T * | |
279 movechangelist(count) | |
280 int count; | |
281 { | |
282 int n; | |
283 | |
284 if (curbuf->b_changelistlen == 0) /* nothing to jump to */ | |
285 return (pos_T *)NULL; | |
286 | |
287 n = curwin->w_changelistidx; | |
288 if (n + count < 0) | |
289 { | |
290 if (n == 0) | |
291 return (pos_T *)NULL; | |
292 n = 0; | |
293 } | |
294 else if (n + count >= curbuf->b_changelistlen) | |
295 { | |
296 if (n == curbuf->b_changelistlen - 1) | |
297 return (pos_T *)NULL; | |
298 n = curbuf->b_changelistlen - 1; | |
299 } | |
300 else | |
301 n += count; | |
302 curwin->w_changelistidx = n; | |
303 return curbuf->b_changelist + n; | |
304 } | |
305 #endif | |
306 | |
307 /* | |
4043 | 308 * Find mark "c" in buffer pointed to by "buf". |
706 | 309 * If "changefile" is TRUE it's allowed to edit another file for '0, 'A, etc. |
310 * If "fnum" is not NULL store the fnum there for '0, 'A etc., don't edit | |
311 * another file. | |
7 | 312 * Returns: |
313 * - pointer to pos_T if found. lnum is 0 when mark not set, -1 when mark is | |
314 * in another file which can't be gotten. (caller needs to check lnum!) | |
315 * - NULL if there is no mark called 'c'. | |
316 * - -1 if mark is in other file and jumped there (only if changefile is TRUE) | |
317 */ | |
318 pos_T * | |
4043 | 319 getmark_buf(buf, c, changefile) |
320 buf_T *buf; | |
321 int c; | |
322 int changefile; | |
323 { | |
324 return getmark_buf_fnum(buf, c, changefile, NULL); | |
325 } | |
326 | |
327 pos_T * | |
7 | 328 getmark(c, changefile) |
329 int c; | |
706 | 330 int changefile; |
331 { | |
4043 | 332 return getmark_buf_fnum(curbuf, c, changefile, NULL); |
706 | 333 } |
334 | |
335 pos_T * | |
4043 | 336 getmark_buf_fnum(buf, c, changefile, fnum) |
337 buf_T *buf; | |
706 | 338 int c; |
339 int changefile; | |
340 int *fnum; | |
7 | 341 { |
342 pos_T *posp; | |
343 #ifdef FEAT_VISUAL | |
344 pos_T *startp, *endp; | |
345 #endif | |
346 static pos_T pos_copy; | |
347 | |
348 posp = NULL; | |
349 | |
350 /* Check for special key, can't be a mark name and might cause islower() | |
351 * to crash. */ | |
352 if (c < 0) | |
353 return posp; | |
354 #ifndef EBCDIC | |
355 if (c > '~') /* check for islower()/isupper() */ | |
356 ; | |
357 else | |
358 #endif | |
359 if (c == '\'' || c == '`') /* previous context mark */ | |
360 { | |
361 pos_copy = curwin->w_pcmark; /* need to make a copy because */ | |
362 posp = &pos_copy; /* w_pcmark may be changed soon */ | |
363 } | |
364 else if (c == '"') /* to pos when leaving buffer */ | |
4043 | 365 posp = &(buf->b_last_cursor); |
7 | 366 else if (c == '^') /* to where Insert mode stopped */ |
4043 | 367 posp = &(buf->b_last_insert); |
7 | 368 else if (c == '.') /* to where last change was made */ |
4043 | 369 posp = &(buf->b_last_change); |
7 | 370 else if (c == '[') /* to start of previous operator */ |
4043 | 371 posp = &(buf->b_op_start); |
7 | 372 else if (c == ']') /* to end of previous operator */ |
4043 | 373 posp = &(buf->b_op_end); |
7 | 374 else if (c == '{' || c == '}') /* to previous/next paragraph */ |
375 { | |
376 pos_T pos; | |
377 oparg_T oa; | |
378 int slcb = listcmd_busy; | |
379 | |
380 pos = curwin->w_cursor; | |
381 listcmd_busy = TRUE; /* avoid that '' is changed */ | |
503 | 382 if (findpar(&oa.inclusive, |
383 c == '}' ? FORWARD : BACKWARD, 1L, NUL, FALSE)) | |
7 | 384 { |
385 pos_copy = curwin->w_cursor; | |
386 posp = &pos_copy; | |
387 } | |
388 curwin->w_cursor = pos; | |
389 listcmd_busy = slcb; | |
390 } | |
391 else if (c == '(' || c == ')') /* to previous/next sentence */ | |
392 { | |
393 pos_T pos; | |
394 int slcb = listcmd_busy; | |
395 | |
396 pos = curwin->w_cursor; | |
397 listcmd_busy = TRUE; /* avoid that '' is changed */ | |
398 if (findsent(c == ')' ? FORWARD : BACKWARD, 1L)) | |
399 { | |
400 pos_copy = curwin->w_cursor; | |
401 posp = &pos_copy; | |
402 } | |
403 curwin->w_cursor = pos; | |
404 listcmd_busy = slcb; | |
405 } | |
406 #ifdef FEAT_VISUAL | |
407 else if (c == '<' || c == '>') /* start/end of visual area */ | |
408 { | |
4043 | 409 startp = &buf->b_visual.vi_start; |
410 endp = &buf->b_visual.vi_end; | |
7 | 411 if ((c == '<') == lt(*startp, *endp)) |
412 posp = startp; | |
413 else | |
414 posp = endp; | |
415 /* | |
416 * For Visual line mode, set mark at begin or end of line | |
417 */ | |
4043 | 418 if (buf->b_visual.vi_mode == 'V') |
7 | 419 { |
420 pos_copy = *posp; | |
421 posp = &pos_copy; | |
422 if (c == '<') | |
423 pos_copy.col = 0; | |
424 else | |
425 pos_copy.col = MAXCOL; | |
426 #ifdef FEAT_VIRTUALEDIT | |
427 pos_copy.coladd = 0; | |
428 #endif | |
429 } | |
430 } | |
431 #endif | |
432 else if (ASCII_ISLOWER(c)) /* normal named mark */ | |
433 { | |
4043 | 434 posp = &(buf->b_namedm[c - 'a']); |
7 | 435 } |
436 else if (ASCII_ISUPPER(c) || VIM_ISDIGIT(c)) /* named file mark */ | |
437 { | |
438 if (VIM_ISDIGIT(c)) | |
439 c = c - '0' + NMARKS; | |
440 else | |
441 c -= 'A'; | |
442 posp = &(namedfm[c].fmark.mark); | |
443 | |
444 if (namedfm[c].fmark.fnum == 0) | |
445 fname2fnum(&namedfm[c]); | |
706 | 446 |
447 if (fnum != NULL) | |
448 *fnum = namedfm[c].fmark.fnum; | |
4043 | 449 else if (namedfm[c].fmark.fnum != buf->b_fnum) |
7 | 450 { |
706 | 451 /* mark is in another file */ |
7 | 452 posp = &pos_copy; |
453 | |
454 if (namedfm[c].fmark.mark.lnum != 0 | |
455 && changefile && namedfm[c].fmark.fnum) | |
456 { | |
457 if (buflist_getfile(namedfm[c].fmark.fnum, | |
458 (linenr_T)1, GETF_SETMARK, FALSE) == OK) | |
459 { | |
460 /* Set the lnum now, autocommands could have changed it */ | |
461 curwin->w_cursor = namedfm[c].fmark.mark; | |
462 return (pos_T *)-1; | |
463 } | |
464 pos_copy.lnum = -1; /* can't get file */ | |
465 } | |
466 else | |
467 pos_copy.lnum = 0; /* mark exists, but is not valid in | |
468 current buffer */ | |
469 } | |
470 } | |
471 | |
472 return posp; | |
473 } | |
474 | |
475 /* | |
476 * Search for the next named mark in the current file. | |
477 * | |
478 * Returns pointer to pos_T of the next mark or NULL if no mark is found. | |
479 */ | |
480 pos_T * | |
481 getnextmark(startpos, dir, begin_line) | |
482 pos_T *startpos; /* where to start */ | |
483 int dir; /* direction for search */ | |
484 int begin_line; | |
485 { | |
486 int i; | |
487 pos_T *result = NULL; | |
488 pos_T pos; | |
489 | |
490 pos = *startpos; | |
491 | |
492 /* When searching backward and leaving the cursor on the first non-blank, | |
493 * position must be in a previous line. | |
494 * When searching forward and leaving the cursor on the first non-blank, | |
495 * position must be in a next line. */ | |
496 if (dir == BACKWARD && begin_line) | |
497 pos.col = 0; | |
498 else if (dir == FORWARD && begin_line) | |
499 pos.col = MAXCOL; | |
500 | |
501 for (i = 0; i < NMARKS; i++) | |
502 { | |
503 if (curbuf->b_namedm[i].lnum > 0) | |
504 { | |
505 if (dir == FORWARD) | |
506 { | |
507 if ((result == NULL || lt(curbuf->b_namedm[i], *result)) | |
508 && lt(pos, curbuf->b_namedm[i])) | |
509 result = &curbuf->b_namedm[i]; | |
510 } | |
511 else | |
512 { | |
513 if ((result == NULL || lt(*result, curbuf->b_namedm[i])) | |
514 && lt(curbuf->b_namedm[i], pos)) | |
515 result = &curbuf->b_namedm[i]; | |
516 } | |
517 } | |
518 } | |
519 | |
520 return result; | |
521 } | |
522 | |
523 /* | |
524 * For an xtended filemark: set the fnum from the fname. | |
525 * This is used for marks obtained from the .viminfo file. It's postponed | |
526 * until the mark is used to avoid a long startup delay. | |
527 */ | |
528 static void | |
529 fname2fnum(fm) | |
530 xfmark_T *fm; | |
531 { | |
532 char_u *p; | |
533 | |
534 if (fm->fname != NULL) | |
535 { | |
536 /* | |
537 * First expand "~/" in the file name to the home directory. | |
1480 | 538 * Don't expand the whole name, it may contain other '~' chars. |
7 | 539 */ |
1480 | 540 if (fm->fname[0] == '~' && (fm->fname[1] == '/' |
541 #ifdef BACKSLASH_IN_FILENAME | |
542 || fm->fname[1] == '\\' | |
543 #endif | |
544 )) | |
545 { | |
546 int len; | |
547 | |
548 expand_env((char_u *)"~/", NameBuff, MAXPATHL); | |
1570 | 549 len = (int)STRLEN(NameBuff); |
1480 | 550 vim_strncpy(NameBuff + len, fm->fname + 2, MAXPATHL - len - 1); |
551 } | |
552 else | |
553 vim_strncpy(NameBuff, fm->fname, MAXPATHL - 1); | |
554 | |
555 /* Try to shorten the file name. */ | |
7 | 556 mch_dirname(IObuff, IOSIZE); |
557 p = shorten_fname(NameBuff, IObuff); | |
558 | |
559 /* buflist_new() will call fmarks_check_names() */ | |
560 (void)buflist_new(NameBuff, p, (linenr_T)1, 0); | |
561 } | |
562 } | |
563 | |
564 /* | |
565 * Check all file marks for a name that matches the file name in buf. | |
566 * May replace the name with an fnum. | |
567 * Used for marks that come from the .viminfo file. | |
568 */ | |
569 void | |
570 fmarks_check_names(buf) | |
571 buf_T *buf; | |
572 { | |
573 char_u *name; | |
574 int i; | |
575 #ifdef FEAT_JUMPLIST | |
576 win_T *wp; | |
577 #endif | |
578 | |
579 if (buf->b_ffname == NULL) | |
580 return; | |
581 | |
582 name = home_replace_save(buf, buf->b_ffname); | |
583 if (name == NULL) | |
584 return; | |
585 | |
586 for (i = 0; i < NMARKS + EXTRA_MARKS; ++i) | |
587 fmarks_check_one(&namedfm[i], name, buf); | |
588 | |
589 #ifdef FEAT_JUMPLIST | |
590 FOR_ALL_WINDOWS(wp) | |
591 { | |
592 for (i = 0; i < wp->w_jumplistlen; ++i) | |
593 fmarks_check_one(&wp->w_jumplist[i], name, buf); | |
594 } | |
595 #endif | |
596 | |
597 vim_free(name); | |
598 } | |
599 | |
600 static void | |
601 fmarks_check_one(fm, name, buf) | |
602 xfmark_T *fm; | |
603 char_u *name; | |
604 buf_T *buf; | |
605 { | |
606 if (fm->fmark.fnum == 0 | |
607 && fm->fname != NULL | |
608 && fnamecmp(name, fm->fname) == 0) | |
609 { | |
610 fm->fmark.fnum = buf->b_fnum; | |
611 vim_free(fm->fname); | |
612 fm->fname = NULL; | |
613 } | |
614 } | |
615 | |
616 /* | |
617 * Check a if a position from a mark is valid. | |
618 * Give and error message and return FAIL if not. | |
619 */ | |
620 int | |
621 check_mark(pos) | |
622 pos_T *pos; | |
623 { | |
624 if (pos == NULL) | |
625 { | |
626 EMSG(_(e_umark)); | |
627 return FAIL; | |
628 } | |
629 if (pos->lnum <= 0) | |
630 { | |
631 /* lnum is negative if mark is in another file can can't get that | |
632 * file, error message already give then. */ | |
633 if (pos->lnum == 0) | |
634 EMSG(_(e_marknotset)); | |
635 return FAIL; | |
636 } | |
637 if (pos->lnum > curbuf->b_ml.ml_line_count) | |
638 { | |
639 EMSG(_(e_markinval)); | |
640 return FAIL; | |
641 } | |
642 return OK; | |
643 } | |
644 | |
645 /* | |
646 * clrallmarks() - clear all marks in the buffer 'buf' | |
647 * | |
648 * Used mainly when trashing the entire buffer during ":e" type commands | |
649 */ | |
650 void | |
651 clrallmarks(buf) | |
652 buf_T *buf; | |
653 { | |
654 static int i = -1; | |
655 | |
656 if (i == -1) /* first call ever: initialize */ | |
657 for (i = 0; i < NMARKS + 1; i++) | |
658 { | |
659 namedfm[i].fmark.mark.lnum = 0; | |
660 namedfm[i].fname = NULL; | |
661 } | |
662 | |
663 for (i = 0; i < NMARKS; i++) | |
664 buf->b_namedm[i].lnum = 0; | |
665 buf->b_op_start.lnum = 0; /* start/end op mark cleared */ | |
666 buf->b_op_end.lnum = 0; | |
667 buf->b_last_cursor.lnum = 1; /* '" mark cleared */ | |
668 buf->b_last_cursor.col = 0; | |
669 #ifdef FEAT_VIRTUALEDIT | |
670 buf->b_last_cursor.coladd = 0; | |
671 #endif | |
672 buf->b_last_insert.lnum = 0; /* '^ mark cleared */ | |
673 buf->b_last_change.lnum = 0; /* '. mark cleared */ | |
674 #ifdef FEAT_JUMPLIST | |
675 buf->b_changelistlen = 0; | |
676 #endif | |
677 } | |
678 | |
679 /* | |
680 * Get name of file from a filemark. | |
681 * When it's in the current buffer, return the text at the mark. | |
682 * Returns an allocated string. | |
683 */ | |
684 char_u * | |
685 fm_getname(fmark, lead_len) | |
686 fmark_T *fmark; | |
687 int lead_len; | |
688 { | |
689 if (fmark->fnum == curbuf->b_fnum) /* current buffer */ | |
690 return mark_line(&(fmark->mark), lead_len); | |
691 return buflist_nr2name(fmark->fnum, FALSE, TRUE); | |
692 } | |
693 | |
694 /* | |
695 * Return the line at mark "mp". Truncate to fit in window. | |
696 * The returned string has been allocated. | |
697 */ | |
698 static char_u * | |
699 mark_line(mp, lead_len) | |
700 pos_T *mp; | |
701 int lead_len; | |
702 { | |
703 char_u *s, *p; | |
704 int len; | |
705 | |
706 if (mp->lnum == 0 || mp->lnum > curbuf->b_ml.ml_line_count) | |
707 return vim_strsave((char_u *)"-invalid-"); | |
708 s = vim_strnsave(skipwhite(ml_get(mp->lnum)), (int)Columns); | |
709 if (s == NULL) | |
710 return NULL; | |
711 /* Truncate the line to fit it in the window */ | |
712 len = 0; | |
39 | 713 for (p = s; *p != NUL; mb_ptr_adv(p)) |
7 | 714 { |
715 len += ptr2cells(p); | |
716 if (len >= Columns - lead_len) | |
717 break; | |
718 } | |
719 *p = NUL; | |
720 return s; | |
721 } | |
722 | |
723 /* | |
724 * print the marks | |
725 */ | |
726 void | |
727 do_marks(eap) | |
728 exarg_T *eap; | |
729 { | |
730 char_u *arg = eap->arg; | |
731 int i; | |
732 char_u *name; | |
733 | |
734 if (arg != NULL && *arg == NUL) | |
735 arg = NULL; | |
736 | |
737 show_one_mark('\'', arg, &curwin->w_pcmark, NULL, TRUE); | |
738 for (i = 0; i < NMARKS; ++i) | |
739 show_one_mark(i + 'a', arg, &curbuf->b_namedm[i], NULL, TRUE); | |
740 for (i = 0; i < NMARKS + EXTRA_MARKS; ++i) | |
741 { | |
742 if (namedfm[i].fmark.fnum != 0) | |
743 name = fm_getname(&namedfm[i].fmark, 15); | |
744 else | |
745 name = namedfm[i].fname; | |
746 if (name != NULL) | |
747 { | |
748 show_one_mark(i >= NMARKS ? i - NMARKS + '0' : i + 'A', | |
749 arg, &namedfm[i].fmark.mark, name, | |
750 namedfm[i].fmark.fnum == curbuf->b_fnum); | |
751 if (namedfm[i].fmark.fnum != 0) | |
752 vim_free(name); | |
753 } | |
754 } | |
755 show_one_mark('"', arg, &curbuf->b_last_cursor, NULL, TRUE); | |
756 show_one_mark('[', arg, &curbuf->b_op_start, NULL, TRUE); | |
757 show_one_mark(']', arg, &curbuf->b_op_end, NULL, TRUE); | |
758 show_one_mark('^', arg, &curbuf->b_last_insert, NULL, TRUE); | |
759 show_one_mark('.', arg, &curbuf->b_last_change, NULL, TRUE); | |
760 #ifdef FEAT_VISUAL | |
690 | 761 show_one_mark('<', arg, &curbuf->b_visual.vi_start, NULL, TRUE); |
762 show_one_mark('>', arg, &curbuf->b_visual.vi_end, NULL, TRUE); | |
7 | 763 #endif |
764 show_one_mark(-1, arg, NULL, NULL, FALSE); | |
765 } | |
766 | |
767 static void | |
768 show_one_mark(c, arg, p, name, current) | |
769 int c; | |
770 char_u *arg; | |
771 pos_T *p; | |
772 char_u *name; | |
773 int current; /* in current file */ | |
774 { | |
775 static int did_title = FALSE; | |
776 int mustfree = FALSE; | |
777 | |
778 if (c == -1) /* finish up */ | |
779 { | |
780 if (did_title) | |
781 did_title = FALSE; | |
782 else | |
783 { | |
784 if (arg == NULL) | |
785 MSG(_("No marks set")); | |
786 else | |
787 EMSG2(_("E283: No marks matching \"%s\""), arg); | |
788 } | |
789 } | |
790 /* don't output anything if 'q' typed at --more-- prompt */ | |
791 else if (!got_int | |
792 && (arg == NULL || vim_strchr(arg, c) != NULL) | |
793 && p->lnum != 0) | |
794 { | |
795 if (!did_title) | |
796 { | |
797 /* Highlight title */ | |
798 MSG_PUTS_TITLE(_("\nmark line col file/text")); | |
799 did_title = TRUE; | |
800 } | |
801 msg_putchar('\n'); | |
802 if (!got_int) | |
803 { | |
804 sprintf((char *)IObuff, " %c %6ld %4d ", c, p->lnum, p->col); | |
805 msg_outtrans(IObuff); | |
806 if (name == NULL && current) | |
807 { | |
808 name = mark_line(p, 15); | |
809 mustfree = TRUE; | |
810 } | |
811 if (name != NULL) | |
812 { | |
813 msg_outtrans_attr(name, current ? hl_attr(HLF_D) : 0); | |
814 if (mustfree) | |
815 vim_free(name); | |
816 } | |
817 } | |
818 out_flush(); /* show one line at a time */ | |
819 } | |
820 } | |
821 | |
24 | 822 /* |
823 * ":delmarks[!] [marks]" | |
824 */ | |
825 void | |
826 ex_delmarks(eap) | |
827 exarg_T *eap; | |
828 { | |
829 char_u *p; | |
830 int from, to; | |
831 int i; | |
832 int lower; | |
833 int digit; | |
834 int n; | |
835 | |
836 if (*eap->arg == NUL && eap->forceit) | |
837 /* clear all marks */ | |
838 clrallmarks(curbuf); | |
839 else if (eap->forceit) | |
840 EMSG(_(e_invarg)); | |
841 else if (*eap->arg == NUL) | |
842 EMSG(_(e_argreq)); | |
843 else | |
844 { | |
845 /* clear specified marks only */ | |
846 for (p = eap->arg; *p != NUL; ++p) | |
847 { | |
848 lower = ASCII_ISLOWER(*p); | |
849 digit = VIM_ISDIGIT(*p); | |
850 if (lower || digit || ASCII_ISUPPER(*p)) | |
851 { | |
852 if (p[1] == '-') | |
853 { | |
854 /* clear range of marks */ | |
855 from = *p; | |
856 to = p[2]; | |
857 if (!(lower ? ASCII_ISLOWER(p[2]) | |
858 : (digit ? VIM_ISDIGIT(p[2]) | |
859 : ASCII_ISUPPER(p[2]))) | |
860 || to < from) | |
861 { | |
862 EMSG2(_(e_invarg2), p); | |
863 return; | |
864 } | |
865 p += 2; | |
866 } | |
867 else | |
868 /* clear one lower case mark */ | |
869 from = to = *p; | |
870 | |
871 for (i = from; i <= to; ++i) | |
872 { | |
873 if (lower) | |
874 curbuf->b_namedm[i - 'a'].lnum = 0; | |
875 else | |
876 { | |
877 if (digit) | |
878 n = i - '0' + NMARKS; | |
879 else | |
880 n = i - 'A'; | |
881 namedfm[n].fmark.mark.lnum = 0; | |
882 vim_free(namedfm[n].fname); | |
883 namedfm[n].fname = NULL; | |
884 } | |
885 } | |
886 } | |
887 else | |
888 switch (*p) | |
889 { | |
890 case '"': curbuf->b_last_cursor.lnum = 0; break; | |
891 case '^': curbuf->b_last_insert.lnum = 0; break; | |
892 case '.': curbuf->b_last_change.lnum = 0; break; | |
893 case '[': curbuf->b_op_start.lnum = 0; break; | |
894 case ']': curbuf->b_op_end.lnum = 0; break; | |
895 #ifdef FEAT_VISUAL | |
690 | 896 case '<': curbuf->b_visual.vi_start.lnum = 0; break; |
897 case '>': curbuf->b_visual.vi_end.lnum = 0; break; | |
24 | 898 #endif |
899 case ' ': break; | |
900 default: EMSG2(_(e_invarg2), p); | |
901 return; | |
902 } | |
903 } | |
904 } | |
905 } | |
906 | |
7 | 907 #if defined(FEAT_JUMPLIST) || defined(PROTO) |
908 /* | |
909 * print the jumplist | |
910 */ | |
911 void | |
912 ex_jumps(eap) | |
1880 | 913 exarg_T *eap UNUSED; |
7 | 914 { |
915 int i; | |
916 char_u *name; | |
917 | |
918 cleanup_jumplist(); | |
919 /* Highlight title */ | |
920 MSG_PUTS_TITLE(_("\n jump line col file/text")); | |
921 for (i = 0; i < curwin->w_jumplistlen && !got_int; ++i) | |
922 { | |
923 if (curwin->w_jumplist[i].fmark.mark.lnum != 0) | |
924 { | |
925 if (curwin->w_jumplist[i].fmark.fnum == 0) | |
926 fname2fnum(&curwin->w_jumplist[i]); | |
927 name = fm_getname(&curwin->w_jumplist[i].fmark, 16); | |
928 if (name == NULL) /* file name not available */ | |
929 continue; | |
930 | |
931 msg_putchar('\n'); | |
932 if (got_int) | |
1702 | 933 { |
934 vim_free(name); | |
7 | 935 break; |
1702 | 936 } |
7 | 937 sprintf((char *)IObuff, "%c %2d %5ld %4d ", |
938 i == curwin->w_jumplistidx ? '>' : ' ', | |
939 i > curwin->w_jumplistidx ? i - curwin->w_jumplistidx | |
940 : curwin->w_jumplistidx - i, | |
941 curwin->w_jumplist[i].fmark.mark.lnum, | |
942 curwin->w_jumplist[i].fmark.mark.col); | |
943 msg_outtrans(IObuff); | |
944 msg_outtrans_attr(name, | |
945 curwin->w_jumplist[i].fmark.fnum == curbuf->b_fnum | |
946 ? hl_attr(HLF_D) : 0); | |
947 vim_free(name); | |
948 ui_breakcheck(); | |
949 } | |
950 out_flush(); | |
951 } | |
952 if (curwin->w_jumplistidx == curwin->w_jumplistlen) | |
953 MSG_PUTS("\n>"); | |
954 } | |
955 | |
956 /* | |
957 * print the changelist | |
958 */ | |
959 void | |
960 ex_changes(eap) | |
1880 | 961 exarg_T *eap UNUSED; |
7 | 962 { |
963 int i; | |
964 char_u *name; | |
965 | |
966 /* Highlight title */ | |
967 MSG_PUTS_TITLE(_("\nchange line col text")); | |
968 | |
969 for (i = 0; i < curbuf->b_changelistlen && !got_int; ++i) | |
970 { | |
971 if (curbuf->b_changelist[i].lnum != 0) | |
972 { | |
973 msg_putchar('\n'); | |
974 if (got_int) | |
975 break; | |
976 sprintf((char *)IObuff, "%c %3d %5ld %4d ", | |
977 i == curwin->w_changelistidx ? '>' : ' ', | |
978 i > curwin->w_changelistidx ? i - curwin->w_changelistidx | |
979 : curwin->w_changelistidx - i, | |
980 (long)curbuf->b_changelist[i].lnum, | |
981 curbuf->b_changelist[i].col); | |
982 msg_outtrans(IObuff); | |
983 name = mark_line(&curbuf->b_changelist[i], 17); | |
984 if (name == NULL) | |
985 break; | |
986 msg_outtrans_attr(name, hl_attr(HLF_D)); | |
987 vim_free(name); | |
988 ui_breakcheck(); | |
989 } | |
990 out_flush(); | |
991 } | |
992 if (curwin->w_changelistidx == curbuf->b_changelistlen) | |
993 MSG_PUTS("\n>"); | |
994 } | |
995 #endif | |
996 | |
997 #define one_adjust(add) \ | |
998 { \ | |
999 lp = add; \ | |
1000 if (*lp >= line1 && *lp <= line2) \ | |
1001 { \ | |
1002 if (amount == MAXLNUM) \ | |
1003 *lp = 0; \ | |
1004 else \ | |
1005 *lp += amount; \ | |
1006 } \ | |
1007 else if (amount_after && *lp > line2) \ | |
1008 *lp += amount_after; \ | |
1009 } | |
1010 | |
1011 /* don't delete the line, just put at first deleted line */ | |
1012 #define one_adjust_nodel(add) \ | |
1013 { \ | |
1014 lp = add; \ | |
1015 if (*lp >= line1 && *lp <= line2) \ | |
1016 { \ | |
1017 if (amount == MAXLNUM) \ | |
1018 *lp = line1; \ | |
1019 else \ | |
1020 *lp += amount; \ | |
1021 } \ | |
1022 else if (amount_after && *lp > line2) \ | |
1023 *lp += amount_after; \ | |
1024 } | |
1025 | |
1026 /* | |
1027 * Adjust marks between line1 and line2 (inclusive) to move 'amount' lines. | |
1028 * Must be called before changed_*(), appended_lines() or deleted_lines(). | |
1029 * May be called before or after changing the text. | |
1030 * When deleting lines line1 to line2, use an 'amount' of MAXLNUM: The marks | |
1031 * within this range are made invalid. | |
1032 * If 'amount_after' is non-zero adjust marks after line2. | |
1033 * Example: Delete lines 34 and 35: mark_adjust(34, 35, MAXLNUM, -2); | |
1034 * Example: Insert two lines below 55: mark_adjust(56, MAXLNUM, 2, 0); | |
1035 * or: mark_adjust(56, 55, MAXLNUM, 2); | |
1036 */ | |
1037 void | |
1038 mark_adjust(line1, line2, amount, amount_after) | |
1039 linenr_T line1; | |
1040 linenr_T line2; | |
1041 long amount; | |
1042 long amount_after; | |
1043 { | |
1044 int i; | |
1045 int fnum = curbuf->b_fnum; | |
1046 linenr_T *lp; | |
1047 win_T *win; | |
1863 | 1048 #ifdef FEAT_WINDOWS |
1049 tabpage_T *tab; | |
1050 #endif | |
4092 | 1051 static pos_T initpos = INIT_POS_T(1, 0, 0); |
7 | 1052 |
1053 if (line2 < line1 && amount_after == 0L) /* nothing to do */ | |
1054 return; | |
1055 | |
1056 if (!cmdmod.lockmarks) | |
1057 { | |
1058 /* named marks, lower case and upper case */ | |
1059 for (i = 0; i < NMARKS; i++) | |
1060 { | |
1061 one_adjust(&(curbuf->b_namedm[i].lnum)); | |
1062 if (namedfm[i].fmark.fnum == fnum) | |
1063 one_adjust_nodel(&(namedfm[i].fmark.mark.lnum)); | |
1064 } | |
1065 for (i = NMARKS; i < NMARKS + EXTRA_MARKS; i++) | |
1066 { | |
1067 if (namedfm[i].fmark.fnum == fnum) | |
1068 one_adjust_nodel(&(namedfm[i].fmark.mark.lnum)); | |
1069 } | |
1070 | |
1071 /* last Insert position */ | |
1072 one_adjust(&(curbuf->b_last_insert.lnum)); | |
1073 | |
1074 /* last change position */ | |
1075 one_adjust(&(curbuf->b_last_change.lnum)); | |
1076 | |
4092 | 1077 /* last cursor position, if it was set */ |
1078 if (!equalpos(curbuf->b_last_cursor, initpos)) | |
1079 one_adjust(&(curbuf->b_last_cursor.lnum)); | |
1080 | |
1081 | |
7 | 1082 #ifdef FEAT_JUMPLIST |
1083 /* list of change positions */ | |
1084 for (i = 0; i < curbuf->b_changelistlen; ++i) | |
1085 one_adjust_nodel(&(curbuf->b_changelist[i].lnum)); | |
1086 #endif | |
1087 | |
1088 #ifdef FEAT_VISUAL | |
1089 /* Visual area */ | |
690 | 1090 one_adjust_nodel(&(curbuf->b_visual.vi_start.lnum)); |
1091 one_adjust_nodel(&(curbuf->b_visual.vi_end.lnum)); | |
7 | 1092 #endif |
1093 | |
1094 #ifdef FEAT_QUICKFIX | |
1095 /* quickfix marks */ | |
643 | 1096 qf_mark_adjust(NULL, line1, line2, amount, amount_after); |
1097 /* location lists */ | |
1863 | 1098 FOR_ALL_TAB_WINDOWS(tab, win) |
643 | 1099 qf_mark_adjust(win, line1, line2, amount, amount_after); |
7 | 1100 #endif |
1101 | |
1102 #ifdef FEAT_SIGNS | |
1103 sign_mark_adjust(line1, line2, amount, amount_after); | |
1104 #endif | |
1105 } | |
1106 | |
1107 /* previous context mark */ | |
1108 one_adjust(&(curwin->w_pcmark.lnum)); | |
1109 | |
1110 /* previous pcmark */ | |
1111 one_adjust(&(curwin->w_prev_pcmark.lnum)); | |
1112 | |
1113 /* saved cursor for formatting */ | |
1114 if (saved_cursor.lnum != 0) | |
1115 one_adjust_nodel(&(saved_cursor.lnum)); | |
1116 | |
1117 /* | |
1118 * Adjust items in all windows related to the current buffer. | |
1119 */ | |
1863 | 1120 FOR_ALL_TAB_WINDOWS(tab, win) |
7 | 1121 { |
1122 #ifdef FEAT_JUMPLIST | |
1123 if (!cmdmod.lockmarks) | |
1124 /* Marks in the jumplist. When deleting lines, this may create | |
1125 * duplicate marks in the jumplist, they will be removed later. */ | |
1126 for (i = 0; i < win->w_jumplistlen; ++i) | |
1127 if (win->w_jumplist[i].fmark.fnum == fnum) | |
1128 one_adjust_nodel(&(win->w_jumplist[i].fmark.mark.lnum)); | |
1129 #endif | |
1130 | |
1131 if (win->w_buffer == curbuf) | |
1132 { | |
1133 if (!cmdmod.lockmarks) | |
1134 /* marks in the tag stack */ | |
1135 for (i = 0; i < win->w_tagstacklen; i++) | |
1136 if (win->w_tagstack[i].fmark.fnum == fnum) | |
1137 one_adjust_nodel(&(win->w_tagstack[i].fmark.mark.lnum)); | |
1138 | |
1139 #ifdef FEAT_VISUAL | |
1140 /* the displayed Visual area */ | |
1141 if (win->w_old_cursor_lnum != 0) | |
1142 { | |
1143 one_adjust_nodel(&(win->w_old_cursor_lnum)); | |
1144 one_adjust_nodel(&(win->w_old_visual_lnum)); | |
1145 } | |
1146 #endif | |
1147 | |
1148 /* topline and cursor position for windows with the same buffer | |
1149 * other than the current window */ | |
1150 if (win != curwin) | |
1151 { | |
1152 if (win->w_topline >= line1 && win->w_topline <= line2) | |
1153 { | |
1154 if (amount == MAXLNUM) /* topline is deleted */ | |
1155 { | |
1156 if (line1 <= 1) | |
1157 win->w_topline = 1; | |
1158 else | |
1159 win->w_topline = line1 - 1; | |
1160 } | |
1161 else /* keep topline on the same line */ | |
1162 win->w_topline += amount; | |
1163 #ifdef FEAT_DIFF | |
1164 win->w_topfill = 0; | |
1165 #endif | |
1166 } | |
1167 else if (amount_after && win->w_topline > line2) | |
1168 { | |
1169 win->w_topline += amount_after; | |
1170 #ifdef FEAT_DIFF | |
1171 win->w_topfill = 0; | |
1172 #endif | |
1173 } | |
1174 if (win->w_cursor.lnum >= line1 && win->w_cursor.lnum <= line2) | |
1175 { | |
1176 if (amount == MAXLNUM) /* line with cursor is deleted */ | |
1177 { | |
1178 if (line1 <= 1) | |
1179 win->w_cursor.lnum = 1; | |
1180 else | |
1181 win->w_cursor.lnum = line1 - 1; | |
1182 win->w_cursor.col = 0; | |
1183 } | |
1184 else /* keep cursor on the same line */ | |
1185 win->w_cursor.lnum += amount; | |
1186 } | |
1187 else if (amount_after && win->w_cursor.lnum > line2) | |
1188 win->w_cursor.lnum += amount_after; | |
1189 } | |
1190 | |
1191 #ifdef FEAT_FOLDING | |
1192 /* adjust folds */ | |
1193 foldMarkAdjust(win, line1, line2, amount, amount_after); | |
1194 #endif | |
1195 } | |
1196 } | |
1197 | |
1198 #ifdef FEAT_DIFF | |
1199 /* adjust diffs */ | |
1200 diff_mark_adjust(line1, line2, amount, amount_after); | |
1201 #endif | |
1202 } | |
1203 | |
1204 /* This code is used often, needs to be fast. */ | |
1205 #define col_adjust(pp) \ | |
1206 { \ | |
1207 posp = pp; \ | |
1208 if (posp->lnum == lnum && posp->col >= mincol) \ | |
1209 { \ | |
1210 posp->lnum += lnum_amount; \ | |
1211 if (col_amount < 0 && posp->col <= (colnr_T)-col_amount) \ | |
1212 posp->col = 0; \ | |
1213 else \ | |
1214 posp->col += col_amount; \ | |
1215 } \ | |
1216 } | |
1217 | |
1218 /* | |
1219 * Adjust marks in line "lnum" at column "mincol" and further: add | |
1220 * "lnum_amount" to the line number and add "col_amount" to the column | |
1221 * position. | |
1222 */ | |
1223 void | |
1224 mark_col_adjust(lnum, mincol, lnum_amount, col_amount) | |
1225 linenr_T lnum; | |
1226 colnr_T mincol; | |
1227 long lnum_amount; | |
1228 long col_amount; | |
1229 { | |
1230 int i; | |
1231 int fnum = curbuf->b_fnum; | |
1232 win_T *win; | |
1233 pos_T *posp; | |
1234 | |
1235 if ((col_amount == 0L && lnum_amount == 0L) || cmdmod.lockmarks) | |
1236 return; /* nothing to do */ | |
1237 | |
1238 /* named marks, lower case and upper case */ | |
1239 for (i = 0; i < NMARKS; i++) | |
1240 { | |
1241 col_adjust(&(curbuf->b_namedm[i])); | |
1242 if (namedfm[i].fmark.fnum == fnum) | |
1243 col_adjust(&(namedfm[i].fmark.mark)); | |
1244 } | |
1245 for (i = NMARKS; i < NMARKS + EXTRA_MARKS; i++) | |
1246 { | |
1247 if (namedfm[i].fmark.fnum == fnum) | |
1248 col_adjust(&(namedfm[i].fmark.mark)); | |
1249 } | |
1250 | |
1251 /* last Insert position */ | |
1252 col_adjust(&(curbuf->b_last_insert)); | |
1253 | |
1254 /* last change position */ | |
1255 col_adjust(&(curbuf->b_last_change)); | |
1256 | |
1257 #ifdef FEAT_JUMPLIST | |
1258 /* list of change positions */ | |
1259 for (i = 0; i < curbuf->b_changelistlen; ++i) | |
1260 col_adjust(&(curbuf->b_changelist[i])); | |
1261 #endif | |
1262 | |
1263 #ifdef FEAT_VISUAL | |
1264 /* Visual area */ | |
690 | 1265 col_adjust(&(curbuf->b_visual.vi_start)); |
1266 col_adjust(&(curbuf->b_visual.vi_end)); | |
7 | 1267 #endif |
1268 | |
1269 /* previous context mark */ | |
1270 col_adjust(&(curwin->w_pcmark)); | |
1271 | |
1272 /* previous pcmark */ | |
1273 col_adjust(&(curwin->w_prev_pcmark)); | |
1274 | |
1275 /* saved cursor for formatting */ | |
1276 col_adjust(&saved_cursor); | |
1277 | |
1278 /* | |
1279 * Adjust items in all windows related to the current buffer. | |
1280 */ | |
1281 FOR_ALL_WINDOWS(win) | |
1282 { | |
1283 #ifdef FEAT_JUMPLIST | |
1284 /* marks in the jumplist */ | |
1285 for (i = 0; i < win->w_jumplistlen; ++i) | |
1286 if (win->w_jumplist[i].fmark.fnum == fnum) | |
1287 col_adjust(&(win->w_jumplist[i].fmark.mark)); | |
1288 #endif | |
1289 | |
1290 if (win->w_buffer == curbuf) | |
1291 { | |
1292 /* marks in the tag stack */ | |
1293 for (i = 0; i < win->w_tagstacklen; i++) | |
1294 if (win->w_tagstack[i].fmark.fnum == fnum) | |
1295 col_adjust(&(win->w_tagstack[i].fmark.mark)); | |
1296 | |
1297 /* cursor position for other windows with the same buffer */ | |
1298 if (win != curwin) | |
1299 col_adjust(&win->w_cursor); | |
1300 } | |
1301 } | |
1302 } | |
1303 | |
1304 #ifdef FEAT_JUMPLIST | |
1305 /* | |
1306 * When deleting lines, this may create duplicate marks in the | |
1307 * jumplist. They will be removed here for the current window. | |
1308 */ | |
1309 static void | |
1310 cleanup_jumplist() | |
1311 { | |
1312 int i; | |
1313 int from, to; | |
1314 | |
1315 to = 0; | |
1316 for (from = 0; from < curwin->w_jumplistlen; ++from) | |
1317 { | |
1318 if (curwin->w_jumplistidx == from) | |
1319 curwin->w_jumplistidx = to; | |
1320 for (i = from + 1; i < curwin->w_jumplistlen; ++i) | |
1321 if (curwin->w_jumplist[i].fmark.fnum | |
1322 == curwin->w_jumplist[from].fmark.fnum | |
1323 && curwin->w_jumplist[from].fmark.fnum != 0 | |
1324 && curwin->w_jumplist[i].fmark.mark.lnum | |
1325 == curwin->w_jumplist[from].fmark.mark.lnum) | |
1326 break; | |
1327 if (i >= curwin->w_jumplistlen) /* no duplicate */ | |
1328 curwin->w_jumplist[to++] = curwin->w_jumplist[from]; | |
1329 else | |
1330 vim_free(curwin->w_jumplist[from].fname); | |
1331 } | |
1332 if (curwin->w_jumplistidx == curwin->w_jumplistlen) | |
1333 curwin->w_jumplistidx = to; | |
1334 curwin->w_jumplistlen = to; | |
1335 } | |
1336 | |
1337 # if defined(FEAT_WINDOWS) || defined(PROTO) | |
1338 /* | |
1339 * Copy the jumplist from window "from" to window "to". | |
1340 */ | |
1341 void | |
1342 copy_jumplist(from, to) | |
1343 win_T *from; | |
1344 win_T *to; | |
1345 { | |
1346 int i; | |
1347 | |
1348 for (i = 0; i < from->w_jumplistlen; ++i) | |
1349 { | |
1350 to->w_jumplist[i] = from->w_jumplist[i]; | |
1351 if (from->w_jumplist[i].fname != NULL) | |
1352 to->w_jumplist[i].fname = vim_strsave(from->w_jumplist[i].fname); | |
1353 } | |
1354 to->w_jumplistlen = from->w_jumplistlen; | |
1355 to->w_jumplistidx = from->w_jumplistidx; | |
1356 } | |
1357 | |
1358 /* | |
1359 * Free items in the jumplist of window "wp". | |
1360 */ | |
1361 void | |
1362 free_jumplist(wp) | |
1363 win_T *wp; | |
1364 { | |
1365 int i; | |
1366 | |
1367 for (i = 0; i < wp->w_jumplistlen; ++i) | |
1368 vim_free(wp->w_jumplist[i].fname); | |
1369 } | |
1370 # endif | |
1371 #endif /* FEAT_JUMPLIST */ | |
1372 | |
1373 void | |
1374 set_last_cursor(win) | |
1375 win_T *win; | |
1376 { | |
5417 | 1377 if (win->w_buffer != NULL) |
1378 win->w_buffer->b_last_cursor = win->w_cursor; | |
7 | 1379 } |
1380 | |
358 | 1381 #if defined(EXITFREE) || defined(PROTO) |
1382 void | |
1383 free_all_marks() | |
1384 { | |
1385 int i; | |
1386 | |
1387 for (i = 0; i < NMARKS + EXTRA_MARKS; i++) | |
1388 if (namedfm[i].fmark.mark.lnum != 0) | |
1389 vim_free(namedfm[i].fname); | |
1390 } | |
1391 #endif | |
1392 | |
7 | 1393 #if defined(FEAT_VIMINFO) || defined(PROTO) |
1394 int | |
1395 read_viminfo_filemark(virp, force) | |
1396 vir_T *virp; | |
1397 int force; | |
1398 { | |
1399 char_u *str; | |
1400 xfmark_T *fm; | |
1401 int i; | |
1402 | |
1403 /* We only get here if line[0] == '\'' or '-'. | |
1404 * Illegal mark names are ignored (for future expansion). */ | |
1405 str = virp->vir_line + 1; | |
1406 if ( | |
1407 #ifndef EBCDIC | |
1408 *str <= 127 && | |
1409 #endif | |
1410 ((*virp->vir_line == '\'' && (VIM_ISDIGIT(*str) || isupper(*str))) | |
1411 || (*virp->vir_line == '-' && *str == '\''))) | |
1412 { | |
1413 if (*str == '\'') | |
1414 { | |
1415 #ifdef FEAT_JUMPLIST | |
1416 /* If the jumplist isn't full insert fmark as oldest entry */ | |
1417 if (curwin->w_jumplistlen == JUMPLISTSIZE) | |
1418 fm = NULL; | |
1419 else | |
1420 { | |
1421 for (i = curwin->w_jumplistlen; i > 0; --i) | |
1422 curwin->w_jumplist[i] = curwin->w_jumplist[i - 1]; | |
1423 ++curwin->w_jumplistidx; | |
1424 ++curwin->w_jumplistlen; | |
1425 fm = &curwin->w_jumplist[0]; | |
1426 fm->fmark.mark.lnum = 0; | |
1427 fm->fname = NULL; | |
1428 } | |
1429 #else | |
1430 fm = NULL; | |
1431 #endif | |
1432 } | |
1433 else if (VIM_ISDIGIT(*str)) | |
1434 fm = &namedfm[*str - '0' + NMARKS]; | |
1435 else | |
1436 fm = &namedfm[*str - 'A']; | |
1437 if (fm != NULL && (fm->fmark.mark.lnum == 0 || force)) | |
1438 { | |
1439 str = skipwhite(str + 1); | |
1440 fm->fmark.mark.lnum = getdigits(&str); | |
1441 str = skipwhite(str); | |
1442 fm->fmark.mark.col = getdigits(&str); | |
1443 #ifdef FEAT_VIRTUALEDIT | |
1444 fm->fmark.mark.coladd = 0; | |
1445 #endif | |
1446 fm->fmark.fnum = 0; | |
1447 str = skipwhite(str); | |
1448 vim_free(fm->fname); | |
1449 fm->fname = viminfo_readstring(virp, (int)(str - virp->vir_line), | |
1450 FALSE); | |
1451 } | |
1452 } | |
1453 return vim_fgets(virp->vir_line, LSIZE, virp->vir_fd); | |
1454 } | |
1455 | |
1456 void | |
1457 write_viminfo_filemarks(fp) | |
1458 FILE *fp; | |
1459 { | |
1460 int i; | |
1461 char_u *name; | |
1462 buf_T *buf; | |
1463 xfmark_T *fm; | |
1464 | |
1465 if (get_viminfo_parameter('f') == 0) | |
1466 return; | |
1467 | |
2545
298d8d6e69be
Avoid warnings from the clang compiler. (Dominique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
1880
diff
changeset
|
1468 fputs(_("\n# File marks:\n"), fp); |
7 | 1469 |
1470 /* | |
1471 * Find a mark that is the same file and position as the cursor. | |
1472 * That one, or else the last one is deleted. | |
1473 * Move '0 to '1, '1 to '2, etc. until the matching one or '9 | |
1474 * Set '0 mark to current cursor position. | |
1475 */ | |
1476 if (curbuf->b_ffname != NULL && !removable(curbuf->b_ffname)) | |
1477 { | |
1478 name = buflist_nr2name(curbuf->b_fnum, TRUE, FALSE); | |
1479 for (i = NMARKS; i < NMARKS + EXTRA_MARKS - 1; ++i) | |
1480 if (namedfm[i].fmark.mark.lnum == curwin->w_cursor.lnum | |
1481 && (namedfm[i].fname == NULL | |
1482 ? namedfm[i].fmark.fnum == curbuf->b_fnum | |
1483 : (name != NULL | |
1484 && STRCMP(name, namedfm[i].fname) == 0))) | |
1485 break; | |
1486 vim_free(name); | |
1487 | |
1488 vim_free(namedfm[i].fname); | |
1489 for ( ; i > NMARKS; --i) | |
1490 namedfm[i] = namedfm[i - 1]; | |
1491 namedfm[NMARKS].fmark.mark = curwin->w_cursor; | |
1492 namedfm[NMARKS].fmark.fnum = curbuf->b_fnum; | |
1493 namedfm[NMARKS].fname = NULL; | |
1494 } | |
1495 | |
1496 /* Write the filemarks '0 - '9 and 'A - 'Z */ | |
1497 for (i = 0; i < NMARKS + EXTRA_MARKS; i++) | |
1498 write_one_filemark(fp, &namedfm[i], '\'', | |
1499 i < NMARKS ? i + 'A' : i - NMARKS + '0'); | |
1500 | |
1501 #ifdef FEAT_JUMPLIST | |
1502 /* Write the jumplist with -' */ | |
2545
298d8d6e69be
Avoid warnings from the clang compiler. (Dominique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
1880
diff
changeset
|
1503 fputs(_("\n# Jumplist (newest first):\n"), fp); |
7 | 1504 setpcmark(); /* add current cursor position */ |
1505 cleanup_jumplist(); | |
1506 for (fm = &curwin->w_jumplist[curwin->w_jumplistlen - 1]; | |
1507 fm >= &curwin->w_jumplist[0]; --fm) | |
1508 { | |
1509 if (fm->fmark.fnum == 0 | |
1510 || ((buf = buflist_findnr(fm->fmark.fnum)) != NULL | |
1511 && !removable(buf->b_ffname))) | |
1512 write_one_filemark(fp, fm, '-', '\''); | |
1513 } | |
1514 #endif | |
1515 } | |
1516 | |
1517 static void | |
1518 write_one_filemark(fp, fm, c1, c2) | |
1519 FILE *fp; | |
1520 xfmark_T *fm; | |
1521 int c1; | |
1522 int c2; | |
1523 { | |
1524 char_u *name; | |
1525 | |
1526 if (fm->fmark.mark.lnum == 0) /* not set */ | |
1527 return; | |
1528 | |
1529 if (fm->fmark.fnum != 0) /* there is a buffer */ | |
1530 name = buflist_nr2name(fm->fmark.fnum, TRUE, FALSE); | |
1531 else | |
1532 name = fm->fname; /* use name from .viminfo */ | |
1533 if (name != NULL && *name != NUL) | |
1534 { | |
1535 fprintf(fp, "%c%c %ld %ld ", c1, c2, (long)fm->fmark.mark.lnum, | |
1536 (long)fm->fmark.mark.col); | |
1537 viminfo_writestring(fp, name); | |
1538 } | |
1539 | |
1540 if (fm->fmark.fnum != 0) | |
1541 vim_free(name); | |
1542 } | |
1543 | |
1544 /* | |
1545 * Return TRUE if "name" is on removable media (depending on 'viminfo'). | |
1546 */ | |
1547 int | |
1548 removable(name) | |
1549 char_u *name; | |
1550 { | |
1551 char_u *p; | |
1552 char_u part[51]; | |
1553 int retval = FALSE; | |
307 | 1554 size_t n; |
7 | 1555 |
1556 name = home_replace_save(NULL, name); | |
1557 if (name != NULL) | |
1558 { | |
1559 for (p = p_viminfo; *p; ) | |
1560 { | |
1561 copy_option_part(&p, part, 51, ", "); | |
307 | 1562 if (part[0] == 'r') |
7 | 1563 { |
307 | 1564 n = STRLEN(part + 1); |
1565 if (MB_STRNICMP(part + 1, name, n) == 0) | |
1566 { | |
1567 retval = TRUE; | |
1568 break; | |
1569 } | |
7 | 1570 } |
1571 } | |
1572 vim_free(name); | |
1573 } | |
1574 return retval; | |
1575 } | |
1576 | |
1577 static void write_one_mark __ARGS((FILE *fp_out, int c, pos_T *pos)); | |
1578 | |
1579 /* | |
1580 * Write all the named marks for all buffers. | |
1581 * Return the number of buffers for which marks have been written. | |
1582 */ | |
1583 int | |
1584 write_viminfo_marks(fp_out) | |
1585 FILE *fp_out; | |
1586 { | |
1587 int count; | |
1588 buf_T *buf; | |
1589 int is_mark_set; | |
1590 int i; | |
1591 #ifdef FEAT_WINDOWS | |
1592 win_T *win; | |
671 | 1593 tabpage_T *tp; |
7 | 1594 |
1595 /* | |
1596 * Set b_last_cursor for the all buffers that have a window. | |
1597 */ | |
671 | 1598 FOR_ALL_TAB_WINDOWS(tp, win) |
7 | 1599 set_last_cursor(win); |
1600 #else | |
1601 set_last_cursor(curwin); | |
1602 #endif | |
1603 | |
2545
298d8d6e69be
Avoid warnings from the clang compiler. (Dominique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
1880
diff
changeset
|
1604 fputs(_("\n# History of marks within files (newest to oldest):\n"), fp_out); |
7 | 1605 count = 0; |
1606 for (buf = firstbuf; buf != NULL; buf = buf->b_next) | |
1607 { | |
1608 /* | |
1609 * Only write something if buffer has been loaded and at least one | |
1610 * mark is set. | |
1611 */ | |
1612 if (buf->b_marks_read) | |
1613 { | |
1614 if (buf->b_last_cursor.lnum != 0) | |
1615 is_mark_set = TRUE; | |
1616 else | |
1617 { | |
1618 is_mark_set = FALSE; | |
1619 for (i = 0; i < NMARKS; i++) | |
1620 if (buf->b_namedm[i].lnum != 0) | |
1621 { | |
1622 is_mark_set = TRUE; | |
1623 break; | |
1624 } | |
1625 } | |
1626 if (is_mark_set && buf->b_ffname != NULL | |
1627 && buf->b_ffname[0] != NUL && !removable(buf->b_ffname)) | |
1628 { | |
1629 home_replace(NULL, buf->b_ffname, IObuff, IOSIZE, TRUE); | |
1630 fprintf(fp_out, "\n> "); | |
1631 viminfo_writestring(fp_out, IObuff); | |
1632 write_one_mark(fp_out, '"', &buf->b_last_cursor); | |
1633 write_one_mark(fp_out, '^', &buf->b_last_insert); | |
1634 write_one_mark(fp_out, '.', &buf->b_last_change); | |
1635 #ifdef FEAT_JUMPLIST | |
1636 /* changelist positions are stored oldest first */ | |
1637 for (i = 0; i < buf->b_changelistlen; ++i) | |
1638 write_one_mark(fp_out, '+', &buf->b_changelist[i]); | |
1639 #endif | |
1640 for (i = 0; i < NMARKS; i++) | |
1641 write_one_mark(fp_out, 'a' + i, &buf->b_namedm[i]); | |
1642 count++; | |
1643 } | |
1644 } | |
1645 } | |
1646 | |
1647 return count; | |
1648 } | |
1649 | |
1650 static void | |
1651 write_one_mark(fp_out, c, pos) | |
1652 FILE *fp_out; | |
1653 int c; | |
1654 pos_T *pos; | |
1655 { | |
1656 if (pos->lnum != 0) | |
1657 fprintf(fp_out, "\t%c\t%ld\t%d\n", c, (long)pos->lnum, (int)pos->col); | |
1658 } | |
1659 | |
1660 /* | |
1661 * Handle marks in the viminfo file: | |
1733 | 1662 * fp_out != NULL: copy marks for buffers not in buffer list |
1663 * fp_out == NULL && (flags & VIF_WANT_MARKS): read marks for curbuf only | |
1664 * fp_out == NULL && (flags & VIF_GET_OLDFILES | VIF_FORCEIT): fill v:oldfiles | |
7 | 1665 */ |
1666 void | |
1733 | 1667 copy_viminfo_marks(virp, fp_out, count, eof, flags) |
7 | 1668 vir_T *virp; |
1669 FILE *fp_out; | |
1670 int count; | |
1671 int eof; | |
1733 | 1672 int flags; |
7 | 1673 { |
1674 char_u *line = virp->vir_line; | |
1675 buf_T *buf; | |
1676 int num_marked_files; | |
1677 int load_marks; | |
1678 int copy_marks_out; | |
1679 char_u *str; | |
1680 int i; | |
1681 char_u *p; | |
1682 char_u *name_buf; | |
1683 pos_T pos; | |
1733 | 1684 #ifdef FEAT_EVAL |
1685 list_T *list = NULL; | |
1686 #endif | |
7 | 1687 |
1688 if ((name_buf = alloc(LSIZE)) == NULL) | |
1689 return; | |
1690 *name_buf = NUL; | |
1733 | 1691 |
1692 #ifdef FEAT_EVAL | |
1693 if (fp_out == NULL && (flags & (VIF_GET_OLDFILES | VIF_FORCEIT))) | |
1694 { | |
1695 list = list_alloc(); | |
1696 if (list != NULL) | |
1697 set_vim_var_list(VV_OLDFILES, list); | |
1698 } | |
1699 #endif | |
1700 | |
7 | 1701 num_marked_files = get_viminfo_parameter('\''); |
1702 while (!eof && (count < num_marked_files || fp_out == NULL)) | |
1703 { | |
1704 if (line[0] != '>') | |
1705 { | |
1706 if (line[0] != '\n' && line[0] != '\r' && line[0] != '#') | |
1707 { | |
1708 if (viminfo_error("E576: ", _("Missing '>'"), line)) | |
1709 break; /* too many errors, return now */ | |
1710 } | |
1711 eof = vim_fgets(line, LSIZE, virp->vir_fd); | |
1712 continue; /* Skip this dud line */ | |
1713 } | |
1714 | |
1715 /* | |
1716 * Handle long line and translate escaped characters. | |
1717 * Find file name, set str to start. | |
1718 * Ignore leading and trailing white space. | |
1719 */ | |
1720 str = skipwhite(line + 1); | |
1721 str = viminfo_readstring(virp, (int)(str - virp->vir_line), FALSE); | |
1722 if (str == NULL) | |
1723 continue; | |
1724 p = str + STRLEN(str); | |
1725 while (p != str && (*p == NUL || vim_isspace(*p))) | |
1726 p--; | |
1727 if (*p) | |
1728 p++; | |
1729 *p = NUL; | |
1730 | |
1733 | 1731 #ifdef FEAT_EVAL |
1732 if (list != NULL) | |
1733 list_append_string(list, str, -1); | |
1734 #endif | |
1735 | |
7 | 1736 /* |
1737 * If fp_out == NULL, load marks for current buffer. | |
1738 * If fp_out != NULL, copy marks for buffers not in buflist. | |
1739 */ | |
1740 load_marks = copy_marks_out = FALSE; | |
1741 if (fp_out == NULL) | |
1742 { | |
1733 | 1743 if ((flags & VIF_WANT_MARKS) && curbuf->b_ffname != NULL) |
7 | 1744 { |
1745 if (*name_buf == NUL) /* only need to do this once */ | |
1746 home_replace(NULL, curbuf->b_ffname, name_buf, LSIZE, TRUE); | |
1747 if (fnamecmp(str, name_buf) == 0) | |
1748 load_marks = TRUE; | |
1749 } | |
1750 } | |
1751 else /* fp_out != NULL */ | |
1752 { | |
1753 /* This is slow if there are many buffers!! */ | |
1754 for (buf = firstbuf; buf != NULL; buf = buf->b_next) | |
1755 if (buf->b_ffname != NULL) | |
1756 { | |
1757 home_replace(NULL, buf->b_ffname, name_buf, LSIZE, TRUE); | |
1758 if (fnamecmp(str, name_buf) == 0) | |
1759 break; | |
1760 } | |
1761 | |
1762 /* | |
1763 * copy marks if the buffer has not been loaded | |
1764 */ | |
1765 if (buf == NULL || !buf->b_marks_read) | |
1766 { | |
1767 copy_marks_out = TRUE; | |
1768 fputs("\n> ", fp_out); | |
1769 viminfo_writestring(fp_out, str); | |
1770 count++; | |
1771 } | |
1772 } | |
1773 vim_free(str); | |
1774 | |
1775 #ifdef FEAT_VIRTUALEDIT | |
1776 pos.coladd = 0; | |
1777 #endif | |
1778 while (!(eof = viminfo_readline(virp)) && line[0] == TAB) | |
1779 { | |
1780 if (load_marks) | |
1781 { | |
1782 if (line[1] != NUL) | |
1783 { | |
2712 | 1784 unsigned u; |
1785 | |
1786 sscanf((char *)line + 2, "%ld %u", &pos.lnum, &u); | |
1787 pos.col = u; | |
7 | 1788 switch (line[1]) |
1789 { | |
1790 case '"': curbuf->b_last_cursor = pos; break; | |
1791 case '^': curbuf->b_last_insert = pos; break; | |
1792 case '.': curbuf->b_last_change = pos; break; | |
1793 case '+': | |
1794 #ifdef FEAT_JUMPLIST | |
1795 /* changelist positions are stored oldest | |
1796 * first */ | |
1797 if (curbuf->b_changelistlen == JUMPLISTSIZE) | |
1798 /* list is full, remove oldest entry */ | |
1799 mch_memmove(curbuf->b_changelist, | |
1800 curbuf->b_changelist + 1, | |
1801 sizeof(pos_T) * (JUMPLISTSIZE - 1)); | |
1802 else | |
1803 ++curbuf->b_changelistlen; | |
1804 curbuf->b_changelist[ | |
1805 curbuf->b_changelistlen - 1] = pos; | |
1806 #endif | |
1807 break; | |
1808 default: if ((i = line[1] - 'a') >= 0 && i < NMARKS) | |
1809 curbuf->b_namedm[i] = pos; | |
1810 } | |
1811 } | |
1812 } | |
1813 else if (copy_marks_out) | |
1814 fputs((char *)line, fp_out); | |
1815 } | |
1816 if (load_marks) | |
1817 { | |
1818 #ifdef FEAT_JUMPLIST | |
1819 win_T *wp; | |
1820 | |
1821 FOR_ALL_WINDOWS(wp) | |
1822 { | |
1823 if (wp->w_buffer == curbuf) | |
1824 wp->w_changelistidx = curbuf->b_changelistlen; | |
1825 } | |
1826 #endif | |
1827 break; | |
1828 } | |
1829 } | |
1830 vim_free(name_buf); | |
1831 } | |
1832 #endif /* FEAT_VIMINFO */ |