annotate src/mark.c @ 26931:6cdf92e77a91 v8.2.3994

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