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