annotate src/mark.c @ 75:388f285bda1b

updated for version 7.0031
author vimboss
date Wed, 05 Jan 2005 22:16:17 +0000
parents 410fa1a31baf
children 86cd0a77d2ae
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 static void fname2fnum __ARGS((xfmark_T *fm));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 static void fmarks_check_one __ARGS((xfmark_T *fm, char_u *name, buf_T *buf));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 static char_u *mark_line __ARGS((pos_T *mp, int lead_len));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 static void show_one_mark __ARGS((int, char_u *, pos_T *, char_u *, int current));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 #ifdef FEAT_JUMPLIST
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 static void cleanup_jumplist __ARGS((void));
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 static void write_one_filemark __ARGS((FILE *fp, xfmark_T *fm, int c1, int c2));
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 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 * Set named mark 'c' at current cursor position.
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 setmark(c)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 int c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 /* Check for a special key (may cause islower() to crash). */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 if (c < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 if (c == '\'' || c == '`')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 setpcmark();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 /* keep it even when the cursor doesn't move */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 curwin->w_prev_pcmark = curwin->w_pcmark;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 /* Allow setting '[ and '] for an autocommand that simulates reading a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 * file. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 if (c == '[')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 curbuf->b_op_start = curwin->w_cursor;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 if (c == ']')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 curbuf->b_op_end = curwin->w_cursor;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 #ifndef EBCDIC
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 if (c > 'z') /* some islower() and isupper() cannot handle
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 characters above 127 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 if (islower(c))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 i = c - 'a';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 curbuf->b_namedm[i] = curwin->w_cursor;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 if (isupper(c))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 i = c - 'A';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 namedfm[i].fmark.mark = curwin->w_cursor;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 namedfm[i].fmark.fnum = curbuf->b_fnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 vim_free(namedfm[i].fname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 namedfm[i].fname = NULL;
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 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 * Set the previous context mark to the current position and add it to the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 * jump list.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 setpcmark()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 #ifdef FEAT_JUMPLIST
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 xfmark_T *fm;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 #ifdef JUMPLIST_ROTATE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 xfmark_T tempmark;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 /* for :global the mark is set only once */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 if (global_busy || listcmd_busy || cmdmod.keepjumps)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 curwin->w_prev_pcmark = curwin->w_pcmark;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 curwin->w_pcmark = curwin->w_cursor;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 #ifdef FEAT_JUMPLIST
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 # ifdef JUMPLIST_ROTATE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 * 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
125 * the stack until it is (the newer entries will be at the bottom).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 * Keep one entry (the last used one) at the top.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 if (curwin->w_jumplistidx < curwin->w_jumplistlen)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129 ++curwin->w_jumplistidx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 while (curwin->w_jumplistidx < curwin->w_jumplistlen)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 tempmark = curwin->w_jumplist[curwin->w_jumplistlen - 1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 for (i = curwin->w_jumplistlen - 1; i > 0; --i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 curwin->w_jumplist[i] = curwin->w_jumplist[i - 1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 curwin->w_jumplist[0] = tempmark;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 ++curwin->w_jumplistidx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 /* If jumplist is full: remove oldest entry */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 if (++curwin->w_jumplistlen > JUMPLISTSIZE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 curwin->w_jumplistlen = JUMPLISTSIZE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144 vim_free(curwin->w_jumplist[0].fname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 for (i = 1; i < JUMPLISTSIZE; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 curwin->w_jumplist[i - 1] = curwin->w_jumplist[i];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 curwin->w_jumplistidx = curwin->w_jumplistlen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 fm = &curwin->w_jumplist[curwin->w_jumplistlen - 1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 fm->fmark.mark = curwin->w_pcmark;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152 fm->fmark.fnum = curbuf->b_fnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 fm->fname = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158 * To change context, call setpcmark(), then move the current position to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159 * where ever, then call checkpcmark(). This ensures that the previous
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160 * context will only be changed if the cursor moved to a different line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161 * If pcmark was deleted (with "dG") the previous mark is restored.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164 checkpcmark()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
166 if (curwin->w_prev_pcmark.lnum != 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167 && (equalpos(curwin->w_pcmark, curwin->w_cursor)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168 || curwin->w_pcmark.lnum == 0))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
169 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170 curwin->w_pcmark = curwin->w_prev_pcmark;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171 curwin->w_prev_pcmark.lnum = 0; /* Show it has been checked */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175 #if defined(FEAT_JUMPLIST) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177 * move "count" positions in the jump list (count may be negative)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179 pos_T *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180 movemark(count)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 int count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 pos_T *pos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 xfmark_T *jmp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186 cleanup_jumplist();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 if (curwin->w_jumplistlen == 0) /* nothing to jump to */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 return (pos_T *)NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 for (;;)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193 if (curwin->w_jumplistidx + count < 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194 || curwin->w_jumplistidx + count >= curwin->w_jumplistlen)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195 return (pos_T *)NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198 * if first CTRL-O or CTRL-I command after a jump, add cursor position
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 * to list. Careful: If there are duplicates (CTRL-O immidiately after
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200 * starting Vim on a file), another entry may have been removed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
201 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202 if (curwin->w_jumplistidx == curwin->w_jumplistlen)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204 setpcmark();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 --curwin->w_jumplistidx; /* skip the new entry */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206 if (curwin->w_jumplistidx + count < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207 return (pos_T *)NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
209
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210 curwin->w_jumplistidx += count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212 jmp = curwin->w_jumplist + curwin->w_jumplistidx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213 if (jmp->fmark.fnum == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214 fname2fnum(jmp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215 if (jmp->fmark.fnum != curbuf->b_fnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217 /* jump to other file */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218 if (buflist_findnr(jmp->fmark.fnum) == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
219 { /* Skip this one .. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220 count += count < 0 ? -1 : 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
221 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223 if (buflist_getfile(jmp->fmark.fnum, jmp->fmark.mark.lnum,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224 0, FALSE) == FAIL)
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 /* Set lnum again, autocommands my have changed it */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227 curwin->w_cursor = jmp->fmark.mark;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
228 pos = (pos_T *)-1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
229 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
230 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
231 pos = &(jmp->fmark.mark);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232 return pos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
233 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
235
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
236 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
237 * Move "count" positions in the changelist (count may be negative).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239 pos_T *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240 movechangelist(count)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
241 int count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
242 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243 int n;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
244
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
245 if (curbuf->b_changelistlen == 0) /* nothing to jump to */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
246 return (pos_T *)NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
247
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
248 n = curwin->w_changelistidx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
249 if (n + count < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
250 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
251 if (n == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
252 return (pos_T *)NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253 n = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
254 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255 else if (n + count >= curbuf->b_changelistlen)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
257 if (n == curbuf->b_changelistlen - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
258 return (pos_T *)NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
259 n = curbuf->b_changelistlen - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
260 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
261 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
262 n += count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
263 curwin->w_changelistidx = n;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
264 return curbuf->b_changelist + n;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
265 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
266 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
267
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
268 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
269 * Find mark "c".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
270 * Returns:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
271 * - 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
272 * in another file which can't be gotten. (caller needs to check lnum!)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
273 * - NULL if there is no mark called 'c'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
274 * - -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
275 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
276 pos_T *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
277 getmark(c, changefile)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
278 int c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
279 int changefile; /* allowed to edit another file */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
280 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
281 pos_T *posp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
282 #ifdef FEAT_VISUAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
283 pos_T *startp, *endp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
284 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
285 static pos_T pos_copy;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
286
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
287 posp = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
288
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
289 /* Check for special key, can't be a mark name and might cause islower()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
290 * to crash. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
291 if (c < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
292 return posp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
293 #ifndef EBCDIC
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
294 if (c > '~') /* check for islower()/isupper() */
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 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
298 if (c == '\'' || c == '`') /* previous context mark */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
299 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
300 pos_copy = curwin->w_pcmark; /* need to make a copy because */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
301 posp = &pos_copy; /* w_pcmark may be changed soon */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
302 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
303 else if (c == '"') /* to pos when leaving buffer */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
304 posp = &(curbuf->b_last_cursor);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
305 else if (c == '^') /* to where Insert mode stopped */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
306 posp = &(curbuf->b_last_insert);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
307 else if (c == '.') /* to where last change was made */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
308 posp = &(curbuf->b_last_change);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
309 else if (c == '[') /* to start of previous operator */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
310 posp = &(curbuf->b_op_start);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
311 else if (c == ']') /* to end of previous operator */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
312 posp = &(curbuf->b_op_end);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
313 else if (c == '{' || c == '}') /* to previous/next paragraph */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
314 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
315 pos_T pos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
316 oparg_T oa;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
317 int slcb = listcmd_busy;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
318
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
319 pos = curwin->w_cursor;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
320 listcmd_busy = TRUE; /* avoid that '' is changed */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
321 if (findpar(&oa, c == '}' ? FORWARD : BACKWARD, 1L, NUL, FALSE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
322 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
323 pos_copy = curwin->w_cursor;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
324 posp = &pos_copy;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
325 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
326 curwin->w_cursor = pos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
327 listcmd_busy = slcb;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
328 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
329 else if (c == '(' || c == ')') /* to previous/next sentence */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
330 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
331 pos_T pos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
332 int slcb = listcmd_busy;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
333
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
334 pos = curwin->w_cursor;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
335 listcmd_busy = TRUE; /* avoid that '' is changed */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
336 if (findsent(c == ')' ? FORWARD : BACKWARD, 1L))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
337 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
338 pos_copy = curwin->w_cursor;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
339 posp = &pos_copy;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
340 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
341 curwin->w_cursor = pos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
342 listcmd_busy = slcb;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
343 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
344 #ifdef FEAT_VISUAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
345 else if (c == '<' || c == '>') /* start/end of visual area */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
346 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
347 startp = &curbuf->b_visual_start;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
348 endp = &curbuf->b_visual_end;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
349 if ((c == '<') == lt(*startp, *endp))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
350 posp = startp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
351 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
352 posp = endp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
353 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
354 * For Visual line mode, set mark at begin or end of line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
355 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
356 if (curbuf->b_visual_mode == 'V')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
357 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
358 pos_copy = *posp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
359 posp = &pos_copy;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
360 if (c == '<')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
361 pos_copy.col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
362 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
363 pos_copy.col = MAXCOL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
364 #ifdef FEAT_VIRTUALEDIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
365 pos_copy.coladd = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
366 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
367 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
368 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
369 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
370 else if (ASCII_ISLOWER(c)) /* normal named mark */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
371 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
372 posp = &(curbuf->b_namedm[c - 'a']);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
373 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
374 else if (ASCII_ISUPPER(c) || VIM_ISDIGIT(c)) /* named file mark */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
375 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
376 if (VIM_ISDIGIT(c))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
377 c = c - '0' + NMARKS;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
378 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
379 c -= 'A';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
380 posp = &(namedfm[c].fmark.mark);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
381
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
382 if (namedfm[c].fmark.fnum == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
383 fname2fnum(&namedfm[c]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
384 if (namedfm[c].fmark.fnum != curbuf->b_fnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
385 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
386 posp = &pos_copy;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
387
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
388 /* mark is in another file */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
389 if (namedfm[c].fmark.mark.lnum != 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
390 && changefile && namedfm[c].fmark.fnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
391 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
392 if (buflist_getfile(namedfm[c].fmark.fnum,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
393 (linenr_T)1, GETF_SETMARK, FALSE) == OK)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
394 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
395 /* Set the lnum now, autocommands could have changed it */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
396 curwin->w_cursor = namedfm[c].fmark.mark;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
397 return (pos_T *)-1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
398 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
399 pos_copy.lnum = -1; /* can't get file */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
400 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
401 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
402 pos_copy.lnum = 0; /* mark exists, but is not valid in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
403 current buffer */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
404 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
405 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
406
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
407 return posp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
408 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
409
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
410 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
411 * Search for the next named mark in the current file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
412 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
413 * 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
414 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
415 pos_T *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
416 getnextmark(startpos, dir, begin_line)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
417 pos_T *startpos; /* where to start */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
418 int dir; /* direction for search */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
419 int begin_line;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
420 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
421 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
422 pos_T *result = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
423 pos_T pos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
424
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
425 pos = *startpos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
426
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
427 /* When searching backward and leaving the cursor on the first non-blank,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
428 * position must be in a previous line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
429 * When searching forward and leaving the cursor on the first non-blank,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
430 * position must be in a next line. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
431 if (dir == BACKWARD && begin_line)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
432 pos.col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
433 else if (dir == FORWARD && begin_line)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
434 pos.col = MAXCOL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
435
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
436 for (i = 0; i < NMARKS; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
437 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
438 if (curbuf->b_namedm[i].lnum > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
439 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
440 if (dir == FORWARD)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
441 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
442 if ((result == NULL || lt(curbuf->b_namedm[i], *result))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
443 && lt(pos, curbuf->b_namedm[i]))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
444 result = &curbuf->b_namedm[i];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
445 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
446 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
447 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
448 if ((result == NULL || lt(*result, curbuf->b_namedm[i]))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
449 && lt(curbuf->b_namedm[i], pos))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
450 result = &curbuf->b_namedm[i];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
451 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
452 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
453 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
454
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
455 return result;
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 * For an xtended filemark: set the fnum from the fname.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
460 * This is used for marks obtained from the .viminfo file. It's postponed
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
461 * until the mark is used to avoid a long startup delay.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
462 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
463 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
464 fname2fnum(fm)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
465 xfmark_T *fm;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
466 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
467 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
468
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
469 if (fm->fname != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
470 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
471 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
472 * First expand "~/" in the file name to the home directory.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
473 * Try to shorten the file name.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
474 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
475 expand_env(fm->fname, NameBuff, MAXPATHL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
476 mch_dirname(IObuff, IOSIZE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
477 p = shorten_fname(NameBuff, IObuff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
478
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
479 /* buflist_new() will call fmarks_check_names() */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
480 (void)buflist_new(NameBuff, p, (linenr_T)1, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
481 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
482 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
483
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
484 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
485 * Check all file marks for a name that matches the file name in buf.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
486 * May replace the name with an fnum.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
487 * Used for marks that come from the .viminfo file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
488 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
489 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
490 fmarks_check_names(buf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
491 buf_T *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
492 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
493 char_u *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
494 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
495 #ifdef FEAT_JUMPLIST
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
496 win_T *wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
497 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
498
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
499 if (buf->b_ffname == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
500 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
501
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
502 name = home_replace_save(buf, buf->b_ffname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
503 if (name == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
504 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
505
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
506 for (i = 0; i < NMARKS + EXTRA_MARKS; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
507 fmarks_check_one(&namedfm[i], name, buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
508
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
509 #ifdef FEAT_JUMPLIST
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
510 FOR_ALL_WINDOWS(wp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
511 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
512 for (i = 0; i < wp->w_jumplistlen; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
513 fmarks_check_one(&wp->w_jumplist[i], name, buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
514 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
515 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
516
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
517 vim_free(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
518 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
519
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
520 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
521 fmarks_check_one(fm, name, buf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
522 xfmark_T *fm;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
523 char_u *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
524 buf_T *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
525 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
526 if (fm->fmark.fnum == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
527 && fm->fname != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
528 && fnamecmp(name, fm->fname) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
529 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
530 fm->fmark.fnum = buf->b_fnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
531 vim_free(fm->fname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
532 fm->fname = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
533 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
534 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
535
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
536 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
537 * Check a if a position from a mark is valid.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
538 * Give and error message and return FAIL if not.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
539 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
540 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
541 check_mark(pos)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
542 pos_T *pos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
543 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
544 if (pos == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
545 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
546 EMSG(_(e_umark));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
547 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
548 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
549 if (pos->lnum <= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
550 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
551 /* lnum is negative if mark is in another file can can't get that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
552 * file, error message already give then. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
553 if (pos->lnum == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
554 EMSG(_(e_marknotset));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
555 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
556 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
557 if (pos->lnum > curbuf->b_ml.ml_line_count)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
558 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
559 EMSG(_(e_markinval));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
560 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
561 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
562 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
563 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
564
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
565 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
566 * clrallmarks() - clear all marks in the buffer 'buf'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
567 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
568 * Used mainly when trashing the entire buffer during ":e" type commands
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
569 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
570 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
571 clrallmarks(buf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
572 buf_T *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
573 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
574 static int i = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
575
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
576 if (i == -1) /* first call ever: initialize */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
577 for (i = 0; i < NMARKS + 1; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
578 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
579 namedfm[i].fmark.mark.lnum = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
580 namedfm[i].fname = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
581 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
582
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
583 for (i = 0; i < NMARKS; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
584 buf->b_namedm[i].lnum = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
585 buf->b_op_start.lnum = 0; /* start/end op mark cleared */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
586 buf->b_op_end.lnum = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
587 buf->b_last_cursor.lnum = 1; /* '" mark cleared */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
588 buf->b_last_cursor.col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
589 #ifdef FEAT_VIRTUALEDIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
590 buf->b_last_cursor.coladd = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
591 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
592 buf->b_last_insert.lnum = 0; /* '^ mark cleared */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
593 buf->b_last_change.lnum = 0; /* '. mark cleared */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
594 #ifdef FEAT_JUMPLIST
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
595 buf->b_changelistlen = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
596 #endif
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 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
600 * Get name of file from a filemark.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
601 * When it's in the current buffer, return the text at the mark.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
602 * Returns an allocated string.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
603 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
604 char_u *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
605 fm_getname(fmark, lead_len)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
606 fmark_T *fmark;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
607 int lead_len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
608 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
609 if (fmark->fnum == curbuf->b_fnum) /* current buffer */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
610 return mark_line(&(fmark->mark), lead_len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
611 return buflist_nr2name(fmark->fnum, FALSE, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
612 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
613
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
614 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
615 * Return the line at mark "mp". Truncate to fit in window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
616 * The returned string has been allocated.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
617 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
618 static char_u *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
619 mark_line(mp, lead_len)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
620 pos_T *mp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
621 int lead_len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
622 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
623 char_u *s, *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
624 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
625
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
626 if (mp->lnum == 0 || mp->lnum > curbuf->b_ml.ml_line_count)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
627 return vim_strsave((char_u *)"-invalid-");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
628 s = vim_strnsave(skipwhite(ml_get(mp->lnum)), (int)Columns);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
629 if (s == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
630 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
631 /* Truncate the line to fit it in the window */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
632 len = 0;
39
410fa1a31baf updated for version 7.0023
vimboss
parents: 24
diff changeset
633 for (p = s; *p != NUL; mb_ptr_adv(p))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
634 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
635 len += ptr2cells(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
636 if (len >= Columns - lead_len)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
637 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
638 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
639 *p = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
640 return s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
641 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
642
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
643 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
644 * print the marks
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
645 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
646 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
647 do_marks(eap)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
648 exarg_T *eap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
649 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
650 char_u *arg = eap->arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
651 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
652 char_u *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
653
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
654 if (arg != NULL && *arg == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
655 arg = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
656
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
657 show_one_mark('\'', arg, &curwin->w_pcmark, NULL, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
658 for (i = 0; i < NMARKS; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
659 show_one_mark(i + 'a', arg, &curbuf->b_namedm[i], NULL, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
660 for (i = 0; i < NMARKS + EXTRA_MARKS; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
661 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
662 if (namedfm[i].fmark.fnum != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
663 name = fm_getname(&namedfm[i].fmark, 15);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
664 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
665 name = namedfm[i].fname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
666 if (name != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
667 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
668 show_one_mark(i >= NMARKS ? i - NMARKS + '0' : i + 'A',
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
669 arg, &namedfm[i].fmark.mark, name,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
670 namedfm[i].fmark.fnum == curbuf->b_fnum);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
671 if (namedfm[i].fmark.fnum != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
672 vim_free(name);
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 show_one_mark('"', arg, &curbuf->b_last_cursor, NULL, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
676 show_one_mark('[', arg, &curbuf->b_op_start, NULL, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
677 show_one_mark(']', arg, &curbuf->b_op_end, NULL, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
678 show_one_mark('^', arg, &curbuf->b_last_insert, NULL, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
679 show_one_mark('.', arg, &curbuf->b_last_change, NULL, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
680 #ifdef FEAT_VISUAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
681 show_one_mark('<', arg, &curbuf->b_visual_start, NULL, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
682 show_one_mark('>', arg, &curbuf->b_visual_end, NULL, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
683 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
684 show_one_mark(-1, arg, NULL, NULL, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
685 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
686
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
687 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
688 show_one_mark(c, arg, p, name, current)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
689 int c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
690 char_u *arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
691 pos_T *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
692 char_u *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
693 int current; /* in current file */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
694 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
695 static int did_title = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
696 int mustfree = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
697
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
698 if (c == -1) /* finish up */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
699 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
700 if (did_title)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
701 did_title = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
702 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
703 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
704 if (arg == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
705 MSG(_("No marks set"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
706 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
707 EMSG2(_("E283: No marks matching \"%s\""), arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
708 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
709 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
710 /* don't output anything if 'q' typed at --more-- prompt */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
711 else if (!got_int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
712 && (arg == NULL || vim_strchr(arg, c) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
713 && p->lnum != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
714 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
715 if (!did_title)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
716 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
717 /* Highlight title */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
718 MSG_PUTS_TITLE(_("\nmark line col file/text"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
719 did_title = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
720 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
721 msg_putchar('\n');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
722 if (!got_int)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
723 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
724 sprintf((char *)IObuff, " %c %6ld %4d ", c, p->lnum, p->col);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
725 msg_outtrans(IObuff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
726 if (name == NULL && current)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
727 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
728 name = mark_line(p, 15);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
729 mustfree = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
730 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
731 if (name != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
732 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
733 msg_outtrans_attr(name, current ? hl_attr(HLF_D) : 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
734 if (mustfree)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
735 vim_free(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
736 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
737 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
738 out_flush(); /* show one line at a time */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
739 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
740 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
741
24
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
742 /*
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
743 * ":delmarks[!] [marks]"
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
744 */
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
745 void
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
746 ex_delmarks(eap)
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
747 exarg_T *eap;
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
748 {
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
749 char_u *p;
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
750 int from, to;
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
751 int i;
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
752 int lower;
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
753 int digit;
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
754 int n;
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
755
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
756 if (*eap->arg == NUL && eap->forceit)
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
757 /* clear all marks */
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
758 clrallmarks(curbuf);
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
759 else if (eap->forceit)
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
760 EMSG(_(e_invarg));
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
761 else if (*eap->arg == NUL)
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
762 EMSG(_(e_argreq));
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
763 else
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
764 {
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
765 /* clear specified marks only */
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
766 for (p = eap->arg; *p != NUL; ++p)
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
767 {
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
768 lower = ASCII_ISLOWER(*p);
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
769 digit = VIM_ISDIGIT(*p);
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
770 if (lower || digit || ASCII_ISUPPER(*p))
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
771 {
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
772 if (p[1] == '-')
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
773 {
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
774 /* clear range of marks */
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
775 from = *p;
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
776 to = p[2];
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
777 if (!(lower ? ASCII_ISLOWER(p[2])
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
778 : (digit ? VIM_ISDIGIT(p[2])
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
779 : ASCII_ISUPPER(p[2])))
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
780 || to < from)
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
781 {
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
782 EMSG2(_(e_invarg2), p);
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
783 return;
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
784 }
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
785 p += 2;
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
786 }
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
787 else
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
788 /* clear one lower case mark */
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
789 from = to = *p;
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
790
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
791 for (i = from; i <= to; ++i)
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
792 {
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
793 if (lower)
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
794 curbuf->b_namedm[i - 'a'].lnum = 0;
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
795 else
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
796 {
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
797 if (digit)
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
798 n = i - '0' + NMARKS;
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
799 else
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
800 n = i - 'A';
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
801 namedfm[n].fmark.mark.lnum = 0;
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
802 vim_free(namedfm[n].fname);
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
803 namedfm[n].fname = NULL;
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
804 }
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
805 }
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
806 }
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
807 else
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
808 switch (*p)
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
809 {
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
810 case '"': curbuf->b_last_cursor.lnum = 0; break;
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
811 case '^': curbuf->b_last_insert.lnum = 0; break;
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
812 case '.': curbuf->b_last_change.lnum = 0; break;
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
813 case '[': curbuf->b_op_start.lnum = 0; break;
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
814 case ']': curbuf->b_op_end.lnum = 0; break;
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
815 #ifdef FEAT_VISUAL
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
816 case '<': curbuf->b_visual_start.lnum = 0; break;
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
817 case '>': curbuf->b_visual_end.lnum = 0; break;
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
818 #endif
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
819 case ' ': break;
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
820 default: EMSG2(_(e_invarg2), p);
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
821 return;
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
822 }
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
823 }
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
824 }
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
825 }
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
826
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
827 #if defined(FEAT_JUMPLIST) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
828 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
829 * print the jumplist
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
830 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
831 /*ARGSUSED*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
832 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
833 ex_jumps(eap)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
834 exarg_T *eap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
835 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
836 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
837 char_u *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
838
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
839 cleanup_jumplist();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
840 /* Highlight title */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
841 MSG_PUTS_TITLE(_("\n jump line col file/text"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
842 for (i = 0; i < curwin->w_jumplistlen && !got_int; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
843 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
844 if (curwin->w_jumplist[i].fmark.mark.lnum != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
845 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
846 if (curwin->w_jumplist[i].fmark.fnum == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
847 fname2fnum(&curwin->w_jumplist[i]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
848 name = fm_getname(&curwin->w_jumplist[i].fmark, 16);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
849 if (name == NULL) /* file name not available */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
850 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
851
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
852 msg_putchar('\n');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
853 if (got_int)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
854 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
855 sprintf((char *)IObuff, "%c %2d %5ld %4d ",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
856 i == curwin->w_jumplistidx ? '>' : ' ',
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
857 i > curwin->w_jumplistidx ? i - curwin->w_jumplistidx
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
858 : curwin->w_jumplistidx - i,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
859 curwin->w_jumplist[i].fmark.mark.lnum,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
860 curwin->w_jumplist[i].fmark.mark.col);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
861 msg_outtrans(IObuff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
862 msg_outtrans_attr(name,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
863 curwin->w_jumplist[i].fmark.fnum == curbuf->b_fnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
864 ? hl_attr(HLF_D) : 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
865 vim_free(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
866 ui_breakcheck();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
867 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
868 out_flush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
869 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
870 if (curwin->w_jumplistidx == curwin->w_jumplistlen)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
871 MSG_PUTS("\n>");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
872 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
873
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
874 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
875 * print the changelist
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
876 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
877 /*ARGSUSED*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
878 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
879 ex_changes(eap)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
880 exarg_T *eap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
881 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
882 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
883 char_u *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
884
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
885 /* Highlight title */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
886 MSG_PUTS_TITLE(_("\nchange line col text"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
887
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
888 for (i = 0; i < curbuf->b_changelistlen && !got_int; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
889 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
890 if (curbuf->b_changelist[i].lnum != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
891 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
892 msg_putchar('\n');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
893 if (got_int)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
894 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
895 sprintf((char *)IObuff, "%c %3d %5ld %4d ",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
896 i == curwin->w_changelistidx ? '>' : ' ',
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
897 i > curwin->w_changelistidx ? i - curwin->w_changelistidx
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
898 : curwin->w_changelistidx - i,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
899 (long)curbuf->b_changelist[i].lnum,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
900 curbuf->b_changelist[i].col);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
901 msg_outtrans(IObuff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
902 name = mark_line(&curbuf->b_changelist[i], 17);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
903 if (name == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
904 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
905 msg_outtrans_attr(name, hl_attr(HLF_D));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
906 vim_free(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
907 ui_breakcheck();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
908 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
909 out_flush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
910 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
911 if (curwin->w_changelistidx == curbuf->b_changelistlen)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
912 MSG_PUTS("\n>");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
913 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
914 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
915
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
916 #define one_adjust(add) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
917 { \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
918 lp = add; \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
919 if (*lp >= line1 && *lp <= line2) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
920 { \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
921 if (amount == MAXLNUM) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
922 *lp = 0; \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
923 else \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
924 *lp += amount; \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
925 } \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
926 else if (amount_after && *lp > line2) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
927 *lp += amount_after; \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
928 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
929
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
930 /* don't delete the line, just put at first deleted line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
931 #define one_adjust_nodel(add) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
932 { \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
933 lp = add; \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
934 if (*lp >= line1 && *lp <= line2) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
935 { \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
936 if (amount == MAXLNUM) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
937 *lp = line1; \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
938 else \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
939 *lp += amount; \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
940 } \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
941 else if (amount_after && *lp > line2) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
942 *lp += amount_after; \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
943 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
944
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
945 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
946 * Adjust marks between line1 and line2 (inclusive) to move 'amount' lines.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
947 * Must be called before changed_*(), appended_lines() or deleted_lines().
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
948 * May be called before or after changing the text.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
949 * When deleting lines line1 to line2, use an 'amount' of MAXLNUM: The marks
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
950 * within this range are made invalid.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
951 * If 'amount_after' is non-zero adjust marks after line2.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
952 * Example: Delete lines 34 and 35: mark_adjust(34, 35, MAXLNUM, -2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
953 * Example: Insert two lines below 55: mark_adjust(56, MAXLNUM, 2, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
954 * or: mark_adjust(56, 55, MAXLNUM, 2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
955 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
956 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
957 mark_adjust(line1, line2, amount, amount_after)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
958 linenr_T line1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
959 linenr_T line2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
960 long amount;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
961 long amount_after;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
962 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
963 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
964 int fnum = curbuf->b_fnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
965 linenr_T *lp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
966 win_T *win;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
967
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
968 if (line2 < line1 && amount_after == 0L) /* nothing to do */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
969 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
970
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
971 if (!cmdmod.lockmarks)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
972 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
973 /* named marks, lower case and upper case */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
974 for (i = 0; i < NMARKS; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
975 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
976 one_adjust(&(curbuf->b_namedm[i].lnum));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
977 if (namedfm[i].fmark.fnum == fnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
978 one_adjust_nodel(&(namedfm[i].fmark.mark.lnum));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
979 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
980 for (i = NMARKS; i < NMARKS + EXTRA_MARKS; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
981 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
982 if (namedfm[i].fmark.fnum == fnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
983 one_adjust_nodel(&(namedfm[i].fmark.mark.lnum));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
984 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
985
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
986 /* last Insert position */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
987 one_adjust(&(curbuf->b_last_insert.lnum));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
988
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
989 /* last change position */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
990 one_adjust(&(curbuf->b_last_change.lnum));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
991
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
992 #ifdef FEAT_JUMPLIST
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
993 /* list of change positions */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
994 for (i = 0; i < curbuf->b_changelistlen; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
995 one_adjust_nodel(&(curbuf->b_changelist[i].lnum));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
996 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
997
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
998 #ifdef FEAT_VISUAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
999 /* Visual area */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1000 one_adjust_nodel(&(curbuf->b_visual_start.lnum));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1001 one_adjust_nodel(&(curbuf->b_visual_end.lnum));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1002 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1003
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1004 #ifdef FEAT_QUICKFIX
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1005 /* quickfix marks */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1006 qf_mark_adjust(line1, line2, amount, amount_after);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1007 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1008
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1009 #ifdef FEAT_SIGNS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1010 sign_mark_adjust(line1, line2, amount, amount_after);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1011 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1012 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1013
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1014 /* previous context mark */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1015 one_adjust(&(curwin->w_pcmark.lnum));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1016
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1017 /* previous pcmark */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1018 one_adjust(&(curwin->w_prev_pcmark.lnum));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1019
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1020 /* saved cursor for formatting */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1021 if (saved_cursor.lnum != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1022 one_adjust_nodel(&(saved_cursor.lnum));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1023
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1024 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1025 * Adjust items in all windows related to the current buffer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1026 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1027 FOR_ALL_WINDOWS(win)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1028 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1029 #ifdef FEAT_JUMPLIST
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1030 if (!cmdmod.lockmarks)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1031 /* Marks in the jumplist. When deleting lines, this may create
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1032 * duplicate marks in the jumplist, they will be removed later. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1033 for (i = 0; i < win->w_jumplistlen; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1034 if (win->w_jumplist[i].fmark.fnum == fnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1035 one_adjust_nodel(&(win->w_jumplist[i].fmark.mark.lnum));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1036 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1037
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1038 if (win->w_buffer == curbuf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1039 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1040 if (!cmdmod.lockmarks)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1041 /* marks in the tag stack */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1042 for (i = 0; i < win->w_tagstacklen; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1043 if (win->w_tagstack[i].fmark.fnum == fnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1044 one_adjust_nodel(&(win->w_tagstack[i].fmark.mark.lnum));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1045
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1046 #ifdef FEAT_VISUAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1047 /* the displayed Visual area */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1048 if (win->w_old_cursor_lnum != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1049 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1050 one_adjust_nodel(&(win->w_old_cursor_lnum));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1051 one_adjust_nodel(&(win->w_old_visual_lnum));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1052 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1053 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1054
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1055 /* topline and cursor position for windows with the same buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1056 * other than the current window */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1057 if (win != curwin)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1058 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1059 if (win->w_topline >= line1 && win->w_topline <= line2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1060 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1061 if (amount == MAXLNUM) /* topline is deleted */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1062 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1063 if (line1 <= 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1064 win->w_topline = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1065 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1066 win->w_topline = line1 - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1067 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1068 else /* keep topline on the same line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1069 win->w_topline += amount;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1070 #ifdef FEAT_DIFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1071 win->w_topfill = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1072 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1073 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1074 else if (amount_after && win->w_topline > line2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1075 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1076 win->w_topline += amount_after;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1077 #ifdef FEAT_DIFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1078 win->w_topfill = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1079 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1080 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1081 if (win->w_cursor.lnum >= line1 && win->w_cursor.lnum <= line2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1082 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1083 if (amount == MAXLNUM) /* line with cursor is deleted */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1084 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1085 if (line1 <= 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1086 win->w_cursor.lnum = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1087 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1088 win->w_cursor.lnum = line1 - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1089 win->w_cursor.col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1090 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1091 else /* keep cursor on the same line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1092 win->w_cursor.lnum += amount;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1093 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1094 else if (amount_after && win->w_cursor.lnum > line2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1095 win->w_cursor.lnum += amount_after;
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 #ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1099 /* adjust folds */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1100 foldMarkAdjust(win, line1, line2, amount, amount_after);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1101 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1102 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1103 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1104
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1105 #ifdef FEAT_DIFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1106 /* adjust diffs */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1107 diff_mark_adjust(line1, line2, amount, amount_after);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1108 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1109 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1110
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1111 /* This code is used often, needs to be fast. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1112 #define col_adjust(pp) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1113 { \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1114 posp = pp; \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1115 if (posp->lnum == lnum && posp->col >= mincol) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1116 { \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1117 posp->lnum += lnum_amount; \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1118 if (col_amount < 0 && posp->col <= (colnr_T)-col_amount) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1119 posp->col = 0; \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1120 else \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1121 posp->col += col_amount; \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1122 } \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1123 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1124
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1125 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1126 * Adjust marks in line "lnum" at column "mincol" and further: add
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1127 * "lnum_amount" to the line number and add "col_amount" to the column
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1128 * position.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1129 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1130 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1131 mark_col_adjust(lnum, mincol, lnum_amount, col_amount)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1132 linenr_T lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1133 colnr_T mincol;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1134 long lnum_amount;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1135 long col_amount;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1136 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1137 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1138 int fnum = curbuf->b_fnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1139 win_T *win;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1140 pos_T *posp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1141
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1142 if ((col_amount == 0L && lnum_amount == 0L) || cmdmod.lockmarks)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1143 return; /* nothing to do */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1144
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1145 /* named marks, lower case and upper case */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1146 for (i = 0; i < NMARKS; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1147 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1148 col_adjust(&(curbuf->b_namedm[i]));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1149 if (namedfm[i].fmark.fnum == fnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1150 col_adjust(&(namedfm[i].fmark.mark));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1151 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1152 for (i = NMARKS; i < NMARKS + EXTRA_MARKS; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1153 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1154 if (namedfm[i].fmark.fnum == fnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1155 col_adjust(&(namedfm[i].fmark.mark));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1156 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1157
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1158 /* last Insert position */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1159 col_adjust(&(curbuf->b_last_insert));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1160
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1161 /* last change position */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1162 col_adjust(&(curbuf->b_last_change));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1163
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1164 #ifdef FEAT_JUMPLIST
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1165 /* list of change positions */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1166 for (i = 0; i < curbuf->b_changelistlen; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1167 col_adjust(&(curbuf->b_changelist[i]));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1168 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1169
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1170 #ifdef FEAT_VISUAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1171 /* Visual area */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1172 col_adjust(&(curbuf->b_visual_start));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1173 col_adjust(&(curbuf->b_visual_end));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1174 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1175
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1176 /* previous context mark */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1177 col_adjust(&(curwin->w_pcmark));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1178
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1179 /* previous pcmark */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1180 col_adjust(&(curwin->w_prev_pcmark));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1181
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1182 /* saved cursor for formatting */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1183 col_adjust(&saved_cursor);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1184
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1185 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1186 * Adjust items in all windows related to the current buffer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1187 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1188 FOR_ALL_WINDOWS(win)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1189 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1190 #ifdef FEAT_JUMPLIST
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1191 /* marks in the jumplist */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1192 for (i = 0; i < win->w_jumplistlen; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1193 if (win->w_jumplist[i].fmark.fnum == fnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1194 col_adjust(&(win->w_jumplist[i].fmark.mark));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1195 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1196
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1197 if (win->w_buffer == curbuf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1198 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1199 /* marks in the tag stack */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1200 for (i = 0; i < win->w_tagstacklen; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1201 if (win->w_tagstack[i].fmark.fnum == fnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1202 col_adjust(&(win->w_tagstack[i].fmark.mark));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1203
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1204 /* cursor position for other windows with the same buffer */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1205 if (win != curwin)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1206 col_adjust(&win->w_cursor);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1207 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1208 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1209 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1210
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1211 #ifdef FEAT_JUMPLIST
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1212 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1213 * When deleting lines, this may create duplicate marks in the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1214 * jumplist. They will be removed here for the current window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1215 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1216 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1217 cleanup_jumplist()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1218 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1219 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1220 int from, to;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1221
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1222 to = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1223 for (from = 0; from < curwin->w_jumplistlen; ++from)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1224 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1225 if (curwin->w_jumplistidx == from)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1226 curwin->w_jumplistidx = to;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1227 for (i = from + 1; i < curwin->w_jumplistlen; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1228 if (curwin->w_jumplist[i].fmark.fnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1229 == curwin->w_jumplist[from].fmark.fnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1230 && curwin->w_jumplist[from].fmark.fnum != 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1231 && curwin->w_jumplist[i].fmark.mark.lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1232 == curwin->w_jumplist[from].fmark.mark.lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1233 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1234 if (i >= curwin->w_jumplistlen) /* no duplicate */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1235 curwin->w_jumplist[to++] = curwin->w_jumplist[from];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1236 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1237 vim_free(curwin->w_jumplist[from].fname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1238 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1239 if (curwin->w_jumplistidx == curwin->w_jumplistlen)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1240 curwin->w_jumplistidx = to;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1241 curwin->w_jumplistlen = to;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1242 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1243
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1244 # if defined(FEAT_WINDOWS) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1245 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1246 * Copy the jumplist from window "from" to window "to".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1247 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1248 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1249 copy_jumplist(from, to)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1250 win_T *from;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1251 win_T *to;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1252 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1253 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1254
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1255 for (i = 0; i < from->w_jumplistlen; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1256 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1257 to->w_jumplist[i] = from->w_jumplist[i];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1258 if (from->w_jumplist[i].fname != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1259 to->w_jumplist[i].fname = vim_strsave(from->w_jumplist[i].fname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1260 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1261 to->w_jumplistlen = from->w_jumplistlen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1262 to->w_jumplistidx = from->w_jumplistidx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1263 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1264
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1265 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1266 * Free items in the jumplist of window "wp".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1267 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1268 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1269 free_jumplist(wp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1270 win_T *wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1271 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1272 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1273
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1274 for (i = 0; i < wp->w_jumplistlen; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1275 vim_free(wp->w_jumplist[i].fname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1276 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1277 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1278 #endif /* FEAT_JUMPLIST */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1279
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1280 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1281 set_last_cursor(win)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1282 win_T *win;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1283 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1284 win->w_buffer->b_last_cursor = win->w_cursor;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1285 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1286
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1287 #if defined(FEAT_VIMINFO) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1288 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1289 read_viminfo_filemark(virp, force)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1290 vir_T *virp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1291 int force;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1292 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1293 char_u *str;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1294 xfmark_T *fm;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1295 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1296
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1297 /* We only get here if line[0] == '\'' or '-'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1298 * Illegal mark names are ignored (for future expansion). */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1299 str = virp->vir_line + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1300 if (
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1301 #ifndef EBCDIC
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1302 *str <= 127 &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1303 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1304 ((*virp->vir_line == '\'' && (VIM_ISDIGIT(*str) || isupper(*str)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1305 || (*virp->vir_line == '-' && *str == '\'')))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1306 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1307 if (*str == '\'')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1308 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1309 #ifdef FEAT_JUMPLIST
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1310 /* If the jumplist isn't full insert fmark as oldest entry */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1311 if (curwin->w_jumplistlen == JUMPLISTSIZE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1312 fm = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1313 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1314 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1315 for (i = curwin->w_jumplistlen; i > 0; --i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1316 curwin->w_jumplist[i] = curwin->w_jumplist[i - 1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1317 ++curwin->w_jumplistidx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1318 ++curwin->w_jumplistlen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1319 fm = &curwin->w_jumplist[0];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1320 fm->fmark.mark.lnum = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1321 fm->fname = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1322 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1323 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1324 fm = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1325 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1326 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1327 else if (VIM_ISDIGIT(*str))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1328 fm = &namedfm[*str - '0' + NMARKS];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1329 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1330 fm = &namedfm[*str - 'A'];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1331 if (fm != NULL && (fm->fmark.mark.lnum == 0 || force))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1332 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1333 str = skipwhite(str + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1334 fm->fmark.mark.lnum = getdigits(&str);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1335 str = skipwhite(str);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1336 fm->fmark.mark.col = getdigits(&str);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1337 #ifdef FEAT_VIRTUALEDIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1338 fm->fmark.mark.coladd = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1339 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1340 fm->fmark.fnum = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1341 str = skipwhite(str);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1342 vim_free(fm->fname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1343 fm->fname = viminfo_readstring(virp, (int)(str - virp->vir_line),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1344 FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1345 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1346 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1347 return vim_fgets(virp->vir_line, LSIZE, virp->vir_fd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1348 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1349
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1350 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1351 write_viminfo_filemarks(fp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1352 FILE *fp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1353 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1354 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1355 char_u *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1356 buf_T *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1357 xfmark_T *fm;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1358
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1359 if (get_viminfo_parameter('f') == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1360 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1361
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1362 fprintf(fp, _("\n# File marks:\n"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1363
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1364 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1365 * Find a mark that is the same file and position as the cursor.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1366 * That one, or else the last one is deleted.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1367 * Move '0 to '1, '1 to '2, etc. until the matching one or '9
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1368 * Set '0 mark to current cursor position.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1369 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1370 if (curbuf->b_ffname != NULL && !removable(curbuf->b_ffname))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1371 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1372 name = buflist_nr2name(curbuf->b_fnum, TRUE, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1373 for (i = NMARKS; i < NMARKS + EXTRA_MARKS - 1; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1374 if (namedfm[i].fmark.mark.lnum == curwin->w_cursor.lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1375 && (namedfm[i].fname == NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1376 ? namedfm[i].fmark.fnum == curbuf->b_fnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1377 : (name != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1378 && STRCMP(name, namedfm[i].fname) == 0)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1379 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1380 vim_free(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1381
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1382 vim_free(namedfm[i].fname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1383 for ( ; i > NMARKS; --i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1384 namedfm[i] = namedfm[i - 1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1385 namedfm[NMARKS].fmark.mark = curwin->w_cursor;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1386 namedfm[NMARKS].fmark.fnum = curbuf->b_fnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1387 namedfm[NMARKS].fname = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1388 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1389
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1390 /* Write the filemarks '0 - '9 and 'A - 'Z */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1391 for (i = 0; i < NMARKS + EXTRA_MARKS; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1392 write_one_filemark(fp, &namedfm[i], '\'',
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1393 i < NMARKS ? i + 'A' : i - NMARKS + '0');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1394
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1395 #ifdef FEAT_JUMPLIST
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1396 /* Write the jumplist with -' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1397 fprintf(fp, _("\n# Jumplist (newest first):\n"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1398 setpcmark(); /* add current cursor position */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1399 cleanup_jumplist();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1400 for (fm = &curwin->w_jumplist[curwin->w_jumplistlen - 1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1401 fm >= &curwin->w_jumplist[0]; --fm)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1402 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1403 if (fm->fmark.fnum == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1404 || ((buf = buflist_findnr(fm->fmark.fnum)) != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1405 && !removable(buf->b_ffname)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1406 write_one_filemark(fp, fm, '-', '\'');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1407 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1408 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1409 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1410
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1411 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1412 write_one_filemark(fp, fm, c1, c2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1413 FILE *fp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1414 xfmark_T *fm;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1415 int c1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1416 int c2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1417 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1418 char_u *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1419
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1420 if (fm->fmark.mark.lnum == 0) /* not set */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1421 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1422
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1423 if (fm->fmark.fnum != 0) /* there is a buffer */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1424 name = buflist_nr2name(fm->fmark.fnum, TRUE, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1425 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1426 name = fm->fname; /* use name from .viminfo */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1427 if (name != NULL && *name != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1428 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1429 fprintf(fp, "%c%c %ld %ld ", c1, c2, (long)fm->fmark.mark.lnum,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1430 (long)fm->fmark.mark.col);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1431 viminfo_writestring(fp, name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1432 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1433
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1434 if (fm->fmark.fnum != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1435 vim_free(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1436 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1437
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1438 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1439 * Return TRUE if "name" is on removable media (depending on 'viminfo').
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1440 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1441 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1442 removable(name)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1443 char_u *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1444 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1445 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1446 char_u part[51];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1447 int retval = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1448
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1449 name = home_replace_save(NULL, name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1450 if (name != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1451 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1452 for (p = p_viminfo; *p; )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1453 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1454 copy_option_part(&p, part, 51, ", ");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1455 if (part[0] == 'r'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1456 && MB_STRNICMP(part + 1, name, STRLEN(part + 1)) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1457 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1458 retval = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1459 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1460 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1461 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1462 vim_free(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1463 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1464 return retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1465 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1466
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1467 static void write_one_mark __ARGS((FILE *fp_out, int c, pos_T *pos));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1468
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1469 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1470 * Write all the named marks for all buffers.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1471 * Return the number of buffers for which marks have been written.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1472 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1473 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1474 write_viminfo_marks(fp_out)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1475 FILE *fp_out;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1476 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1477 int count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1478 buf_T *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1479 int is_mark_set;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1480 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1481 #ifdef FEAT_WINDOWS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1482 win_T *win;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1483
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1484 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1485 * Set b_last_cursor for the all buffers that have a window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1486 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1487 for (win = firstwin; win != NULL; win = win->w_next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1488 set_last_cursor(win);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1489 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1490 set_last_cursor(curwin);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1491 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1492
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1493 fprintf(fp_out, _("\n# History of marks within files (newest to oldest):\n"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1494 count = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1495 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1496 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1497 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1498 * Only write something if buffer has been loaded and at least one
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1499 * mark is set.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1500 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1501 if (buf->b_marks_read)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1502 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1503 if (buf->b_last_cursor.lnum != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1504 is_mark_set = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1505 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1506 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1507 is_mark_set = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1508 for (i = 0; i < NMARKS; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1509 if (buf->b_namedm[i].lnum != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1510 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1511 is_mark_set = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1512 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1513 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1514 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1515 if (is_mark_set && buf->b_ffname != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1516 && buf->b_ffname[0] != NUL && !removable(buf->b_ffname))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1517 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1518 home_replace(NULL, buf->b_ffname, IObuff, IOSIZE, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1519 fprintf(fp_out, "\n> ");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1520 viminfo_writestring(fp_out, IObuff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1521 write_one_mark(fp_out, '"', &buf->b_last_cursor);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1522 write_one_mark(fp_out, '^', &buf->b_last_insert);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1523 write_one_mark(fp_out, '.', &buf->b_last_change);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1524 #ifdef FEAT_JUMPLIST
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1525 /* changelist positions are stored oldest first */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1526 for (i = 0; i < buf->b_changelistlen; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1527 write_one_mark(fp_out, '+', &buf->b_changelist[i]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1528 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1529 for (i = 0; i < NMARKS; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1530 write_one_mark(fp_out, 'a' + i, &buf->b_namedm[i]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1531 count++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1532 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1533 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1534 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1535
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1536 return count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1537 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1538
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1539 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1540 write_one_mark(fp_out, c, pos)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1541 FILE *fp_out;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1542 int c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1543 pos_T *pos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1544 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1545 if (pos->lnum != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1546 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
1547 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1548
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1549 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1550 * Handle marks in the viminfo file:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1551 * fp_out == NULL read marks for current buffer only
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1552 * fp_out != NULL copy marks for buffers not in buffer list
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1553 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1554 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1555 copy_viminfo_marks(virp, fp_out, count, eof)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1556 vir_T *virp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1557 FILE *fp_out;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1558 int count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1559 int eof;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1560 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1561 char_u *line = virp->vir_line;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1562 buf_T *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1563 int num_marked_files;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1564 int load_marks;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1565 int copy_marks_out;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1566 char_u *str;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1567 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1568 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1569 char_u *name_buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1570 pos_T pos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1571
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1572 if ((name_buf = alloc(LSIZE)) == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1573 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1574 *name_buf = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1575 num_marked_files = get_viminfo_parameter('\'');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1576 while (!eof && (count < num_marked_files || fp_out == NULL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1577 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1578 if (line[0] != '>')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1579 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1580 if (line[0] != '\n' && line[0] != '\r' && line[0] != '#')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1581 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1582 if (viminfo_error("E576: ", _("Missing '>'"), line))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1583 break; /* too many errors, return now */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1584 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1585 eof = vim_fgets(line, LSIZE, virp->vir_fd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1586 continue; /* Skip this dud line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1587 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1588
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1589 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1590 * Handle long line and translate escaped characters.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1591 * Find file name, set str to start.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1592 * Ignore leading and trailing white space.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1593 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1594 str = skipwhite(line + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1595 str = viminfo_readstring(virp, (int)(str - virp->vir_line), FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1596 if (str == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1597 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1598 p = str + STRLEN(str);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1599 while (p != str && (*p == NUL || vim_isspace(*p)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1600 p--;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1601 if (*p)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1602 p++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1603 *p = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1604
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1605 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1606 * If fp_out == NULL, load marks for current buffer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1607 * If fp_out != NULL, copy marks for buffers not in buflist.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1608 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1609 load_marks = copy_marks_out = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1610 if (fp_out == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1611 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1612 if (curbuf->b_ffname != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1613 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1614 if (*name_buf == NUL) /* only need to do this once */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1615 home_replace(NULL, curbuf->b_ffname, name_buf, LSIZE, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1616 if (fnamecmp(str, name_buf) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1617 load_marks = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1618 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1619 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1620 else /* fp_out != NULL */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1621 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1622 /* This is slow if there are many buffers!! */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1623 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1624 if (buf->b_ffname != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1625 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1626 home_replace(NULL, buf->b_ffname, name_buf, LSIZE, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1627 if (fnamecmp(str, name_buf) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1628 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1629 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1630
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1631 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1632 * copy marks if the buffer has not been loaded
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1633 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1634 if (buf == NULL || !buf->b_marks_read)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1635 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1636 copy_marks_out = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1637 fputs("\n> ", fp_out);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1638 viminfo_writestring(fp_out, str);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1639 count++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1640 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1641 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1642 vim_free(str);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1643
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1644 #ifdef FEAT_VIRTUALEDIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1645 pos.coladd = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1646 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1647 while (!(eof = viminfo_readline(virp)) && line[0] == TAB)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1648 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1649 if (load_marks)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1650 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1651 if (line[1] != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1652 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1653 sscanf((char *)line + 2, "%ld %u", &pos.lnum, &pos.col);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1654 switch (line[1])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1655 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1656 case '"': curbuf->b_last_cursor = pos; break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1657 case '^': curbuf->b_last_insert = pos; break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1658 case '.': curbuf->b_last_change = pos; break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1659 case '+':
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1660 #ifdef FEAT_JUMPLIST
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1661 /* changelist positions are stored oldest
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1662 * first */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1663 if (curbuf->b_changelistlen == JUMPLISTSIZE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1664 /* list is full, remove oldest entry */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1665 mch_memmove(curbuf->b_changelist,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1666 curbuf->b_changelist + 1,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1667 sizeof(pos_T) * (JUMPLISTSIZE - 1));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1668 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1669 ++curbuf->b_changelistlen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1670 curbuf->b_changelist[
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1671 curbuf->b_changelistlen - 1] = pos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1672 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1673 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1674 default: if ((i = line[1] - 'a') >= 0 && i < NMARKS)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1675 curbuf->b_namedm[i] = pos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1676 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1677 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1678 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1679 else if (copy_marks_out)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1680 fputs((char *)line, fp_out);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1681 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1682 if (load_marks)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1683 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1684 #ifdef FEAT_JUMPLIST
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1685 win_T *wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1686
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1687 FOR_ALL_WINDOWS(wp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1688 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1689 if (wp->w_buffer == curbuf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1690 wp->w_changelistidx = curbuf->b_changelistlen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1691 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1692 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1693 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1694 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1695 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1696 vim_free(name_buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1697 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1698 #endif /* FEAT_VIMINFO */