Mercurial > vim
annotate src/mark.c @ 14838:6040d93396de v8.1.0431
patch 8.1.0431: the qf_jump() function is too long
commit https://github.com/vim/vim/commit/6dae96ef7ad56191c13c4993f04cbfd450d91ad2
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Sep 24 21:50:12 2018 +0200
patch 8.1.0431: the qf_jump() function is too long
Problem: The qf_jump() function is too long.
Solution: Refactor to split it into several functions. (Yegappan Lakshmanan)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Mon, 24 Sep 2018 22:00:06 +0200 |
parents | 8a4c0ab88201 |
children | c5ec5ddbe814 |
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 */ | |
27 #define EXTRA_MARKS 10 /* marks 0-9 */ | |
28 static xfmark_T namedfm[NMARKS + EXTRA_MARKS]; /* marks with file nr */ | |
29 | |
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); |
7 | 33 #ifdef FEAT_VIMINFO |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
5735
diff
changeset
|
34 static void write_one_filemark(FILE *fp, xfmark_T *fm, int c1, int c2); |
7 | 35 #endif |
11140
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
36 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
|
37 long amount_after, int adjust_folds); |
7 | 38 |
39 /* | |
706 | 40 * Set named mark "c" at current cursor position. |
7 | 41 * Returns OK on success, FAIL if bad name given. |
42 */ | |
43 int | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
44 setmark(int c) |
7 | 45 { |
706 | 46 return setmark_pos(c, &curwin->w_cursor, curbuf->b_fnum); |
47 } | |
48 | |
49 /* | |
50 * Set named mark "c" to position "pos". | |
51 * When "c" is upper case use file "fnum". | |
52 * Returns OK on success, FAIL if bad name given. | |
53 */ | |
54 int | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
55 setmark_pos(int c, pos_T *pos, int fnum) |
706 | 56 { |
7 | 57 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
|
58 buf_T *buf; |
7 | 59 |
60 /* Check for a special key (may cause islower() to crash). */ | |
61 if (c < 0) | |
62 return FAIL; | |
63 | |
64 if (c == '\'' || c == '`') | |
65 { | |
706 | 66 if (pos == &curwin->w_cursor) |
67 { | |
68 setpcmark(); | |
69 /* keep it even when the cursor doesn't move */ | |
70 curwin->w_prev_pcmark = curwin->w_pcmark; | |
71 } | |
72 else | |
73 curwin->w_pcmark = *pos; | |
7 | 74 return OK; |
75 } | |
76 | |
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
|
77 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
|
78 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
|
79 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
|
80 |
1533 | 81 if (c == '"') |
82 { | |
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
|
83 buf->b_last_cursor = *pos; |
1533 | 84 return OK; |
85 } | |
86 | |
7 | 87 /* Allow setting '[ and '] for an autocommand that simulates reading a |
88 * file. */ | |
89 if (c == '[') | |
90 { | |
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
|
91 buf->b_op_start = *pos; |
7 | 92 return OK; |
93 } | |
94 if (c == ']') | |
95 { | |
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
|
96 buf->b_op_end = *pos; |
7 | 97 return OK; |
98 } | |
99 | |
5265
cd971e951b06
updated for version 7.4b.009
Bram Moolenaar <bram@vim.org>
parents:
4092
diff
changeset
|
100 if (c == '<' || c == '>') |
3660 | 101 { |
5265
cd971e951b06
updated for version 7.4b.009
Bram Moolenaar <bram@vim.org>
parents:
4092
diff
changeset
|
102 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
|
103 buf->b_visual.vi_start = *pos; |
5265
cd971e951b06
updated for version 7.4b.009
Bram Moolenaar <bram@vim.org>
parents:
4092
diff
changeset
|
104 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
|
105 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
|
106 if (buf->b_visual.vi_mode == NUL) |
5265
cd971e951b06
updated for version 7.4b.009
Bram Moolenaar <bram@vim.org>
parents:
4092
diff
changeset
|
107 /* 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
|
108 buf->b_visual.vi_mode = 'v'; |
3660 | 109 return OK; |
110 } | |
111 | |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
112 if (ASCII_ISLOWER(c)) |
7 | 113 { |
114 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
|
115 buf->b_namedm[i] = *pos; |
7 | 116 return OK; |
117 } | |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
118 if (ASCII_ISUPPER(c) || VIM_ISDIGIT(c)) |
7 | 119 { |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
120 if (VIM_ISDIGIT(c)) |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
121 i = c - '0' + NMARKS; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
122 else |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
123 i = c - 'A'; |
706 | 124 namedfm[i].fmark.mark = *pos; |
125 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
|
126 VIM_CLEAR(namedfm[i].fname); |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
127 #ifdef FEAT_VIMINFO |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
128 namedfm[i].time_set = vim_time(); |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
129 #endif |
7 | 130 return OK; |
131 } | |
132 return FAIL; | |
133 } | |
134 | |
135 /* | |
136 * Set the previous context mark to the current position and add it to the | |
137 * jump list. | |
138 */ | |
139 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
140 setpcmark(void) |
7 | 141 { |
142 #ifdef FEAT_JUMPLIST | |
143 int i; | |
144 xfmark_T *fm; | |
145 #endif | |
146 #ifdef JUMPLIST_ROTATE | |
147 xfmark_T tempmark; | |
148 #endif | |
149 | |
150 /* for :global the mark is set only once */ | |
151 if (global_busy || listcmd_busy || cmdmod.keepjumps) | |
152 return; | |
153 | |
154 curwin->w_prev_pcmark = curwin->w_pcmark; | |
155 curwin->w_pcmark = curwin->w_cursor; | |
156 | |
157 #ifdef FEAT_JUMPLIST | |
158 # ifdef JUMPLIST_ROTATE | |
159 /* | |
160 * If last used entry is not at the top, put it at the top by rotating | |
161 * the stack until it is (the newer entries will be at the bottom). | |
162 * Keep one entry (the last used one) at the top. | |
163 */ | |
164 if (curwin->w_jumplistidx < curwin->w_jumplistlen) | |
165 ++curwin->w_jumplistidx; | |
166 while (curwin->w_jumplistidx < curwin->w_jumplistlen) | |
167 { | |
168 tempmark = curwin->w_jumplist[curwin->w_jumplistlen - 1]; | |
169 for (i = curwin->w_jumplistlen - 1; i > 0; --i) | |
170 curwin->w_jumplist[i] = curwin->w_jumplist[i - 1]; | |
171 curwin->w_jumplist[0] = tempmark; | |
172 ++curwin->w_jumplistidx; | |
173 } | |
174 # endif | |
175 | |
176 /* If jumplist is full: remove oldest entry */ | |
177 if (++curwin->w_jumplistlen > JUMPLISTSIZE) | |
178 { | |
179 curwin->w_jumplistlen = JUMPLISTSIZE; | |
180 vim_free(curwin->w_jumplist[0].fname); | |
181 for (i = 1; i < JUMPLISTSIZE; ++i) | |
182 curwin->w_jumplist[i - 1] = curwin->w_jumplist[i]; | |
183 } | |
184 curwin->w_jumplistidx = curwin->w_jumplistlen; | |
185 fm = &curwin->w_jumplist[curwin->w_jumplistlen - 1]; | |
186 | |
187 fm->fmark.mark = curwin->w_pcmark; | |
188 fm->fmark.fnum = curbuf->b_fnum; | |
189 fm->fname = NULL; | |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
190 # ifdef FEAT_VIMINFO |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
191 fm->time_set = vim_time(); |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
192 # endif |
7 | 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 | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
203 checkpcmark(void) |
7 | 204 { |
205 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
|
206 && (EQUAL_POS(curwin->w_pcmark, curwin->w_cursor) |
7 | 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 * | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
219 movemark(int count) |
7 | 220 { |
221 pos_T *pos; | |
222 xfmark_T *jmp; | |
223 | |
13278
28ae299c6af0
patch 8.0.1513: the jumplist is not always properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
13248
diff
changeset
|
224 cleanup_jumplist(curwin, TRUE); |
7 | 225 |
226 if (curwin->w_jumplistlen == 0) /* nothing to jump to */ | |
227 return (pos_T *)NULL; | |
228 | |
229 for (;;) | |
230 { | |
231 if (curwin->w_jumplistidx + count < 0 | |
232 || curwin->w_jumplistidx + count >= curwin->w_jumplistlen) | |
233 return (pos_T *)NULL; | |
234 | |
235 /* | |
236 * if first CTRL-O or CTRL-I command after a jump, add cursor position | |
1188 | 237 * to list. Careful: If there are duplicates (CTRL-O immediately after |
7 | 238 * starting Vim on a file), another entry may have been removed. |
239 */ | |
240 if (curwin->w_jumplistidx == curwin->w_jumplistlen) | |
241 { | |
242 setpcmark(); | |
243 --curwin->w_jumplistidx; /* skip the new entry */ | |
244 if (curwin->w_jumplistidx + count < 0) | |
245 return (pos_T *)NULL; | |
246 } | |
247 | |
248 curwin->w_jumplistidx += count; | |
249 | |
250 jmp = curwin->w_jumplist + curwin->w_jumplistidx; | |
251 if (jmp->fmark.fnum == 0) | |
252 fname2fnum(jmp); | |
253 if (jmp->fmark.fnum != curbuf->b_fnum) | |
254 { | |
255 /* jump to other file */ | |
256 if (buflist_findnr(jmp->fmark.fnum) == NULL) | |
257 { /* Skip this one .. */ | |
258 count += count < 0 ? -1 : 1; | |
259 continue; | |
260 } | |
261 if (buflist_getfile(jmp->fmark.fnum, jmp->fmark.mark.lnum, | |
262 0, FALSE) == FAIL) | |
263 return (pos_T *)NULL; | |
264 /* Set lnum again, autocommands my have changed it */ | |
265 curwin->w_cursor = jmp->fmark.mark; | |
266 pos = (pos_T *)-1; | |
267 } | |
268 else | |
269 pos = &(jmp->fmark.mark); | |
270 return pos; | |
271 } | |
272 } | |
273 | |
274 /* | |
275 * Move "count" positions in the changelist (count may be negative). | |
276 */ | |
277 pos_T * | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
278 movechangelist(int count) |
7 | 279 { |
280 int n; | |
281 | |
282 if (curbuf->b_changelistlen == 0) /* nothing to jump to */ | |
283 return (pos_T *)NULL; | |
284 | |
285 n = curwin->w_changelistidx; | |
286 if (n + count < 0) | |
287 { | |
288 if (n == 0) | |
289 return (pos_T *)NULL; | |
290 n = 0; | |
291 } | |
292 else if (n + count >= curbuf->b_changelistlen) | |
293 { | |
294 if (n == curbuf->b_changelistlen - 1) | |
295 return (pos_T *)NULL; | |
296 n = curbuf->b_changelistlen - 1; | |
297 } | |
298 else | |
299 n += count; | |
300 curwin->w_changelistidx = n; | |
301 return curbuf->b_changelist + n; | |
302 } | |
303 #endif | |
304 | |
305 /* | |
4043 | 306 * Find mark "c" in buffer pointed to by "buf". |
706 | 307 * If "changefile" is TRUE it's allowed to edit another file for '0, 'A, etc. |
308 * If "fnum" is not NULL store the fnum there for '0, 'A etc., don't edit | |
309 * another file. | |
7 | 310 * Returns: |
311 * - pointer to pos_T if found. lnum is 0 when mark not set, -1 when mark is | |
312 * in another file which can't be gotten. (caller needs to check lnum!) | |
313 * - NULL if there is no mark called 'c'. | |
314 * - -1 if mark is in other file and jumped there (only if changefile is TRUE) | |
315 */ | |
316 pos_T * | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
317 getmark_buf(buf_T *buf, int c, int changefile) |
4043 | 318 { |
319 return getmark_buf_fnum(buf, c, changefile, NULL); | |
320 } | |
321 | |
322 pos_T * | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
323 getmark(int c, int changefile) |
706 | 324 { |
4043 | 325 return getmark_buf_fnum(curbuf, c, changefile, NULL); |
706 | 326 } |
327 | |
328 pos_T * | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
329 getmark_buf_fnum( |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
330 buf_T *buf, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
331 int c, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
332 int changefile, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
333 int *fnum) |
7 | 334 { |
335 pos_T *posp; | |
336 pos_T *startp, *endp; | |
337 static pos_T pos_copy; | |
338 | |
339 posp = NULL; | |
340 | |
341 /* Check for special key, can't be a mark name and might cause islower() | |
342 * to crash. */ | |
343 if (c < 0) | |
344 return posp; | |
345 #ifndef EBCDIC | |
346 if (c > '~') /* check for islower()/isupper() */ | |
347 ; | |
348 else | |
349 #endif | |
350 if (c == '\'' || c == '`') /* previous context mark */ | |
351 { | |
352 pos_copy = curwin->w_pcmark; /* need to make a copy because */ | |
353 posp = &pos_copy; /* w_pcmark may be changed soon */ | |
354 } | |
355 else if (c == '"') /* to pos when leaving buffer */ | |
4043 | 356 posp = &(buf->b_last_cursor); |
7 | 357 else if (c == '^') /* to where Insert mode stopped */ |
4043 | 358 posp = &(buf->b_last_insert); |
7 | 359 else if (c == '.') /* to where last change was made */ |
4043 | 360 posp = &(buf->b_last_change); |
7 | 361 else if (c == '[') /* to start of previous operator */ |
4043 | 362 posp = &(buf->b_op_start); |
7 | 363 else if (c == ']') /* to end of previous operator */ |
4043 | 364 posp = &(buf->b_op_end); |
7 | 365 else if (c == '{' || c == '}') /* to previous/next paragraph */ |
366 { | |
367 pos_T pos; | |
368 oparg_T oa; | |
369 int slcb = listcmd_busy; | |
370 | |
371 pos = curwin->w_cursor; | |
372 listcmd_busy = TRUE; /* avoid that '' is changed */ | |
503 | 373 if (findpar(&oa.inclusive, |
374 c == '}' ? FORWARD : BACKWARD, 1L, NUL, FALSE)) | |
7 | 375 { |
376 pos_copy = curwin->w_cursor; | |
377 posp = &pos_copy; | |
378 } | |
379 curwin->w_cursor = pos; | |
380 listcmd_busy = slcb; | |
381 } | |
382 else if (c == '(' || c == ')') /* to previous/next sentence */ | |
383 { | |
384 pos_T pos; | |
385 int slcb = listcmd_busy; | |
386 | |
387 pos = curwin->w_cursor; | |
388 listcmd_busy = TRUE; /* avoid that '' is changed */ | |
389 if (findsent(c == ')' ? FORWARD : BACKWARD, 1L)) | |
390 { | |
391 pos_copy = curwin->w_cursor; | |
392 posp = &pos_copy; | |
393 } | |
394 curwin->w_cursor = pos; | |
395 listcmd_busy = slcb; | |
396 } | |
397 else if (c == '<' || c == '>') /* start/end of visual area */ | |
398 { | |
4043 | 399 startp = &buf->b_visual.vi_start; |
400 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
|
401 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
|
402 && startp->lnum != 0) |
7 | 403 posp = startp; |
404 else | |
405 posp = endp; | |
406 /* | |
407 * For Visual line mode, set mark at begin or end of line | |
408 */ | |
4043 | 409 if (buf->b_visual.vi_mode == 'V') |
7 | 410 { |
411 pos_copy = *posp; | |
412 posp = &pos_copy; | |
413 if (c == '<') | |
414 pos_copy.col = 0; | |
415 else | |
416 pos_copy.col = MAXCOL; | |
417 #ifdef FEAT_VIRTUALEDIT | |
418 pos_copy.coladd = 0; | |
419 #endif | |
420 } | |
421 } | |
422 else if (ASCII_ISLOWER(c)) /* normal named mark */ | |
423 { | |
4043 | 424 posp = &(buf->b_namedm[c - 'a']); |
7 | 425 } |
426 else if (ASCII_ISUPPER(c) || VIM_ISDIGIT(c)) /* named file mark */ | |
427 { | |
428 if (VIM_ISDIGIT(c)) | |
429 c = c - '0' + NMARKS; | |
430 else | |
431 c -= 'A'; | |
432 posp = &(namedfm[c].fmark.mark); | |
433 | |
434 if (namedfm[c].fmark.fnum == 0) | |
435 fname2fnum(&namedfm[c]); | |
706 | 436 |
437 if (fnum != NULL) | |
438 *fnum = namedfm[c].fmark.fnum; | |
4043 | 439 else if (namedfm[c].fmark.fnum != buf->b_fnum) |
7 | 440 { |
706 | 441 /* mark is in another file */ |
7 | 442 posp = &pos_copy; |
443 | |
444 if (namedfm[c].fmark.mark.lnum != 0 | |
445 && changefile && namedfm[c].fmark.fnum) | |
446 { | |
447 if (buflist_getfile(namedfm[c].fmark.fnum, | |
448 (linenr_T)1, GETF_SETMARK, FALSE) == OK) | |
449 { | |
450 /* Set the lnum now, autocommands could have changed it */ | |
451 curwin->w_cursor = namedfm[c].fmark.mark; | |
452 return (pos_T *)-1; | |
453 } | |
454 pos_copy.lnum = -1; /* can't get file */ | |
455 } | |
456 else | |
457 pos_copy.lnum = 0; /* mark exists, but is not valid in | |
458 current buffer */ | |
459 } | |
460 } | |
461 | |
462 return posp; | |
463 } | |
464 | |
465 /* | |
466 * Search for the next named mark in the current file. | |
467 * | |
468 * Returns pointer to pos_T of the next mark or NULL if no mark is found. | |
469 */ | |
470 pos_T * | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
471 getnextmark( |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
472 pos_T *startpos, /* where to start */ |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
473 int dir, /* direction for search */ |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
474 int begin_line) |
7 | 475 { |
476 int i; | |
477 pos_T *result = NULL; | |
478 pos_T pos; | |
479 | |
480 pos = *startpos; | |
481 | |
482 /* When searching backward and leaving the cursor on the first non-blank, | |
483 * position must be in a previous line. | |
484 * When searching forward and leaving the cursor on the first non-blank, | |
485 * position must be in a next line. */ | |
486 if (dir == BACKWARD && begin_line) | |
487 pos.col = 0; | |
488 else if (dir == FORWARD && begin_line) | |
489 pos.col = MAXCOL; | |
490 | |
491 for (i = 0; i < NMARKS; i++) | |
492 { | |
493 if (curbuf->b_namedm[i].lnum > 0) | |
494 { | |
495 if (dir == FORWARD) | |
496 { | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10730
diff
changeset
|
497 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
|
498 && LT_POS(pos, curbuf->b_namedm[i])) |
7 | 499 result = &curbuf->b_namedm[i]; |
500 } | |
501 else | |
502 { | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10730
diff
changeset
|
503 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
|
504 && LT_POS(curbuf->b_namedm[i], pos)) |
7 | 505 result = &curbuf->b_namedm[i]; |
506 } | |
507 } | |
508 } | |
509 | |
510 return result; | |
511 } | |
512 | |
513 /* | |
514 * For an xtended filemark: set the fnum from the fname. | |
515 * This is used for marks obtained from the .viminfo file. It's postponed | |
516 * until the mark is used to avoid a long startup delay. | |
517 */ | |
13248
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
518 void |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
519 fname2fnum(xfmark_T *fm) |
7 | 520 { |
521 char_u *p; | |
522 | |
523 if (fm->fname != NULL) | |
524 { | |
525 /* | |
526 * First expand "~/" in the file name to the home directory. | |
1480 | 527 * Don't expand the whole name, it may contain other '~' chars. |
7 | 528 */ |
1480 | 529 if (fm->fname[0] == '~' && (fm->fname[1] == '/' |
530 #ifdef BACKSLASH_IN_FILENAME | |
531 || fm->fname[1] == '\\' | |
532 #endif | |
533 )) | |
534 { | |
535 int len; | |
536 | |
537 expand_env((char_u *)"~/", NameBuff, MAXPATHL); | |
1570 | 538 len = (int)STRLEN(NameBuff); |
1480 | 539 vim_strncpy(NameBuff + len, fm->fname + 2, MAXPATHL - len - 1); |
540 } | |
541 else | |
542 vim_strncpy(NameBuff, fm->fname, MAXPATHL - 1); | |
543 | |
544 /* Try to shorten the file name. */ | |
7 | 545 mch_dirname(IObuff, IOSIZE); |
546 p = shorten_fname(NameBuff, IObuff); | |
547 | |
548 /* buflist_new() will call fmarks_check_names() */ | |
549 (void)buflist_new(NameBuff, p, (linenr_T)1, 0); | |
550 } | |
551 } | |
552 | |
553 /* | |
554 * Check all file marks for a name that matches the file name in buf. | |
555 * May replace the name with an fnum. | |
556 * Used for marks that come from the .viminfo file. | |
557 */ | |
558 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
559 fmarks_check_names(buf_T *buf) |
7 | 560 { |
561 char_u *name; | |
562 int i; | |
563 #ifdef FEAT_JUMPLIST | |
564 win_T *wp; | |
565 #endif | |
566 | |
567 if (buf->b_ffname == NULL) | |
568 return; | |
569 | |
570 name = home_replace_save(buf, buf->b_ffname); | |
571 if (name == NULL) | |
572 return; | |
573 | |
574 for (i = 0; i < NMARKS + EXTRA_MARKS; ++i) | |
575 fmarks_check_one(&namedfm[i], name, buf); | |
576 | |
577 #ifdef FEAT_JUMPLIST | |
578 FOR_ALL_WINDOWS(wp) | |
579 { | |
580 for (i = 0; i < wp->w_jumplistlen; ++i) | |
581 fmarks_check_one(&wp->w_jumplist[i], name, buf); | |
582 } | |
583 #endif | |
584 | |
585 vim_free(name); | |
586 } | |
587 | |
588 static void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
589 fmarks_check_one(xfmark_T *fm, char_u *name, buf_T *buf) |
7 | 590 { |
591 if (fm->fmark.fnum == 0 | |
592 && fm->fname != NULL | |
593 && fnamecmp(name, fm->fname) == 0) | |
594 { | |
595 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
|
596 VIM_CLEAR(fm->fname); |
7 | 597 } |
598 } | |
599 | |
600 /* | |
601 * Check a if a position from a mark is valid. | |
602 * Give and error message and return FAIL if not. | |
603 */ | |
604 int | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
605 check_mark(pos_T *pos) |
7 | 606 { |
607 if (pos == NULL) | |
608 { | |
609 EMSG(_(e_umark)); | |
610 return FAIL; | |
611 } | |
612 if (pos->lnum <= 0) | |
613 { | |
614 /* lnum is negative if mark is in another file can can't get that | |
615 * file, error message already give then. */ | |
616 if (pos->lnum == 0) | |
617 EMSG(_(e_marknotset)); | |
618 return FAIL; | |
619 } | |
620 if (pos->lnum > curbuf->b_ml.ml_line_count) | |
621 { | |
622 EMSG(_(e_markinval)); | |
623 return FAIL; | |
624 } | |
625 return OK; | |
626 } | |
627 | |
628 /* | |
629 * clrallmarks() - clear all marks in the buffer 'buf' | |
630 * | |
631 * Used mainly when trashing the entire buffer during ":e" type commands | |
632 */ | |
633 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
634 clrallmarks(buf_T *buf) |
7 | 635 { |
636 static int i = -1; | |
637 | |
638 if (i == -1) /* first call ever: initialize */ | |
639 for (i = 0; i < NMARKS + 1; i++) | |
640 { | |
641 namedfm[i].fmark.mark.lnum = 0; | |
642 namedfm[i].fname = NULL; | |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
643 #ifdef FEAT_VIMINFO |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
644 namedfm[i].time_set = 0; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
645 #endif |
7 | 646 } |
647 | |
648 for (i = 0; i < NMARKS; i++) | |
649 buf->b_namedm[i].lnum = 0; | |
650 buf->b_op_start.lnum = 0; /* start/end op mark cleared */ | |
651 buf->b_op_end.lnum = 0; | |
652 buf->b_last_cursor.lnum = 1; /* '" mark cleared */ | |
653 buf->b_last_cursor.col = 0; | |
654 #ifdef FEAT_VIRTUALEDIT | |
655 buf->b_last_cursor.coladd = 0; | |
656 #endif | |
657 buf->b_last_insert.lnum = 0; /* '^ mark cleared */ | |
658 buf->b_last_change.lnum = 0; /* '. mark cleared */ | |
659 #ifdef FEAT_JUMPLIST | |
660 buf->b_changelistlen = 0; | |
661 #endif | |
662 } | |
663 | |
664 /* | |
665 * Get name of file from a filemark. | |
666 * When it's in the current buffer, return the text at the mark. | |
667 * Returns an allocated string. | |
668 */ | |
669 char_u * | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
670 fm_getname(fmark_T *fmark, int lead_len) |
7 | 671 { |
672 if (fmark->fnum == curbuf->b_fnum) /* current buffer */ | |
673 return mark_line(&(fmark->mark), lead_len); | |
674 return buflist_nr2name(fmark->fnum, FALSE, TRUE); | |
675 } | |
676 | |
677 /* | |
678 * Return the line at mark "mp". Truncate to fit in window. | |
679 * The returned string has been allocated. | |
680 */ | |
681 static char_u * | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
682 mark_line(pos_T *mp, int lead_len) |
7 | 683 { |
684 char_u *s, *p; | |
685 int len; | |
686 | |
687 if (mp->lnum == 0 || mp->lnum > curbuf->b_ml.ml_line_count) | |
688 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
|
689 // Allow for up to 5 bytes per character. |
8a4c0ab88201
patch 8.1.0168: output of :marks is too short with multi-byte chars
Christian Brabandt <cb@256bit.org>
parents:
13278
diff
changeset
|
690 s = vim_strnsave(skipwhite(ml_get(mp->lnum)), (int)Columns * 5); |
7 | 691 if (s == NULL) |
692 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
|
693 // Truncate the line to fit it in the window. |
7 | 694 len = 0; |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11121
diff
changeset
|
695 for (p = s; *p != NUL; MB_PTR_ADV(p)) |
7 | 696 { |
697 len += ptr2cells(p); | |
698 if (len >= Columns - lead_len) | |
699 break; | |
700 } | |
701 *p = NUL; | |
702 return s; | |
703 } | |
704 | |
705 /* | |
706 * print the marks | |
707 */ | |
708 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
709 do_marks(exarg_T *eap) |
7 | 710 { |
711 char_u *arg = eap->arg; | |
712 int i; | |
713 char_u *name; | |
714 | |
715 if (arg != NULL && *arg == NUL) | |
716 arg = NULL; | |
717 | |
718 show_one_mark('\'', arg, &curwin->w_pcmark, NULL, TRUE); | |
719 for (i = 0; i < NMARKS; ++i) | |
720 show_one_mark(i + 'a', arg, &curbuf->b_namedm[i], NULL, TRUE); | |
721 for (i = 0; i < NMARKS + EXTRA_MARKS; ++i) | |
722 { | |
723 if (namedfm[i].fmark.fnum != 0) | |
724 name = fm_getname(&namedfm[i].fmark, 15); | |
725 else | |
726 name = namedfm[i].fname; | |
727 if (name != NULL) | |
728 { | |
729 show_one_mark(i >= NMARKS ? i - NMARKS + '0' : i + 'A', | |
730 arg, &namedfm[i].fmark.mark, name, | |
731 namedfm[i].fmark.fnum == curbuf->b_fnum); | |
732 if (namedfm[i].fmark.fnum != 0) | |
733 vim_free(name); | |
734 } | |
735 } | |
736 show_one_mark('"', arg, &curbuf->b_last_cursor, NULL, TRUE); | |
737 show_one_mark('[', arg, &curbuf->b_op_start, NULL, TRUE); | |
738 show_one_mark(']', arg, &curbuf->b_op_end, NULL, TRUE); | |
739 show_one_mark('^', arg, &curbuf->b_last_insert, NULL, TRUE); | |
740 show_one_mark('.', arg, &curbuf->b_last_change, NULL, TRUE); | |
690 | 741 show_one_mark('<', arg, &curbuf->b_visual.vi_start, NULL, TRUE); |
742 show_one_mark('>', arg, &curbuf->b_visual.vi_end, NULL, TRUE); | |
7 | 743 show_one_mark(-1, arg, NULL, NULL, FALSE); |
744 } | |
745 | |
746 static void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
747 show_one_mark( |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
748 int c, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
749 char_u *arg, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
750 pos_T *p, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
751 char_u *name, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
752 int current) /* in current file */ |
7 | 753 { |
754 static int did_title = FALSE; | |
755 int mustfree = FALSE; | |
756 | |
757 if (c == -1) /* finish up */ | |
758 { | |
759 if (did_title) | |
760 did_title = FALSE; | |
761 else | |
762 { | |
763 if (arg == NULL) | |
764 MSG(_("No marks set")); | |
765 else | |
766 EMSG2(_("E283: No marks matching \"%s\""), arg); | |
767 } | |
768 } | |
769 /* don't output anything if 'q' typed at --more-- prompt */ | |
770 else if (!got_int | |
771 && (arg == NULL || vim_strchr(arg, c) != NULL) | |
772 && p->lnum != 0) | |
773 { | |
774 if (!did_title) | |
775 { | |
776 /* Highlight title */ | |
777 MSG_PUTS_TITLE(_("\nmark line col file/text")); | |
778 did_title = TRUE; | |
779 } | |
780 msg_putchar('\n'); | |
781 if (!got_int) | |
782 { | |
783 sprintf((char *)IObuff, " %c %6ld %4d ", c, p->lnum, p->col); | |
784 msg_outtrans(IObuff); | |
785 if (name == NULL && current) | |
786 { | |
787 name = mark_line(p, 15); | |
788 mustfree = TRUE; | |
789 } | |
790 if (name != NULL) | |
791 { | |
11158
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
11140
diff
changeset
|
792 msg_outtrans_attr(name, current ? HL_ATTR(HLF_D) : 0); |
7 | 793 if (mustfree) |
794 vim_free(name); | |
795 } | |
796 } | |
797 out_flush(); /* show one line at a time */ | |
798 } | |
799 } | |
800 | |
24 | 801 /* |
802 * ":delmarks[!] [marks]" | |
803 */ | |
804 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
805 ex_delmarks(exarg_T *eap) |
24 | 806 { |
807 char_u *p; | |
808 int from, to; | |
809 int i; | |
810 int lower; | |
811 int digit; | |
812 int n; | |
813 | |
814 if (*eap->arg == NUL && eap->forceit) | |
815 /* clear all marks */ | |
816 clrallmarks(curbuf); | |
817 else if (eap->forceit) | |
818 EMSG(_(e_invarg)); | |
819 else if (*eap->arg == NUL) | |
820 EMSG(_(e_argreq)); | |
821 else | |
822 { | |
823 /* clear specified marks only */ | |
824 for (p = eap->arg; *p != NUL; ++p) | |
825 { | |
826 lower = ASCII_ISLOWER(*p); | |
827 digit = VIM_ISDIGIT(*p); | |
828 if (lower || digit || ASCII_ISUPPER(*p)) | |
829 { | |
830 if (p[1] == '-') | |
831 { | |
832 /* clear range of marks */ | |
833 from = *p; | |
834 to = p[2]; | |
835 if (!(lower ? ASCII_ISLOWER(p[2]) | |
836 : (digit ? VIM_ISDIGIT(p[2]) | |
837 : ASCII_ISUPPER(p[2]))) | |
838 || to < from) | |
839 { | |
840 EMSG2(_(e_invarg2), p); | |
841 return; | |
842 } | |
843 p += 2; | |
844 } | |
845 else | |
846 /* clear one lower case mark */ | |
847 from = to = *p; | |
848 | |
849 for (i = from; i <= to; ++i) | |
850 { | |
851 if (lower) | |
852 curbuf->b_namedm[i - 'a'].lnum = 0; | |
853 else | |
854 { | |
855 if (digit) | |
856 n = i - '0' + NMARKS; | |
857 else | |
858 n = i - 'A'; | |
859 namedfm[n].fmark.mark.lnum = 0; | |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
860 VIM_CLEAR(namedfm[n].fname); |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
861 #ifdef FEAT_VIMINFO |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
862 namedfm[n].time_set = 0; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
863 #endif |
24 | 864 } |
865 } | |
866 } | |
867 else | |
868 switch (*p) | |
869 { | |
870 case '"': curbuf->b_last_cursor.lnum = 0; break; | |
871 case '^': curbuf->b_last_insert.lnum = 0; break; | |
872 case '.': curbuf->b_last_change.lnum = 0; break; | |
873 case '[': curbuf->b_op_start.lnum = 0; break; | |
874 case ']': curbuf->b_op_end.lnum = 0; break; | |
690 | 875 case '<': curbuf->b_visual.vi_start.lnum = 0; break; |
876 case '>': curbuf->b_visual.vi_end.lnum = 0; break; | |
24 | 877 case ' ': break; |
878 default: EMSG2(_(e_invarg2), p); | |
879 return; | |
880 } | |
881 } | |
882 } | |
883 } | |
884 | |
7 | 885 #if defined(FEAT_JUMPLIST) || defined(PROTO) |
886 /* | |
887 * print the jumplist | |
888 */ | |
889 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
890 ex_jumps(exarg_T *eap UNUSED) |
7 | 891 { |
892 int i; | |
893 char_u *name; | |
894 | |
13278
28ae299c6af0
patch 8.0.1513: the jumplist is not always properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
13248
diff
changeset
|
895 cleanup_jumplist(curwin, TRUE); |
13248
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
896 |
7 | 897 /* Highlight title */ |
898 MSG_PUTS_TITLE(_("\n jump line col file/text")); | |
899 for (i = 0; i < curwin->w_jumplistlen && !got_int; ++i) | |
900 { | |
901 if (curwin->w_jumplist[i].fmark.mark.lnum != 0) | |
902 { | |
903 name = fm_getname(&curwin->w_jumplist[i].fmark, 16); | |
904 if (name == NULL) /* file name not available */ | |
905 continue; | |
906 | |
907 msg_putchar('\n'); | |
908 if (got_int) | |
1702 | 909 { |
910 vim_free(name); | |
7 | 911 break; |
1702 | 912 } |
7 | 913 sprintf((char *)IObuff, "%c %2d %5ld %4d ", |
914 i == curwin->w_jumplistidx ? '>' : ' ', | |
915 i > curwin->w_jumplistidx ? i - curwin->w_jumplistidx | |
916 : curwin->w_jumplistidx - i, | |
917 curwin->w_jumplist[i].fmark.mark.lnum, | |
918 curwin->w_jumplist[i].fmark.mark.col); | |
919 msg_outtrans(IObuff); | |
920 msg_outtrans_attr(name, | |
921 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
|
922 ? HL_ATTR(HLF_D) : 0); |
7 | 923 vim_free(name); |
924 ui_breakcheck(); | |
925 } | |
926 out_flush(); | |
927 } | |
928 if (curwin->w_jumplistidx == curwin->w_jumplistlen) | |
929 MSG_PUTS("\n>"); | |
930 } | |
931 | |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
932 void |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
933 ex_clearjumps(exarg_T *eap UNUSED) |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
934 { |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
935 free_jumplist(curwin); |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
936 curwin->w_jumplistlen = 0; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
937 curwin->w_jumplistidx = 0; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
938 } |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
939 |
7 | 940 /* |
941 * print the changelist | |
942 */ | |
943 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
944 ex_changes(exarg_T *eap UNUSED) |
7 | 945 { |
946 int i; | |
947 char_u *name; | |
948 | |
949 /* Highlight title */ | |
950 MSG_PUTS_TITLE(_("\nchange line col text")); | |
951 | |
952 for (i = 0; i < curbuf->b_changelistlen && !got_int; ++i) | |
953 { | |
954 if (curbuf->b_changelist[i].lnum != 0) | |
955 { | |
956 msg_putchar('\n'); | |
957 if (got_int) | |
958 break; | |
959 sprintf((char *)IObuff, "%c %3d %5ld %4d ", | |
960 i == curwin->w_changelistidx ? '>' : ' ', | |
961 i > curwin->w_changelistidx ? i - curwin->w_changelistidx | |
962 : curwin->w_changelistidx - i, | |
963 (long)curbuf->b_changelist[i].lnum, | |
964 curbuf->b_changelist[i].col); | |
965 msg_outtrans(IObuff); | |
966 name = mark_line(&curbuf->b_changelist[i], 17); | |
967 if (name == NULL) | |
968 break; | |
11158
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
11140
diff
changeset
|
969 msg_outtrans_attr(name, HL_ATTR(HLF_D)); |
7 | 970 vim_free(name); |
971 ui_breakcheck(); | |
972 } | |
973 out_flush(); | |
974 } | |
975 if (curwin->w_changelistidx == curbuf->b_changelistlen) | |
976 MSG_PUTS("\n>"); | |
977 } | |
978 #endif | |
979 | |
980 #define one_adjust(add) \ | |
981 { \ | |
982 lp = add; \ | |
983 if (*lp >= line1 && *lp <= line2) \ | |
984 { \ | |
985 if (amount == MAXLNUM) \ | |
986 *lp = 0; \ | |
987 else \ | |
988 *lp += amount; \ | |
989 } \ | |
990 else if (amount_after && *lp > line2) \ | |
991 *lp += amount_after; \ | |
992 } | |
993 | |
994 /* don't delete the line, just put at first deleted line */ | |
995 #define one_adjust_nodel(add) \ | |
996 { \ | |
997 lp = add; \ | |
998 if (*lp >= line1 && *lp <= line2) \ | |
999 { \ | |
1000 if (amount == MAXLNUM) \ | |
1001 *lp = line1; \ | |
1002 else \ | |
1003 *lp += amount; \ | |
1004 } \ | |
1005 else if (amount_after && *lp > line2) \ | |
1006 *lp += amount_after; \ | |
1007 } | |
1008 | |
1009 /* | |
1010 * Adjust marks between line1 and line2 (inclusive) to move 'amount' lines. | |
1011 * Must be called before changed_*(), appended_lines() or deleted_lines(). | |
1012 * May be called before or after changing the text. | |
1013 * When deleting lines line1 to line2, use an 'amount' of MAXLNUM: The marks | |
1014 * within this range are made invalid. | |
1015 * If 'amount_after' is non-zero adjust marks after line2. | |
1016 * Example: Delete lines 34 and 35: mark_adjust(34, 35, MAXLNUM, -2); | |
1017 * Example: Insert two lines below 55: mark_adjust(56, MAXLNUM, 2, 0); | |
1018 * or: mark_adjust(56, 55, MAXLNUM, 2); | |
1019 */ | |
1020 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1021 mark_adjust( |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1022 linenr_T line1, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1023 linenr_T line2, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1024 long amount, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1025 long amount_after) |
7 | 1026 { |
11140
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1027 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
|
1028 } |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1029 |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1030 void |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1031 mark_adjust_nofold( |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1032 linenr_T line1, |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1033 linenr_T line2, |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1034 long amount, |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1035 long amount_after) |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1036 { |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1037 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
|
1038 } |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1039 |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1040 static void |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1041 mark_adjust_internal( |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1042 linenr_T line1, |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1043 linenr_T line2, |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1044 long amount, |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1045 long amount_after, |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1046 int adjust_folds UNUSED) |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1047 { |
7 | 1048 int i; |
1049 int fnum = curbuf->b_fnum; | |
1050 linenr_T *lp; | |
1051 win_T *win; | |
1863 | 1052 tabpage_T *tab; |
4092 | 1053 static pos_T initpos = INIT_POS_T(1, 0, 0); |
7 | 1054 |
1055 if (line2 < line1 && amount_after == 0L) /* nothing to do */ | |
1056 return; | |
1057 | |
1058 if (!cmdmod.lockmarks) | |
1059 { | |
1060 /* named marks, lower case and upper case */ | |
1061 for (i = 0; i < NMARKS; i++) | |
1062 { | |
1063 one_adjust(&(curbuf->b_namedm[i].lnum)); | |
1064 if (namedfm[i].fmark.fnum == fnum) | |
1065 one_adjust_nodel(&(namedfm[i].fmark.mark.lnum)); | |
1066 } | |
1067 for (i = NMARKS; i < NMARKS + EXTRA_MARKS; i++) | |
1068 { | |
1069 if (namedfm[i].fmark.fnum == fnum) | |
1070 one_adjust_nodel(&(namedfm[i].fmark.mark.lnum)); | |
1071 } | |
1072 | |
1073 /* last Insert position */ | |
1074 one_adjust(&(curbuf->b_last_insert.lnum)); | |
1075 | |
1076 /* last change position */ | |
1077 one_adjust(&(curbuf->b_last_change.lnum)); | |
1078 | |
4092 | 1079 /* 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
|
1080 if (!EQUAL_POS(curbuf->b_last_cursor, initpos)) |
4092 | 1081 one_adjust(&(curbuf->b_last_cursor.lnum)); |
1082 | |
1083 | |
7 | 1084 #ifdef FEAT_JUMPLIST |
1085 /* list of change positions */ | |
1086 for (i = 0; i < curbuf->b_changelistlen; ++i) | |
1087 one_adjust_nodel(&(curbuf->b_changelist[i].lnum)); | |
1088 #endif | |
1089 | |
1090 /* Visual area */ | |
690 | 1091 one_adjust_nodel(&(curbuf->b_visual.vi_start.lnum)); |
1092 one_adjust_nodel(&(curbuf->b_visual.vi_end.lnum)); | |
7 | 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 /* the displayed Visual area */ | |
1140 if (win->w_old_cursor_lnum != 0) | |
1141 { | |
1142 one_adjust_nodel(&(win->w_old_cursor_lnum)); | |
1143 one_adjust_nodel(&(win->w_old_visual_lnum)); | |
1144 } | |
1145 | |
1146 /* topline and cursor position for windows with the same buffer | |
1147 * other than the current window */ | |
1148 if (win != curwin) | |
1149 { | |
1150 if (win->w_topline >= line1 && win->w_topline <= line2) | |
1151 { | |
1152 if (amount == MAXLNUM) /* topline is deleted */ | |
1153 { | |
1154 if (line1 <= 1) | |
1155 win->w_topline = 1; | |
1156 else | |
1157 win->w_topline = line1 - 1; | |
1158 } | |
1159 else /* keep topline on the same line */ | |
1160 win->w_topline += amount; | |
1161 #ifdef FEAT_DIFF | |
1162 win->w_topfill = 0; | |
1163 #endif | |
1164 } | |
1165 else if (amount_after && win->w_topline > line2) | |
1166 { | |
1167 win->w_topline += amount_after; | |
1168 #ifdef FEAT_DIFF | |
1169 win->w_topfill = 0; | |
1170 #endif | |
1171 } | |
1172 if (win->w_cursor.lnum >= line1 && win->w_cursor.lnum <= line2) | |
1173 { | |
1174 if (amount == MAXLNUM) /* line with cursor is deleted */ | |
1175 { | |
1176 if (line1 <= 1) | |
1177 win->w_cursor.lnum = 1; | |
1178 else | |
1179 win->w_cursor.lnum = line1 - 1; | |
1180 win->w_cursor.col = 0; | |
1181 } | |
1182 else /* keep cursor on the same line */ | |
1183 win->w_cursor.lnum += amount; | |
1184 } | |
1185 else if (amount_after && win->w_cursor.lnum > line2) | |
1186 win->w_cursor.lnum += amount_after; | |
1187 } | |
1188 | |
1189 #ifdef FEAT_FOLDING | |
1190 /* adjust folds */ | |
11140
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1191 if (adjust_folds) |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1192 foldMarkAdjust(win, line1, line2, amount, amount_after); |
7 | 1193 #endif |
1194 } | |
1195 } | |
1196 | |
1197 #ifdef FEAT_DIFF | |
1198 /* adjust diffs */ | |
1199 diff_mark_adjust(line1, line2, amount, amount_after); | |
1200 #endif | |
1201 } | |
1202 | |
1203 /* This code is used often, needs to be fast. */ | |
1204 #define col_adjust(pp) \ | |
1205 { \ | |
1206 posp = pp; \ | |
1207 if (posp->lnum == lnum && posp->col >= mincol) \ | |
1208 { \ | |
1209 posp->lnum += lnum_amount; \ | |
1210 if (col_amount < 0 && posp->col <= (colnr_T)-col_amount) \ | |
1211 posp->col = 0; \ | |
1212 else \ | |
1213 posp->col += col_amount; \ | |
1214 } \ | |
1215 } | |
1216 | |
1217 /* | |
1218 * Adjust marks in line "lnum" at column "mincol" and further: add | |
1219 * "lnum_amount" to the line number and add "col_amount" to the column | |
1220 * position. | |
1221 */ | |
1222 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1223 mark_col_adjust( |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1224 linenr_T lnum, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1225 colnr_T mincol, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1226 long lnum_amount, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1227 long col_amount) |
7 | 1228 { |
1229 int i; | |
1230 int fnum = curbuf->b_fnum; | |
1231 win_T *win; | |
1232 pos_T *posp; | |
1233 | |
1234 if ((col_amount == 0L && lnum_amount == 0L) || cmdmod.lockmarks) | |
1235 return; /* nothing to do */ | |
1236 | |
1237 /* named marks, lower case and upper case */ | |
1238 for (i = 0; i < NMARKS; i++) | |
1239 { | |
1240 col_adjust(&(curbuf->b_namedm[i])); | |
1241 if (namedfm[i].fmark.fnum == fnum) | |
1242 col_adjust(&(namedfm[i].fmark.mark)); | |
1243 } | |
1244 for (i = NMARKS; i < NMARKS + EXTRA_MARKS; i++) | |
1245 { | |
1246 if (namedfm[i].fmark.fnum == fnum) | |
1247 col_adjust(&(namedfm[i].fmark.mark)); | |
1248 } | |
1249 | |
1250 /* last Insert position */ | |
1251 col_adjust(&(curbuf->b_last_insert)); | |
1252 | |
1253 /* last change position */ | |
1254 col_adjust(&(curbuf->b_last_change)); | |
1255 | |
1256 #ifdef FEAT_JUMPLIST | |
1257 /* list of change positions */ | |
1258 for (i = 0; i < curbuf->b_changelistlen; ++i) | |
1259 col_adjust(&(curbuf->b_changelist[i])); | |
1260 #endif | |
1261 | |
1262 /* Visual area */ | |
690 | 1263 col_adjust(&(curbuf->b_visual.vi_start)); |
1264 col_adjust(&(curbuf->b_visual.vi_end)); | |
7 | 1265 |
1266 /* previous context mark */ | |
1267 col_adjust(&(curwin->w_pcmark)); | |
1268 | |
1269 /* previous pcmark */ | |
1270 col_adjust(&(curwin->w_prev_pcmark)); | |
1271 | |
1272 /* saved cursor for formatting */ | |
1273 col_adjust(&saved_cursor); | |
1274 | |
1275 /* | |
1276 * Adjust items in all windows related to the current buffer. | |
1277 */ | |
1278 FOR_ALL_WINDOWS(win) | |
1279 { | |
1280 #ifdef FEAT_JUMPLIST | |
1281 /* marks in the jumplist */ | |
1282 for (i = 0; i < win->w_jumplistlen; ++i) | |
1283 if (win->w_jumplist[i].fmark.fnum == fnum) | |
1284 col_adjust(&(win->w_jumplist[i].fmark.mark)); | |
1285 #endif | |
1286 | |
1287 if (win->w_buffer == curbuf) | |
1288 { | |
1289 /* marks in the tag stack */ | |
1290 for (i = 0; i < win->w_tagstacklen; i++) | |
1291 if (win->w_tagstack[i].fmark.fnum == fnum) | |
1292 col_adjust(&(win->w_tagstack[i].fmark.mark)); | |
1293 | |
1294 /* cursor position for other windows with the same buffer */ | |
1295 if (win != curwin) | |
1296 col_adjust(&win->w_cursor); | |
1297 } | |
1298 } | |
1299 } | |
1300 | |
1301 #ifdef FEAT_JUMPLIST | |
1302 /* | |
1303 * 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
|
1304 * 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
|
1305 * 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
|
1306 * (this may be a bit slow). |
7 | 1307 */ |
13248
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1308 void |
13278
28ae299c6af0
patch 8.0.1513: the jumplist is not always properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
13248
diff
changeset
|
1309 cleanup_jumplist(win_T *wp, int loadfiles) |
7 | 1310 { |
1311 int i; | |
1312 int from, to; | |
1313 | |
13278
28ae299c6af0
patch 8.0.1513: the jumplist is not always properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
13248
diff
changeset
|
1314 if (loadfiles) |
28ae299c6af0
patch 8.0.1513: the jumplist is not always properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
13248
diff
changeset
|
1315 { |
28ae299c6af0
patch 8.0.1513: the jumplist is not always properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
13248
diff
changeset
|
1316 /* If specified, load all the files from the jump list. This is |
28ae299c6af0
patch 8.0.1513: the jumplist is not always properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
13248
diff
changeset
|
1317 * needed to properly clean up duplicate entries, but will take some |
28ae299c6af0
patch 8.0.1513: the jumplist is not always properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
13248
diff
changeset
|
1318 * time. */ |
28ae299c6af0
patch 8.0.1513: the jumplist is not always properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
13248
diff
changeset
|
1319 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
|
1320 { |
28ae299c6af0
patch 8.0.1513: the jumplist is not always properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
13248
diff
changeset
|
1321 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
|
1322 (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
|
1323 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
|
1324 } |
28ae299c6af0
patch 8.0.1513: the jumplist is not always properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
13248
diff
changeset
|
1325 } |
28ae299c6af0
patch 8.0.1513: the jumplist is not always properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
13248
diff
changeset
|
1326 |
7 | 1327 to = 0; |
13248
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1328 for (from = 0; from < wp->w_jumplistlen; ++from) |
7 | 1329 { |
13248
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1330 if (wp->w_jumplistidx == from) |
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1331 wp->w_jumplistidx = to; |
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1332 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
|
1333 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
|
1334 == wp->w_jumplist[from].fmark.fnum |
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1335 && 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
|
1336 && 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
|
1337 == wp->w_jumplist[from].fmark.mark.lnum) |
7 | 1338 break; |
13248
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1339 if (i >= wp->w_jumplistlen) /* no duplicate */ |
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1340 wp->w_jumplist[to++] = wp->w_jumplist[from]; |
7 | 1341 else |
13248
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1342 vim_free(wp->w_jumplist[from].fname); |
7 | 1343 } |
13248
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1344 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
|
1345 wp->w_jumplistidx = to; |
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1346 wp->w_jumplistlen = to; |
7 | 1347 } |
1348 | |
1349 /* | |
1350 * Copy the jumplist from window "from" to window "to". | |
1351 */ | |
1352 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1353 copy_jumplist(win_T *from, win_T *to) |
7 | 1354 { |
1355 int i; | |
1356 | |
1357 for (i = 0; i < from->w_jumplistlen; ++i) | |
1358 { | |
1359 to->w_jumplist[i] = from->w_jumplist[i]; | |
1360 if (from->w_jumplist[i].fname != NULL) | |
1361 to->w_jumplist[i].fname = vim_strsave(from->w_jumplist[i].fname); | |
1362 } | |
1363 to->w_jumplistlen = from->w_jumplistlen; | |
1364 to->w_jumplistidx = from->w_jumplistidx; | |
1365 } | |
1366 | |
1367 /* | |
1368 * Free items in the jumplist of window "wp". | |
1369 */ | |
1370 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1371 free_jumplist(win_T *wp) |
7 | 1372 { |
1373 int i; | |
1374 | |
1375 for (i = 0; i < wp->w_jumplistlen; ++i) | |
1376 vim_free(wp->w_jumplist[i].fname); | |
1377 } | |
1378 #endif /* FEAT_JUMPLIST */ | |
1379 | |
1380 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1381 set_last_cursor(win_T *win) |
7 | 1382 { |
5417 | 1383 if (win->w_buffer != NULL) |
1384 win->w_buffer->b_last_cursor = win->w_cursor; | |
7 | 1385 } |
1386 | |
358 | 1387 #if defined(EXITFREE) || defined(PROTO) |
1388 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1389 free_all_marks(void) |
358 | 1390 { |
1391 int i; | |
1392 | |
1393 for (i = 0; i < NMARKS + EXTRA_MARKS; i++) | |
1394 if (namedfm[i].fmark.mark.lnum != 0) | |
1395 vim_free(namedfm[i].fname); | |
1396 } | |
1397 #endif | |
1398 | |
7 | 1399 #if defined(FEAT_VIMINFO) || defined(PROTO) |
1400 int | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1401 read_viminfo_filemark(vir_T *virp, int force) |
7 | 1402 { |
1403 char_u *str; | |
1404 xfmark_T *fm; | |
1405 int i; | |
1406 | |
1407 /* We only get here if line[0] == '\'' or '-'. | |
1408 * Illegal mark names are ignored (for future expansion). */ | |
1409 str = virp->vir_line + 1; | |
1410 if ( | |
1411 #ifndef EBCDIC | |
1412 *str <= 127 && | |
1413 #endif | |
1414 ((*virp->vir_line == '\'' && (VIM_ISDIGIT(*str) || isupper(*str))) | |
1415 || (*virp->vir_line == '-' && *str == '\''))) | |
1416 { | |
1417 if (*str == '\'') | |
1418 { | |
1419 #ifdef FEAT_JUMPLIST | |
1420 /* If the jumplist isn't full insert fmark as oldest entry */ | |
1421 if (curwin->w_jumplistlen == JUMPLISTSIZE) | |
1422 fm = NULL; | |
1423 else | |
1424 { | |
1425 for (i = curwin->w_jumplistlen; i > 0; --i) | |
1426 curwin->w_jumplist[i] = curwin->w_jumplist[i - 1]; | |
1427 ++curwin->w_jumplistidx; | |
1428 ++curwin->w_jumplistlen; | |
1429 fm = &curwin->w_jumplist[0]; | |
1430 fm->fmark.mark.lnum = 0; | |
1431 fm->fname = NULL; | |
1432 } | |
1433 #else | |
1434 fm = NULL; | |
1435 #endif | |
1436 } | |
1437 else if (VIM_ISDIGIT(*str)) | |
1438 fm = &namedfm[*str - '0' + NMARKS]; | |
1439 else | |
1440 fm = &namedfm[*str - 'A']; | |
1441 if (fm != NULL && (fm->fmark.mark.lnum == 0 || force)) | |
1442 { | |
1443 str = skipwhite(str + 1); | |
1444 fm->fmark.mark.lnum = getdigits(&str); | |
1445 str = skipwhite(str); | |
1446 fm->fmark.mark.col = getdigits(&str); | |
1447 #ifdef FEAT_VIRTUALEDIT | |
1448 fm->fmark.mark.coladd = 0; | |
1449 #endif | |
1450 fm->fmark.fnum = 0; | |
1451 str = skipwhite(str); | |
1452 vim_free(fm->fname); | |
1453 fm->fname = viminfo_readstring(virp, (int)(str - virp->vir_line), | |
1454 FALSE); | |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1455 fm->time_set = 0; |
7 | 1456 } |
1457 } | |
1458 return vim_fgets(virp->vir_line, LSIZE, virp->vir_fd); | |
1459 } | |
1460 | |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1461 static xfmark_T *vi_namedfm = NULL; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1462 #ifdef FEAT_JUMPLIST |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1463 static xfmark_T *vi_jumplist = NULL; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1464 static int vi_jumplist_len = 0; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1465 #endif |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1466 |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1467 /* |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1468 * Prepare for reading viminfo marks when writing viminfo later. |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1469 */ |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1470 void |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1471 prepare_viminfo_marks(void) |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1472 { |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1473 vi_namedfm = (xfmark_T *)alloc_clear((NMARKS + EXTRA_MARKS) |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1474 * (int)sizeof(xfmark_T)); |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1475 #ifdef FEAT_JUMPLIST |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1476 vi_jumplist = (xfmark_T *)alloc_clear(JUMPLISTSIZE |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1477 * (int)sizeof(xfmark_T)); |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1478 vi_jumplist_len = 0; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1479 #endif |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1480 } |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1481 |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1482 void |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1483 finish_viminfo_marks(void) |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1484 { |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1485 int i; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1486 |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1487 if (vi_namedfm != NULL) |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1488 { |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1489 for (i = 0; i < NMARKS + EXTRA_MARKS; ++i) |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1490 vim_free(vi_namedfm[i].fname); |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
1491 VIM_CLEAR(vi_namedfm); |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1492 } |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1493 #ifdef FEAT_JUMPLIST |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1494 if (vi_jumplist != NULL) |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1495 { |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1496 for (i = 0; i < vi_jumplist_len; ++i) |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1497 vim_free(vi_jumplist[i].fname); |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
1498 VIM_CLEAR(vi_jumplist); |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1499 } |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1500 #endif |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1501 } |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1502 |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1503 /* |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1504 * Accept a new style mark line from the viminfo, store it when it's new. |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1505 */ |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1506 void |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1507 handle_viminfo_mark(garray_T *values, int force) |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1508 { |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1509 bval_T *vp = (bval_T *)values->ga_data; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1510 int name; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1511 linenr_T lnum; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1512 colnr_T col; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1513 time_t timestamp; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1514 xfmark_T *fm = NULL; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1515 |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1516 /* Check the format: |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1517 * |{bartype},{name},{lnum},{col},{timestamp},{filename} */ |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1518 if (values->ga_len < 5 |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1519 || vp[0].bv_type != BVAL_NR |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1520 || vp[1].bv_type != BVAL_NR |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1521 || vp[2].bv_type != BVAL_NR |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1522 || vp[3].bv_type != BVAL_NR |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1523 || vp[4].bv_type != BVAL_STRING) |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1524 return; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1525 |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1526 name = vp[0].bv_nr; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1527 if (name != '\'' && !VIM_ISDIGIT(name) && !ASCII_ISUPPER(name)) |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1528 return; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1529 lnum = vp[1].bv_nr; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1530 col = vp[2].bv_nr; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1531 if (lnum <= 0 || col < 0) |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1532 return; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1533 timestamp = (time_t)vp[3].bv_nr; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1534 |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1535 if (name == '\'') |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1536 { |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1537 #ifdef FEAT_JUMPLIST |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1538 if (vi_jumplist != NULL) |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1539 { |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1540 if (vi_jumplist_len < JUMPLISTSIZE) |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1541 fm = &vi_jumplist[vi_jumplist_len++]; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1542 } |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1543 else |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1544 { |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1545 int idx; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1546 int i; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1547 |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1548 /* If we have a timestamp insert it in the right place. */ |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1549 if (timestamp != 0) |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1550 { |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1551 for (idx = curwin->w_jumplistlen - 1; idx >= 0; --idx) |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1552 if (curwin->w_jumplist[idx].time_set < timestamp) |
9299
8000f0a44744
commit https://github.com/vim/vim/commit/ece74ab103eca15e17435efbe9cb21039787f1ea
Christian Brabandt <cb@256bit.org>
parents:
9284
diff
changeset
|
1553 { |
8000f0a44744
commit https://github.com/vim/vim/commit/ece74ab103eca15e17435efbe9cb21039787f1ea
Christian Brabandt <cb@256bit.org>
parents:
9284
diff
changeset
|
1554 ++idx; |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1555 break; |
9299
8000f0a44744
commit https://github.com/vim/vim/commit/ece74ab103eca15e17435efbe9cb21039787f1ea
Christian Brabandt <cb@256bit.org>
parents:
9284
diff
changeset
|
1556 } |
9322
f2e534fdbe65
commit https://github.com/vim/vim/commit/678e480529bce7ba3c09e71233249e3b56531b24
Christian Brabandt <cb@256bit.org>
parents:
9313
diff
changeset
|
1557 /* idx cannot be zero now */ |
9299
8000f0a44744
commit https://github.com/vim/vim/commit/ece74ab103eca15e17435efbe9cb21039787f1ea
Christian Brabandt <cb@256bit.org>
parents:
9284
diff
changeset
|
1558 if (idx < 0 && curwin->w_jumplistlen < JUMPLISTSIZE) |
8000f0a44744
commit https://github.com/vim/vim/commit/ece74ab103eca15e17435efbe9cb21039787f1ea
Christian Brabandt <cb@256bit.org>
parents:
9284
diff
changeset
|
1559 /* insert as the oldest entry */ |
8000f0a44744
commit https://github.com/vim/vim/commit/ece74ab103eca15e17435efbe9cb21039787f1ea
Christian Brabandt <cb@256bit.org>
parents:
9284
diff
changeset
|
1560 idx = 0; |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1561 } |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1562 else if (curwin->w_jumplistlen < JUMPLISTSIZE) |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1563 /* insert as oldest entry */ |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1564 idx = 0; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1565 else |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1566 idx = -1; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1567 |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1568 if (idx >= 0) |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1569 { |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1570 if (curwin->w_jumplistlen == JUMPLISTSIZE) |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1571 { |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1572 /* Drop the oldest entry. */ |
9313
c0760b25f31d
commit https://github.com/vim/vim/commit/28607ba2b82668503f8406bc13690d59af46deb3
Christian Brabandt <cb@256bit.org>
parents:
9311
diff
changeset
|
1573 --idx; |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1574 vim_free(curwin->w_jumplist[0].fname); |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1575 for (i = 0; i < idx; ++i) |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1576 curwin->w_jumplist[i] = curwin->w_jumplist[i + 1]; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1577 } |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1578 else |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1579 { |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1580 /* Move newer entries forward. */ |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1581 for (i = curwin->w_jumplistlen; i > idx; --i) |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1582 curwin->w_jumplist[i] = curwin->w_jumplist[i - 1]; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1583 ++curwin->w_jumplistidx; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1584 ++curwin->w_jumplistlen; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1585 } |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1586 fm = &curwin->w_jumplist[idx]; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1587 fm->fmark.mark.lnum = 0; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1588 fm->fname = NULL; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1589 fm->time_set = 0; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1590 } |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1591 } |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1592 #endif |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1593 } |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1594 else |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1595 { |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1596 int idx; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1597 |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1598 if (VIM_ISDIGIT(name)) |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1599 { |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1600 if (vi_namedfm != NULL) |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1601 idx = name - '0' + NMARKS; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1602 else |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1603 { |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1604 int i; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1605 |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1606 /* Do not use the name from the viminfo file, insert in time |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1607 * order. */ |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1608 for (idx = NMARKS; idx < NMARKS + EXTRA_MARKS; ++idx) |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1609 if (namedfm[idx].time_set < timestamp) |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1610 break; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1611 if (idx == NMARKS + EXTRA_MARKS) |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1612 /* All existing entries are newer. */ |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1613 return; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1614 i = NMARKS + EXTRA_MARKS - 1; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1615 |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1616 vim_free(namedfm[i].fname); |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1617 for ( ; i > idx; --i) |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1618 namedfm[i] = namedfm[i - 1]; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1619 namedfm[idx].fname = NULL; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1620 } |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1621 } |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1622 else |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1623 idx = name - 'A'; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1624 if (vi_namedfm != NULL) |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1625 fm = &vi_namedfm[idx]; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1626 else |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1627 fm = &namedfm[idx]; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1628 } |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1629 |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1630 if (fm != NULL) |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1631 { |
10285
cd16ef948ad1
commit https://github.com/vim/vim/commit/156919f99afd1ac11d19d4270afbc1afb7245640
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1632 if (vi_namedfm != NULL || fm->fmark.mark.lnum == 0 |
cd16ef948ad1
commit https://github.com/vim/vim/commit/156919f99afd1ac11d19d4270afbc1afb7245640
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1633 || fm->time_set < timestamp || force) |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1634 { |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1635 fm->fmark.mark.lnum = lnum; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1636 fm->fmark.mark.col = col; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1637 #ifdef FEAT_VIRTUALEDIT |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1638 fm->fmark.mark.coladd = 0; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1639 #endif |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1640 fm->fmark.fnum = 0; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1641 vim_free(fm->fname); |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1642 if (vp[4].bv_allocated) |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1643 { |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1644 fm->fname = vp[4].bv_string; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1645 vp[4].bv_string = NULL; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1646 } |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1647 else |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1648 fm->fname = vim_strsave(vp[4].bv_string); |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1649 fm->time_set = timestamp; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1650 } |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1651 } |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1652 } |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1653 |
12100
d4ffc3dc9fb0
patch 8.0.0930: terminal buffers are stored in the viminfo file
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1654 /* |
d4ffc3dc9fb0
patch 8.0.0930: terminal buffers are stored in the viminfo file
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1655 * Return TRUE if marks for "buf" should not be written. |
d4ffc3dc9fb0
patch 8.0.0930: terminal buffers are stored in the viminfo file
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1656 */ |
d4ffc3dc9fb0
patch 8.0.0930: terminal buffers are stored in the viminfo file
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1657 static int |
d4ffc3dc9fb0
patch 8.0.0930: terminal buffers are stored in the viminfo file
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1658 skip_for_viminfo(buf_T *buf) |
d4ffc3dc9fb0
patch 8.0.0930: terminal buffers are stored in the viminfo file
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1659 { |
d4ffc3dc9fb0
patch 8.0.0930: terminal buffers are stored in the viminfo file
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1660 return |
d4ffc3dc9fb0
patch 8.0.0930: terminal buffers are stored in the viminfo file
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1661 #ifdef FEAT_TERMINAL |
d4ffc3dc9fb0
patch 8.0.0930: terminal buffers are stored in the viminfo file
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1662 bt_terminal(buf) || |
d4ffc3dc9fb0
patch 8.0.0930: terminal buffers are stored in the viminfo file
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1663 #endif |
d4ffc3dc9fb0
patch 8.0.0930: terminal buffers are stored in the viminfo file
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1664 removable(buf->b_ffname); |
d4ffc3dc9fb0
patch 8.0.0930: terminal buffers are stored in the viminfo file
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1665 } |
d4ffc3dc9fb0
patch 8.0.0930: terminal buffers are stored in the viminfo file
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1666 |
7 | 1667 void |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1668 write_viminfo_filemarks(FILE *fp) |
7 | 1669 { |
1670 int i; | |
1671 char_u *name; | |
1672 buf_T *buf; | |
1673 xfmark_T *fm; | |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1674 int vi_idx; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1675 int idx; |
7 | 1676 |
1677 if (get_viminfo_parameter('f') == 0) | |
1678 return; | |
1679 | |
2545
298d8d6e69be
Avoid warnings from the clang compiler. (Dominique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
1880
diff
changeset
|
1680 fputs(_("\n# File marks:\n"), fp); |
7 | 1681 |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1682 /* Write the filemarks 'A - 'Z */ |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1683 for (i = 0; i < NMARKS; i++) |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1684 { |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1685 if (vi_namedfm != NULL && (vi_namedfm[i].time_set > namedfm[i].time_set |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1686 || namedfm[i].fmark.mark.lnum == 0)) |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1687 fm = &vi_namedfm[i]; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1688 else |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1689 fm = &namedfm[i]; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1690 write_one_filemark(fp, fm, '\'', i + 'A'); |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1691 } |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1692 |
7 | 1693 /* |
1694 * Find a mark that is the same file and position as the cursor. | |
1695 * That one, or else the last one is deleted. | |
1696 * Move '0 to '1, '1 to '2, etc. until the matching one or '9 | |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1697 * Set the '0 mark to current cursor position. |
7 | 1698 */ |
12100
d4ffc3dc9fb0
patch 8.0.0930: terminal buffers are stored in the viminfo file
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1699 if (curbuf->b_ffname != NULL && !skip_for_viminfo(curbuf)) |
7 | 1700 { |
1701 name = buflist_nr2name(curbuf->b_fnum, TRUE, FALSE); | |
1702 for (i = NMARKS; i < NMARKS + EXTRA_MARKS - 1; ++i) | |
1703 if (namedfm[i].fmark.mark.lnum == curwin->w_cursor.lnum | |
1704 && (namedfm[i].fname == NULL | |
1705 ? namedfm[i].fmark.fnum == curbuf->b_fnum | |
1706 : (name != NULL | |
1707 && STRCMP(name, namedfm[i].fname) == 0))) | |
1708 break; | |
1709 vim_free(name); | |
1710 | |
1711 vim_free(namedfm[i].fname); | |
1712 for ( ; i > NMARKS; --i) | |
1713 namedfm[i] = namedfm[i - 1]; | |
1714 namedfm[NMARKS].fmark.mark = curwin->w_cursor; | |
1715 namedfm[NMARKS].fmark.fnum = curbuf->b_fnum; | |
1716 namedfm[NMARKS].fname = NULL; | |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1717 namedfm[NMARKS].time_set = vim_time(); |
7 | 1718 } |
1719 | |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1720 /* Write the filemarks '0 - '9. Newest (highest timestamp) first. */ |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1721 vi_idx = NMARKS; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1722 idx = NMARKS; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1723 for (i = NMARKS; i < NMARKS + EXTRA_MARKS; i++) |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1724 { |
9311
7a6f64de57d5
commit https://github.com/vim/vim/commit/36f0f0686ca313ef7b76387378cd5dc7acea1924
Christian Brabandt <cb@256bit.org>
parents:
9299
diff
changeset
|
1725 xfmark_T *vi_fm = vi_namedfm != NULL ? &vi_namedfm[vi_idx] : NULL; |
7a6f64de57d5
commit https://github.com/vim/vim/commit/36f0f0686ca313ef7b76387378cd5dc7acea1924
Christian Brabandt <cb@256bit.org>
parents:
9299
diff
changeset
|
1726 |
7a6f64de57d5
commit https://github.com/vim/vim/commit/36f0f0686ca313ef7b76387378cd5dc7acea1924
Christian Brabandt <cb@256bit.org>
parents:
9299
diff
changeset
|
1727 if (vi_fm != NULL |
7a6f64de57d5
commit https://github.com/vim/vim/commit/36f0f0686ca313ef7b76387378cd5dc7acea1924
Christian Brabandt <cb@256bit.org>
parents:
9299
diff
changeset
|
1728 && vi_fm->fmark.mark.lnum != 0 |
7a6f64de57d5
commit https://github.com/vim/vim/commit/36f0f0686ca313ef7b76387378cd5dc7acea1924
Christian Brabandt <cb@256bit.org>
parents:
9299
diff
changeset
|
1729 && (vi_fm->time_set > namedfm[idx].time_set |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1730 || namedfm[idx].fmark.mark.lnum == 0)) |
9311
7a6f64de57d5
commit https://github.com/vim/vim/commit/36f0f0686ca313ef7b76387378cd5dc7acea1924
Christian Brabandt <cb@256bit.org>
parents:
9299
diff
changeset
|
1731 { |
7a6f64de57d5
commit https://github.com/vim/vim/commit/36f0f0686ca313ef7b76387378cd5dc7acea1924
Christian Brabandt <cb@256bit.org>
parents:
9299
diff
changeset
|
1732 fm = vi_fm; |
7a6f64de57d5
commit https://github.com/vim/vim/commit/36f0f0686ca313ef7b76387378cd5dc7acea1924
Christian Brabandt <cb@256bit.org>
parents:
9299
diff
changeset
|
1733 ++vi_idx; |
7a6f64de57d5
commit https://github.com/vim/vim/commit/36f0f0686ca313ef7b76387378cd5dc7acea1924
Christian Brabandt <cb@256bit.org>
parents:
9299
diff
changeset
|
1734 } |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1735 else |
9311
7a6f64de57d5
commit https://github.com/vim/vim/commit/36f0f0686ca313ef7b76387378cd5dc7acea1924
Christian Brabandt <cb@256bit.org>
parents:
9299
diff
changeset
|
1736 { |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1737 fm = &namedfm[idx++]; |
9311
7a6f64de57d5
commit https://github.com/vim/vim/commit/36f0f0686ca313ef7b76387378cd5dc7acea1924
Christian Brabandt <cb@256bit.org>
parents:
9299
diff
changeset
|
1738 if (vi_fm != NULL |
7a6f64de57d5
commit https://github.com/vim/vim/commit/36f0f0686ca313ef7b76387378cd5dc7acea1924
Christian Brabandt <cb@256bit.org>
parents:
9299
diff
changeset
|
1739 && vi_fm->fmark.mark.lnum == fm->fmark.mark.lnum |
7a6f64de57d5
commit https://github.com/vim/vim/commit/36f0f0686ca313ef7b76387378cd5dc7acea1924
Christian Brabandt <cb@256bit.org>
parents:
9299
diff
changeset
|
1740 && vi_fm->time_set == fm->time_set |
7a6f64de57d5
commit https://github.com/vim/vim/commit/36f0f0686ca313ef7b76387378cd5dc7acea1924
Christian Brabandt <cb@256bit.org>
parents:
9299
diff
changeset
|
1741 && ((vi_fm->fmark.fnum != 0 |
7a6f64de57d5
commit https://github.com/vim/vim/commit/36f0f0686ca313ef7b76387378cd5dc7acea1924
Christian Brabandt <cb@256bit.org>
parents:
9299
diff
changeset
|
1742 && vi_fm->fmark.fnum == fm->fmark.fnum) |
7a6f64de57d5
commit https://github.com/vim/vim/commit/36f0f0686ca313ef7b76387378cd5dc7acea1924
Christian Brabandt <cb@256bit.org>
parents:
9299
diff
changeset
|
1743 || (vi_fm->fname != NULL |
7a6f64de57d5
commit https://github.com/vim/vim/commit/36f0f0686ca313ef7b76387378cd5dc7acea1924
Christian Brabandt <cb@256bit.org>
parents:
9299
diff
changeset
|
1744 && fm->fname != NULL |
7a6f64de57d5
commit https://github.com/vim/vim/commit/36f0f0686ca313ef7b76387378cd5dc7acea1924
Christian Brabandt <cb@256bit.org>
parents:
9299
diff
changeset
|
1745 && STRCMP(vi_fm->fname, fm->fname) == 0))) |
7a6f64de57d5
commit https://github.com/vim/vim/commit/36f0f0686ca313ef7b76387378cd5dc7acea1924
Christian Brabandt <cb@256bit.org>
parents:
9299
diff
changeset
|
1746 ++vi_idx; /* skip duplicate */ |
7a6f64de57d5
commit https://github.com/vim/vim/commit/36f0f0686ca313ef7b76387378cd5dc7acea1924
Christian Brabandt <cb@256bit.org>
parents:
9299
diff
changeset
|
1747 } |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1748 write_one_filemark(fp, fm, '\'', i - NMARKS + '0'); |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1749 } |
7 | 1750 |
1751 #ifdef FEAT_JUMPLIST | |
1752 /* Write the jumplist with -' */ | |
2545
298d8d6e69be
Avoid warnings from the clang compiler. (Dominique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
1880
diff
changeset
|
1753 fputs(_("\n# Jumplist (newest first):\n"), fp); |
7 | 1754 setpcmark(); /* add current cursor position */ |
13278
28ae299c6af0
patch 8.0.1513: the jumplist is not always properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
13248
diff
changeset
|
1755 cleanup_jumplist(curwin, FALSE); |
9299
8000f0a44744
commit https://github.com/vim/vim/commit/ece74ab103eca15e17435efbe9cb21039787f1ea
Christian Brabandt <cb@256bit.org>
parents:
9284
diff
changeset
|
1756 vi_idx = 0; |
8000f0a44744
commit https://github.com/vim/vim/commit/ece74ab103eca15e17435efbe9cb21039787f1ea
Christian Brabandt <cb@256bit.org>
parents:
9284
diff
changeset
|
1757 idx = curwin->w_jumplistlen - 1; |
8000f0a44744
commit https://github.com/vim/vim/commit/ece74ab103eca15e17435efbe9cb21039787f1ea
Christian Brabandt <cb@256bit.org>
parents:
9284
diff
changeset
|
1758 for (i = 0; i < JUMPLISTSIZE; ++i) |
7 | 1759 { |
9299
8000f0a44744
commit https://github.com/vim/vim/commit/ece74ab103eca15e17435efbe9cb21039787f1ea
Christian Brabandt <cb@256bit.org>
parents:
9284
diff
changeset
|
1760 xfmark_T *vi_fm; |
8000f0a44744
commit https://github.com/vim/vim/commit/ece74ab103eca15e17435efbe9cb21039787f1ea
Christian Brabandt <cb@256bit.org>
parents:
9284
diff
changeset
|
1761 |
8000f0a44744
commit https://github.com/vim/vim/commit/ece74ab103eca15e17435efbe9cb21039787f1ea
Christian Brabandt <cb@256bit.org>
parents:
9284
diff
changeset
|
1762 fm = idx >= 0 ? &curwin->w_jumplist[idx] : NULL; |
8000f0a44744
commit https://github.com/vim/vim/commit/ece74ab103eca15e17435efbe9cb21039787f1ea
Christian Brabandt <cb@256bit.org>
parents:
9284
diff
changeset
|
1763 vi_fm = vi_idx < vi_jumplist_len ? &vi_jumplist[vi_idx] : NULL; |
8000f0a44744
commit https://github.com/vim/vim/commit/ece74ab103eca15e17435efbe9cb21039787f1ea
Christian Brabandt <cb@256bit.org>
parents:
9284
diff
changeset
|
1764 if (fm == NULL && vi_fm == NULL) |
8000f0a44744
commit https://github.com/vim/vim/commit/ece74ab103eca15e17435efbe9cb21039787f1ea
Christian Brabandt <cb@256bit.org>
parents:
9284
diff
changeset
|
1765 break; |
8000f0a44744
commit https://github.com/vim/vim/commit/ece74ab103eca15e17435efbe9cb21039787f1ea
Christian Brabandt <cb@256bit.org>
parents:
9284
diff
changeset
|
1766 if (fm == NULL || (vi_fm != NULL && fm->time_set < vi_fm->time_set)) |
8000f0a44744
commit https://github.com/vim/vim/commit/ece74ab103eca15e17435efbe9cb21039787f1ea
Christian Brabandt <cb@256bit.org>
parents:
9284
diff
changeset
|
1767 { |
8000f0a44744
commit https://github.com/vim/vim/commit/ece74ab103eca15e17435efbe9cb21039787f1ea
Christian Brabandt <cb@256bit.org>
parents:
9284
diff
changeset
|
1768 fm = vi_fm; |
8000f0a44744
commit https://github.com/vim/vim/commit/ece74ab103eca15e17435efbe9cb21039787f1ea
Christian Brabandt <cb@256bit.org>
parents:
9284
diff
changeset
|
1769 ++vi_idx; |
8000f0a44744
commit https://github.com/vim/vim/commit/ece74ab103eca15e17435efbe9cb21039787f1ea
Christian Brabandt <cb@256bit.org>
parents:
9284
diff
changeset
|
1770 } |
8000f0a44744
commit https://github.com/vim/vim/commit/ece74ab103eca15e17435efbe9cb21039787f1ea
Christian Brabandt <cb@256bit.org>
parents:
9284
diff
changeset
|
1771 else |
8000f0a44744
commit https://github.com/vim/vim/commit/ece74ab103eca15e17435efbe9cb21039787f1ea
Christian Brabandt <cb@256bit.org>
parents:
9284
diff
changeset
|
1772 --idx; |
7 | 1773 if (fm->fmark.fnum == 0 |
1774 || ((buf = buflist_findnr(fm->fmark.fnum)) != NULL | |
12100
d4ffc3dc9fb0
patch 8.0.0930: terminal buffers are stored in the viminfo file
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1775 && !skip_for_viminfo(buf))) |
7 | 1776 write_one_filemark(fp, fm, '-', '\''); |
1777 } | |
1778 #endif | |
1779 } | |
1780 | |
1781 static void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1782 write_one_filemark( |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1783 FILE *fp, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1784 xfmark_T *fm, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1785 int c1, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1786 int c2) |
7 | 1787 { |
1788 char_u *name; | |
1789 | |
1790 if (fm->fmark.mark.lnum == 0) /* not set */ | |
1791 return; | |
1792 | |
1793 if (fm->fmark.fnum != 0) /* there is a buffer */ | |
1794 name = buflist_nr2name(fm->fmark.fnum, TRUE, FALSE); | |
1795 else | |
1796 name = fm->fname; /* use name from .viminfo */ | |
1797 if (name != NULL && *name != NUL) | |
1798 { | |
1799 fprintf(fp, "%c%c %ld %ld ", c1, c2, (long)fm->fmark.mark.lnum, | |
1800 (long)fm->fmark.mark.col); | |
1801 viminfo_writestring(fp, name); | |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1802 |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1803 /* Barline: |{bartype},{name},{lnum},{col},{timestamp},{filename} |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1804 * size up to filename: 8 + 3 * 20 */ |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1805 fprintf(fp, "|%d,%d,%ld,%ld,%ld,", BARTYPE_MARK, c2, |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1806 (long)fm->fmark.mark.lnum, (long)fm->fmark.mark.col, |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1807 (long)fm->time_set); |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1808 barline_writestring(fp, name, LSIZE - 70); |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1809 putc('\n', fp); |
7 | 1810 } |
1811 | |
1812 if (fm->fmark.fnum != 0) | |
1813 vim_free(name); | |
1814 } | |
1815 | |
1816 /* | |
1817 * Return TRUE if "name" is on removable media (depending on 'viminfo'). | |
1818 */ | |
1819 int | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1820 removable(char_u *name) |
7 | 1821 { |
1822 char_u *p; | |
1823 char_u part[51]; | |
1824 int retval = FALSE; | |
307 | 1825 size_t n; |
7 | 1826 |
1827 name = home_replace_save(NULL, name); | |
1828 if (name != NULL) | |
1829 { | |
1830 for (p = p_viminfo; *p; ) | |
1831 { | |
1832 copy_option_part(&p, part, 51, ", "); | |
307 | 1833 if (part[0] == 'r') |
7 | 1834 { |
307 | 1835 n = STRLEN(part + 1); |
1836 if (MB_STRNICMP(part + 1, name, n) == 0) | |
1837 { | |
1838 retval = TRUE; | |
1839 break; | |
1840 } | |
7 | 1841 } |
1842 } | |
1843 vim_free(name); | |
1844 } | |
1845 return retval; | |
1846 } | |
1847 | |
9414
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1848 static void |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1849 write_one_mark(FILE *fp_out, int c, pos_T *pos) |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1850 { |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1851 if (pos->lnum != 0) |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1852 fprintf(fp_out, "\t%c\t%ld\t%d\n", c, (long)pos->lnum, (int)pos->col); |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1853 } |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1854 |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1855 |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1856 static void |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1857 write_buffer_marks(buf_T *buf, FILE *fp_out) |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1858 { |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1859 int i; |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1860 pos_T pos; |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1861 |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1862 home_replace(NULL, buf->b_ffname, IObuff, IOSIZE, TRUE); |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1863 fprintf(fp_out, "\n> "); |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1864 viminfo_writestring(fp_out, IObuff); |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1865 |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1866 /* Write the last used timestamp as the lnum of the non-existing mark '*'. |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1867 * Older Vims will ignore it and/or copy it. */ |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1868 pos.lnum = (linenr_T)buf->b_last_used; |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1869 pos.col = 0; |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1870 write_one_mark(fp_out, '*', &pos); |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1871 |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1872 write_one_mark(fp_out, '"', &buf->b_last_cursor); |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1873 write_one_mark(fp_out, '^', &buf->b_last_insert); |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1874 write_one_mark(fp_out, '.', &buf->b_last_change); |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1875 #ifdef FEAT_JUMPLIST |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1876 /* changelist positions are stored oldest first */ |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1877 for (i = 0; i < buf->b_changelistlen; ++i) |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1878 { |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1879 /* skip duplicates */ |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10730
diff
changeset
|
1880 if (i == 0 || !EQUAL_POS(buf->b_changelist[i - 1], |
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10730
diff
changeset
|
1881 buf->b_changelist[i])) |
9414
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1882 write_one_mark(fp_out, '+', &buf->b_changelist[i]); |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1883 } |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1884 #endif |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1885 for (i = 0; i < NMARKS; i++) |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1886 write_one_mark(fp_out, 'a' + i, &buf->b_namedm[i]); |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1887 } |
7 | 1888 |
1889 /* | |
1890 * Write all the named marks for all buffers. | |
9414
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1891 * When "buflist" is not NULL fill it with the buffers for which marks are to |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1892 * be written. |
7 | 1893 */ |
9414
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1894 void |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1895 write_viminfo_marks(FILE *fp_out, garray_T *buflist) |
7 | 1896 { |
1897 buf_T *buf; | |
1898 int is_mark_set; | |
1899 int i; | |
1900 win_T *win; | |
671 | 1901 tabpage_T *tp; |
7 | 1902 |
1903 /* | |
1904 * Set b_last_cursor for the all buffers that have a window. | |
1905 */ | |
671 | 1906 FOR_ALL_TAB_WINDOWS(tp, win) |
7 | 1907 set_last_cursor(win); |
1908 | |
2545
298d8d6e69be
Avoid warnings from the clang compiler. (Dominique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
1880
diff
changeset
|
1909 fputs(_("\n# History of marks within files (newest to oldest):\n"), fp_out); |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9414
diff
changeset
|
1910 FOR_ALL_BUFFERS(buf) |
7 | 1911 { |
1912 /* | |
1913 * Only write something if buffer has been loaded and at least one | |
1914 * mark is set. | |
1915 */ | |
1916 if (buf->b_marks_read) | |
1917 { | |
1918 if (buf->b_last_cursor.lnum != 0) | |
1919 is_mark_set = TRUE; | |
1920 else | |
1921 { | |
1922 is_mark_set = FALSE; | |
1923 for (i = 0; i < NMARKS; i++) | |
1924 if (buf->b_namedm[i].lnum != 0) | |
1925 { | |
1926 is_mark_set = TRUE; | |
1927 break; | |
1928 } | |
1929 } | |
1930 if (is_mark_set && buf->b_ffname != NULL | |
12100
d4ffc3dc9fb0
patch 8.0.0930: terminal buffers are stored in the viminfo file
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1931 && buf->b_ffname[0] != NUL |
d4ffc3dc9fb0
patch 8.0.0930: terminal buffers are stored in the viminfo file
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1932 && !skip_for_viminfo(buf)) |
7 | 1933 { |
9414
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1934 if (buflist == NULL) |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1935 write_buffer_marks(buf, fp_out); |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1936 else if (ga_grow(buflist, 1) == OK) |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1937 ((buf_T **)buflist->ga_data)[buflist->ga_len++] = buf; |
7 | 1938 } |
1939 } | |
1940 } | |
1941 } | |
1942 | |
9414
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1943 /* |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1944 * Compare functions for qsort() below, that compares b_last_used. |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1945 */ |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1946 static int |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1947 #ifdef __BORLANDC__ |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1948 _RTLENTRYF |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1949 #endif |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1950 buf_compare(const void *s1, const void *s2) |
7 | 1951 { |
9414
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1952 buf_T *buf1 = *(buf_T **)s1; |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1953 buf_T *buf2 = *(buf_T **)s2; |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1954 |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1955 if (buf1->b_last_used == buf2->b_last_used) |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1956 return 0; |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1957 return buf1->b_last_used > buf2->b_last_used ? -1 : 1; |
7 | 1958 } |
1959 | |
1960 /* | |
1961 * Handle marks in the viminfo file: | |
9414
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1962 * fp_out != NULL: copy marks, in time order with buffers in "buflist". |
1733 | 1963 * fp_out == NULL && (flags & VIF_WANT_MARKS): read marks for curbuf only |
1964 * fp_out == NULL && (flags & VIF_GET_OLDFILES | VIF_FORCEIT): fill v:oldfiles | |
7 | 1965 */ |
1966 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1967 copy_viminfo_marks( |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1968 vir_T *virp, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1969 FILE *fp_out, |
9414
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1970 garray_T *buflist, |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1971 int eof, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1972 int flags) |
7 | 1973 { |
1974 char_u *line = virp->vir_line; | |
1975 buf_T *buf; | |
1976 int num_marked_files; | |
1977 int load_marks; | |
1978 int copy_marks_out; | |
1979 char_u *str; | |
1980 int i; | |
1981 char_u *p; | |
1982 char_u *name_buf; | |
1983 pos_T pos; | |
1733 | 1984 #ifdef FEAT_EVAL |
1985 list_T *list = NULL; | |
1986 #endif | |
9414
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1987 int count = 0; |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1988 int buflist_used = 0; |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1989 buf_T *buflist_buf = NULL; |
7 | 1990 |
1991 if ((name_buf = alloc(LSIZE)) == NULL) | |
1992 return; | |
1993 *name_buf = NUL; | |
1733 | 1994 |
9414
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1995 if (fp_out != NULL && buflist->ga_len > 0) |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1996 { |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1997 /* Sort the list of buffers on b_last_used. */ |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1998 qsort(buflist->ga_data, (size_t)buflist->ga_len, |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
1999 sizeof(buf_T *), buf_compare); |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2000 buflist_buf = ((buf_T **)buflist->ga_data)[0]; |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2001 } |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2002 |
1733 | 2003 #ifdef FEAT_EVAL |
2004 if (fp_out == NULL && (flags & (VIF_GET_OLDFILES | VIF_FORCEIT))) | |
2005 { | |
2006 list = list_alloc(); | |
2007 if (list != NULL) | |
2008 set_vim_var_list(VV_OLDFILES, list); | |
2009 } | |
2010 #endif | |
2011 | |
7 | 2012 num_marked_files = get_viminfo_parameter('\''); |
2013 while (!eof && (count < num_marked_files || fp_out == NULL)) | |
2014 { | |
2015 if (line[0] != '>') | |
2016 { | |
2017 if (line[0] != '\n' && line[0] != '\r' && line[0] != '#') | |
2018 { | |
2019 if (viminfo_error("E576: ", _("Missing '>'"), line)) | |
2020 break; /* too many errors, return now */ | |
2021 } | |
2022 eof = vim_fgets(line, LSIZE, virp->vir_fd); | |
2023 continue; /* Skip this dud line */ | |
2024 } | |
2025 | |
2026 /* | |
2027 * Handle long line and translate escaped characters. | |
2028 * Find file name, set str to start. | |
2029 * Ignore leading and trailing white space. | |
2030 */ | |
2031 str = skipwhite(line + 1); | |
2032 str = viminfo_readstring(virp, (int)(str - virp->vir_line), FALSE); | |
2033 if (str == NULL) | |
2034 continue; | |
2035 p = str + STRLEN(str); | |
2036 while (p != str && (*p == NUL || vim_isspace(*p))) | |
2037 p--; | |
2038 if (*p) | |
2039 p++; | |
2040 *p = NUL; | |
2041 | |
1733 | 2042 #ifdef FEAT_EVAL |
2043 if (list != NULL) | |
2044 list_append_string(list, str, -1); | |
2045 #endif | |
2046 | |
7 | 2047 /* |
2048 * If fp_out == NULL, load marks for current buffer. | |
2049 * If fp_out != NULL, copy marks for buffers not in buflist. | |
2050 */ | |
2051 load_marks = copy_marks_out = FALSE; | |
2052 if (fp_out == NULL) | |
2053 { | |
1733 | 2054 if ((flags & VIF_WANT_MARKS) && curbuf->b_ffname != NULL) |
7 | 2055 { |
2056 if (*name_buf == NUL) /* only need to do this once */ | |
2057 home_replace(NULL, curbuf->b_ffname, name_buf, LSIZE, TRUE); | |
2058 if (fnamecmp(str, name_buf) == 0) | |
2059 load_marks = TRUE; | |
2060 } | |
2061 } | |
2062 else /* fp_out != NULL */ | |
2063 { | |
2064 /* This is slow if there are many buffers!! */ | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9414
diff
changeset
|
2065 FOR_ALL_BUFFERS(buf) |
7 | 2066 if (buf->b_ffname != NULL) |
2067 { | |
2068 home_replace(NULL, buf->b_ffname, name_buf, LSIZE, TRUE); | |
2069 if (fnamecmp(str, name_buf) == 0) | |
2070 break; | |
2071 } | |
2072 | |
2073 /* | |
9414
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2074 * Copy marks if the buffer has not been loaded. |
7 | 2075 */ |
2076 if (buf == NULL || !buf->b_marks_read) | |
2077 { | |
9414
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2078 int did_read_line = FALSE; |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2079 |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2080 if (buflist_buf != NULL) |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2081 { |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2082 /* Read the next line. If it has the "*" mark compare the |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2083 * time stamps. Write entries from "buflist" that are |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2084 * newer. */ |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2085 if (!(eof = viminfo_readline(virp)) && line[0] == TAB) |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2086 { |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2087 did_read_line = TRUE; |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2088 if (line[1] == '*') |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2089 { |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2090 long ltime; |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2091 |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2092 sscanf((char *)line + 2, "%ld ", <ime); |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2093 while ((time_T)ltime < buflist_buf->b_last_used) |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2094 { |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2095 write_buffer_marks(buflist_buf, fp_out); |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2096 if (++count >= num_marked_files) |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2097 break; |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2098 if (++buflist_used == buflist->ga_len) |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2099 { |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2100 buflist_buf = NULL; |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2101 break; |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2102 } |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2103 buflist_buf = |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2104 ((buf_T **)buflist->ga_data)[buflist_used]; |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2105 } |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2106 } |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2107 else |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2108 { |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2109 /* No timestamp, must be written by an older Vim. |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2110 * Assume all remaining buffers are older then |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2111 * ours. */ |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2112 while (count < num_marked_files |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2113 && buflist_used < buflist->ga_len) |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2114 { |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2115 buflist_buf = ((buf_T **)buflist->ga_data) |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2116 [buflist_used++]; |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2117 write_buffer_marks(buflist_buf, fp_out); |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2118 ++count; |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2119 } |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2120 buflist_buf = NULL; |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2121 } |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2122 |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2123 if (count >= num_marked_files) |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2124 { |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2125 vim_free(str); |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2126 break; |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2127 } |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2128 } |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2129 } |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2130 |
7 | 2131 fputs("\n> ", fp_out); |
2132 viminfo_writestring(fp_out, str); | |
9414
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2133 if (did_read_line) |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2134 fputs((char *)line, fp_out); |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2135 |
7 | 2136 count++; |
9414
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2137 copy_marks_out = TRUE; |
7 | 2138 } |
2139 } | |
2140 vim_free(str); | |
2141 | |
2142 #ifdef FEAT_VIRTUALEDIT | |
2143 pos.coladd = 0; | |
2144 #endif | |
2145 while (!(eof = viminfo_readline(virp)) && line[0] == TAB) | |
2146 { | |
2147 if (load_marks) | |
2148 { | |
2149 if (line[1] != NUL) | |
2150 { | |
2712 | 2151 unsigned u; |
2152 | |
2153 sscanf((char *)line + 2, "%ld %u", &pos.lnum, &u); | |
2154 pos.col = u; | |
7 | 2155 switch (line[1]) |
2156 { | |
2157 case '"': curbuf->b_last_cursor = pos; break; | |
2158 case '^': curbuf->b_last_insert = pos; break; | |
2159 case '.': curbuf->b_last_change = pos; break; | |
2160 case '+': | |
2161 #ifdef FEAT_JUMPLIST | |
2162 /* changelist positions are stored oldest | |
2163 * first */ | |
2164 if (curbuf->b_changelistlen == JUMPLISTSIZE) | |
2165 /* list is full, remove oldest entry */ | |
2166 mch_memmove(curbuf->b_changelist, | |
2167 curbuf->b_changelist + 1, | |
2168 sizeof(pos_T) * (JUMPLISTSIZE - 1)); | |
2169 else | |
2170 ++curbuf->b_changelistlen; | |
2171 curbuf->b_changelist[ | |
2172 curbuf->b_changelistlen - 1] = pos; | |
2173 #endif | |
2174 break; | |
9414
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2175 |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2176 /* Using the line number for the last-used |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2177 * timestamp. */ |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2178 case '*': curbuf->b_last_used = pos.lnum; break; |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2179 |
7 | 2180 default: if ((i = line[1] - 'a') >= 0 && i < NMARKS) |
2181 curbuf->b_namedm[i] = pos; | |
2182 } | |
2183 } | |
2184 } | |
2185 else if (copy_marks_out) | |
2186 fputs((char *)line, fp_out); | |
2187 } | |
9414
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2188 |
7 | 2189 if (load_marks) |
2190 { | |
2191 #ifdef FEAT_JUMPLIST | |
2192 win_T *wp; | |
2193 | |
2194 FOR_ALL_WINDOWS(wp) | |
2195 { | |
2196 if (wp->w_buffer == curbuf) | |
2197 wp->w_changelistidx = curbuf->b_changelistlen; | |
2198 } | |
2199 #endif | |
2200 break; | |
2201 } | |
2202 } | |
9414
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2203 |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2204 if (fp_out != NULL) |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2205 /* Write any remaining entries from buflist. */ |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2206 while (count < num_marked_files && buflist_used < buflist->ga_len) |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2207 { |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2208 buflist_buf = ((buf_T **)buflist->ga_data)[buflist_used++]; |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2209 write_buffer_marks(buflist_buf, fp_out); |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2210 ++count; |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2211 } |
1003973c99df
commit https://github.com/vim/vim/commit/ab9c89b68dcbdb3fbda8c5a50dd90caca64f1bfd
Christian Brabandt <cb@256bit.org>
parents:
9401
diff
changeset
|
2212 |
7 | 2213 vim_free(name_buf); |
2214 } | |
2215 #endif /* FEAT_VIMINFO */ |