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