annotate src/mark.c @ 12488:6867d1bb5d9c

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