Mercurial > vim
annotate src/mark.c @ 35956:11fc42b05554
runtime(javascript): fix a few issues with syntax higlighting
Commit: https://github.com/vim/vim/commit/ea76096fa98ac26c23703bffdc4d9b3dc8a94d7e
Author: Tobiasz Laskowski <tobil4sk@outlook.com>
Date: Wed Aug 14 14:50:56 2024 +0200
runtime(javascript): fix a few issues with syntax higlighting
It addresses the following issues:
- Fix highlight of let and var javascript keywords
According to runtime/doc/syntax.txt, Identifier is for variable names.
let/var are not variable names, they are keywords
- Add highlighting for "from" keyword in javascript
- Fix highlight of function keyword in javascript
According to docs, Function is for function names, so the function
keyword should just be Keyword.
- Fix highlight of static keyword in javascript
According to vim docs: StorageClass static, register, volatile, etc.
closes: #15480
Signed-off-by: Tobiasz Laskowski <tobil4sk@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Wed, 14 Aug 2024 15:00:07 +0200 |
parents | 256723b12b48 |
children |
rev | line source |
---|---|
10042
4aead6a9b7a9
commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
7 | 2 * |
3 * VIM - Vi IMproved by Bram Moolenaar | |
4 * | |
5 * Do ":help uganda" in Vim to read copying and usage conditions. | |
6 * Do ":help credits" in Vim to see a list of people who contributed. | |
7 * See README.txt for an overview of the Vim source code. | |
8 */ | |
9 | |
10 /* | |
11 * mark.c: functions for setting marks and jumping to them | |
12 */ | |
13 | |
14 #include "vim.h" | |
15 | |
16 /* | |
17 * This file contains routines to maintain and manipulate marks. | |
18 */ | |
19 | |
20 /* | |
21 * If a named file mark's lnum is non-zero, it is valid. | |
22 * If a named file mark's fnum is non-zero, it is for an existing buffer, | |
23 * otherwise it is from .viminfo and namedfm[n].fname is the file name. | |
24 * There are marks 'A - 'Z (set by user) and '0 to '9 (set when writing | |
25 * viminfo). | |
26 */ | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
27 static xfmark_T namedfm[NMARKS + EXTRA_MARKS]; // marks with file nr |
7 | 28 |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17464
diff
changeset
|
29 static void fname2fnum(xfmark_T *fm); |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
5735
diff
changeset
|
30 static void fmarks_check_one(xfmark_T *fm, char_u *name, buf_T *buf); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
5735
diff
changeset
|
31 static char_u *mark_line(pos_T *mp, int lead_len); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
5735
diff
changeset
|
32 static void show_one_mark(int, char_u *, pos_T *, char_u *, int current); |
11140
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
33 static void mark_adjust_internal(linenr_T line1, linenr_T line2, long amount, |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
34 long amount_after, int adjust_folds); |
7 | 35 |
36 /* | |
706 | 37 * Set named mark "c" at current cursor position. |
7 | 38 * Returns OK on success, FAIL if bad name given. |
39 */ | |
40 int | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
41 setmark(int c) |
7 | 42 { |
706 | 43 return setmark_pos(c, &curwin->w_cursor, curbuf->b_fnum); |
44 } | |
45 | |
46 /* | |
47 * Set named mark "c" to position "pos". | |
48 * When "c" is upper case use file "fnum". | |
49 * Returns OK on success, FAIL if bad name given. | |
50 */ | |
51 int | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
52 setmark_pos(int c, pos_T *pos, int fnum) |
706 | 53 { |
7 | 54 int i; |
10730
44e9340dc604
patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents:
10285
diff
changeset
|
55 buf_T *buf; |
7 | 56 |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
57 // Check for a special key (may cause islower() to crash). |
7 | 58 if (c < 0) |
59 return FAIL; | |
60 | |
61 if (c == '\'' || c == '`') | |
62 { | |
706 | 63 if (pos == &curwin->w_cursor) |
64 { | |
65 setpcmark(); | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
66 // keep it even when the cursor doesn't move |
706 | 67 curwin->w_prev_pcmark = curwin->w_pcmark; |
68 } | |
69 else | |
70 curwin->w_pcmark = *pos; | |
7 | 71 return OK; |
72 } | |
73 | |
10730
44e9340dc604
patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents:
10285
diff
changeset
|
74 buf = buflist_findnr(fnum); |
44e9340dc604
patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents:
10285
diff
changeset
|
75 if (buf == NULL) |
44e9340dc604
patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents:
10285
diff
changeset
|
76 return FAIL; |
44e9340dc604
patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents:
10285
diff
changeset
|
77 |
1533 | 78 if (c == '"') |
79 { | |
10730
44e9340dc604
patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents:
10285
diff
changeset
|
80 buf->b_last_cursor = *pos; |
1533 | 81 return OK; |
82 } | |
83 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
84 // Allow setting '[ and '] for an autocommand that simulates reading a |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
85 // file. |
7 | 86 if (c == '[') |
87 { | |
10730
44e9340dc604
patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents:
10285
diff
changeset
|
88 buf->b_op_start = *pos; |
7 | 89 return OK; |
90 } | |
91 if (c == ']') | |
92 { | |
10730
44e9340dc604
patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents:
10285
diff
changeset
|
93 buf->b_op_end = *pos; |
7 | 94 return OK; |
95 } | |
96 | |
5265
cd971e951b06
updated for version 7.4b.009
Bram Moolenaar <bram@vim.org>
parents:
4092
diff
changeset
|
97 if (c == '<' || c == '>') |
3660 | 98 { |
5265
cd971e951b06
updated for version 7.4b.009
Bram Moolenaar <bram@vim.org>
parents:
4092
diff
changeset
|
99 if (c == '<') |
10730
44e9340dc604
patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents:
10285
diff
changeset
|
100 buf->b_visual.vi_start = *pos; |
5265
cd971e951b06
updated for version 7.4b.009
Bram Moolenaar <bram@vim.org>
parents:
4092
diff
changeset
|
101 else |
10730
44e9340dc604
patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents:
10285
diff
changeset
|
102 buf->b_visual.vi_end = *pos; |
44e9340dc604
patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents:
10285
diff
changeset
|
103 if (buf->b_visual.vi_mode == NUL) |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
104 // Visual_mode has not yet been set, use a sane default. |
10730
44e9340dc604
patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents:
10285
diff
changeset
|
105 buf->b_visual.vi_mode = 'v'; |
3660 | 106 return OK; |
107 } | |
108 | |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
109 if (ASCII_ISLOWER(c)) |
7 | 110 { |
111 i = c - 'a'; | |
10730
44e9340dc604
patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents:
10285
diff
changeset
|
112 buf->b_namedm[i] = *pos; |
7 | 113 return OK; |
114 } | |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
115 if (ASCII_ISUPPER(c) || VIM_ISDIGIT(c)) |
7 | 116 { |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
117 if (VIM_ISDIGIT(c)) |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
118 i = c - '0' + NMARKS; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
119 else |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
120 i = c - 'A'; |
706 | 121 namedfm[i].fmark.mark = *pos; |
122 namedfm[i].fmark.fnum = fnum; | |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
123 VIM_CLEAR(namedfm[i].fname); |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
124 #ifdef FEAT_VIMINFO |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
125 namedfm[i].time_set = vim_time(); |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
126 #endif |
7 | 127 return OK; |
128 } | |
129 return FAIL; | |
130 } | |
131 | |
132 /* | |
35622
814fcbca4d8d
patch 9.1.0554: :bw leaves jumplist and tagstack data around
Christian Brabandt <cb@256bit.org>
parents:
33311
diff
changeset
|
133 * Delete every entry referring to file 'fnum' from both the jumplist and the |
814fcbca4d8d
patch 9.1.0554: :bw leaves jumplist and tagstack data around
Christian Brabandt <cb@256bit.org>
parents:
33311
diff
changeset
|
134 * tag stack. |
814fcbca4d8d
patch 9.1.0554: :bw leaves jumplist and tagstack data around
Christian Brabandt <cb@256bit.org>
parents:
33311
diff
changeset
|
135 */ |
814fcbca4d8d
patch 9.1.0554: :bw leaves jumplist and tagstack data around
Christian Brabandt <cb@256bit.org>
parents:
33311
diff
changeset
|
136 void |
814fcbca4d8d
patch 9.1.0554: :bw leaves jumplist and tagstack data around
Christian Brabandt <cb@256bit.org>
parents:
33311
diff
changeset
|
137 mark_forget_file(win_T *wp, int fnum) |
814fcbca4d8d
patch 9.1.0554: :bw leaves jumplist and tagstack data around
Christian Brabandt <cb@256bit.org>
parents:
33311
diff
changeset
|
138 { |
814fcbca4d8d
patch 9.1.0554: :bw leaves jumplist and tagstack data around
Christian Brabandt <cb@256bit.org>
parents:
33311
diff
changeset
|
139 int i; |
814fcbca4d8d
patch 9.1.0554: :bw leaves jumplist and tagstack data around
Christian Brabandt <cb@256bit.org>
parents:
33311
diff
changeset
|
140 |
35627
256723b12b48
patch 9.1.0556: :bwipe doesn't remove file from jumplist of other tabpages
Christian Brabandt <cb@256bit.org>
parents:
35622
diff
changeset
|
141 for (i = wp->w_jumplistlen - 1; i >= 0; --i) |
35622
814fcbca4d8d
patch 9.1.0554: :bw leaves jumplist and tagstack data around
Christian Brabandt <cb@256bit.org>
parents:
33311
diff
changeset
|
142 if (wp->w_jumplist[i].fmark.fnum == fnum) |
814fcbca4d8d
patch 9.1.0554: :bw leaves jumplist and tagstack data around
Christian Brabandt <cb@256bit.org>
parents:
33311
diff
changeset
|
143 { |
814fcbca4d8d
patch 9.1.0554: :bw leaves jumplist and tagstack data around
Christian Brabandt <cb@256bit.org>
parents:
33311
diff
changeset
|
144 vim_free(wp->w_jumplist[i].fname); |
814fcbca4d8d
patch 9.1.0554: :bw leaves jumplist and tagstack data around
Christian Brabandt <cb@256bit.org>
parents:
33311
diff
changeset
|
145 if (wp->w_jumplistidx > i) |
814fcbca4d8d
patch 9.1.0554: :bw leaves jumplist and tagstack data around
Christian Brabandt <cb@256bit.org>
parents:
33311
diff
changeset
|
146 --wp->w_jumplistidx; |
814fcbca4d8d
patch 9.1.0554: :bw leaves jumplist and tagstack data around
Christian Brabandt <cb@256bit.org>
parents:
33311
diff
changeset
|
147 --wp->w_jumplistlen; |
35627
256723b12b48
patch 9.1.0556: :bwipe doesn't remove file from jumplist of other tabpages
Christian Brabandt <cb@256bit.org>
parents:
35622
diff
changeset
|
148 mch_memmove(&wp->w_jumplist[i], &wp->w_jumplist[i + 1], |
256723b12b48
patch 9.1.0556: :bwipe doesn't remove file from jumplist of other tabpages
Christian Brabandt <cb@256bit.org>
parents:
35622
diff
changeset
|
149 (wp->w_jumplistlen - i) * sizeof(wp->w_jumplist[i])); |
35622
814fcbca4d8d
patch 9.1.0554: :bw leaves jumplist and tagstack data around
Christian Brabandt <cb@256bit.org>
parents:
33311
diff
changeset
|
150 } |
814fcbca4d8d
patch 9.1.0554: :bw leaves jumplist and tagstack data around
Christian Brabandt <cb@256bit.org>
parents:
33311
diff
changeset
|
151 |
35627
256723b12b48
patch 9.1.0556: :bwipe doesn't remove file from jumplist of other tabpages
Christian Brabandt <cb@256bit.org>
parents:
35622
diff
changeset
|
152 for (i = wp->w_tagstacklen - 1; i >= 0; --i) |
35622
814fcbca4d8d
patch 9.1.0554: :bw leaves jumplist and tagstack data around
Christian Brabandt <cb@256bit.org>
parents:
33311
diff
changeset
|
153 if (wp->w_tagstack[i].fmark.fnum == fnum) |
814fcbca4d8d
patch 9.1.0554: :bw leaves jumplist and tagstack data around
Christian Brabandt <cb@256bit.org>
parents:
33311
diff
changeset
|
154 { |
814fcbca4d8d
patch 9.1.0554: :bw leaves jumplist and tagstack data around
Christian Brabandt <cb@256bit.org>
parents:
33311
diff
changeset
|
155 tagstack_clear_entry(&wp->w_tagstack[i]); |
814fcbca4d8d
patch 9.1.0554: :bw leaves jumplist and tagstack data around
Christian Brabandt <cb@256bit.org>
parents:
33311
diff
changeset
|
156 if (wp->w_tagstackidx > i) |
814fcbca4d8d
patch 9.1.0554: :bw leaves jumplist and tagstack data around
Christian Brabandt <cb@256bit.org>
parents:
33311
diff
changeset
|
157 --wp->w_tagstackidx; |
814fcbca4d8d
patch 9.1.0554: :bw leaves jumplist and tagstack data around
Christian Brabandt <cb@256bit.org>
parents:
33311
diff
changeset
|
158 --wp->w_tagstacklen; |
35627
256723b12b48
patch 9.1.0556: :bwipe doesn't remove file from jumplist of other tabpages
Christian Brabandt <cb@256bit.org>
parents:
35622
diff
changeset
|
159 mch_memmove(&wp->w_tagstack[i], &wp->w_tagstack[i + 1], |
256723b12b48
patch 9.1.0556: :bwipe doesn't remove file from jumplist of other tabpages
Christian Brabandt <cb@256bit.org>
parents:
35622
diff
changeset
|
160 (wp->w_tagstacklen - i) * sizeof(wp->w_tagstack[i])); |
35622
814fcbca4d8d
patch 9.1.0554: :bw leaves jumplist and tagstack data around
Christian Brabandt <cb@256bit.org>
parents:
33311
diff
changeset
|
161 } |
814fcbca4d8d
patch 9.1.0554: :bw leaves jumplist and tagstack data around
Christian Brabandt <cb@256bit.org>
parents:
33311
diff
changeset
|
162 } |
814fcbca4d8d
patch 9.1.0554: :bw leaves jumplist and tagstack data around
Christian Brabandt <cb@256bit.org>
parents:
33311
diff
changeset
|
163 |
814fcbca4d8d
patch 9.1.0554: :bw leaves jumplist and tagstack data around
Christian Brabandt <cb@256bit.org>
parents:
33311
diff
changeset
|
164 /* |
7 | 165 * Set the previous context mark to the current position and add it to the |
166 * jump list. | |
167 */ | |
168 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
169 setpcmark(void) |
7 | 170 { |
171 int i; | |
172 xfmark_T *fm; | |
173 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
174 // for :global the mark is set only once |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
21403
diff
changeset
|
175 if (global_busy || listcmd_busy || (cmdmod.cmod_flags & CMOD_KEEPJUMPS)) |
7 | 176 return; |
177 | |
178 curwin->w_prev_pcmark = curwin->w_pcmark; | |
179 curwin->w_pcmark = curwin->w_cursor; | |
180 | |
33311
1f3bcb7f3bd0
patch 9.0.1921: not possible to use the jumplist like a stack
Christian Brabandt <cb@256bit.org>
parents:
32288
diff
changeset
|
181 if (jop_flags & JOP_STACK) |
1f3bcb7f3bd0
patch 9.0.1921: not possible to use the jumplist like a stack
Christian Brabandt <cb@256bit.org>
parents:
32288
diff
changeset
|
182 { |
1f3bcb7f3bd0
patch 9.0.1921: not possible to use the jumplist like a stack
Christian Brabandt <cb@256bit.org>
parents:
32288
diff
changeset
|
183 // jumpoptions=stack: if we're somewhere in the middle of the jumplist |
1f3bcb7f3bd0
patch 9.0.1921: not possible to use the jumplist like a stack
Christian Brabandt <cb@256bit.org>
parents:
32288
diff
changeset
|
184 // discard everything after the current index. |
1f3bcb7f3bd0
patch 9.0.1921: not possible to use the jumplist like a stack
Christian Brabandt <cb@256bit.org>
parents:
32288
diff
changeset
|
185 if (curwin->w_jumplistidx < curwin->w_jumplistlen - 1) |
1f3bcb7f3bd0
patch 9.0.1921: not possible to use the jumplist like a stack
Christian Brabandt <cb@256bit.org>
parents:
32288
diff
changeset
|
186 // Discard the rest of the jumplist by cutting the length down to |
1f3bcb7f3bd0
patch 9.0.1921: not possible to use the jumplist like a stack
Christian Brabandt <cb@256bit.org>
parents:
32288
diff
changeset
|
187 // contain nothing beyond the current index. |
1f3bcb7f3bd0
patch 9.0.1921: not possible to use the jumplist like a stack
Christian Brabandt <cb@256bit.org>
parents:
32288
diff
changeset
|
188 curwin->w_jumplistlen = curwin->w_jumplistidx + 1; |
1f3bcb7f3bd0
patch 9.0.1921: not possible to use the jumplist like a stack
Christian Brabandt <cb@256bit.org>
parents:
32288
diff
changeset
|
189 } |
1f3bcb7f3bd0
patch 9.0.1921: not possible to use the jumplist like a stack
Christian Brabandt <cb@256bit.org>
parents:
32288
diff
changeset
|
190 |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
191 // If jumplist is full: remove oldest entry |
7 | 192 if (++curwin->w_jumplistlen > JUMPLISTSIZE) |
193 { | |
194 curwin->w_jumplistlen = JUMPLISTSIZE; | |
195 vim_free(curwin->w_jumplist[0].fname); | |
196 for (i = 1; i < JUMPLISTSIZE; ++i) | |
197 curwin->w_jumplist[i - 1] = curwin->w_jumplist[i]; | |
198 } | |
199 curwin->w_jumplistidx = curwin->w_jumplistlen; | |
200 fm = &curwin->w_jumplist[curwin->w_jumplistlen - 1]; | |
201 | |
202 fm->fmark.mark = curwin->w_pcmark; | |
203 fm->fmark.fnum = curbuf->b_fnum; | |
204 fm->fname = NULL; | |
26532
255bc9a08e58
patch 8.2.3795: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
26439
diff
changeset
|
205 #ifdef FEAT_VIMINFO |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
206 fm->time_set = vim_time(); |
7 | 207 #endif |
208 } | |
209 | |
210 /* | |
211 * To change context, call setpcmark(), then move the current position to | |
212 * where ever, then call checkpcmark(). This ensures that the previous | |
213 * context will only be changed if the cursor moved to a different line. | |
214 * If pcmark was deleted (with "dG") the previous mark is restored. | |
215 */ | |
216 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
217 checkpcmark(void) |
7 | 218 { |
219 if (curwin->w_prev_pcmark.lnum != 0 | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10730
diff
changeset
|
220 && (EQUAL_POS(curwin->w_pcmark, curwin->w_cursor) |
7 | 221 || curwin->w_pcmark.lnum == 0)) |
222 curwin->w_pcmark = curwin->w_prev_pcmark; | |
25998
902aab6dc499
patch 8.2.3532: the previous '' mark is restored after moving the cursor
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
223 curwin->w_prev_pcmark.lnum = 0; // it has been checked |
7 | 224 } |
225 | |
226 /* | |
227 * move "count" positions in the jump list (count may be negative) | |
228 */ | |
229 pos_T * | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
230 movemark(int count) |
7 | 231 { |
232 pos_T *pos; | |
233 xfmark_T *jmp; | |
234 | |
13278
28ae299c6af0
patch 8.0.1513: the jumplist is not always properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
13248
diff
changeset
|
235 cleanup_jumplist(curwin, TRUE); |
7 | 236 |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
237 if (curwin->w_jumplistlen == 0) // nothing to jump to |
7 | 238 return (pos_T *)NULL; |
239 | |
240 for (;;) | |
241 { | |
242 if (curwin->w_jumplistidx + count < 0 | |
243 || curwin->w_jumplistidx + count >= curwin->w_jumplistlen) | |
244 return (pos_T *)NULL; | |
245 | |
246 /* | |
247 * if first CTRL-O or CTRL-I command after a jump, add cursor position | |
1188 | 248 * to list. Careful: If there are duplicates (CTRL-O immediately after |
7 | 249 * starting Vim on a file), another entry may have been removed. |
250 */ | |
251 if (curwin->w_jumplistidx == curwin->w_jumplistlen) | |
252 { | |
253 setpcmark(); | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
254 --curwin->w_jumplistidx; // skip the new entry |
7 | 255 if (curwin->w_jumplistidx + count < 0) |
256 return (pos_T *)NULL; | |
257 } | |
258 | |
259 curwin->w_jumplistidx += count; | |
260 | |
261 jmp = curwin->w_jumplist + curwin->w_jumplistidx; | |
262 if (jmp->fmark.fnum == 0) | |
263 fname2fnum(jmp); | |
264 if (jmp->fmark.fnum != curbuf->b_fnum) | |
265 { | |
30389
14c0d0c72bcd
patch 9.0.0530: using freed memory when autocmd changes mark
Bram Moolenaar <Bram@vim.org>
parents:
29239
diff
changeset
|
266 // Make a copy, an autocommand may make "jmp" invalid. |
14c0d0c72bcd
patch 9.0.0530: using freed memory when autocmd changes mark
Bram Moolenaar <Bram@vim.org>
parents:
29239
diff
changeset
|
267 fmark_T fmark = jmp->fmark; |
14c0d0c72bcd
patch 9.0.0530: using freed memory when autocmd changes mark
Bram Moolenaar <Bram@vim.org>
parents:
29239
diff
changeset
|
268 |
14c0d0c72bcd
patch 9.0.0530: using freed memory when autocmd changes mark
Bram Moolenaar <Bram@vim.org>
parents:
29239
diff
changeset
|
269 // jump to the file with the mark |
14c0d0c72bcd
patch 9.0.0530: using freed memory when autocmd changes mark
Bram Moolenaar <Bram@vim.org>
parents:
29239
diff
changeset
|
270 if (buflist_findnr(fmark.fnum) == NULL) |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
271 { // Skip this one .. |
7 | 272 count += count < 0 ? -1 : 1; |
273 continue; | |
274 } | |
30389
14c0d0c72bcd
patch 9.0.0530: using freed memory when autocmd changes mark
Bram Moolenaar <Bram@vim.org>
parents:
29239
diff
changeset
|
275 if (buflist_getfile(fmark.fnum, fmark.mark.lnum, 0, FALSE) == FAIL) |
7 | 276 return (pos_T *)NULL; |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
277 // Set lnum again, autocommands my have changed it |
30389
14c0d0c72bcd
patch 9.0.0530: using freed memory when autocmd changes mark
Bram Moolenaar <Bram@vim.org>
parents:
29239
diff
changeset
|
278 curwin->w_cursor = fmark.mark; |
7 | 279 pos = (pos_T *)-1; |
280 } | |
281 else | |
282 pos = &(jmp->fmark.mark); | |
283 return pos; | |
284 } | |
285 } | |
286 | |
287 /* | |
288 * Move "count" positions in the changelist (count may be negative). | |
289 */ | |
290 pos_T * | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
291 movechangelist(int count) |
7 | 292 { |
293 int n; | |
294 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
295 if (curbuf->b_changelistlen == 0) // nothing to jump to |
7 | 296 return (pos_T *)NULL; |
297 | |
298 n = curwin->w_changelistidx; | |
299 if (n + count < 0) | |
300 { | |
301 if (n == 0) | |
302 return (pos_T *)NULL; | |
303 n = 0; | |
304 } | |
305 else if (n + count >= curbuf->b_changelistlen) | |
306 { | |
307 if (n == curbuf->b_changelistlen - 1) | |
308 return (pos_T *)NULL; | |
309 n = curbuf->b_changelistlen - 1; | |
310 } | |
311 else | |
312 n += count; | |
313 curwin->w_changelistidx = n; | |
314 return curbuf->b_changelist + n; | |
315 } | |
316 | |
317 /* | |
4043 | 318 * Find mark "c" in buffer pointed to by "buf". |
706 | 319 * If "changefile" is TRUE it's allowed to edit another file for '0, 'A, etc. |
320 * If "fnum" is not NULL store the fnum there for '0, 'A etc., don't edit | |
321 * another file. | |
7 | 322 * Returns: |
323 * - pointer to pos_T if found. lnum is 0 when mark not set, -1 when mark is | |
324 * in another file which can't be gotten. (caller needs to check lnum!) | |
325 * - NULL if there is no mark called 'c'. | |
326 * - -1 if mark is in other file and jumped there (only if changefile is TRUE) | |
327 */ | |
328 pos_T * | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
329 getmark_buf(buf_T *buf, int c, int changefile) |
4043 | 330 { |
331 return getmark_buf_fnum(buf, c, changefile, NULL); | |
332 } | |
333 | |
334 pos_T * | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
335 getmark(int c, int changefile) |
706 | 336 { |
4043 | 337 return getmark_buf_fnum(curbuf, c, changefile, NULL); |
706 | 338 } |
339 | |
340 pos_T * | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
341 getmark_buf_fnum( |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
342 buf_T *buf, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
343 int c, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
344 int changefile, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
345 int *fnum) |
7 | 346 { |
347 pos_T *posp; | |
348 pos_T *startp, *endp; | |
349 static pos_T pos_copy; | |
350 | |
351 posp = NULL; | |
352 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
353 // Check for special key, can't be a mark name and might cause islower() |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
354 // to crash. |
7 | 355 if (c < 0) |
356 return posp; | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
357 if (c > '~') // check for islower()/isupper() |
7 | 358 ; |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
359 else if (c == '\'' || c == '`') // previous context mark |
7 | 360 { |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
361 pos_copy = curwin->w_pcmark; // need to make a copy because |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
362 posp = &pos_copy; // w_pcmark may be changed soon |
7 | 363 } |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
364 else if (c == '"') // to pos when leaving buffer |
4043 | 365 posp = &(buf->b_last_cursor); |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
366 else if (c == '^') // to where Insert mode stopped |
4043 | 367 posp = &(buf->b_last_insert); |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
368 else if (c == '.') // to where last change was made |
4043 | 369 posp = &(buf->b_last_change); |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
370 else if (c == '[') // to start of previous operator |
4043 | 371 posp = &(buf->b_op_start); |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
372 else if (c == ']') // to end of previous operator |
4043 | 373 posp = &(buf->b_op_end); |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
374 else if (c == '{' || c == '}') // to previous/next paragraph |
7 | 375 { |
376 pos_T pos; | |
377 oparg_T oa; | |
378 int slcb = listcmd_busy; | |
379 | |
380 pos = curwin->w_cursor; | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
381 listcmd_busy = TRUE; // avoid that '' is changed |
503 | 382 if (findpar(&oa.inclusive, |
383 c == '}' ? FORWARD : BACKWARD, 1L, NUL, FALSE)) | |
7 | 384 { |
385 pos_copy = curwin->w_cursor; | |
386 posp = &pos_copy; | |
387 } | |
388 curwin->w_cursor = pos; | |
389 listcmd_busy = slcb; | |
390 } | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
391 else if (c == '(' || c == ')') // to previous/next sentence |
7 | 392 { |
393 pos_T pos; | |
394 int slcb = listcmd_busy; | |
395 | |
396 pos = curwin->w_cursor; | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
397 listcmd_busy = TRUE; // avoid that '' is changed |
7 | 398 if (findsent(c == ')' ? FORWARD : BACKWARD, 1L)) |
399 { | |
400 pos_copy = curwin->w_cursor; | |
401 posp = &pos_copy; | |
402 } | |
403 curwin->w_cursor = pos; | |
404 listcmd_busy = slcb; | |
405 } | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
406 else if (c == '<' || c == '>') // start/end of visual area |
7 | 407 { |
4043 | 408 startp = &buf->b_visual.vi_start; |
409 endp = &buf->b_visual.vi_end; | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10730
diff
changeset
|
410 if (((c == '<') == LT_POS(*startp, *endp) || endp->lnum == 0) |
10730
44e9340dc604
patch 8.0.0255: setpos() does not use the buffer argument for all marks
Christian Brabandt <cb@256bit.org>
parents:
10285
diff
changeset
|
411 && startp->lnum != 0) |
7 | 412 posp = startp; |
413 else | |
414 posp = endp; | |
415 /* | |
416 * For Visual line mode, set mark at begin or end of line | |
417 */ | |
4043 | 418 if (buf->b_visual.vi_mode == 'V') |
7 | 419 { |
420 pos_copy = *posp; | |
421 posp = &pos_copy; | |
422 if (c == '<') | |
423 pos_copy.col = 0; | |
424 else | |
425 pos_copy.col = MAXCOL; | |
426 pos_copy.coladd = 0; | |
427 } | |
428 } | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
429 else if (ASCII_ISLOWER(c)) // normal named mark |
7 | 430 { |
4043 | 431 posp = &(buf->b_namedm[c - 'a']); |
7 | 432 } |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
433 else if (ASCII_ISUPPER(c) || VIM_ISDIGIT(c)) // named file mark |
7 | 434 { |
435 if (VIM_ISDIGIT(c)) | |
436 c = c - '0' + NMARKS; | |
437 else | |
438 c -= 'A'; | |
439 posp = &(namedfm[c].fmark.mark); | |
440 | |
441 if (namedfm[c].fmark.fnum == 0) | |
442 fname2fnum(&namedfm[c]); | |
706 | 443 |
444 if (fnum != NULL) | |
445 *fnum = namedfm[c].fmark.fnum; | |
4043 | 446 else if (namedfm[c].fmark.fnum != buf->b_fnum) |
7 | 447 { |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
448 // mark is in another file |
7 | 449 posp = &pos_copy; |
450 | |
451 if (namedfm[c].fmark.mark.lnum != 0 | |
452 && changefile && namedfm[c].fmark.fnum) | |
453 { | |
454 if (buflist_getfile(namedfm[c].fmark.fnum, | |
455 (linenr_T)1, GETF_SETMARK, FALSE) == OK) | |
456 { | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
457 // Set the lnum now, autocommands could have changed it |
7 | 458 curwin->w_cursor = namedfm[c].fmark.mark; |
459 return (pos_T *)-1; | |
460 } | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
461 pos_copy.lnum = -1; // can't get file |
7 | 462 } |
463 else | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
464 pos_copy.lnum = 0; // mark exists, but is not valid in |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
465 // current buffer |
7 | 466 } |
467 } | |
468 | |
469 return posp; | |
470 } | |
471 | |
472 /* | |
473 * Search for the next named mark in the current file. | |
474 * | |
475 * Returns pointer to pos_T of the next mark or NULL if no mark is found. | |
476 */ | |
477 pos_T * | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
478 getnextmark( |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
479 pos_T *startpos, // where to start |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
480 int dir, // direction for search |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
481 int begin_line) |
7 | 482 { |
483 int i; | |
484 pos_T *result = NULL; | |
485 pos_T pos; | |
486 | |
487 pos = *startpos; | |
488 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
489 // When searching backward and leaving the cursor on the first non-blank, |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
490 // position must be in a previous line. |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
491 // When searching forward and leaving the cursor on the first non-blank, |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
492 // position must be in a next line. |
7 | 493 if (dir == BACKWARD && begin_line) |
494 pos.col = 0; | |
495 else if (dir == FORWARD && begin_line) | |
496 pos.col = MAXCOL; | |
497 | |
498 for (i = 0; i < NMARKS; i++) | |
499 { | |
500 if (curbuf->b_namedm[i].lnum > 0) | |
501 { | |
502 if (dir == FORWARD) | |
503 { | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10730
diff
changeset
|
504 if ((result == NULL || LT_POS(curbuf->b_namedm[i], *result)) |
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10730
diff
changeset
|
505 && LT_POS(pos, curbuf->b_namedm[i])) |
7 | 506 result = &curbuf->b_namedm[i]; |
507 } | |
508 else | |
509 { | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10730
diff
changeset
|
510 if ((result == NULL || LT_POS(*result, curbuf->b_namedm[i])) |
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10730
diff
changeset
|
511 && LT_POS(curbuf->b_namedm[i], pos)) |
7 | 512 result = &curbuf->b_namedm[i]; |
513 } | |
514 } | |
515 } | |
516 | |
517 return result; | |
518 } | |
519 | |
520 /* | |
521 * For an xtended filemark: set the fnum from the fname. | |
522 * This is used for marks obtained from the .viminfo file. It's postponed | |
523 * until the mark is used to avoid a long startup delay. | |
524 */ | |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17464
diff
changeset
|
525 static void |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
526 fname2fnum(xfmark_T *fm) |
7 | 527 { |
528 char_u *p; | |
529 | |
31728
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
30389
diff
changeset
|
530 if (fm->fname == NULL) |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
30389
diff
changeset
|
531 return; |
1480 | 532 |
31728
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
30389
diff
changeset
|
533 /* |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
30389
diff
changeset
|
534 * First expand "~/" in the file name to the home directory. |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
30389
diff
changeset
|
535 * Don't expand the whole name, it may contain other '~' chars. |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
30389
diff
changeset
|
536 */ |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
30389
diff
changeset
|
537 if (fm->fname[0] == '~' && (fm->fname[1] == '/' |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
30389
diff
changeset
|
538 #ifdef BACKSLASH_IN_FILENAME |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
30389
diff
changeset
|
539 || fm->fname[1] == '\\' |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
30389
diff
changeset
|
540 #endif |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
30389
diff
changeset
|
541 )) |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
30389
diff
changeset
|
542 { |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
30389
diff
changeset
|
543 int len; |
1480 | 544 |
31728
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
30389
diff
changeset
|
545 expand_env((char_u *)"~/", NameBuff, MAXPATHL); |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
30389
diff
changeset
|
546 len = (int)STRLEN(NameBuff); |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
30389
diff
changeset
|
547 vim_strncpy(NameBuff + len, fm->fname + 2, MAXPATHL - len - 1); |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
30389
diff
changeset
|
548 } |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
30389
diff
changeset
|
549 else |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
30389
diff
changeset
|
550 vim_strncpy(NameBuff, fm->fname, MAXPATHL - 1); |
7 | 551 |
31728
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
30389
diff
changeset
|
552 // Try to shorten the file name. |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
30389
diff
changeset
|
553 mch_dirname(IObuff, IOSIZE); |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
30389
diff
changeset
|
554 p = shorten_fname(NameBuff, IObuff); |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
30389
diff
changeset
|
555 |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
30389
diff
changeset
|
556 // buflist_new() will call fmarks_check_names() |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
30389
diff
changeset
|
557 (void)buflist_new(NameBuff, p, (linenr_T)1, 0); |
7 | 558 } |
559 | |
560 /* | |
561 * Check all file marks for a name that matches the file name in buf. | |
562 * May replace the name with an fnum. | |
563 * Used for marks that come from the .viminfo file. | |
564 */ | |
565 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
566 fmarks_check_names(buf_T *buf) |
7 | 567 { |
568 char_u *name; | |
569 int i; | |
570 win_T *wp; | |
571 | |
572 if (buf->b_ffname == NULL) | |
573 return; | |
574 | |
575 name = home_replace_save(buf, buf->b_ffname); | |
576 if (name == NULL) | |
577 return; | |
578 | |
579 for (i = 0; i < NMARKS + EXTRA_MARKS; ++i) | |
580 fmarks_check_one(&namedfm[i], name, buf); | |
581 | |
582 FOR_ALL_WINDOWS(wp) | |
583 { | |
584 for (i = 0; i < wp->w_jumplistlen; ++i) | |
585 fmarks_check_one(&wp->w_jumplist[i], name, buf); | |
586 } | |
587 | |
588 vim_free(name); | |
589 } | |
590 | |
591 static void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
592 fmarks_check_one(xfmark_T *fm, char_u *name, buf_T *buf) |
7 | 593 { |
594 if (fm->fmark.fnum == 0 | |
595 && fm->fname != NULL | |
596 && fnamecmp(name, fm->fname) == 0) | |
597 { | |
598 fm->fmark.fnum = buf->b_fnum; | |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
599 VIM_CLEAR(fm->fname); |
7 | 600 } |
601 } | |
602 | |
603 /* | |
604 * Check a if a position from a mark is valid. | |
605 * Give and error message and return FAIL if not. | |
606 */ | |
607 int | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
608 check_mark(pos_T *pos) |
7 | 609 { |
610 if (pos == NULL) | |
611 { | |
26439
b18f3b0f317c
patch 8.2.3750: error messages are everywhere
Bram Moolenaar <Bram@vim.org>
parents:
25998
diff
changeset
|
612 emsg(_(e_unknown_mark)); |
7 | 613 return FAIL; |
614 } | |
615 if (pos->lnum <= 0) | |
616 { | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
617 // lnum is negative if mark is in another file can can't get that |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
618 // file, error message already give then. |
7 | 619 if (pos->lnum == 0) |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
23731
diff
changeset
|
620 emsg(_(e_mark_not_set)); |
7 | 621 return FAIL; |
622 } | |
623 if (pos->lnum > curbuf->b_ml.ml_line_count) | |
624 { | |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
23731
diff
changeset
|
625 emsg(_(e_mark_has_invalid_line_number)); |
7 | 626 return FAIL; |
627 } | |
628 return OK; | |
629 } | |
630 | |
631 /* | |
632 * clrallmarks() - clear all marks in the buffer 'buf' | |
633 * | |
634 * Used mainly when trashing the entire buffer during ":e" type commands | |
635 */ | |
636 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
637 clrallmarks(buf_T *buf) |
7 | 638 { |
639 static int i = -1; | |
640 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
641 if (i == -1) // first call ever: initialize |
7 | 642 for (i = 0; i < NMARKS + 1; i++) |
643 { | |
644 namedfm[i].fmark.mark.lnum = 0; | |
645 namedfm[i].fname = NULL; | |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
646 #ifdef FEAT_VIMINFO |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
647 namedfm[i].time_set = 0; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
648 #endif |
7 | 649 } |
650 | |
651 for (i = 0; i < NMARKS; i++) | |
652 buf->b_namedm[i].lnum = 0; | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
653 buf->b_op_start.lnum = 0; // start/end op mark cleared |
7 | 654 buf->b_op_end.lnum = 0; |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
655 buf->b_last_cursor.lnum = 1; // '" mark cleared |
7 | 656 buf->b_last_cursor.col = 0; |
657 buf->b_last_cursor.coladd = 0; | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
658 buf->b_last_insert.lnum = 0; // '^ mark cleared |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
659 buf->b_last_change.lnum = 0; // '. mark cleared |
7 | 660 buf->b_changelistlen = 0; |
661 } | |
662 | |
663 /* | |
664 * Get name of file from a filemark. | |
665 * When it's in the current buffer, return the text at the mark. | |
666 * Returns an allocated string. | |
667 */ | |
668 char_u * | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
669 fm_getname(fmark_T *fmark, int lead_len) |
7 | 670 { |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
671 if (fmark->fnum == curbuf->b_fnum) // current buffer |
7 | 672 return mark_line(&(fmark->mark), lead_len); |
673 return buflist_nr2name(fmark->fnum, FALSE, TRUE); | |
674 } | |
675 | |
676 /* | |
677 * Return the line at mark "mp". Truncate to fit in window. | |
678 * The returned string has been allocated. | |
679 */ | |
680 static char_u * | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
681 mark_line(pos_T *mp, int lead_len) |
7 | 682 { |
683 char_u *s, *p; | |
684 int len; | |
685 | |
686 if (mp->lnum == 0 || mp->lnum > curbuf->b_ml.ml_line_count) | |
687 return vim_strsave((char_u *)"-invalid-"); | |
14305
8a4c0ab88201
patch 8.1.0168: output of :marks is too short with multi-byte chars
Christian Brabandt <cb@256bit.org>
parents:
13278
diff
changeset
|
688 // Allow for up to 5 bytes per character. |
20830
9064044fd4f6
patch 8.2.0967: unnecessary type casts for vim_strnsave()
Bram Moolenaar <Bram@vim.org>
parents:
20635
diff
changeset
|
689 s = vim_strnsave(skipwhite(ml_get(mp->lnum)), Columns * 5); |
7 | 690 if (s == NULL) |
691 return NULL; | |
14305
8a4c0ab88201
patch 8.1.0168: output of :marks is too short with multi-byte chars
Christian Brabandt <cb@256bit.org>
parents:
13278
diff
changeset
|
692 // Truncate the line to fit it in the window. |
7 | 693 len = 0; |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11121
diff
changeset
|
694 for (p = s; *p != NUL; MB_PTR_ADV(p)) |
7 | 695 { |
696 len += ptr2cells(p); | |
697 if (len >= Columns - lead_len) | |
698 break; | |
699 } | |
700 *p = NUL; | |
701 return s; | |
702 } | |
703 | |
704 /* | |
705 * print the marks | |
706 */ | |
707 void | |
18126
f89e2e720b5b
patch 8.1.2058: function for ex command is named inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
708 ex_marks(exarg_T *eap) |
7 | 709 { |
710 char_u *arg = eap->arg; | |
711 int i; | |
712 char_u *name; | |
21403
d387121083a4
patch 8.2.1252: ":marks" may show '< and '> mixed up
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
713 pos_T *posp, *startp, *endp; |
7 | 714 |
715 if (arg != NULL && *arg == NUL) | |
716 arg = NULL; | |
717 | |
718 show_one_mark('\'', arg, &curwin->w_pcmark, NULL, TRUE); | |
719 for (i = 0; i < NMARKS; ++i) | |
720 show_one_mark(i + 'a', arg, &curbuf->b_namedm[i], NULL, TRUE); | |
721 for (i = 0; i < NMARKS + EXTRA_MARKS; ++i) | |
722 { | |
723 if (namedfm[i].fmark.fnum != 0) | |
724 name = fm_getname(&namedfm[i].fmark, 15); | |
725 else | |
726 name = namedfm[i].fname; | |
727 if (name != NULL) | |
728 { | |
729 show_one_mark(i >= NMARKS ? i - NMARKS + '0' : i + 'A', | |
730 arg, &namedfm[i].fmark.mark, name, | |
731 namedfm[i].fmark.fnum == curbuf->b_fnum); | |
732 if (namedfm[i].fmark.fnum != 0) | |
733 vim_free(name); | |
734 } | |
735 } | |
736 show_one_mark('"', arg, &curbuf->b_last_cursor, NULL, TRUE); | |
737 show_one_mark('[', arg, &curbuf->b_op_start, NULL, TRUE); | |
738 show_one_mark(']', arg, &curbuf->b_op_end, NULL, TRUE); | |
739 show_one_mark('^', arg, &curbuf->b_last_insert, NULL, TRUE); | |
740 show_one_mark('.', arg, &curbuf->b_last_change, NULL, TRUE); | |
21403
d387121083a4
patch 8.2.1252: ":marks" may show '< and '> mixed up
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
741 |
d387121083a4
patch 8.2.1252: ":marks" may show '< and '> mixed up
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
742 // Show the marks as where they will jump to. |
d387121083a4
patch 8.2.1252: ":marks" may show '< and '> mixed up
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
743 startp = &curbuf->b_visual.vi_start; |
d387121083a4
patch 8.2.1252: ":marks" may show '< and '> mixed up
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
744 endp = &curbuf->b_visual.vi_end; |
d387121083a4
patch 8.2.1252: ":marks" may show '< and '> mixed up
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
745 if ((LT_POS(*startp, *endp) || endp->lnum == 0) && startp->lnum != 0) |
d387121083a4
patch 8.2.1252: ":marks" may show '< and '> mixed up
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
746 posp = startp; |
d387121083a4
patch 8.2.1252: ":marks" may show '< and '> mixed up
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
747 else |
d387121083a4
patch 8.2.1252: ":marks" may show '< and '> mixed up
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
748 posp = endp; |
d387121083a4
patch 8.2.1252: ":marks" may show '< and '> mixed up
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
749 show_one_mark('<', arg, posp, NULL, TRUE); |
d387121083a4
patch 8.2.1252: ":marks" may show '< and '> mixed up
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
750 show_one_mark('>', arg, posp == startp ? endp : startp, NULL, TRUE); |
d387121083a4
patch 8.2.1252: ":marks" may show '< and '> mixed up
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
751 |
7 | 752 show_one_mark(-1, arg, NULL, NULL, FALSE); |
753 } | |
754 | |
755 static void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
756 show_one_mark( |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
757 int c, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
758 char_u *arg, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
759 pos_T *p, |
16433
9c206a78ec04
patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents:
15651
diff
changeset
|
760 char_u *name_arg, |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
761 int current) // in current file |
7 | 762 { |
763 static int did_title = FALSE; | |
764 int mustfree = FALSE; | |
16433
9c206a78ec04
patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents:
15651
diff
changeset
|
765 char_u *name = name_arg; |
7 | 766 |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
767 if (c == -1) // finish up |
7 | 768 { |
769 if (did_title) | |
770 did_title = FALSE; | |
771 else | |
772 { | |
773 if (arg == NULL) | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
774 msg(_("No marks set")); |
7 | 775 else |
26897
d02d40f0261c
patch 8.2.3977: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
776 semsg(_(e_no_marks_matching_str), arg); |
7 | 777 } |
778 } | |
16433
9c206a78ec04
patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents:
15651
diff
changeset
|
779 // don't output anything if 'q' typed at --more-- prompt |
7 | 780 else if (!got_int |
781 && (arg == NULL || vim_strchr(arg, c) != NULL) | |
782 && p->lnum != 0) | |
783 { | |
16433
9c206a78ec04
patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents:
15651
diff
changeset
|
784 if (name == NULL && current) |
7 | 785 { |
16433
9c206a78ec04
patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents:
15651
diff
changeset
|
786 name = mark_line(p, 15); |
9c206a78ec04
patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents:
15651
diff
changeset
|
787 mustfree = TRUE; |
7 | 788 } |
16433
9c206a78ec04
patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents:
15651
diff
changeset
|
789 if (!message_filtered(name)) |
7 | 790 { |
16433
9c206a78ec04
patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents:
15651
diff
changeset
|
791 if (!did_title) |
7 | 792 { |
16433
9c206a78ec04
patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents:
15651
diff
changeset
|
793 // Highlight title |
9c206a78ec04
patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents:
15651
diff
changeset
|
794 msg_puts_title(_("\nmark line col file/text")); |
9c206a78ec04
patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents:
15651
diff
changeset
|
795 did_title = TRUE; |
7 | 796 } |
16433
9c206a78ec04
patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents:
15651
diff
changeset
|
797 msg_putchar('\n'); |
9c206a78ec04
patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents:
15651
diff
changeset
|
798 if (!got_int) |
7 | 799 { |
16433
9c206a78ec04
patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents:
15651
diff
changeset
|
800 sprintf((char *)IObuff, " %c %6ld %4d ", c, p->lnum, p->col); |
9c206a78ec04
patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents:
15651
diff
changeset
|
801 msg_outtrans(IObuff); |
9c206a78ec04
patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents:
15651
diff
changeset
|
802 if (name != NULL) |
9c206a78ec04
patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents:
15651
diff
changeset
|
803 { |
9c206a78ec04
patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents:
15651
diff
changeset
|
804 msg_outtrans_attr(name, current ? HL_ATTR(HLF_D) : 0); |
9c206a78ec04
patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents:
15651
diff
changeset
|
805 } |
7 | 806 } |
16433
9c206a78ec04
patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents:
15651
diff
changeset
|
807 out_flush(); // show one line at a time |
7 | 808 } |
16433
9c206a78ec04
patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents:
15651
diff
changeset
|
809 if (mustfree) |
9c206a78ec04
patch 8.1.1221: filtering does not work when listing marks
Bram Moolenaar <Bram@vim.org>
parents:
15651
diff
changeset
|
810 vim_free(name); |
7 | 811 } |
812 } | |
813 | |
24 | 814 /* |
815 * ":delmarks[!] [marks]" | |
816 */ | |
817 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
818 ex_delmarks(exarg_T *eap) |
24 | 819 { |
820 char_u *p; | |
821 int from, to; | |
822 int i; | |
823 int lower; | |
824 int digit; | |
825 int n; | |
826 | |
827 if (*eap->arg == NUL && eap->forceit) | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
828 // clear all marks |
24 | 829 clrallmarks(curbuf); |
830 else if (eap->forceit) | |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26532
diff
changeset
|
831 emsg(_(e_invalid_argument)); |
24 | 832 else if (*eap->arg == NUL) |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26532
diff
changeset
|
833 emsg(_(e_argument_required)); |
24 | 834 else |
835 { | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
836 // clear specified marks only |
24 | 837 for (p = eap->arg; *p != NUL; ++p) |
838 { | |
839 lower = ASCII_ISLOWER(*p); | |
840 digit = VIM_ISDIGIT(*p); | |
841 if (lower || digit || ASCII_ISUPPER(*p)) | |
842 { | |
843 if (p[1] == '-') | |
844 { | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
845 // clear range of marks |
24 | 846 from = *p; |
847 to = p[2]; | |
848 if (!(lower ? ASCII_ISLOWER(p[2]) | |
849 : (digit ? VIM_ISDIGIT(p[2]) | |
850 : ASCII_ISUPPER(p[2]))) | |
851 || to < from) | |
852 { | |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26532
diff
changeset
|
853 semsg(_(e_invalid_argument_str), p); |
24 | 854 return; |
855 } | |
856 p += 2; | |
857 } | |
858 else | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
859 // clear one lower case mark |
24 | 860 from = to = *p; |
861 | |
862 for (i = from; i <= to; ++i) | |
863 { | |
864 if (lower) | |
865 curbuf->b_namedm[i - 'a'].lnum = 0; | |
866 else | |
867 { | |
868 if (digit) | |
869 n = i - '0' + NMARKS; | |
870 else | |
871 n = i - 'A'; | |
872 namedfm[n].fmark.mark.lnum = 0; | |
18979
de2d1820215a
patch 8.2.0050: after deleting a file mark it is still in viminfo
Bram Moolenaar <Bram@vim.org>
parents:
18800
diff
changeset
|
873 namedfm[n].fmark.fnum = 0; |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
874 VIM_CLEAR(namedfm[n].fname); |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
875 #ifdef FEAT_VIMINFO |
18979
de2d1820215a
patch 8.2.0050: after deleting a file mark it is still in viminfo
Bram Moolenaar <Bram@vim.org>
parents:
18800
diff
changeset
|
876 namedfm[n].time_set = digit ? 0 : vim_time(); |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
877 #endif |
24 | 878 } |
879 } | |
880 } | |
881 else | |
882 switch (*p) | |
883 { | |
884 case '"': curbuf->b_last_cursor.lnum = 0; break; | |
885 case '^': curbuf->b_last_insert.lnum = 0; break; | |
886 case '.': curbuf->b_last_change.lnum = 0; break; | |
887 case '[': curbuf->b_op_start.lnum = 0; break; | |
888 case ']': curbuf->b_op_end.lnum = 0; break; | |
690 | 889 case '<': curbuf->b_visual.vi_start.lnum = 0; break; |
890 case '>': curbuf->b_visual.vi_end.lnum = 0; break; | |
24 | 891 case ' ': break; |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26532
diff
changeset
|
892 default: semsg(_(e_invalid_argument_str), p); |
24 | 893 return; |
894 } | |
895 } | |
896 } | |
897 } | |
898 | |
7 | 899 /* |
900 * print the jumplist | |
901 */ | |
902 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
903 ex_jumps(exarg_T *eap UNUSED) |
7 | 904 { |
905 int i; | |
906 char_u *name; | |
907 | |
13278
28ae299c6af0
patch 8.0.1513: the jumplist is not always properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
13248
diff
changeset
|
908 cleanup_jumplist(curwin, TRUE); |
13248
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
909 |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
910 // Highlight title |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
911 msg_puts_title(_("\n jump line col file/text")); |
7 | 912 for (i = 0; i < curwin->w_jumplistlen && !got_int; ++i) |
913 { | |
914 if (curwin->w_jumplist[i].fmark.mark.lnum != 0) | |
915 { | |
916 name = fm_getname(&curwin->w_jumplist[i].fmark, 16); | |
14968
c5ec5ddbe814
patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents:
14305
diff
changeset
|
917 |
28388
320991d9812e
patch 8.2.4719: ">" marker sometimes not displayed in the jumplist
Bram Moolenaar <Bram@vim.org>
parents:
28247
diff
changeset
|
918 // Make sure to output the current indicator, even when on an wiped |
320991d9812e
patch 8.2.4719: ">" marker sometimes not displayed in the jumplist
Bram Moolenaar <Bram@vim.org>
parents:
28247
diff
changeset
|
919 // out buffer. ":filter" may still skip it. |
320991d9812e
patch 8.2.4719: ">" marker sometimes not displayed in the jumplist
Bram Moolenaar <Bram@vim.org>
parents:
28247
diff
changeset
|
920 if (name == NULL && i == curwin->w_jumplistidx) |
320991d9812e
patch 8.2.4719: ">" marker sometimes not displayed in the jumplist
Bram Moolenaar <Bram@vim.org>
parents:
28247
diff
changeset
|
921 name = vim_strsave((char_u *)"-invalid-"); |
14968
c5ec5ddbe814
patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents:
14305
diff
changeset
|
922 // apply :filter /pat/ or file name not available |
c5ec5ddbe814
patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents:
14305
diff
changeset
|
923 if (name == NULL || message_filtered(name)) |
15651
dd4e6f077874
patch 8.1.0833: memory leak when jumps output is filtered
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
924 { |
dd4e6f077874
patch 8.1.0833: memory leak when jumps output is filtered
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
925 vim_free(name); |
7 | 926 continue; |
15651
dd4e6f077874
patch 8.1.0833: memory leak when jumps output is filtered
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
927 } |
7 | 928 |
929 msg_putchar('\n'); | |
930 if (got_int) | |
1702 | 931 { |
932 vim_free(name); | |
7 | 933 break; |
1702 | 934 } |
7 | 935 sprintf((char *)IObuff, "%c %2d %5ld %4d ", |
936 i == curwin->w_jumplistidx ? '>' : ' ', | |
937 i > curwin->w_jumplistidx ? i - curwin->w_jumplistidx | |
938 : curwin->w_jumplistidx - i, | |
939 curwin->w_jumplist[i].fmark.mark.lnum, | |
940 curwin->w_jumplist[i].fmark.mark.col); | |
941 msg_outtrans(IObuff); | |
942 msg_outtrans_attr(name, | |
943 curwin->w_jumplist[i].fmark.fnum == curbuf->b_fnum | |
11158
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
11140
diff
changeset
|
944 ? HL_ATTR(HLF_D) : 0); |
7 | 945 vim_free(name); |
946 ui_breakcheck(); | |
947 } | |
948 out_flush(); | |
949 } | |
950 if (curwin->w_jumplistidx == curwin->w_jumplistlen) | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
951 msg_puts("\n>"); |
7 | 952 } |
953 | |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
954 void |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
955 ex_clearjumps(exarg_T *eap UNUSED) |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
956 { |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
957 free_jumplist(curwin); |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
958 curwin->w_jumplistlen = 0; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
959 curwin->w_jumplistidx = 0; |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
960 } |
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
961 |
7 | 962 /* |
963 * print the changelist | |
964 */ | |
965 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
966 ex_changes(exarg_T *eap UNUSED) |
7 | 967 { |
968 int i; | |
969 char_u *name; | |
970 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
971 // Highlight title |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
972 msg_puts_title(_("\nchange line col text")); |
7 | 973 |
974 for (i = 0; i < curbuf->b_changelistlen && !got_int; ++i) | |
975 { | |
976 if (curbuf->b_changelist[i].lnum != 0) | |
977 { | |
978 msg_putchar('\n'); | |
979 if (got_int) | |
980 break; | |
981 sprintf((char *)IObuff, "%c %3d %5ld %4d ", | |
982 i == curwin->w_changelistidx ? '>' : ' ', | |
983 i > curwin->w_changelistidx ? i - curwin->w_changelistidx | |
984 : curwin->w_changelistidx - i, | |
985 (long)curbuf->b_changelist[i].lnum, | |
986 curbuf->b_changelist[i].col); | |
987 msg_outtrans(IObuff); | |
988 name = mark_line(&curbuf->b_changelist[i], 17); | |
989 if (name == NULL) | |
990 break; | |
11158
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
11140
diff
changeset
|
991 msg_outtrans_attr(name, HL_ATTR(HLF_D)); |
7 | 992 vim_free(name); |
993 ui_breakcheck(); | |
994 } | |
995 out_flush(); | |
996 } | |
997 if (curwin->w_changelistidx == curbuf->b_changelistlen) | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
998 msg_puts("\n>"); |
7 | 999 } |
1000 | |
1001 #define one_adjust(add) \ | |
1002 { \ | |
1003 lp = add; \ | |
1004 if (*lp >= line1 && *lp <= line2) \ | |
1005 { \ | |
1006 if (amount == MAXLNUM) \ | |
1007 *lp = 0; \ | |
1008 else \ | |
1009 *lp += amount; \ | |
1010 } \ | |
1011 else if (amount_after && *lp > line2) \ | |
1012 *lp += amount_after; \ | |
1013 } | |
1014 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1015 // don't delete the line, just put at first deleted line |
7 | 1016 #define one_adjust_nodel(add) \ |
1017 { \ | |
1018 lp = add; \ | |
1019 if (*lp >= line1 && *lp <= line2) \ | |
1020 { \ | |
1021 if (amount == MAXLNUM) \ | |
1022 *lp = line1; \ | |
1023 else \ | |
1024 *lp += amount; \ | |
1025 } \ | |
1026 else if (amount_after && *lp > line2) \ | |
1027 *lp += amount_after; \ | |
1028 } | |
1029 | |
1030 /* | |
32288
8201b0fcea02
patch 9.0.1476: lines put in non-current window are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
31728
diff
changeset
|
1031 * Adjust marks between "line1" and "line2" (inclusive) to move "amount" lines. |
7 | 1032 * Must be called before changed_*(), appended_lines() or deleted_lines(). |
1033 * May be called before or after changing the text. | |
32288
8201b0fcea02
patch 9.0.1476: lines put in non-current window are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
31728
diff
changeset
|
1034 * When deleting lines "line1" to "line2", use an "amount" of MAXLNUM: The |
8201b0fcea02
patch 9.0.1476: lines put in non-current window are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
31728
diff
changeset
|
1035 * marks within this range are made invalid. |
8201b0fcea02
patch 9.0.1476: lines put in non-current window are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
31728
diff
changeset
|
1036 * If "amount_after" is non-zero adjust marks after "line2". |
7 | 1037 * Example: Delete lines 34 and 35: mark_adjust(34, 35, MAXLNUM, -2); |
1038 * Example: Insert two lines below 55: mark_adjust(56, MAXLNUM, 2, 0); | |
1039 * or: mark_adjust(56, 55, MAXLNUM, 2); | |
1040 */ | |
1041 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1042 mark_adjust( |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1043 linenr_T line1, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1044 linenr_T line2, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1045 long amount, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1046 long amount_after) |
7 | 1047 { |
11140
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1048 mark_adjust_internal(line1, line2, amount, amount_after, TRUE); |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1049 } |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1050 |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1051 void |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1052 mark_adjust_nofold( |
28247
f70015784777
patch 8.2.4649: various formatting problems
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
1053 linenr_T line1, |
f70015784777
patch 8.2.4649: various formatting problems
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
1054 linenr_T line2, |
f70015784777
patch 8.2.4649: various formatting problems
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
1055 long amount, |
f70015784777
patch 8.2.4649: various formatting problems
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
1056 long amount_after) |
11140
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1057 { |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1058 mark_adjust_internal(line1, line2, amount, amount_after, FALSE); |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1059 } |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1060 |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1061 static void |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1062 mark_adjust_internal( |
28247
f70015784777
patch 8.2.4649: various formatting problems
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
1063 linenr_T line1, |
f70015784777
patch 8.2.4649: various formatting problems
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
1064 linenr_T line2, |
f70015784777
patch 8.2.4649: various formatting problems
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
1065 long amount, |
f70015784777
patch 8.2.4649: various formatting problems
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
1066 long amount_after, |
f70015784777
patch 8.2.4649: various formatting problems
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
1067 int adjust_folds UNUSED) |
11140
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1068 { |
7 | 1069 int i; |
1070 int fnum = curbuf->b_fnum; | |
1071 linenr_T *lp; | |
1072 win_T *win; | |
1863 | 1073 tabpage_T *tab; |
15636
6f1c7e9a6393
patch 8.1.0826: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
1074 static pos_T initpos = {1, 0, 0}; |
7 | 1075 |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1076 if (line2 < line1 && amount_after == 0L) // nothing to do |
7 | 1077 return; |
1078 | |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
21403
diff
changeset
|
1079 if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) |
7 | 1080 { |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1081 // named marks, lower case and upper case |
7 | 1082 for (i = 0; i < NMARKS; i++) |
1083 { | |
1084 one_adjust(&(curbuf->b_namedm[i].lnum)); | |
1085 if (namedfm[i].fmark.fnum == fnum) | |
1086 one_adjust_nodel(&(namedfm[i].fmark.mark.lnum)); | |
1087 } | |
1088 for (i = NMARKS; i < NMARKS + EXTRA_MARKS; i++) | |
1089 { | |
1090 if (namedfm[i].fmark.fnum == fnum) | |
1091 one_adjust_nodel(&(namedfm[i].fmark.mark.lnum)); | |
1092 } | |
1093 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1094 // last Insert position |
7 | 1095 one_adjust(&(curbuf->b_last_insert.lnum)); |
1096 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1097 // last change position |
7 | 1098 one_adjust(&(curbuf->b_last_change.lnum)); |
1099 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1100 // last cursor position, if it was set |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10730
diff
changeset
|
1101 if (!EQUAL_POS(curbuf->b_last_cursor, initpos)) |
4092 | 1102 one_adjust(&(curbuf->b_last_cursor.lnum)); |
1103 | |
1104 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1105 // list of change positions |
7 | 1106 for (i = 0; i < curbuf->b_changelistlen; ++i) |
1107 one_adjust_nodel(&(curbuf->b_changelist[i].lnum)); | |
1108 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1109 // Visual area |
690 | 1110 one_adjust_nodel(&(curbuf->b_visual.vi_start.lnum)); |
1111 one_adjust_nodel(&(curbuf->b_visual.vi_end.lnum)); | |
7 | 1112 |
1113 #ifdef FEAT_QUICKFIX | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1114 // quickfix marks |
643 | 1115 qf_mark_adjust(NULL, line1, line2, amount, amount_after); |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1116 // location lists |
1863 | 1117 FOR_ALL_TAB_WINDOWS(tab, win) |
643 | 1118 qf_mark_adjust(win, line1, line2, amount, amount_after); |
7 | 1119 #endif |
1120 | |
1121 #ifdef FEAT_SIGNS | |
1122 sign_mark_adjust(line1, line2, amount, amount_after); | |
1123 #endif | |
1124 } | |
1125 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1126 // previous context mark |
7 | 1127 one_adjust(&(curwin->w_pcmark.lnum)); |
1128 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1129 // previous pcmark |
7 | 1130 one_adjust(&(curwin->w_prev_pcmark.lnum)); |
1131 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1132 // saved cursor for formatting |
7 | 1133 if (saved_cursor.lnum != 0) |
1134 one_adjust_nodel(&(saved_cursor.lnum)); | |
1135 | |
1136 /* | |
1137 * Adjust items in all windows related to the current buffer. | |
1138 */ | |
1863 | 1139 FOR_ALL_TAB_WINDOWS(tab, win) |
7 | 1140 { |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
21403
diff
changeset
|
1141 if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1142 // Marks in the jumplist. When deleting lines, this may create |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1143 // duplicate marks in the jumplist, they will be removed later. |
7 | 1144 for (i = 0; i < win->w_jumplistlen; ++i) |
1145 if (win->w_jumplist[i].fmark.fnum == fnum) | |
1146 one_adjust_nodel(&(win->w_jumplist[i].fmark.mark.lnum)); | |
1147 | |
1148 if (win->w_buffer == curbuf) | |
1149 { | |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
21403
diff
changeset
|
1150 if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1151 // marks in the tag stack |
7 | 1152 for (i = 0; i < win->w_tagstacklen; i++) |
1153 if (win->w_tagstack[i].fmark.fnum == fnum) | |
1154 one_adjust_nodel(&(win->w_tagstack[i].fmark.mark.lnum)); | |
1155 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1156 // the displayed Visual area |
7 | 1157 if (win->w_old_cursor_lnum != 0) |
1158 { | |
1159 one_adjust_nodel(&(win->w_old_cursor_lnum)); | |
1160 one_adjust_nodel(&(win->w_old_visual_lnum)); | |
1161 } | |
1162 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1163 // topline and cursor position for windows with the same buffer |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1164 // other than the current window |
7 | 1165 if (win != curwin) |
1166 { | |
1167 if (win->w_topline >= line1 && win->w_topline <= line2) | |
1168 { | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1169 if (amount == MAXLNUM) // topline is deleted |
7 | 1170 { |
1171 if (line1 <= 1) | |
1172 win->w_topline = 1; | |
1173 else | |
1174 win->w_topline = line1 - 1; | |
1175 } | |
32288
8201b0fcea02
patch 9.0.1476: lines put in non-current window are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
31728
diff
changeset
|
1176 else if (win->w_topline > line1) |
8201b0fcea02
patch 9.0.1476: lines put in non-current window are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
31728
diff
changeset
|
1177 // keep topline on the same line, unless inserting just |
8201b0fcea02
patch 9.0.1476: lines put in non-current window are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
31728
diff
changeset
|
1178 // above it (we probably want to see that line then) |
7 | 1179 win->w_topline += amount; |
1180 #ifdef FEAT_DIFF | |
1181 win->w_topfill = 0; | |
1182 #endif | |
1183 } | |
1184 else if (amount_after && win->w_topline > line2) | |
1185 { | |
1186 win->w_topline += amount_after; | |
1187 #ifdef FEAT_DIFF | |
1188 win->w_topfill = 0; | |
1189 #endif | |
1190 } | |
1191 if (win->w_cursor.lnum >= line1 && win->w_cursor.lnum <= line2) | |
1192 { | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1193 if (amount == MAXLNUM) // line with cursor is deleted |
7 | 1194 { |
1195 if (line1 <= 1) | |
1196 win->w_cursor.lnum = 1; | |
1197 else | |
1198 win->w_cursor.lnum = line1 - 1; | |
1199 win->w_cursor.col = 0; | |
1200 } | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1201 else // keep cursor on the same line |
7 | 1202 win->w_cursor.lnum += amount; |
1203 } | |
1204 else if (amount_after && win->w_cursor.lnum > line2) | |
1205 win->w_cursor.lnum += amount_after; | |
1206 } | |
1207 | |
1208 #ifdef FEAT_FOLDING | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1209 // adjust folds |
11140
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1210 if (adjust_folds) |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
1211 foldMarkAdjust(win, line1, line2, amount, amount_after); |
7 | 1212 #endif |
1213 } | |
1214 } | |
1215 | |
1216 #ifdef FEAT_DIFF | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1217 // adjust diffs |
7 | 1218 diff_mark_adjust(line1, line2, amount, amount_after); |
1219 #endif | |
1220 } | |
1221 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1222 // This code is used often, needs to be fast. |
7 | 1223 #define col_adjust(pp) \ |
1224 { \ | |
1225 posp = pp; \ | |
1226 if (posp->lnum == lnum && posp->col >= mincol) \ | |
1227 { \ | |
1228 posp->lnum += lnum_amount; \ | |
1229 if (col_amount < 0 && posp->col <= (colnr_T)-col_amount) \ | |
1230 posp->col = 0; \ | |
15326
fe428bee74b3
patch 8.1.0671: cursor in the wrong column after auto-formatting
Bram Moolenaar <Bram@vim.org>
parents:
14968
diff
changeset
|
1231 else if (posp->col < spaces_removed) \ |
fe428bee74b3
patch 8.1.0671: cursor in the wrong column after auto-formatting
Bram Moolenaar <Bram@vim.org>
parents:
14968
diff
changeset
|
1232 posp->col = col_amount + spaces_removed; \ |
7 | 1233 else \ |
1234 posp->col += col_amount; \ | |
1235 } \ | |
1236 } | |
1237 | |
1238 /* | |
1239 * Adjust marks in line "lnum" at column "mincol" and further: add | |
1240 * "lnum_amount" to the line number and add "col_amount" to the column | |
1241 * position. | |
15326
fe428bee74b3
patch 8.1.0671: cursor in the wrong column after auto-formatting
Bram Moolenaar <Bram@vim.org>
parents:
14968
diff
changeset
|
1242 * "spaces_removed" is the number of spaces that were removed, matters when the |
fe428bee74b3
patch 8.1.0671: cursor in the wrong column after auto-formatting
Bram Moolenaar <Bram@vim.org>
parents:
14968
diff
changeset
|
1243 * cursor is inside them. |
7 | 1244 */ |
1245 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1246 mark_col_adjust( |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1247 linenr_T lnum, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1248 colnr_T mincol, |
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1249 long lnum_amount, |
15326
fe428bee74b3
patch 8.1.0671: cursor in the wrong column after auto-formatting
Bram Moolenaar <Bram@vim.org>
parents:
14968
diff
changeset
|
1250 long col_amount, |
fe428bee74b3
patch 8.1.0671: cursor in the wrong column after auto-formatting
Bram Moolenaar <Bram@vim.org>
parents:
14968
diff
changeset
|
1251 int spaces_removed) |
7 | 1252 { |
1253 int i; | |
1254 int fnum = curbuf->b_fnum; | |
1255 win_T *win; | |
1256 pos_T *posp; | |
1257 | |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
21403
diff
changeset
|
1258 if ((col_amount == 0L && lnum_amount == 0L) |
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
21403
diff
changeset
|
1259 || (cmdmod.cmod_flags & CMOD_LOCKMARKS)) |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1260 return; // nothing to do |
7 | 1261 |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1262 // named marks, lower case and upper case |
7 | 1263 for (i = 0; i < NMARKS; i++) |
1264 { | |
1265 col_adjust(&(curbuf->b_namedm[i])); | |
1266 if (namedfm[i].fmark.fnum == fnum) | |
1267 col_adjust(&(namedfm[i].fmark.mark)); | |
1268 } | |
1269 for (i = NMARKS; i < NMARKS + EXTRA_MARKS; i++) | |
1270 { | |
1271 if (namedfm[i].fmark.fnum == fnum) | |
1272 col_adjust(&(namedfm[i].fmark.mark)); | |
1273 } | |
1274 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1275 // last Insert position |
7 | 1276 col_adjust(&(curbuf->b_last_insert)); |
1277 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1278 // last change position |
7 | 1279 col_adjust(&(curbuf->b_last_change)); |
1280 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1281 // list of change positions |
7 | 1282 for (i = 0; i < curbuf->b_changelistlen; ++i) |
1283 col_adjust(&(curbuf->b_changelist[i])); | |
1284 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1285 // Visual area |
690 | 1286 col_adjust(&(curbuf->b_visual.vi_start)); |
1287 col_adjust(&(curbuf->b_visual.vi_end)); | |
7 | 1288 |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1289 // previous context mark |
7 | 1290 col_adjust(&(curwin->w_pcmark)); |
1291 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1292 // previous pcmark |
7 | 1293 col_adjust(&(curwin->w_prev_pcmark)); |
1294 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1295 // saved cursor for formatting |
7 | 1296 col_adjust(&saved_cursor); |
1297 | |
1298 /* | |
1299 * Adjust items in all windows related to the current buffer. | |
1300 */ | |
1301 FOR_ALL_WINDOWS(win) | |
1302 { | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1303 // marks in the jumplist |
7 | 1304 for (i = 0; i < win->w_jumplistlen; ++i) |
1305 if (win->w_jumplist[i].fmark.fnum == fnum) | |
1306 col_adjust(&(win->w_jumplist[i].fmark.mark)); | |
1307 | |
1308 if (win->w_buffer == curbuf) | |
1309 { | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1310 // marks in the tag stack |
7 | 1311 for (i = 0; i < win->w_tagstacklen; i++) |
1312 if (win->w_tagstack[i].fmark.fnum == fnum) | |
1313 col_adjust(&(win->w_tagstack[i].fmark.mark)); | |
1314 | |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1315 // cursor position for other windows with the same buffer |
7 | 1316 if (win != curwin) |
1317 col_adjust(&win->w_cursor); | |
1318 } | |
1319 } | |
1320 } | |
1321 | |
1322 /* | |
1323 * When deleting lines, this may create duplicate marks in the | |
13248
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1324 * jumplist. They will be removed here for the specified window. |
13278
28ae299c6af0
patch 8.0.1513: the jumplist is not always properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
13248
diff
changeset
|
1325 * When "loadfiles" is TRUE first ensure entries have the "fnum" field set |
28ae299c6af0
patch 8.0.1513: the jumplist is not always properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
13248
diff
changeset
|
1326 * (this may be a bit slow). |
7 | 1327 */ |
13248
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1328 void |
13278
28ae299c6af0
patch 8.0.1513: the jumplist is not always properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
13248
diff
changeset
|
1329 cleanup_jumplist(win_T *wp, int loadfiles) |
7 | 1330 { |
1331 int i; | |
1332 int from, to; | |
33311
1f3bcb7f3bd0
patch 9.0.1921: not possible to use the jumplist like a stack
Christian Brabandt <cb@256bit.org>
parents:
32288
diff
changeset
|
1333 int mustfree; |
7 | 1334 |
13278
28ae299c6af0
patch 8.0.1513: the jumplist is not always properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
13248
diff
changeset
|
1335 if (loadfiles) |
28ae299c6af0
patch 8.0.1513: the jumplist is not always properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
13248
diff
changeset
|
1336 { |
18800
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1337 // If specified, load all the files from the jump list. This is |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1338 // needed to properly clean up duplicate entries, but will take some |
f41b55f9357c
patch 8.1.2388: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18126
diff
changeset
|
1339 // time. |
13278
28ae299c6af0
patch 8.0.1513: the jumplist is not always properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
13248
diff
changeset
|
1340 for (i = 0; i < wp->w_jumplistlen; ++i) |
28ae299c6af0
patch 8.0.1513: the jumplist is not always properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
13248
diff
changeset
|
1341 { |
28ae299c6af0
patch 8.0.1513: the jumplist is not always properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
13248
diff
changeset
|
1342 if ((wp->w_jumplist[i].fmark.fnum == 0) && |
28ae299c6af0
patch 8.0.1513: the jumplist is not always properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
13248
diff
changeset
|
1343 (wp->w_jumplist[i].fmark.mark.lnum != 0)) |
28ae299c6af0
patch 8.0.1513: the jumplist is not always properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
13248
diff
changeset
|
1344 fname2fnum(&wp->w_jumplist[i]); |
28ae299c6af0
patch 8.0.1513: the jumplist is not always properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
13248
diff
changeset
|
1345 } |
28ae299c6af0
patch 8.0.1513: the jumplist is not always properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
13248
diff
changeset
|
1346 } |
28ae299c6af0
patch 8.0.1513: the jumplist is not always properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
13248
diff
changeset
|
1347 |
7 | 1348 to = 0; |
13248
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1349 for (from = 0; from < wp->w_jumplistlen; ++from) |
7 | 1350 { |
13248
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1351 if (wp->w_jumplistidx == from) |
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1352 wp->w_jumplistidx = to; |
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1353 for (i = from + 1; i < wp->w_jumplistlen; ++i) |
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1354 if (wp->w_jumplist[i].fmark.fnum |
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1355 == wp->w_jumplist[from].fmark.fnum |
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1356 && wp->w_jumplist[from].fmark.fnum != 0 |
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1357 && wp->w_jumplist[i].fmark.mark.lnum |
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1358 == wp->w_jumplist[from].fmark.mark.lnum) |
7 | 1359 break; |
33311
1f3bcb7f3bd0
patch 9.0.1921: not possible to use the jumplist like a stack
Christian Brabandt <cb@256bit.org>
parents:
32288
diff
changeset
|
1360 if (i >= wp->w_jumplistlen) // not duplicate |
1f3bcb7f3bd0
patch 9.0.1921: not possible to use the jumplist like a stack
Christian Brabandt <cb@256bit.org>
parents:
32288
diff
changeset
|
1361 mustfree = FALSE; |
1f3bcb7f3bd0
patch 9.0.1921: not possible to use the jumplist like a stack
Christian Brabandt <cb@256bit.org>
parents:
32288
diff
changeset
|
1362 else if (i > from + 1) // non-adjacent duplicate |
1f3bcb7f3bd0
patch 9.0.1921: not possible to use the jumplist like a stack
Christian Brabandt <cb@256bit.org>
parents:
32288
diff
changeset
|
1363 // jumpoptions=stack: remove duplicates only when adjacent. |
1f3bcb7f3bd0
patch 9.0.1921: not possible to use the jumplist like a stack
Christian Brabandt <cb@256bit.org>
parents:
32288
diff
changeset
|
1364 mustfree = !(jop_flags & JOP_STACK); |
1f3bcb7f3bd0
patch 9.0.1921: not possible to use the jumplist like a stack
Christian Brabandt <cb@256bit.org>
parents:
32288
diff
changeset
|
1365 else // adjacent duplicate |
1f3bcb7f3bd0
patch 9.0.1921: not possible to use the jumplist like a stack
Christian Brabandt <cb@256bit.org>
parents:
32288
diff
changeset
|
1366 mustfree = TRUE; |
1f3bcb7f3bd0
patch 9.0.1921: not possible to use the jumplist like a stack
Christian Brabandt <cb@256bit.org>
parents:
32288
diff
changeset
|
1367 |
1f3bcb7f3bd0
patch 9.0.1921: not possible to use the jumplist like a stack
Christian Brabandt <cb@256bit.org>
parents:
32288
diff
changeset
|
1368 if (mustfree) |
1f3bcb7f3bd0
patch 9.0.1921: not possible to use the jumplist like a stack
Christian Brabandt <cb@256bit.org>
parents:
32288
diff
changeset
|
1369 vim_free(wp->w_jumplist[from].fname); |
1f3bcb7f3bd0
patch 9.0.1921: not possible to use the jumplist like a stack
Christian Brabandt <cb@256bit.org>
parents:
32288
diff
changeset
|
1370 else |
13248
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1371 wp->w_jumplist[to++] = wp->w_jumplist[from]; |
7 | 1372 } |
13248
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1373 if (wp->w_jumplistidx == wp->w_jumplistlen) |
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1374 wp->w_jumplistidx = to; |
5958573d8a72
patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1375 wp->w_jumplistlen = to; |
7 | 1376 } |
1377 | |
1378 /* | |
1379 * Copy the jumplist from window "from" to window "to". | |
1380 */ | |
1381 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1382 copy_jumplist(win_T *from, win_T *to) |
7 | 1383 { |
1384 int i; | |
1385 | |
1386 for (i = 0; i < from->w_jumplistlen; ++i) | |
1387 { | |
1388 to->w_jumplist[i] = from->w_jumplist[i]; | |
1389 if (from->w_jumplist[i].fname != NULL) | |
1390 to->w_jumplist[i].fname = vim_strsave(from->w_jumplist[i].fname); | |
1391 } | |
1392 to->w_jumplistlen = from->w_jumplistlen; | |
1393 to->w_jumplistidx = from->w_jumplistidx; | |
1394 } | |
1395 | |
1396 /* | |
1397 * Free items in the jumplist of window "wp". | |
1398 */ | |
1399 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1400 free_jumplist(win_T *wp) |
7 | 1401 { |
1402 int i; | |
1403 | |
1404 for (i = 0; i < wp->w_jumplistlen; ++i) | |
1405 vim_free(wp->w_jumplist[i].fname); | |
1406 } | |
1407 | |
1408 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1409 set_last_cursor(win_T *win) |
7 | 1410 { |
5417 | 1411 if (win->w_buffer != NULL) |
1412 win->w_buffer->b_last_cursor = win->w_cursor; | |
7 | 1413 } |
1414 | |
358 | 1415 #if defined(EXITFREE) || defined(PROTO) |
1416 void | |
7827
41789f16d6b2
commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1417 free_all_marks(void) |
358 | 1418 { |
1419 int i; | |
1420 | |
1421 for (i = 0; i < NMARKS + EXTRA_MARKS; i++) | |
1422 if (namedfm[i].fmark.mark.lnum != 0) | |
1423 vim_free(namedfm[i].fname); | |
1424 } | |
1425 #endif | |
1426 | |
27018
268f6a3511df
patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents:
26897
diff
changeset
|
1427 #if defined(FEAT_VIMINFO) || defined(PROTO) |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1428 /* |
17464
3e708b5c0509
patch 8.1.1730: wrong place for mark viminfo support
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1429 * Return a pointer to the named file marks. |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
7827
diff
changeset
|
1430 */ |
17464
3e708b5c0509
patch 8.1.1730: wrong place for mark viminfo support
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1431 xfmark_T * |
3e708b5c0509
patch 8.1.1730: wrong place for mark viminfo support
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1432 get_namedfm(void) |
7 | 1433 { |
17464
3e708b5c0509
patch 8.1.1730: wrong place for mark viminfo support
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1434 return namedfm; |
7 | 1435 } |
27018
268f6a3511df
patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents:
26897
diff
changeset
|
1436 #endif |
20615
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1437 |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1438 #if defined(FEAT_EVAL) || defined(PROTO) |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1439 /* |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1440 * Add information about mark 'mname' to list 'l' |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1441 */ |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1442 static int |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1443 add_mark(list_T *l, char_u *mname, pos_T *pos, int bufnr, char_u *fname) |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1444 { |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1445 dict_T *d; |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1446 list_T *lpos; |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1447 |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1448 if (pos->lnum <= 0) |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1449 return OK; |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1450 |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1451 d = dict_alloc(); |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1452 if (d == NULL) |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1453 return FAIL; |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1454 |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1455 if (list_append_dict(l, d) == FAIL) |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1456 { |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1457 dict_unref(d); |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1458 return FAIL; |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1459 } |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1460 |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1461 lpos = list_alloc(); |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1462 if (lpos == NULL) |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1463 return FAIL; |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1464 |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1465 list_append_number(lpos, bufnr); |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1466 list_append_number(lpos, pos->lnum); |
20635
3e36a51ff152
patch 8.2.0871: cannot use getmarklist() as a method
Bram Moolenaar <Bram@vim.org>
parents:
20615
diff
changeset
|
1467 list_append_number(lpos, pos->col + 1); |
20615
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1468 list_append_number(lpos, pos->coladd); |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1469 |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1470 if (dict_add_string(d, "mark", mname) == FAIL |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1471 || dict_add_list(d, "pos", lpos) == FAIL |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1472 || (fname != NULL && dict_add_string(d, "file", fname) == FAIL)) |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1473 return FAIL; |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1474 |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1475 return OK; |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1476 } |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1477 |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1478 /* |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1479 * Get information about marks local to a buffer. |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1480 */ |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1481 static void |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1482 get_buf_local_marks(buf_T *buf, list_T *l) |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1483 { |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1484 char_u mname[3] = "' "; |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1485 int i; |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1486 |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1487 // Marks 'a' to 'z' |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1488 for (i = 0; i < NMARKS; ++i) |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1489 { |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1490 mname[1] = 'a' + i; |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1491 add_mark(l, mname, &buf->b_namedm[i], buf->b_fnum, NULL); |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1492 } |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1493 |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1494 // Mark '' is a window local mark and not a buffer local mark |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1495 add_mark(l, (char_u *)"''", &curwin->w_pcmark, curbuf->b_fnum, NULL); |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1496 |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1497 add_mark(l, (char_u *)"'\"", &buf->b_last_cursor, buf->b_fnum, NULL); |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1498 add_mark(l, (char_u *)"'[", &buf->b_op_start, buf->b_fnum, NULL); |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1499 add_mark(l, (char_u *)"']", &buf->b_op_end, buf->b_fnum, NULL); |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1500 add_mark(l, (char_u *)"'^", &buf->b_last_insert, buf->b_fnum, NULL); |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1501 add_mark(l, (char_u *)"'.", &buf->b_last_change, buf->b_fnum, NULL); |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1502 add_mark(l, (char_u *)"'<", &buf->b_visual.vi_start, buf->b_fnum, NULL); |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1503 add_mark(l, (char_u *)"'>", &buf->b_visual.vi_end, buf->b_fnum, NULL); |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1504 } |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1505 |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1506 /* |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1507 * Get information about global marks ('A' to 'Z' and '0' to '9') |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1508 */ |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1509 static void |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1510 get_global_marks(list_T *l) |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1511 { |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1512 char_u mname[3] = "' "; |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1513 int i; |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1514 char_u *name; |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1515 |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1516 // Marks 'A' to 'Z' and '0' to '9' |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1517 for (i = 0; i < NMARKS + EXTRA_MARKS; ++i) |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1518 { |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1519 if (namedfm[i].fmark.fnum != 0) |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1520 name = buflist_nr2name(namedfm[i].fmark.fnum, TRUE, TRUE); |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1521 else |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1522 name = namedfm[i].fname; |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1523 if (name != NULL) |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1524 { |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1525 mname[1] = i >= NMARKS ? i - NMARKS + '0' : i + 'A'; |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1526 add_mark(l, mname, &namedfm[i].fmark.mark, |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1527 namedfm[i].fmark.fnum, name); |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1528 if (namedfm[i].fmark.fnum != 0) |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1529 vim_free(name); |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1530 } |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1531 } |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1532 } |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1533 |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1534 /* |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1535 * getmarklist() function |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1536 */ |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1537 void |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1538 f_getmarklist(typval_T *argvars, typval_T *rettv) |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1539 { |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1540 buf_T *buf = NULL; |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1541 |
29239
da56650de132
patch 8.2.5138: various small issues
Bram Moolenaar <Bram@vim.org>
parents:
28388
diff
changeset
|
1542 if (rettv_list_alloc(rettv) == FAIL) |
20615
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1543 return; |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1544 |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25064
diff
changeset
|
1545 if (in_vim9script() && check_for_opt_buffer_arg(argvars, 0) == FAIL) |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25064
diff
changeset
|
1546 return; |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25064
diff
changeset
|
1547 |
20615
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1548 if (argvars[0].v_type == VAR_UNKNOWN) |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1549 { |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1550 get_global_marks(rettv->vval.v_list); |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1551 return; |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1552 } |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1553 |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1554 buf = tv_get_buf(&argvars[0], FALSE); |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1555 if (buf == NULL) |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1556 return; |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1557 |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1558 get_buf_local_marks(buf, rettv->vval.v_list); |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1559 } |
8eed1e9389bb
patch 8.2.0861: cannot easily get all the current marks
Bram Moolenaar <Bram@vim.org>
parents:
18979
diff
changeset
|
1560 #endif |