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