annotate src/mark.c @ 9284:78712a2f687a v7.4.1925

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