Mercurial > vim
annotate src/getchar.c @ 22053:0794909e2988 v8.2.1576
patch 8.2.1576: Vim9: index() does not take "true" as argument
Commit: https://github.com/vim/vim/commit/6c553f9c04a698ac2e19584f8ea8e2cb7cd98c80
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Sep 2 22:10:34 2020 +0200
patch 8.2.1576: Vim9: index() does not take "true" as argument
Problem: Vim9: index() does not take "true" as argument.
Solution: Use tv_get_bool_chk(). (closes https://github.com/vim/vim/issues/6823)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 02 Sep 2020 22:15:03 +0200 |
parents | bb0c4325a712 |
children | 679269735ec3 |
rev | line source |
---|---|
10042
4aead6a9b7a9
commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents:
9980
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
7 | 2 * |
3 * VIM - Vi IMproved by Bram Moolenaar | |
4 * | |
5 * Do ":help uganda" in Vim to read copying and usage conditions. | |
6 * Do ":help credits" in Vim to see a list of people who contributed. | |
7 * See README.txt for an overview of the Vim source code. | |
8 */ | |
9 | |
10 /* | |
11 * getchar.c | |
12 * | |
13 * functions related with getting a character from the user/mapping/redo/... | |
14 * | |
15 * manipulations with redo buffer and stuff buffer | |
16 * mappings and abbreviations | |
17 */ | |
18 | |
19 #include "vim.h" | |
20 | |
21 /* | |
22 * These buffers are used for storing: | |
23 * - stuffed characters: A command that is translated into another command. | |
24 * - redo characters: will redo the last change. | |
1992 | 25 * - recorded characters: for the "q" command. |
7 | 26 * |
27 * The bytes are stored like in the typeahead buffer: | |
28 * - K_SPECIAL introduces a special key (two more bytes follow). A literal | |
29 * K_SPECIAL is stored as K_SPECIAL KS_SPECIAL KE_FILLER. | |
30 * - CSI introduces a GUI termcap code (also when gui.in_use is FALSE, | |
31 * otherwise switching the GUI on would make mappings invalid). | |
32 * A literal CSI is stored as CSI KS_EXTRA KE_CSI. | |
33 * These translations are also done on multi-byte characters! | |
34 * | |
35 * Escaping CSI bytes is done by the system-specific input functions, called | |
36 * by ui_inchar(). | |
37 * Escaping K_SPECIAL is done by inchar(). | |
38 * Un-escaping is done by vgetc(). | |
39 */ | |
40 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
41 #define MINIMAL_SIZE 20 // minimal size for b_str |
7 | 42 |
13726
d35b1702a1da
patch 8.0.1735: flexible array member feature not supported by HP-UX
Christian Brabandt <cb@256bit.org>
parents:
13702
diff
changeset
|
43 static buffheader_T redobuff = {{NULL, {NUL}}, NULL, 0, 0}; |
d35b1702a1da
patch 8.0.1735: flexible array member feature not supported by HP-UX
Christian Brabandt <cb@256bit.org>
parents:
13702
diff
changeset
|
44 static buffheader_T old_redobuff = {{NULL, {NUL}}, NULL, 0, 0}; |
d35b1702a1da
patch 8.0.1735: flexible array member feature not supported by HP-UX
Christian Brabandt <cb@256bit.org>
parents:
13702
diff
changeset
|
45 static buffheader_T recordbuff = {{NULL, {NUL}}, NULL, 0, 0}; |
7 | 46 |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
47 static int typeahead_char = 0; // typeahead char that's not flushed |
7 | 48 |
49 /* | |
50 * when block_redo is TRUE redo buffer will not be changed | |
51 * used by edit() to repeat insertions and 'V' command for redoing | |
52 */ | |
53 static int block_redo = FALSE; | |
54 | |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
18281
diff
changeset
|
55 static int KeyNoremap = 0; // remapping flags |
7 | 56 |
57 /* | |
9228
ea504064c996
commit https://github.com/vim/vim/commit/fd89d7ea81b18d32363456b16258174dc9e095dc
Christian Brabandt <cb@256bit.org>
parents:
9205
diff
changeset
|
58 * Variables used by vgetorpeek() and flush_buffers(). |
7 | 59 * |
60 * typebuf.tb_buf[] contains all characters that are not consumed yet. | |
61 * typebuf.tb_buf[typebuf.tb_off] is the first valid character. | |
62 * typebuf.tb_buf[typebuf.tb_off + typebuf.tb_len - 1] is the last valid char. | |
63 * typebuf.tb_buf[typebuf.tb_off + typebuf.tb_len] must be NUL. | |
64 * The head of the buffer may contain the result of mappings, abbreviations | |
65 * and @a commands. The length of this part is typebuf.tb_maplen. | |
66 * typebuf.tb_silent is the part where <silent> applies. | |
67 * After the head are characters that come from the terminal. | |
68 * typebuf.tb_no_abbr_cnt is the number of characters in typebuf.tb_buf that | |
69 * should not be considered for abbreviations. | |
70 * Some parts of typebuf.tb_buf may not be mapped. These parts are remembered | |
71 * in typebuf.tb_noremap[], which is the same length as typebuf.tb_buf and | |
72 * contains RM_NONE for the characters that are not to be remapped. | |
73 * typebuf.tb_noremap[typebuf.tb_off] is the first valid flag. | |
74 * (typebuf has been put in globals.h, because check_termcode() needs it). | |
75 */ | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
76 #define RM_YES 0 // tb_noremap: remap |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
77 #define RM_NONE 1 // tb_noremap: don't remap |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
78 #define RM_SCRIPT 2 // tb_noremap: remap local script mappings |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
79 #define RM_ABBR 4 // tb_noremap: don't remap, do abbrev. |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
80 |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
81 // typebuf.tb_buf has three parts: room in front (for result of mappings), the |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
82 // middle for typeahead and room for new characters (which needs to be 3 * |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
83 // MAXMAPLEN) for the Amiga). |
7 | 84 #define TYPELEN_INIT (5 * (MAXMAPLEN + 3)) |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
85 static char_u typebuf_init[TYPELEN_INIT]; // initial typebuf.tb_buf |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
86 static char_u noremapbuf_init[TYPELEN_INIT]; // initial typebuf.tb_noremap |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
87 |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
88 static int last_recorded_len = 0; // number of last recorded chars |
7 | 89 |
7801
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
90 static int read_readbuf(buffheader_T *buf, int advance); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
91 static void init_typebuf(void); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
92 static void may_sync_undo(void); |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17659
diff
changeset
|
93 static void free_typebuf(void); |
7801
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
94 static void closescript(void); |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17659
diff
changeset
|
95 static void updatescript(int c); |
7801
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
96 static int vgetorpeek(int); |
12281
2738b0cc5f64
patch 8.0.1020: when a timer calls getchar(1) input is overwritten
Christian Brabandt <cb@256bit.org>
parents:
11577
diff
changeset
|
97 static int inchar(char_u *buf, int maxlen, long wait_time); |
7 | 98 |
99 /* | |
100 * Free and clear a buffer. | |
101 */ | |
19916
dcec86d796bc
patch 8.2.0514: several global functions are used in only one file
Bram Moolenaar <Bram@vim.org>
parents:
19627
diff
changeset
|
102 static void |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
103 free_buff(buffheader_T *buf) |
7 | 104 { |
5649 | 105 buffblock_T *p, *np; |
7 | 106 |
13726
d35b1702a1da
patch 8.0.1735: flexible array member feature not supported by HP-UX
Christian Brabandt <cb@256bit.org>
parents:
13702
diff
changeset
|
107 for (p = buf->bh_first.b_next; p != NULL; p = np) |
7 | 108 { |
109 np = p->b_next; | |
110 vim_free(p); | |
111 } | |
13726
d35b1702a1da
patch 8.0.1735: flexible array member feature not supported by HP-UX
Christian Brabandt <cb@256bit.org>
parents:
13702
diff
changeset
|
112 buf->bh_first.b_next = NULL; |
7 | 113 } |
114 | |
115 /* | |
116 * Return the contents of a buffer as a single string. | |
117 * K_SPECIAL and CSI in the returned string are escaped. | |
118 */ | |
119 static char_u * | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
120 get_buffcont( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
121 buffheader_T *buffer, |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
122 int dozero) // count == zero is not an error |
7 | 123 { |
124 long_u count = 0; | |
125 char_u *p = NULL; | |
126 char_u *p2; | |
127 char_u *str; | |
13726
d35b1702a1da
patch 8.0.1735: flexible array member feature not supported by HP-UX
Christian Brabandt <cb@256bit.org>
parents:
13702
diff
changeset
|
128 buffblock_T *bp; |
7 | 129 |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
130 // compute the total length of the string |
13726
d35b1702a1da
patch 8.0.1735: flexible array member feature not supported by HP-UX
Christian Brabandt <cb@256bit.org>
parents:
13702
diff
changeset
|
131 for (bp = buffer->bh_first.b_next; bp != NULL; bp = bp->b_next) |
7 | 132 count += (long_u)STRLEN(bp->b_str); |
133 | |
16768
695d9ef00b03
patch 8.1.1386: unessesary type casts for lalloc()
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
134 if ((count || dozero) && (p = alloc(count + 1)) != NULL) |
7 | 135 { |
136 p2 = p; | |
13726
d35b1702a1da
patch 8.0.1735: flexible array member feature not supported by HP-UX
Christian Brabandt <cb@256bit.org>
parents:
13702
diff
changeset
|
137 for (bp = buffer->bh_first.b_next; bp != NULL; bp = bp->b_next) |
7 | 138 for (str = bp->b_str; *str; ) |
139 *p2++ = *str++; | |
140 *p2 = NUL; | |
141 } | |
142 return (p); | |
143 } | |
144 | |
145 /* | |
146 * Return the contents of the record buffer as a single string | |
147 * and clear the record buffer. | |
148 * K_SPECIAL and CSI in the returned string are escaped. | |
149 */ | |
150 char_u * | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
151 get_recorded(void) |
7 | 152 { |
153 char_u *p; | |
154 size_t len; | |
155 | |
156 p = get_buffcont(&recordbuff, TRUE); | |
157 free_buff(&recordbuff); | |
158 | |
159 /* | |
160 * Remove the characters that were added the last time, these must be the | |
161 * (possibly mapped) characters that stopped the recording. | |
162 */ | |
163 len = STRLEN(p); | |
164 if ((int)len >= last_recorded_len) | |
165 { | |
166 len -= last_recorded_len; | |
167 p[len] = NUL; | |
168 } | |
169 | |
170 /* | |
171 * When stopping recording from Insert mode with CTRL-O q, also remove the | |
172 * CTRL-O. | |
173 */ | |
174 if (len > 0 && restart_edit != 0 && p[len - 1] == Ctrl_O) | |
175 p[len - 1] = NUL; | |
176 | |
177 return (p); | |
178 } | |
179 | |
180 /* | |
181 * Return the contents of the redo buffer as a single string. | |
182 * K_SPECIAL and CSI in the returned string are escaped. | |
183 */ | |
184 char_u * | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
185 get_inserted(void) |
7 | 186 { |
1618 | 187 return get_buffcont(&redobuff, FALSE); |
7 | 188 } |
189 | |
190 /* | |
1130 | 191 * Add string "s" after the current block of buffer "buf". |
7 | 192 * K_SPECIAL and CSI should have been escaped already. |
193 */ | |
194 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
195 add_buff( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
196 buffheader_T *buf, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
197 char_u *s, |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
198 long slen) // length of "s" or -1 |
7 | 199 { |
5649 | 200 buffblock_T *p; |
13726
d35b1702a1da
patch 8.0.1735: flexible array member feature not supported by HP-UX
Christian Brabandt <cb@256bit.org>
parents:
13702
diff
changeset
|
201 long_u len; |
7 | 202 |
203 if (slen < 0) | |
204 slen = (long)STRLEN(s); | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
205 if (slen == 0) // don't add empty strings |
7 | 206 return; |
207 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
208 if (buf->bh_first.b_next == NULL) // first add to list |
7 | 209 { |
210 buf->bh_space = 0; | |
13726
d35b1702a1da
patch 8.0.1735: flexible array member feature not supported by HP-UX
Christian Brabandt <cb@256bit.org>
parents:
13702
diff
changeset
|
211 buf->bh_curr = &(buf->bh_first); |
7 | 212 } |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
213 else if (buf->bh_curr == NULL) // buffer has already been read |
7 | 214 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
14909
diff
changeset
|
215 iemsg(_("E222: Add to read buffer")); |
7 | 216 return; |
217 } | |
218 else if (buf->bh_index != 0) | |
13726
d35b1702a1da
patch 8.0.1735: flexible array member feature not supported by HP-UX
Christian Brabandt <cb@256bit.org>
parents:
13702
diff
changeset
|
219 mch_memmove(buf->bh_first.b_next->b_str, |
d35b1702a1da
patch 8.0.1735: flexible array member feature not supported by HP-UX
Christian Brabandt <cb@256bit.org>
parents:
13702
diff
changeset
|
220 buf->bh_first.b_next->b_str + buf->bh_index, |
d35b1702a1da
patch 8.0.1735: flexible array member feature not supported by HP-UX
Christian Brabandt <cb@256bit.org>
parents:
13702
diff
changeset
|
221 STRLEN(buf->bh_first.b_next->b_str + buf->bh_index) + 1); |
7 | 222 buf->bh_index = 0; |
223 | |
224 if (buf->bh_space >= (int)slen) | |
225 { | |
226 len = (long_u)STRLEN(buf->bh_curr->b_str); | |
416 | 227 vim_strncpy(buf->bh_curr->b_str + len, s, (size_t)slen); |
7 | 228 buf->bh_space -= slen; |
229 } | |
230 else | |
231 { | |
232 if (slen < MINIMAL_SIZE) | |
233 len = MINIMAL_SIZE; | |
234 else | |
235 len = slen; | |
17659
121bdff812b4
patch 8.1.1827: allocating more memory than needed for extended structs
Bram Moolenaar <Bram@vim.org>
parents:
17604
diff
changeset
|
236 p = alloc(offsetof(buffblock_T, b_str) + len + 1); |
7 | 237 if (p == NULL) |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
238 return; // no space, just forget it |
835 | 239 buf->bh_space = (int)(len - slen); |
416 | 240 vim_strncpy(p->b_str, s, (size_t)slen); |
7 | 241 |
13726
d35b1702a1da
patch 8.0.1735: flexible array member feature not supported by HP-UX
Christian Brabandt <cb@256bit.org>
parents:
13702
diff
changeset
|
242 p->b_next = buf->bh_curr->b_next; |
d35b1702a1da
patch 8.0.1735: flexible array member feature not supported by HP-UX
Christian Brabandt <cb@256bit.org>
parents:
13702
diff
changeset
|
243 buf->bh_curr->b_next = p; |
d35b1702a1da
patch 8.0.1735: flexible array member feature not supported by HP-UX
Christian Brabandt <cb@256bit.org>
parents:
13702
diff
changeset
|
244 buf->bh_curr = p; |
7 | 245 } |
246 return; | |
247 } | |
248 | |
249 /* | |
250 * Add number "n" to buffer "buf". | |
251 */ | |
252 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
253 add_num_buff(buffheader_T *buf, long n) |
7 | 254 { |
255 char_u number[32]; | |
256 | |
257 sprintf((char *)number, "%ld", n); | |
258 add_buff(buf, number, -1L); | |
259 } | |
260 | |
261 /* | |
262 * Add character 'c' to buffer "buf". | |
263 * Translates special keys, NUL, CSI, K_SPECIAL and multibyte characters. | |
264 */ | |
265 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
266 add_char_buff(buffheader_T *buf, int c) |
7 | 267 { |
268 char_u bytes[MB_MAXBYTES + 1]; | |
269 int len; | |
270 int i; | |
271 char_u temp[4]; | |
272 | |
273 if (IS_SPECIAL(c)) | |
274 len = 1; | |
275 else | |
276 len = (*mb_char2bytes)(c, bytes); | |
277 for (i = 0; i < len; ++i) | |
278 { | |
279 if (!IS_SPECIAL(c)) | |
280 c = bytes[i]; | |
281 | |
282 if (IS_SPECIAL(c) || c == K_SPECIAL || c == NUL) | |
283 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
284 // translate special key code into three byte sequence |
7 | 285 temp[0] = K_SPECIAL; |
286 temp[1] = K_SECOND(c); | |
287 temp[2] = K_THIRD(c); | |
288 temp[3] = NUL; | |
289 } | |
290 #ifdef FEAT_GUI | |
291 else if (c == CSI) | |
292 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
293 // Translate a CSI to a CSI - KS_EXTRA - KE_CSI sequence |
7 | 294 temp[0] = CSI; |
295 temp[1] = KS_EXTRA; | |
296 temp[2] = (int)KE_CSI; | |
297 temp[3] = NUL; | |
298 } | |
299 #endif | |
300 else | |
301 { | |
302 temp[0] = c; | |
303 temp[1] = NUL; | |
304 } | |
305 add_buff(buf, temp, -1L); | |
306 } | |
307 } | |
308 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
309 // First read ahead buffer. Used for translated commands. |
13726
d35b1702a1da
patch 8.0.1735: flexible array member feature not supported by HP-UX
Christian Brabandt <cb@256bit.org>
parents:
13702
diff
changeset
|
310 static buffheader_T readbuf1 = {{NULL, {NUL}}, NULL, 0, 0}; |
5649 | 311 |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
312 // Second read ahead buffer. Used for redo. |
13726
d35b1702a1da
patch 8.0.1735: flexible array member feature not supported by HP-UX
Christian Brabandt <cb@256bit.org>
parents:
13702
diff
changeset
|
313 static buffheader_T readbuf2 = {{NULL, {NUL}}, NULL, 0, 0}; |
5649 | 314 |
7 | 315 /* |
5649 | 316 * Get one byte from the read buffers. Use readbuf1 one first, use readbuf2 |
317 * if that one is empty. | |
7 | 318 * If advance == TRUE go to the next char. |
319 * No translation is done K_SPECIAL and CSI are escaped. | |
320 */ | |
321 static int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
322 read_readbuffers(int advance) |
7 | 323 { |
5649 | 324 int c; |
325 | |
326 c = read_readbuf(&readbuf1, advance); | |
327 if (c == NUL) | |
328 c = read_readbuf(&readbuf2, advance); | |
329 return c; | |
330 } | |
331 | |
332 static int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
333 read_readbuf(buffheader_T *buf, int advance) |
5649 | 334 { |
335 char_u c; | |
336 buffblock_T *curr; | |
337 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
338 if (buf->bh_first.b_next == NULL) // buffer is empty |
7 | 339 return NUL; |
340 | |
13726
d35b1702a1da
patch 8.0.1735: flexible array member feature not supported by HP-UX
Christian Brabandt <cb@256bit.org>
parents:
13702
diff
changeset
|
341 curr = buf->bh_first.b_next; |
5649 | 342 c = curr->b_str[buf->bh_index]; |
7 | 343 |
344 if (advance) | |
345 { | |
5649 | 346 if (curr->b_str[++buf->bh_index] == NUL) |
7 | 347 { |
13726
d35b1702a1da
patch 8.0.1735: flexible array member feature not supported by HP-UX
Christian Brabandt <cb@256bit.org>
parents:
13702
diff
changeset
|
348 buf->bh_first.b_next = curr->b_next; |
7 | 349 vim_free(curr); |
5649 | 350 buf->bh_index = 0; |
7 | 351 } |
352 } | |
353 return c; | |
354 } | |
355 | |
356 /* | |
5670 | 357 * Prepare the read buffers for reading (if they contain something). |
7 | 358 */ |
359 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
360 start_stuff(void) |
7 | 361 { |
13726
d35b1702a1da
patch 8.0.1735: flexible array member feature not supported by HP-UX
Christian Brabandt <cb@256bit.org>
parents:
13702
diff
changeset
|
362 if (readbuf1.bh_first.b_next != NULL) |
7 | 363 { |
13726
d35b1702a1da
patch 8.0.1735: flexible array member feature not supported by HP-UX
Christian Brabandt <cb@256bit.org>
parents:
13702
diff
changeset
|
364 readbuf1.bh_curr = &(readbuf1.bh_first); |
5649 | 365 readbuf1.bh_space = 0; |
366 } | |
13726
d35b1702a1da
patch 8.0.1735: flexible array member feature not supported by HP-UX
Christian Brabandt <cb@256bit.org>
parents:
13702
diff
changeset
|
367 if (readbuf2.bh_first.b_next != NULL) |
5649 | 368 { |
13726
d35b1702a1da
patch 8.0.1735: flexible array member feature not supported by HP-UX
Christian Brabandt <cb@256bit.org>
parents:
13702
diff
changeset
|
369 readbuf2.bh_curr = &(readbuf2.bh_first); |
5649 | 370 readbuf2.bh_space = 0; |
7 | 371 } |
372 } | |
373 | |
374 /* | |
375 * Return TRUE if the stuff buffer is empty. | |
376 */ | |
377 int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
378 stuff_empty(void) |
7 | 379 { |
13726
d35b1702a1da
patch 8.0.1735: flexible array member feature not supported by HP-UX
Christian Brabandt <cb@256bit.org>
parents:
13702
diff
changeset
|
380 return (readbuf1.bh_first.b_next == NULL |
d35b1702a1da
patch 8.0.1735: flexible array member feature not supported by HP-UX
Christian Brabandt <cb@256bit.org>
parents:
13702
diff
changeset
|
381 && readbuf2.bh_first.b_next == NULL); |
5649 | 382 } |
383 | |
15555
d89c5b339c2a
patch 8.1.0785: depending on the configuration some functions are unused
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
384 #if defined(FEAT_EVAL) || defined(PROTO) |
5649 | 385 /* |
386 * Return TRUE if readbuf1 is empty. There may still be redo characters in | |
387 * redbuf2. | |
388 */ | |
389 int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
390 readbuf1_empty(void) |
5649 | 391 { |
13726
d35b1702a1da
patch 8.0.1735: flexible array member feature not supported by HP-UX
Christian Brabandt <cb@256bit.org>
parents:
13702
diff
changeset
|
392 return (readbuf1.bh_first.b_next == NULL); |
7 | 393 } |
15555
d89c5b339c2a
patch 8.1.0785: depending on the configuration some functions are unused
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
394 #endif |
7 | 395 |
396 /* | |
397 * Set a typeahead character that won't be flushed. | |
398 */ | |
399 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
400 typeahead_noflush(int c) |
7 | 401 { |
402 typeahead_char = c; | |
403 } | |
404 | |
405 /* | |
406 * Remove the contents of the stuff buffer and the mapped characters in the | |
3263 | 407 * typeahead buffer (used in case of an error). If "flush_typeahead" is true, |
7 | 408 * flush all typeahead characters (used when interrupted by a CTRL-C). |
409 */ | |
410 void | |
14909
c97b4b537572
patch 8.1.0466: autocmd test fails
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
411 flush_buffers(flush_buffers_T flush_typeahead) |
7 | 412 { |
413 init_typebuf(); | |
414 | |
415 start_stuff(); | |
5649 | 416 while (read_readbuffers(TRUE) != NUL) |
7 | 417 ; |
418 | |
14909
c97b4b537572
patch 8.1.0466: autocmd test fails
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
419 if (flush_typeahead == FLUSH_MINIMAL) |
c97b4b537572
patch 8.1.0466: autocmd test fails
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
420 { |
c97b4b537572
patch 8.1.0466: autocmd test fails
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
421 // remove mapped characters at the start only |
c97b4b537572
patch 8.1.0466: autocmd test fails
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
422 typebuf.tb_off += typebuf.tb_maplen; |
c97b4b537572
patch 8.1.0466: autocmd test fails
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
423 typebuf.tb_len -= typebuf.tb_maplen; |
19627
6b1564fcab92
patch 8.2.0370: the typebuf_was_filled flag is sometimes not reset
Bram Moolenaar <Bram@vim.org>
parents:
19599
diff
changeset
|
424 #if defined(FEAT_CLIENTSERVER) || defined(FEAT_EVAL) |
6b1564fcab92
patch 8.2.0370: the typebuf_was_filled flag is sometimes not reset
Bram Moolenaar <Bram@vim.org>
parents:
19599
diff
changeset
|
425 if (typebuf.tb_len == 0) |
6b1564fcab92
patch 8.2.0370: the typebuf_was_filled flag is sometimes not reset
Bram Moolenaar <Bram@vim.org>
parents:
19599
diff
changeset
|
426 typebuf_was_filled = FALSE; |
6b1564fcab92
patch 8.2.0370: the typebuf_was_filled flag is sometimes not reset
Bram Moolenaar <Bram@vim.org>
parents:
19599
diff
changeset
|
427 #endif |
14909
c97b4b537572
patch 8.1.0466: autocmd test fails
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
428 } |
c97b4b537572
patch 8.1.0466: autocmd test fails
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
429 else |
7 | 430 { |
14909
c97b4b537572
patch 8.1.0466: autocmd test fails
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
431 // remove typeahead |
c97b4b537572
patch 8.1.0466: autocmd test fails
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
432 if (flush_typeahead == FLUSH_INPUT) |
c97b4b537572
patch 8.1.0466: autocmd test fails
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
433 // We have to get all characters, because we may delete the first |
c97b4b537572
patch 8.1.0466: autocmd test fails
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
434 // part of an escape sequence. In an xterm we get one char at a |
c97b4b537572
patch 8.1.0466: autocmd test fails
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
435 // time and we have to get them all. |
c97b4b537572
patch 8.1.0466: autocmd test fails
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
436 while (inchar(typebuf.tb_buf, typebuf.tb_buflen - 1, 10L) != 0) |
c97b4b537572
patch 8.1.0466: autocmd test fails
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
437 ; |
7 | 438 typebuf.tb_off = MAXMAPLEN; |
439 typebuf.tb_len = 0; | |
11577
2bc04093ed28
patch 8.0.0671: hang when typing CTRL-C in confirm() in timer
Christian Brabandt <cb@256bit.org>
parents:
11490
diff
changeset
|
440 #if defined(FEAT_CLIENTSERVER) || defined(FEAT_EVAL) |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
441 // Reset the flag that text received from a client or from feedkeys() |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
442 // was inserted in the typeahead buffer. |
11577
2bc04093ed28
patch 8.0.0671: hang when typing CTRL-C in confirm() in timer
Christian Brabandt <cb@256bit.org>
parents:
11490
diff
changeset
|
443 typebuf_was_filled = FALSE; |
2bc04093ed28
patch 8.0.0671: hang when typing CTRL-C in confirm() in timer
Christian Brabandt <cb@256bit.org>
parents:
11490
diff
changeset
|
444 #endif |
7 | 445 } |
446 typebuf.tb_maplen = 0; | |
447 typebuf.tb_silent = 0; | |
448 cmd_silent = FALSE; | |
449 typebuf.tb_no_abbr_cnt = 0; | |
21654
bb0c4325a712
patch 8.2.1377: triggering the ATTENTION prompt causes typeahead mess up
Bram Moolenaar <Bram@vim.org>
parents:
21230
diff
changeset
|
450 if (++typebuf.tb_change_cnt == 0) |
bb0c4325a712
patch 8.2.1377: triggering the ATTENTION prompt causes typeahead mess up
Bram Moolenaar <Bram@vim.org>
parents:
21230
diff
changeset
|
451 typebuf.tb_change_cnt = 1; |
7 | 452 } |
453 | |
454 /* | |
455 * The previous contents of the redo buffer is kept in old_redobuffer. | |
456 * This is used for the CTRL-O <.> command in insert mode. | |
457 */ | |
458 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
459 ResetRedobuff(void) |
7 | 460 { |
461 if (!block_redo) | |
462 { | |
463 free_buff(&old_redobuff); | |
464 old_redobuff = redobuff; | |
13726
d35b1702a1da
patch 8.0.1735: flexible array member feature not supported by HP-UX
Christian Brabandt <cb@256bit.org>
parents:
13702
diff
changeset
|
465 redobuff.bh_first.b_next = NULL; |
7 | 466 } |
467 } | |
468 | |
3324 | 469 /* |
470 * Discard the contents of the redo buffer and restore the previous redo | |
471 * buffer. | |
472 */ | |
473 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
474 CancelRedo(void) |
3324 | 475 { |
476 if (!block_redo) | |
477 { | |
478 free_buff(&redobuff); | |
479 redobuff = old_redobuff; | |
13726
d35b1702a1da
patch 8.0.1735: flexible array member feature not supported by HP-UX
Christian Brabandt <cb@256bit.org>
parents:
13702
diff
changeset
|
480 old_redobuff.bh_first.b_next = NULL; |
3324 | 481 start_stuff(); |
5649 | 482 while (read_readbuffers(TRUE) != NUL) |
3324 | 483 ; |
484 } | |
485 } | |
486 | |
7 | 487 /* |
488 * Save redobuff and old_redobuff to save_redobuff and save_old_redobuff. | |
489 * Used before executing autocommands and user functions. | |
490 */ | |
491 void | |
11325
77f3b7316d8b
patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
492 saveRedobuff(save_redo_T *save_redo) |
7 | 493 { |
494 char_u *s; | |
495 | |
11325
77f3b7316d8b
patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
496 save_redo->sr_redobuff = redobuff; |
13726
d35b1702a1da
patch 8.0.1735: flexible array member feature not supported by HP-UX
Christian Brabandt <cb@256bit.org>
parents:
13702
diff
changeset
|
497 redobuff.bh_first.b_next = NULL; |
11325
77f3b7316d8b
patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
498 save_redo->sr_old_redobuff = old_redobuff; |
13726
d35b1702a1da
patch 8.0.1735: flexible array member feature not supported by HP-UX
Christian Brabandt <cb@256bit.org>
parents:
13702
diff
changeset
|
499 old_redobuff.bh_first.b_next = NULL; |
11325
77f3b7316d8b
patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
500 |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
501 // Make a copy, so that ":normal ." in a function works. |
11325
77f3b7316d8b
patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
502 s = get_buffcont(&save_redo->sr_redobuff, FALSE); |
77f3b7316d8b
patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
503 if (s != NULL) |
7 | 504 { |
11325
77f3b7316d8b
patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
505 add_buff(&redobuff, s, -1L); |
77f3b7316d8b
patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
506 vim_free(s); |
7 | 507 } |
508 } | |
509 | |
510 /* | |
511 * Restore redobuff and old_redobuff from save_redobuff and save_old_redobuff. | |
512 * Used after executing autocommands and user functions. | |
513 */ | |
514 void | |
11325
77f3b7316d8b
patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
515 restoreRedobuff(save_redo_T *save_redo) |
7 | 516 { |
11325
77f3b7316d8b
patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
517 free_buff(&redobuff); |
77f3b7316d8b
patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
518 redobuff = save_redo->sr_redobuff; |
77f3b7316d8b
patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
519 free_buff(&old_redobuff); |
77f3b7316d8b
patch 8.0.0548: saving the redo buffer only works one time
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
520 old_redobuff = save_redo->sr_old_redobuff; |
7 | 521 } |
522 | |
523 /* | |
524 * Append "s" to the redo buffer. | |
525 * K_SPECIAL and CSI should already have been escaped. | |
526 */ | |
527 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
528 AppendToRedobuff(char_u *s) |
7 | 529 { |
530 if (!block_redo) | |
531 add_buff(&redobuff, s, -1L); | |
532 } | |
533 | |
534 /* | |
535 * Append to Redo buffer literally, escaping special characters with CTRL-V. | |
536 * K_SPECIAL and CSI are escaped as well. | |
537 */ | |
538 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
539 AppendToRedobuffLit( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
540 char_u *str, |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
541 int len) // length of "str" or -1 for up to the NUL |
7 | 542 { |
620 | 543 char_u *s = str; |
7 | 544 int c; |
545 char_u *start; | |
546 | |
547 if (block_redo) | |
548 return; | |
549 | |
620 | 550 while (len < 0 ? *s != NUL : s - str < len) |
7 | 551 { |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
552 // Put a string of normal characters in the redo buffer (that's |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
553 // faster). |
7 | 554 start = s; |
555 while (*s >= ' ' | |
556 #ifndef EBCDIC | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
557 && *s < DEL // EBCDIC: all chars above space are normal |
7 | 558 #endif |
620 | 559 && (len < 0 || s - str < len)) |
7 | 560 ++s; |
561 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
562 // Don't put '0' or '^' as last character, just in case a CTRL-D is |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
563 // typed next. |
7 | 564 if (*s == NUL && (s[-1] == '0' || s[-1] == '^')) |
565 --s; | |
566 if (s > start) | |
567 add_buff(&redobuff, start, (long)(s - start)); | |
568 | |
620 | 569 if (*s == NUL || (len >= 0 && s - str >= len)) |
570 break; | |
571 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
572 // Handle a special or multibyte character. |
620 | 573 if (has_mbyte) |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
574 // Handle composing chars separately. |
620 | 575 c = mb_cptr2char_adv(&s); |
576 else | |
577 c = *s++; | |
578 if (c < ' ' || c == DEL || (*s == NUL && (c == '0' || c == '^'))) | |
579 add_char_buff(&redobuff, Ctrl_V); | |
580 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
581 // CTRL-V '0' must be inserted as CTRL-V 048 (EBCDIC: xf0) |
620 | 582 if (*s == NUL && c == '0') |
7 | 583 #ifdef EBCDIC |
620 | 584 add_buff(&redobuff, (char_u *)"xf0", 3L); |
7 | 585 #else |
620 | 586 add_buff(&redobuff, (char_u *)"048", 3L); |
7 | 587 #endif |
620 | 588 else |
589 add_char_buff(&redobuff, c); | |
7 | 590 } |
591 } | |
592 | |
593 /* | |
594 * Append a character to the redo buffer. | |
595 * Translates special keys, NUL, CSI, K_SPECIAL and multibyte characters. | |
596 */ | |
597 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
598 AppendCharToRedobuff(int c) |
7 | 599 { |
600 if (!block_redo) | |
601 add_char_buff(&redobuff, c); | |
602 } | |
603 | |
604 /* | |
605 * Append a number to the redo buffer. | |
606 */ | |
607 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
608 AppendNumberToRedobuff(long n) |
7 | 609 { |
610 if (!block_redo) | |
611 add_num_buff(&redobuff, n); | |
612 } | |
613 | |
614 /* | |
615 * Append string "s" to the stuff buffer. | |
616 * CSI and K_SPECIAL must already have been escaped. | |
617 */ | |
618 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
619 stuffReadbuff(char_u *s) |
7 | 620 { |
5649 | 621 add_buff(&readbuf1, s, -1L); |
7 | 622 } |
623 | |
6098 | 624 /* |
625 * Append string "s" to the redo stuff buffer. | |
626 * CSI and K_SPECIAL must already have been escaped. | |
627 */ | |
628 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
629 stuffRedoReadbuff(char_u *s) |
6098 | 630 { |
631 add_buff(&readbuf2, s, -1L); | |
632 } | |
633 | |
7 | 634 void |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
635 stuffReadbuffLen(char_u *s, long len) |
7 | 636 { |
5649 | 637 add_buff(&readbuf1, s, len); |
7 | 638 } |
639 | |
640 #if defined(FEAT_EVAL) || defined(PROTO) | |
641 /* | |
642 * Stuff "s" into the stuff buffer, leaving special key codes unmodified and | |
643 * escaping other K_SPECIAL and CSI bytes. | |
2784 | 644 * Change CR, LF and ESC into a space. |
7 | 645 */ |
646 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
647 stuffReadbuffSpec(char_u *s) |
7 | 648 { |
2784 | 649 int c; |
650 | |
7 | 651 while (*s != NUL) |
652 { | |
653 if (*s == K_SPECIAL && s[1] != NUL && s[2] != NUL) | |
654 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
655 // Insert special key literally. |
7 | 656 stuffReadbuffLen(s, 3L); |
657 s += 3; | |
658 } | |
659 else | |
2784 | 660 { |
661 c = mb_ptr2char_adv(&s); | |
662 if (c == CAR || c == NL || c == ESC) | |
663 c = ' '; | |
664 stuffcharReadbuff(c); | |
665 } | |
7 | 666 } |
667 } | |
668 #endif | |
669 | |
670 /* | |
671 * Append a character to the stuff buffer. | |
672 * Translates special keys, NUL, CSI, K_SPECIAL and multibyte characters. | |
673 */ | |
674 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
675 stuffcharReadbuff(int c) |
7 | 676 { |
5649 | 677 add_char_buff(&readbuf1, c); |
7 | 678 } |
679 | |
680 /* | |
681 * Append a number to the stuff buffer. | |
682 */ | |
683 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
684 stuffnumReadbuff(long n) |
7 | 685 { |
5649 | 686 add_num_buff(&readbuf1, n); |
7 | 687 } |
688 | |
689 /* | |
20237
918245588b50
patch 8.2.0674: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
19916
diff
changeset
|
690 * Stuff a string into the typeahead buffer, such that edit() will insert it |
918245588b50
patch 8.2.0674: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
19916
diff
changeset
|
691 * literally ("literally" TRUE) or interpret is as typed characters. |
918245588b50
patch 8.2.0674: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
19916
diff
changeset
|
692 */ |
918245588b50
patch 8.2.0674: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
19916
diff
changeset
|
693 void |
918245588b50
patch 8.2.0674: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
19916
diff
changeset
|
694 stuffescaped(char_u *arg, int literally) |
918245588b50
patch 8.2.0674: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
19916
diff
changeset
|
695 { |
918245588b50
patch 8.2.0674: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
19916
diff
changeset
|
696 int c; |
918245588b50
patch 8.2.0674: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
19916
diff
changeset
|
697 char_u *start; |
918245588b50
patch 8.2.0674: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
19916
diff
changeset
|
698 |
918245588b50
patch 8.2.0674: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
19916
diff
changeset
|
699 while (*arg != NUL) |
918245588b50
patch 8.2.0674: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
19916
diff
changeset
|
700 { |
918245588b50
patch 8.2.0674: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
19916
diff
changeset
|
701 // Stuff a sequence of normal ASCII characters, that's fast. Also |
918245588b50
patch 8.2.0674: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
19916
diff
changeset
|
702 // stuff K_SPECIAL to get the effect of a special key when "literally" |
918245588b50
patch 8.2.0674: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
19916
diff
changeset
|
703 // is TRUE. |
918245588b50
patch 8.2.0674: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
19916
diff
changeset
|
704 start = arg; |
918245588b50
patch 8.2.0674: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
19916
diff
changeset
|
705 while ((*arg >= ' ' |
918245588b50
patch 8.2.0674: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
19916
diff
changeset
|
706 #ifndef EBCDIC |
918245588b50
patch 8.2.0674: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
19916
diff
changeset
|
707 && *arg < DEL // EBCDIC: chars above space are normal |
918245588b50
patch 8.2.0674: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
19916
diff
changeset
|
708 #endif |
918245588b50
patch 8.2.0674: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
19916
diff
changeset
|
709 ) |
918245588b50
patch 8.2.0674: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
19916
diff
changeset
|
710 || (*arg == K_SPECIAL && !literally)) |
918245588b50
patch 8.2.0674: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
19916
diff
changeset
|
711 ++arg; |
918245588b50
patch 8.2.0674: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
19916
diff
changeset
|
712 if (arg > start) |
918245588b50
patch 8.2.0674: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
19916
diff
changeset
|
713 stuffReadbuffLen(start, (long)(arg - start)); |
918245588b50
patch 8.2.0674: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
19916
diff
changeset
|
714 |
918245588b50
patch 8.2.0674: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
19916
diff
changeset
|
715 // stuff a single special character |
918245588b50
patch 8.2.0674: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
19916
diff
changeset
|
716 if (*arg != NUL) |
918245588b50
patch 8.2.0674: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
19916
diff
changeset
|
717 { |
918245588b50
patch 8.2.0674: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
19916
diff
changeset
|
718 if (has_mbyte) |
918245588b50
patch 8.2.0674: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
19916
diff
changeset
|
719 c = mb_cptr2char_adv(&arg); |
918245588b50
patch 8.2.0674: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
19916
diff
changeset
|
720 else |
918245588b50
patch 8.2.0674: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
19916
diff
changeset
|
721 c = *arg++; |
918245588b50
patch 8.2.0674: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
19916
diff
changeset
|
722 if (literally && ((c < ' ' && c != TAB) || c == DEL)) |
918245588b50
patch 8.2.0674: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
19916
diff
changeset
|
723 stuffcharReadbuff(Ctrl_V); |
918245588b50
patch 8.2.0674: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
19916
diff
changeset
|
724 stuffcharReadbuff(c); |
918245588b50
patch 8.2.0674: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
19916
diff
changeset
|
725 } |
918245588b50
patch 8.2.0674: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
19916
diff
changeset
|
726 } |
918245588b50
patch 8.2.0674: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
19916
diff
changeset
|
727 } |
918245588b50
patch 8.2.0674: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
19916
diff
changeset
|
728 |
918245588b50
patch 8.2.0674: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
19916
diff
changeset
|
729 /* |
7 | 730 * Read a character from the redo buffer. Translates K_SPECIAL, CSI and |
731 * multibyte characters. | |
732 * The redo buffer is left as it is. | |
3324 | 733 * If init is TRUE, prepare for redo, return FAIL if nothing to redo, OK |
734 * otherwise. | |
735 * If old is TRUE, use old_redobuff instead of redobuff. | |
7 | 736 */ |
737 static int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
738 read_redo(int init, int old_redo) |
7 | 739 { |
5649 | 740 static buffblock_T *bp; |
741 static char_u *p; | |
742 int c; | |
743 int n; | |
744 char_u buf[MB_MAXBYTES + 1]; | |
745 int i; | |
7 | 746 |
747 if (init) | |
748 { | |
749 if (old_redo) | |
13726
d35b1702a1da
patch 8.0.1735: flexible array member feature not supported by HP-UX
Christian Brabandt <cb@256bit.org>
parents:
13702
diff
changeset
|
750 bp = old_redobuff.bh_first.b_next; |
7 | 751 else |
13726
d35b1702a1da
patch 8.0.1735: flexible array member feature not supported by HP-UX
Christian Brabandt <cb@256bit.org>
parents:
13702
diff
changeset
|
752 bp = redobuff.bh_first.b_next; |
7 | 753 if (bp == NULL) |
754 return FAIL; | |
755 p = bp->b_str; | |
756 return OK; | |
757 } | |
758 if ((c = *p) != NUL) | |
759 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
760 // Reverse the conversion done by add_char_buff() |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
761 // For a multi-byte character get all the bytes and return the |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
762 // converted character. |
7 | 763 if (has_mbyte && (c != K_SPECIAL || p[1] == KS_SPECIAL)) |
764 n = MB_BYTE2LEN_CHECK(c); | |
765 else | |
766 n = 1; | |
767 for (i = 0; ; ++i) | |
768 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
769 if (c == K_SPECIAL) // special key or escaped K_SPECIAL |
7 | 770 { |
771 c = TO_SPECIAL(p[1], p[2]); | |
772 p += 2; | |
773 } | |
774 #ifdef FEAT_GUI | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
775 if (c == CSI) // escaped CSI |
7 | 776 p += 2; |
777 #endif | |
778 if (*++p == NUL && bp->b_next != NULL) | |
779 { | |
780 bp = bp->b_next; | |
781 p = bp->b_str; | |
782 } | |
783 buf[i] = c; | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
784 if (i == n - 1) // last byte of a character |
7 | 785 { |
786 if (n != 1) | |
787 c = (*mb_ptr2char)(buf); | |
788 break; | |
789 } | |
790 c = *p; | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
791 if (c == NUL) // cannot happen? |
7 | 792 break; |
793 } | |
794 } | |
795 | |
796 return c; | |
797 } | |
798 | |
799 /* | |
800 * Copy the rest of the redo buffer into the stuff buffer (in a slow way). | |
801 * If old_redo is TRUE, use old_redobuff instead of redobuff. | |
802 * The escaped K_SPECIAL and CSI are copied without translation. | |
803 */ | |
804 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
805 copy_redo(int old_redo) |
7 | 806 { |
807 int c; | |
808 | |
809 while ((c = read_redo(FALSE, old_redo)) != NUL) | |
5649 | 810 add_char_buff(&readbuf2, c); |
7 | 811 } |
812 | |
813 /* | |
5649 | 814 * Stuff the redo buffer into readbuf2. |
7 | 815 * Insert the redo count into the command. |
816 * If "old_redo" is TRUE, the last but one command is repeated | |
817 * instead of the last command (inserting text). This is used for | |
818 * CTRL-O <.> in insert mode | |
819 * | |
820 * return FAIL for failure, OK otherwise | |
821 */ | |
822 int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
823 start_redo(long count, int old_redo) |
7 | 824 { |
825 int c; | |
826 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
827 // init the pointers; return if nothing to redo |
7 | 828 if (read_redo(TRUE, old_redo) == FAIL) |
829 return FAIL; | |
830 | |
831 c = read_redo(FALSE, old_redo); | |
832 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
833 // copy the buffer name, if present |
7 | 834 if (c == '"') |
835 { | |
5649 | 836 add_buff(&readbuf2, (char_u *)"\"", 1L); |
7 | 837 c = read_redo(FALSE, old_redo); |
838 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
839 // if a numbered buffer is used, increment the number |
7 | 840 if (c >= '1' && c < '9') |
841 ++c; | |
5649 | 842 add_char_buff(&readbuf2, c); |
14009
830a47e48791
patch 8.1.0022: repeating put from expression register fails
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
843 |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
844 // the expression register should be re-evaluated |
14009
830a47e48791
patch 8.1.0022: repeating put from expression register fails
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
845 if (c == '=') |
830a47e48791
patch 8.1.0022: repeating put from expression register fails
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
846 { |
830a47e48791
patch 8.1.0022: repeating put from expression register fails
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
847 add_char_buff(&readbuf2, CAR); |
830a47e48791
patch 8.1.0022: repeating put from expression register fails
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
848 cmd_silent = TRUE; |
830a47e48791
patch 8.1.0022: repeating put from expression register fails
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
849 } |
830a47e48791
patch 8.1.0022: repeating put from expression register fails
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
850 |
7 | 851 c = read_redo(FALSE, old_redo); |
852 } | |
853 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
854 if (c == 'v') // redo Visual |
7 | 855 { |
856 VIsual = curwin->w_cursor; | |
857 VIsual_active = TRUE; | |
858 VIsual_select = FALSE; | |
859 VIsual_reselect = TRUE; | |
860 redo_VIsual_busy = TRUE; | |
861 c = read_redo(FALSE, old_redo); | |
862 } | |
863 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
864 // try to enter the count (in place of a previous count) |
7 | 865 if (count) |
866 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
867 while (VIM_ISDIGIT(c)) // skip "old" count |
7 | 868 c = read_redo(FALSE, old_redo); |
5649 | 869 add_num_buff(&readbuf2, count); |
7 | 870 } |
871 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
872 // copy from the redo buffer into the stuff buffer |
5649 | 873 add_char_buff(&readbuf2, c); |
7 | 874 copy_redo(old_redo); |
875 return OK; | |
876 } | |
877 | |
878 /* | |
879 * Repeat the last insert (R, o, O, a, A, i or I command) by stuffing | |
5649 | 880 * the redo buffer into readbuf2. |
7 | 881 * return FAIL for failure, OK otherwise |
882 */ | |
883 int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
884 start_redo_ins(void) |
7 | 885 { |
886 int c; | |
887 | |
888 if (read_redo(TRUE, FALSE) == FAIL) | |
889 return FAIL; | |
890 start_stuff(); | |
891 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
892 // skip the count and the command character |
7 | 893 while ((c = read_redo(FALSE, FALSE)) != NUL) |
894 { | |
895 if (vim_strchr((char_u *)"AaIiRrOo", c) != NULL) | |
896 { | |
897 if (c == 'O' || c == 'o') | |
5649 | 898 add_buff(&readbuf2, NL_STR, -1L); |
7 | 899 break; |
900 } | |
901 } | |
902 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
903 // copy the typed text from the redo buffer into the stuff buffer |
7 | 904 copy_redo(FALSE); |
905 block_redo = TRUE; | |
906 return OK; | |
907 } | |
908 | |
909 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
910 stop_redo_ins(void) |
7 | 911 { |
912 block_redo = FALSE; | |
913 } | |
914 | |
915 /* | |
916 * Initialize typebuf.tb_buf to point to typebuf_init. | |
917 * alloc() cannot be used here: In out-of-memory situations it would | |
918 * be impossible to type anything. | |
919 */ | |
920 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
921 init_typebuf(void) |
7 | 922 { |
923 if (typebuf.tb_buf == NULL) | |
924 { | |
925 typebuf.tb_buf = typebuf_init; | |
926 typebuf.tb_noremap = noremapbuf_init; | |
927 typebuf.tb_buflen = TYPELEN_INIT; | |
928 typebuf.tb_len = 0; | |
11331
ff27a6a3a243
patch 8.0.0551: the typeahead buffer is reallocated too often
Christian Brabandt <cb@256bit.org>
parents:
11325
diff
changeset
|
929 typebuf.tb_off = MAXMAPLEN + 4; |
7 | 930 typebuf.tb_change_cnt = 1; |
931 } | |
932 } | |
933 | |
934 /* | |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
935 * Returns TRUE when keys cannot be remapped. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
936 */ |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
937 int |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
938 noremap_keys(void) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
939 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
940 return KeyNoremap & (RM_NONE|RM_SCRIPT); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
941 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
942 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
943 /* |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7117
diff
changeset
|
944 * Insert a string in position 'offset' in the typeahead buffer (for "@r" |
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7117
diff
changeset
|
945 * and ":normal" command, vgetorpeek() and check_termcode()). |
7 | 946 * |
947 * If noremap is REMAP_YES, new string can be mapped again. | |
948 * If noremap is REMAP_NONE, new string cannot be mapped again. | |
10 | 949 * If noremap is REMAP_SKIP, fist char of new string cannot be mapped again, |
950 * but abbreviations are allowed. | |
7 | 951 * If noremap is REMAP_SCRIPT, new string cannot be mapped again, except for |
952 * script-local mappings. | |
953 * If noremap is > 0, that many characters of the new string cannot be mapped. | |
954 * | |
955 * If nottyped is TRUE, the string does not return KeyTyped (don't use when | |
956 * offset is non-zero!). | |
957 * | |
958 * If silent is TRUE, cmd_silent is set when the characters are obtained. | |
959 * | |
960 * return FAIL for failure, OK otherwise | |
961 */ | |
962 int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
963 ins_typebuf( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
964 char_u *str, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
965 int noremap, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
966 int offset, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
967 int nottyped, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
968 int silent) |
7 | 969 { |
970 char_u *s1, *s2; | |
971 int newlen; | |
972 int addlen; | |
973 int i; | |
974 int newoff; | |
975 int val; | |
976 int nrm; | |
977 | |
978 init_typebuf(); | |
979 if (++typebuf.tb_change_cnt == 0) | |
980 typebuf.tb_change_cnt = 1; | |
18116
7f57ea9a4ba8
patch 8.1.2053: SafeStateAgain not triggered if callback uses feedkeys()
Bram Moolenaar <Bram@vim.org>
parents:
18106
diff
changeset
|
981 state_no_longer_safe("ins_typebuf()"); |
7 | 982 |
983 addlen = (int)STRLEN(str); | |
1130 | 984 |
7 | 985 if (offset == 0 && addlen <= typebuf.tb_off) |
986 { | |
10549
055b1633aed7
patch 8.0.0164: outdated and misplaced comments
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
987 /* |
055b1633aed7
patch 8.0.0164: outdated and misplaced comments
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
988 * Easy case: there is room in front of typebuf.tb_buf[typebuf.tb_off] |
055b1633aed7
patch 8.0.0164: outdated and misplaced comments
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
989 */ |
7 | 990 typebuf.tb_off -= addlen; |
991 mch_memmove(typebuf.tb_buf + typebuf.tb_off, str, (size_t)addlen); | |
992 } | |
11331
ff27a6a3a243
patch 8.0.0551: the typeahead buffer is reallocated too often
Christian Brabandt <cb@256bit.org>
parents:
11325
diff
changeset
|
993 else if (typebuf.tb_len == 0 && typebuf.tb_buflen |
ff27a6a3a243
patch 8.0.0551: the typeahead buffer is reallocated too often
Christian Brabandt <cb@256bit.org>
parents:
11325
diff
changeset
|
994 >= addlen + 3 * (MAXMAPLEN + 4)) |
ff27a6a3a243
patch 8.0.0551: the typeahead buffer is reallocated too often
Christian Brabandt <cb@256bit.org>
parents:
11325
diff
changeset
|
995 { |
ff27a6a3a243
patch 8.0.0551: the typeahead buffer is reallocated too often
Christian Brabandt <cb@256bit.org>
parents:
11325
diff
changeset
|
996 /* |
ff27a6a3a243
patch 8.0.0551: the typeahead buffer is reallocated too often
Christian Brabandt <cb@256bit.org>
parents:
11325
diff
changeset
|
997 * Buffer is empty and string fits in the existing buffer. |
ff27a6a3a243
patch 8.0.0551: the typeahead buffer is reallocated too often
Christian Brabandt <cb@256bit.org>
parents:
11325
diff
changeset
|
998 * Leave some space before and after, if possible. |
ff27a6a3a243
patch 8.0.0551: the typeahead buffer is reallocated too often
Christian Brabandt <cb@256bit.org>
parents:
11325
diff
changeset
|
999 */ |
ff27a6a3a243
patch 8.0.0551: the typeahead buffer is reallocated too often
Christian Brabandt <cb@256bit.org>
parents:
11325
diff
changeset
|
1000 typebuf.tb_off = (typebuf.tb_buflen - addlen - 3 * (MAXMAPLEN + 4)) / 2; |
ff27a6a3a243
patch 8.0.0551: the typeahead buffer is reallocated too often
Christian Brabandt <cb@256bit.org>
parents:
11325
diff
changeset
|
1001 mch_memmove(typebuf.tb_buf + typebuf.tb_off, str, (size_t)addlen); |
ff27a6a3a243
patch 8.0.0551: the typeahead buffer is reallocated too often
Christian Brabandt <cb@256bit.org>
parents:
11325
diff
changeset
|
1002 } |
7 | 1003 else |
1004 { | |
10549
055b1633aed7
patch 8.0.0164: outdated and misplaced comments
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
1005 /* |
055b1633aed7
patch 8.0.0164: outdated and misplaced comments
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
1006 * Need to allocate a new buffer. |
11331
ff27a6a3a243
patch 8.0.0551: the typeahead buffer is reallocated too often
Christian Brabandt <cb@256bit.org>
parents:
11325
diff
changeset
|
1007 * In typebuf.tb_buf there must always be room for 3 * (MAXMAPLEN + 4) |
10549
055b1633aed7
patch 8.0.0164: outdated and misplaced comments
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
1008 * characters. We add some extra room to avoid having to allocate too |
055b1633aed7
patch 8.0.0164: outdated and misplaced comments
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
1009 * often. |
055b1633aed7
patch 8.0.0164: outdated and misplaced comments
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
1010 */ |
7 | 1011 newoff = MAXMAPLEN + 4; |
1012 newlen = typebuf.tb_len + addlen + newoff + 4 * (MAXMAPLEN + 4); | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1013 if (newlen < 0) // string is getting too long |
7 | 1014 { |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1015 emsg(_(e_toocompl)); // also calls flush_buffers |
7 | 1016 setcursor(); |
1017 return FAIL; | |
1018 } | |
1019 s1 = alloc(newlen); | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1020 if (s1 == NULL) // out of memory |
7 | 1021 return FAIL; |
1022 s2 = alloc(newlen); | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1023 if (s2 == NULL) // out of memory |
7 | 1024 { |
1025 vim_free(s1); | |
1026 return FAIL; | |
1027 } | |
1028 typebuf.tb_buflen = newlen; | |
1029 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1030 // copy the old chars, before the insertion point |
7 | 1031 mch_memmove(s1 + newoff, typebuf.tb_buf + typebuf.tb_off, |
1032 (size_t)offset); | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1033 // copy the new chars |
7 | 1034 mch_memmove(s1 + newoff + offset, str, (size_t)addlen); |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1035 // copy the old chars, after the insertion point, including the NUL at |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1036 // the end |
7 | 1037 mch_memmove(s1 + newoff + offset + addlen, |
1038 typebuf.tb_buf + typebuf.tb_off + offset, | |
1039 (size_t)(typebuf.tb_len - offset + 1)); | |
1040 if (typebuf.tb_buf != typebuf_init) | |
1041 vim_free(typebuf.tb_buf); | |
1042 typebuf.tb_buf = s1; | |
1043 | |
1044 mch_memmove(s2 + newoff, typebuf.tb_noremap + typebuf.tb_off, | |
1045 (size_t)offset); | |
1046 mch_memmove(s2 + newoff + offset + addlen, | |
1047 typebuf.tb_noremap + typebuf.tb_off + offset, | |
1048 (size_t)(typebuf.tb_len - offset)); | |
1049 if (typebuf.tb_noremap != noremapbuf_init) | |
1050 vim_free(typebuf.tb_noremap); | |
1051 typebuf.tb_noremap = s2; | |
1052 | |
1053 typebuf.tb_off = newoff; | |
1054 } | |
1055 typebuf.tb_len += addlen; | |
1056 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1057 // If noremap == REMAP_SCRIPT: do remap script-local mappings. |
7 | 1058 if (noremap == REMAP_SCRIPT) |
1059 val = RM_SCRIPT; | |
10 | 1060 else if (noremap == REMAP_SKIP) |
1061 val = RM_ABBR; | |
7 | 1062 else |
1063 val = RM_NONE; | |
1064 | |
1065 /* | |
1066 * Adjust typebuf.tb_noremap[] for the new characters: | |
1067 * If noremap == REMAP_NONE or REMAP_SCRIPT: new characters are | |
1068 * (sometimes) not remappable | |
1069 * If noremap == REMAP_YES: all the new characters are mappable | |
1070 * If noremap > 0: "noremap" characters are not remappable, the rest | |
1071 * mappable | |
1072 */ | |
10 | 1073 if (noremap == REMAP_SKIP) |
1074 nrm = 1; | |
1075 else if (noremap < 0) | |
7 | 1076 nrm = addlen; |
1077 else | |
1078 nrm = noremap; | |
1079 for (i = 0; i < addlen; ++i) | |
1080 typebuf.tb_noremap[typebuf.tb_off + i + offset] = | |
1081 (--nrm >= 0) ? val : RM_YES; | |
1082 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1083 // tb_maplen and tb_silent only remember the length of mapped and/or |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1084 // silent mappings at the start of the buffer, assuming that a mapped |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1085 // sequence doesn't result in typed characters. |
7 | 1086 if (nottyped || typebuf.tb_maplen > offset) |
1087 typebuf.tb_maplen += addlen; | |
1088 if (silent || typebuf.tb_silent > offset) | |
1089 { | |
1090 typebuf.tb_silent += addlen; | |
1091 cmd_silent = TRUE; | |
1092 } | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1093 if (typebuf.tb_no_abbr_cnt && offset == 0) // and not used for abbrev.s |
7 | 1094 typebuf.tb_no_abbr_cnt += addlen; |
1095 | |
1096 return OK; | |
1097 } | |
1098 | |
1099 /* | |
852 | 1100 * Put character "c" back into the typeahead buffer. |
1101 * Can be used for a character obtained by vgetc() that needs to be put back. | |
1051 | 1102 * Uses cmd_silent, KeyTyped and KeyNoremap to restore the flags belonging to |
1103 * the char. | |
852 | 1104 */ |
1105 void | |
20571
5995db0fe84a
patch 8.2.0839: dropping modifier when putting a character back in typeahead
Bram Moolenaar <Bram@vim.org>
parents:
20563
diff
changeset
|
1106 ins_char_typebuf(int c, int modifier) |
852 | 1107 { |
20571
5995db0fe84a
patch 8.2.0839: dropping modifier when putting a character back in typeahead
Bram Moolenaar <Bram@vim.org>
parents:
20563
diff
changeset
|
1108 char_u buf[MB_MAXBYTES + 4]; |
5995db0fe84a
patch 8.2.0839: dropping modifier when putting a character back in typeahead
Bram Moolenaar <Bram@vim.org>
parents:
20563
diff
changeset
|
1109 int idx = 0; |
5995db0fe84a
patch 8.2.0839: dropping modifier when putting a character back in typeahead
Bram Moolenaar <Bram@vim.org>
parents:
20563
diff
changeset
|
1110 |
5995db0fe84a
patch 8.2.0839: dropping modifier when putting a character back in typeahead
Bram Moolenaar <Bram@vim.org>
parents:
20563
diff
changeset
|
1111 if (modifier != 0) |
852 | 1112 { |
1113 buf[0] = K_SPECIAL; | |
20571
5995db0fe84a
patch 8.2.0839: dropping modifier when putting a character back in typeahead
Bram Moolenaar <Bram@vim.org>
parents:
20563
diff
changeset
|
1114 buf[1] = KS_MODIFIER; |
5995db0fe84a
patch 8.2.0839: dropping modifier when putting a character back in typeahead
Bram Moolenaar <Bram@vim.org>
parents:
20563
diff
changeset
|
1115 buf[2] = modifier; |
852 | 1116 buf[3] = NUL; |
20571
5995db0fe84a
patch 8.2.0839: dropping modifier when putting a character back in typeahead
Bram Moolenaar <Bram@vim.org>
parents:
20563
diff
changeset
|
1117 idx = 3; |
5995db0fe84a
patch 8.2.0839: dropping modifier when putting a character back in typeahead
Bram Moolenaar <Bram@vim.org>
parents:
20563
diff
changeset
|
1118 } |
5995db0fe84a
patch 8.2.0839: dropping modifier when putting a character back in typeahead
Bram Moolenaar <Bram@vim.org>
parents:
20563
diff
changeset
|
1119 if (IS_SPECIAL(c)) |
5995db0fe84a
patch 8.2.0839: dropping modifier when putting a character back in typeahead
Bram Moolenaar <Bram@vim.org>
parents:
20563
diff
changeset
|
1120 { |
5995db0fe84a
patch 8.2.0839: dropping modifier when putting a character back in typeahead
Bram Moolenaar <Bram@vim.org>
parents:
20563
diff
changeset
|
1121 buf[idx] = K_SPECIAL; |
5995db0fe84a
patch 8.2.0839: dropping modifier when putting a character back in typeahead
Bram Moolenaar <Bram@vim.org>
parents:
20563
diff
changeset
|
1122 buf[idx + 1] = K_SECOND(c); |
5995db0fe84a
patch 8.2.0839: dropping modifier when putting a character back in typeahead
Bram Moolenaar <Bram@vim.org>
parents:
20563
diff
changeset
|
1123 buf[idx + 2] = K_THIRD(c); |
5995db0fe84a
patch 8.2.0839: dropping modifier when putting a character back in typeahead
Bram Moolenaar <Bram@vim.org>
parents:
20563
diff
changeset
|
1124 buf[idx + 3] = NUL; |
5995db0fe84a
patch 8.2.0839: dropping modifier when putting a character back in typeahead
Bram Moolenaar <Bram@vim.org>
parents:
20563
diff
changeset
|
1125 idx += 3; |
852 | 1126 } |
1127 else | |
20571
5995db0fe84a
patch 8.2.0839: dropping modifier when putting a character back in typeahead
Bram Moolenaar <Bram@vim.org>
parents:
20563
diff
changeset
|
1128 buf[(*mb_char2bytes)(c, buf + idx) + idx] = NUL; |
1051 | 1129 (void)ins_typebuf(buf, KeyNoremap, 0, !KeyTyped, cmd_silent); |
852 | 1130 } |
1131 | |
1132 /* | |
7 | 1133 * Return TRUE if the typeahead buffer was changed (while waiting for a |
841 | 1134 * character to arrive). Happens when a message was received from a client or |
842 | 1135 * from feedkeys(). |
7 | 1136 * But check in a more generic way to avoid trouble: When "typebuf.tb_buf" |
1137 * changed it was reallocated and the old pointer can no longer be used. | |
1138 * Or "typebuf.tb_off" may have been changed and we would overwrite characters | |
1139 * that was just added. | |
1140 */ | |
1141 int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1142 typebuf_changed( |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1143 int tb_change_cnt) // old value of typebuf.tb_change_cnt |
7 | 1144 { |
1145 return (tb_change_cnt != 0 && (typebuf.tb_change_cnt != tb_change_cnt | |
841 | 1146 #if defined(FEAT_CLIENTSERVER) || defined(FEAT_EVAL) |
1147 || typebuf_was_filled | |
7 | 1148 #endif |
1149 )); | |
1150 } | |
1151 | |
1152 /* | |
1153 * Return TRUE if there are no characters in the typeahead buffer that have | |
1154 * not been typed (result from a mapping or come from ":normal"). | |
1155 */ | |
1156 int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1157 typebuf_typed(void) |
7 | 1158 { |
1159 return typebuf.tb_maplen == 0; | |
1160 } | |
1161 | |
1162 /* | |
1163 * Return the number of characters that are mapped (or not typed). | |
1164 */ | |
1165 int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1166 typebuf_maplen(void) |
7 | 1167 { |
1168 return typebuf.tb_maplen; | |
1169 } | |
1170 | |
1171 /* | |
1172 * remove "len" characters from typebuf.tb_buf[typebuf.tb_off + offset] | |
1173 */ | |
1174 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1175 del_typebuf(int len, int offset) |
7 | 1176 { |
1177 int i; | |
1178 | |
1179 if (len == 0) | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1180 return; // nothing to do |
7 | 1181 |
1182 typebuf.tb_len -= len; | |
1183 | |
1184 /* | |
1185 * Easy case: Just increase typebuf.tb_off. | |
1186 */ | |
1187 if (offset == 0 && typebuf.tb_buflen - (typebuf.tb_off + len) | |
1188 >= 3 * MAXMAPLEN + 3) | |
1189 typebuf.tb_off += len; | |
1190 /* | |
1191 * Have to move the characters in typebuf.tb_buf[] and typebuf.tb_noremap[] | |
1192 */ | |
1193 else | |
1194 { | |
1195 i = typebuf.tb_off + offset; | |
1196 /* | |
1197 * Leave some extra room at the end to avoid reallocation. | |
1198 */ | |
1199 if (typebuf.tb_off > MAXMAPLEN) | |
1200 { | |
1201 mch_memmove(typebuf.tb_buf + MAXMAPLEN, | |
1202 typebuf.tb_buf + typebuf.tb_off, (size_t)offset); | |
1203 mch_memmove(typebuf.tb_noremap + MAXMAPLEN, | |
1204 typebuf.tb_noremap + typebuf.tb_off, (size_t)offset); | |
1205 typebuf.tb_off = MAXMAPLEN; | |
1206 } | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1207 // adjust typebuf.tb_buf (include the NUL at the end) |
7 | 1208 mch_memmove(typebuf.tb_buf + typebuf.tb_off + offset, |
1209 typebuf.tb_buf + i + len, | |
1210 (size_t)(typebuf.tb_len - offset + 1)); | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1211 // adjust typebuf.tb_noremap[] |
7 | 1212 mch_memmove(typebuf.tb_noremap + typebuf.tb_off + offset, |
1213 typebuf.tb_noremap + i + len, | |
1214 (size_t)(typebuf.tb_len - offset)); | |
1215 } | |
1216 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1217 if (typebuf.tb_maplen > offset) // adjust tb_maplen |
7 | 1218 { |
1219 if (typebuf.tb_maplen < offset + len) | |
1220 typebuf.tb_maplen = offset; | |
1221 else | |
1222 typebuf.tb_maplen -= len; | |
1223 } | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1224 if (typebuf.tb_silent > offset) // adjust tb_silent |
7 | 1225 { |
1226 if (typebuf.tb_silent < offset + len) | |
1227 typebuf.tb_silent = offset; | |
1228 else | |
1229 typebuf.tb_silent -= len; | |
1230 } | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1231 if (typebuf.tb_no_abbr_cnt > offset) // adjust tb_no_abbr_cnt |
7 | 1232 { |
1233 if (typebuf.tb_no_abbr_cnt < offset + len) | |
1234 typebuf.tb_no_abbr_cnt = offset; | |
1235 else | |
1236 typebuf.tb_no_abbr_cnt -= len; | |
1237 } | |
1238 | |
841 | 1239 #if defined(FEAT_CLIENTSERVER) || defined(FEAT_EVAL) |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1240 // Reset the flag that text received from a client or from feedkeys() |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1241 // was inserted in the typeahead buffer. |
841 | 1242 typebuf_was_filled = FALSE; |
7 | 1243 #endif |
1244 if (++typebuf.tb_change_cnt == 0) | |
1245 typebuf.tb_change_cnt = 1; | |
1246 } | |
1247 | |
1248 /* | |
1249 * Write typed characters to script file. | |
1250 * If recording is on put the character in the recordbuffer. | |
1251 */ | |
1252 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1253 gotchars(char_u *chars, int len) |
7 | 1254 { |
14247
381b01f77461
patch 8.1.0140: recording into a register has focus events
Christian Brabandt <cb@256bit.org>
parents:
14069
diff
changeset
|
1255 char_u *s = chars; |
381b01f77461
patch 8.1.0140: recording into a register has focus events
Christian Brabandt <cb@256bit.org>
parents:
14069
diff
changeset
|
1256 int i; |
381b01f77461
patch 8.1.0140: recording into a register has focus events
Christian Brabandt <cb@256bit.org>
parents:
14069
diff
changeset
|
1257 static char_u buf[4]; |
381b01f77461
patch 8.1.0140: recording into a register has focus events
Christian Brabandt <cb@256bit.org>
parents:
14069
diff
changeset
|
1258 static int buflen = 0; |
381b01f77461
patch 8.1.0140: recording into a register has focus events
Christian Brabandt <cb@256bit.org>
parents:
14069
diff
changeset
|
1259 int todo = len; |
381b01f77461
patch 8.1.0140: recording into a register has focus events
Christian Brabandt <cb@256bit.org>
parents:
14069
diff
changeset
|
1260 |
1130 | 1261 while (todo--) |
7 | 1262 { |
14247
381b01f77461
patch 8.1.0140: recording into a register has focus events
Christian Brabandt <cb@256bit.org>
parents:
14069
diff
changeset
|
1263 buf[buflen++] = *s++; |
381b01f77461
patch 8.1.0140: recording into a register has focus events
Christian Brabandt <cb@256bit.org>
parents:
14069
diff
changeset
|
1264 |
381b01f77461
patch 8.1.0140: recording into a register has focus events
Christian Brabandt <cb@256bit.org>
parents:
14069
diff
changeset
|
1265 // When receiving a special key sequence, store it until we have all |
381b01f77461
patch 8.1.0140: recording into a register has focus events
Christian Brabandt <cb@256bit.org>
parents:
14069
diff
changeset
|
1266 // the bytes and we can decide what to do with it. |
381b01f77461
patch 8.1.0140: recording into a register has focus events
Christian Brabandt <cb@256bit.org>
parents:
14069
diff
changeset
|
1267 if (buflen == 1 && buf[0] == K_SPECIAL) |
381b01f77461
patch 8.1.0140: recording into a register has focus events
Christian Brabandt <cb@256bit.org>
parents:
14069
diff
changeset
|
1268 continue; |
381b01f77461
patch 8.1.0140: recording into a register has focus events
Christian Brabandt <cb@256bit.org>
parents:
14069
diff
changeset
|
1269 if (buflen == 2) |
381b01f77461
patch 8.1.0140: recording into a register has focus events
Christian Brabandt <cb@256bit.org>
parents:
14069
diff
changeset
|
1270 continue; |
381b01f77461
patch 8.1.0140: recording into a register has focus events
Christian Brabandt <cb@256bit.org>
parents:
14069
diff
changeset
|
1271 if (buflen == 3 && buf[1] == KS_EXTRA |
381b01f77461
patch 8.1.0140: recording into a register has focus events
Christian Brabandt <cb@256bit.org>
parents:
14069
diff
changeset
|
1272 && (buf[2] == KE_FOCUSGAINED || buf[2] == KE_FOCUSLOST)) |
381b01f77461
patch 8.1.0140: recording into a register has focus events
Christian Brabandt <cb@256bit.org>
parents:
14069
diff
changeset
|
1273 { |
381b01f77461
patch 8.1.0140: recording into a register has focus events
Christian Brabandt <cb@256bit.org>
parents:
14069
diff
changeset
|
1274 // Drop K_FOCUSGAINED and K_FOCUSLOST, they are not useful in a |
381b01f77461
patch 8.1.0140: recording into a register has focus events
Christian Brabandt <cb@256bit.org>
parents:
14069
diff
changeset
|
1275 // recording. |
381b01f77461
patch 8.1.0140: recording into a register has focus events
Christian Brabandt <cb@256bit.org>
parents:
14069
diff
changeset
|
1276 buflen = 0; |
381b01f77461
patch 8.1.0140: recording into a register has focus events
Christian Brabandt <cb@256bit.org>
parents:
14069
diff
changeset
|
1277 continue; |
381b01f77461
patch 8.1.0140: recording into a register has focus events
Christian Brabandt <cb@256bit.org>
parents:
14069
diff
changeset
|
1278 } |
381b01f77461
patch 8.1.0140: recording into a register has focus events
Christian Brabandt <cb@256bit.org>
parents:
14069
diff
changeset
|
1279 |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1280 // Handle one byte at a time; no translation to be done. |
14247
381b01f77461
patch 8.1.0140: recording into a register has focus events
Christian Brabandt <cb@256bit.org>
parents:
14069
diff
changeset
|
1281 for (i = 0; i < buflen; ++i) |
381b01f77461
patch 8.1.0140: recording into a register has focus events
Christian Brabandt <cb@256bit.org>
parents:
14069
diff
changeset
|
1282 updatescript(buf[i]); |
7 | 1283 |
14004
e124262d435e
patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents:
13950
diff
changeset
|
1284 if (reg_recording != 0) |
7 | 1285 { |
14247
381b01f77461
patch 8.1.0140: recording into a register has focus events
Christian Brabandt <cb@256bit.org>
parents:
14069
diff
changeset
|
1286 buf[buflen] = NUL; |
381b01f77461
patch 8.1.0140: recording into a register has focus events
Christian Brabandt <cb@256bit.org>
parents:
14069
diff
changeset
|
1287 add_buff(&recordbuff, buf, (long)buflen); |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1288 // remember how many chars were last recorded |
14247
381b01f77461
patch 8.1.0140: recording into a register has focus events
Christian Brabandt <cb@256bit.org>
parents:
14069
diff
changeset
|
1289 last_recorded_len += buflen; |
7 | 1290 } |
14247
381b01f77461
patch 8.1.0140: recording into a register has focus events
Christian Brabandt <cb@256bit.org>
parents:
14069
diff
changeset
|
1291 buflen = 0; |
7 | 1292 } |
1293 may_sync_undo(); | |
1294 | |
1295 #ifdef FEAT_EVAL | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1296 // output "debug mode" message next time in debug mode |
7 | 1297 debug_did_msg = FALSE; |
1298 #endif | |
1299 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1300 // Since characters have been typed, consider the following to be in |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1301 // another mapping. Search string will be kept in history. |
7 | 1302 ++maptick; |
1303 } | |
1304 | |
1305 /* | |
1306 * Sync undo. Called when typed characters are obtained from the typeahead | |
1307 * buffer, or when a menu is used. | |
1308 * Do not sync: | |
1309 * - In Insert mode, unless cursor key has been used. | |
1310 * - While reading a script file. | |
1311 * - When no_u_sync is non-zero. | |
1312 */ | |
1313 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1314 may_sync_undo(void) |
7 | 1315 { |
1316 if ((!(State & (INSERT + CMDLINE)) || arrow_used) | |
825 | 1317 && scriptin[curscript] == NULL) |
1318 u_sync(FALSE); | |
7 | 1319 } |
1320 | |
1321 /* | |
1322 * Make "typebuf" empty and allocate new buffers. | |
1323 * Returns FAIL when out of memory. | |
1324 */ | |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17659
diff
changeset
|
1325 static int |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1326 alloc_typebuf(void) |
7 | 1327 { |
1328 typebuf.tb_buf = alloc(TYPELEN_INIT); | |
1329 typebuf.tb_noremap = alloc(TYPELEN_INIT); | |
1330 if (typebuf.tb_buf == NULL || typebuf.tb_noremap == NULL) | |
1331 { | |
1332 free_typebuf(); | |
1333 return FAIL; | |
1334 } | |
1335 typebuf.tb_buflen = TYPELEN_INIT; | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1336 typebuf.tb_off = MAXMAPLEN + 4; // can insert without realloc |
7 | 1337 typebuf.tb_len = 0; |
1338 typebuf.tb_maplen = 0; | |
1339 typebuf.tb_silent = 0; | |
1340 typebuf.tb_no_abbr_cnt = 0; | |
1341 if (++typebuf.tb_change_cnt == 0) | |
1342 typebuf.tb_change_cnt = 1; | |
19627
6b1564fcab92
patch 8.2.0370: the typebuf_was_filled flag is sometimes not reset
Bram Moolenaar <Bram@vim.org>
parents:
19599
diff
changeset
|
1343 #if defined(FEAT_CLIENTSERVER) || defined(FEAT_EVAL) |
6b1564fcab92
patch 8.2.0370: the typebuf_was_filled flag is sometimes not reset
Bram Moolenaar <Bram@vim.org>
parents:
19599
diff
changeset
|
1344 typebuf_was_filled = FALSE; |
6b1564fcab92
patch 8.2.0370: the typebuf_was_filled flag is sometimes not reset
Bram Moolenaar <Bram@vim.org>
parents:
19599
diff
changeset
|
1345 #endif |
7 | 1346 return OK; |
1347 } | |
1348 | |
1349 /* | |
1350 * Free the buffers of "typebuf". | |
1351 */ | |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17659
diff
changeset
|
1352 static void |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1353 free_typebuf(void) |
7 | 1354 { |
1462 | 1355 if (typebuf.tb_buf == typebuf_init) |
10359
66f1b5bf3fa6
commit https://github.com/vim/vim/commit/95f096030ed1a8afea028f2ea295d6f6a70f466f
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1356 internal_error("Free typebuf 1"); |
1462 | 1357 else |
18193
f31b0ac6e175
patch 8.1.2091: double free when memory allocation fails
Bram Moolenaar <Bram@vim.org>
parents:
18116
diff
changeset
|
1358 VIM_CLEAR(typebuf.tb_buf); |
1992 | 1359 if (typebuf.tb_noremap == noremapbuf_init) |
10359
66f1b5bf3fa6
commit https://github.com/vim/vim/commit/95f096030ed1a8afea028f2ea295d6f6a70f466f
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1360 internal_error("Free typebuf 2"); |
1462 | 1361 else |
18193
f31b0ac6e175
patch 8.1.2091: double free when memory allocation fails
Bram Moolenaar <Bram@vim.org>
parents:
18116
diff
changeset
|
1362 VIM_CLEAR(typebuf.tb_noremap); |
7 | 1363 } |
1364 | |
1365 /* | |
1366 * When doing ":so! file", the current typeahead needs to be saved, and | |
1367 * restored when "file" has been read completely. | |
1368 */ | |
1369 static typebuf_T saved_typebuf[NSCRIPT]; | |
1370 | |
1371 int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1372 save_typebuf(void) |
7 | 1373 { |
1374 init_typebuf(); | |
1375 saved_typebuf[curscript] = typebuf; | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1376 // If out of memory: restore typebuf and close file. |
7 | 1377 if (alloc_typebuf() == FAIL) |
1378 { | |
1379 closescript(); | |
1380 return FAIL; | |
1381 } | |
1382 return OK; | |
1383 } | |
1384 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1385 static int old_char = -1; // character put back by vungetc() |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1386 static int old_mod_mask; // mod_mask for ungotten character |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1387 static int old_mouse_row; // mouse_row related to old_char |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1388 static int old_mouse_col; // mouse_col related to old_char |
1928 | 1389 |
7 | 1390 /* |
1391 * Save all three kinds of typeahead, so that the user must type at a prompt. | |
1392 */ | |
1393 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1394 save_typeahead(tasave_T *tp) |
7 | 1395 { |
1396 tp->save_typebuf = typebuf; | |
1397 tp->typebuf_valid = (alloc_typebuf() == OK); | |
1398 if (!tp->typebuf_valid) | |
1399 typebuf = tp->save_typebuf; | |
1400 | |
1928 | 1401 tp->old_char = old_char; |
1402 tp->old_mod_mask = old_mod_mask; | |
1403 old_char = -1; | |
1404 | |
5649 | 1405 tp->save_readbuf1 = readbuf1; |
13726
d35b1702a1da
patch 8.0.1735: flexible array member feature not supported by HP-UX
Christian Brabandt <cb@256bit.org>
parents:
13702
diff
changeset
|
1406 readbuf1.bh_first.b_next = NULL; |
5649 | 1407 tp->save_readbuf2 = readbuf2; |
13726
d35b1702a1da
patch 8.0.1735: flexible array member feature not supported by HP-UX
Christian Brabandt <cb@256bit.org>
parents:
13702
diff
changeset
|
1408 readbuf2.bh_first.b_next = NULL; |
7 | 1409 # ifdef USE_INPUT_BUF |
1410 tp->save_inputbuf = get_input_buf(); | |
1411 # endif | |
1412 } | |
1413 | |
1414 /* | |
1415 * Restore the typeahead to what it was before calling save_typeahead(). | |
1416 * The allocated memory is freed, can only be called once! | |
1417 */ | |
1418 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1419 restore_typeahead(tasave_T *tp) |
7 | 1420 { |
1421 if (tp->typebuf_valid) | |
1422 { | |
1423 free_typebuf(); | |
1424 typebuf = tp->save_typebuf; | |
1425 } | |
1426 | |
1928 | 1427 old_char = tp->old_char; |
1428 old_mod_mask = tp->old_mod_mask; | |
1429 | |
5649 | 1430 free_buff(&readbuf1); |
1431 readbuf1 = tp->save_readbuf1; | |
1432 free_buff(&readbuf2); | |
1433 readbuf2 = tp->save_readbuf2; | |
7 | 1434 # ifdef USE_INPUT_BUF |
1435 set_input_buf(tp->save_inputbuf); | |
1436 # endif | |
1437 } | |
1438 | |
1439 /* | |
1440 * Open a new script file for the ":source!" command. | |
1441 */ | |
1442 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1443 openscript( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1444 char_u *name, |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1445 int directly) // when TRUE execute directly |
7 | 1446 { |
1447 if (curscript + 1 == NSCRIPT) | |
1448 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
14909
diff
changeset
|
1449 emsg(_(e_nesting)); |
7 | 1450 return; |
1451 } | |
16726
fbab59a5ee6b
patch 8.1.1365: source command doesn't check for the sandbox
Bram Moolenaar <Bram@vim.org>
parents:
16712
diff
changeset
|
1452 |
fbab59a5ee6b
patch 8.1.1365: source command doesn't check for the sandbox
Bram Moolenaar <Bram@vim.org>
parents:
16712
diff
changeset
|
1453 // Disallow sourcing a file in the sandbox, the commands would be executed |
fbab59a5ee6b
patch 8.1.1365: source command doesn't check for the sandbox
Bram Moolenaar <Bram@vim.org>
parents:
16712
diff
changeset
|
1454 // later, possibly outside of the sandbox. |
fbab59a5ee6b
patch 8.1.1365: source command doesn't check for the sandbox
Bram Moolenaar <Bram@vim.org>
parents:
16712
diff
changeset
|
1455 if (check_secure()) |
fbab59a5ee6b
patch 8.1.1365: source command doesn't check for the sandbox
Bram Moolenaar <Bram@vim.org>
parents:
16712
diff
changeset
|
1456 return; |
fbab59a5ee6b
patch 8.1.1365: source command doesn't check for the sandbox
Bram Moolenaar <Bram@vim.org>
parents:
16712
diff
changeset
|
1457 |
1462 | 1458 #ifdef FEAT_EVAL |
1459 if (ignore_script) | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1460 // Not reading from script, also don't open one. Warning message? |
1462 | 1461 return; |
1462 #endif | |
7 | 1463 |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1464 if (scriptin[curscript] != NULL) // already reading script |
7 | 1465 ++curscript; |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1466 // use NameBuff for expanded name |
7 | 1467 expand_env(name, NameBuff, MAXPATHL); |
1468 if ((scriptin[curscript] = mch_fopen((char *)NameBuff, READBIN)) == NULL) | |
1469 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
14909
diff
changeset
|
1470 semsg(_(e_notopen), name); |
7 | 1471 if (curscript) |
1472 --curscript; | |
1473 return; | |
1474 } | |
1475 if (save_typebuf() == FAIL) | |
1476 return; | |
1477 | |
1478 /* | |
1479 * Execute the commands from the file right now when using ":source!" | |
1480 * after ":global" or ":argdo" or in a loop. Also when another command | |
1481 * follows. This means the display won't be updated. Don't do this | |
1482 * always, "make test" would fail. | |
1483 */ | |
1484 if (directly) | |
1485 { | |
1486 oparg_T oa; | |
1487 int oldcurscript; | |
1488 int save_State = State; | |
1489 int save_restart_edit = restart_edit; | |
1490 int save_insertmode = p_im; | |
1491 int save_finish_op = finish_op; | |
1492 int save_msg_scroll = msg_scroll; | |
1493 | |
1494 State = NORMAL; | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1495 msg_scroll = FALSE; // no msg scrolling in Normal mode |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1496 restart_edit = 0; // don't go to Insert mode |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1497 p_im = FALSE; // don't use 'insertmode' |
7 | 1498 clear_oparg(&oa); |
1499 finish_op = FALSE; | |
1500 | |
1501 oldcurscript = curscript; | |
1502 do | |
1503 { | |
16712
329e28ed10fd
patch 8.1.1358: cannot enter character with a CSI byte
Bram Moolenaar <Bram@vim.org>
parents:
16531
diff
changeset
|
1504 update_topline_cursor(); // update cursor position and topline |
329e28ed10fd
patch 8.1.1358: cannot enter character with a CSI byte
Bram Moolenaar <Bram@vim.org>
parents:
16531
diff
changeset
|
1505 normal_cmd(&oa, FALSE); // execute one command |
21230
e67123c115d2
patch 8.2.1166: once mouse move events are enabled getchar() returns them
Bram Moolenaar <Bram@vim.org>
parents:
20800
diff
changeset
|
1506 (void)vpeekc(); // check for end of file |
7 | 1507 } |
1508 while (scriptin[oldcurscript] != NULL); | |
1509 | |
1510 State = save_State; | |
1511 msg_scroll = save_msg_scroll; | |
1512 restart_edit = save_restart_edit; | |
1513 p_im = save_insertmode; | |
1514 finish_op = save_finish_op; | |
1515 } | |
1516 } | |
1517 | |
1518 /* | |
1519 * Close the currently active input script. | |
1520 */ | |
1521 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1522 closescript(void) |
7 | 1523 { |
1524 free_typebuf(); | |
1525 typebuf = saved_typebuf[curscript]; | |
1526 | |
1527 fclose(scriptin[curscript]); | |
1528 scriptin[curscript] = NULL; | |
1529 if (curscript > 0) | |
1530 --curscript; | |
1531 } | |
1532 | |
358 | 1533 #if defined(EXITFREE) || defined(PROTO) |
1534 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1535 close_all_scripts(void) |
358 | 1536 { |
1537 while (scriptin[0] != NULL) | |
1538 closescript(); | |
1539 } | |
1540 #endif | |
1541 | |
7 | 1542 /* |
1543 * Return TRUE when reading keys from a script file. | |
1544 */ | |
1545 int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1546 using_script(void) |
7 | 1547 { |
1548 return scriptin[curscript] != NULL; | |
1549 } | |
1550 | |
1551 /* | |
365 | 1552 * This function is called just before doing a blocking wait. Thus after |
1553 * waiting 'updatetime' for a character to arrive. | |
1554 */ | |
1555 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1556 before_blocking(void) |
365 | 1557 { |
1558 updatescript(0); | |
1559 #ifdef FEAT_EVAL | |
958 | 1560 if (may_garbage_collect) |
8881
ed0b39dd7fd6
commit https://github.com/vim/vim/commit/ebf7dfa6f121c82f97d2adca3d45fbaba9ad8f7e
Christian Brabandt <cb@256bit.org>
parents:
8212
diff
changeset
|
1561 garbage_collect(FALSE); |
365 | 1562 #endif |
1563 } | |
1564 | |
1565 /* | |
18498
9e6d5a4abb1c
patch 8.1.2243: typos in comments
Bram Moolenaar <Bram@vim.org>
parents:
18412
diff
changeset
|
1566 * updatescript() is called when a character can be written into the script file |
7 | 1567 * or when we have waited some time for a character (c == 0) |
1568 * | |
1569 * All the changed memfiles are synced if c == 0 or when the number of typed | |
1570 * characters reaches 'updatecount' and 'updatecount' is non-zero. | |
1571 */ | |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17659
diff
changeset
|
1572 static void |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1573 updatescript(int c) |
7 | 1574 { |
1575 static int count = 0; | |
1576 | |
1577 if (c && scriptout) | |
1578 putc(c, scriptout); | |
1579 if (c == 0 || (p_uc > 0 && ++count >= p_uc)) | |
1580 { | |
1581 ml_sync_all(c == 0, TRUE); | |
1582 count = 0; | |
1583 } | |
1584 } | |
1585 | |
1586 /* | |
20727
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20701
diff
changeset
|
1587 * Convert "c" plus "modifiers" to merge the effect of modifyOtherKeys into the |
18717
14d2a210fab1
patch 8.1.2350: other text for CTRL-V in Insert mode with modifyOtherKeys
Bram Moolenaar <Bram@vim.org>
parents:
18689
diff
changeset
|
1588 * character. |
14d2a210fab1
patch 8.1.2350: other text for CTRL-V in Insert mode with modifyOtherKeys
Bram Moolenaar <Bram@vim.org>
parents:
18689
diff
changeset
|
1589 */ |
14d2a210fab1
patch 8.1.2350: other text for CTRL-V in Insert mode with modifyOtherKeys
Bram Moolenaar <Bram@vim.org>
parents:
18689
diff
changeset
|
1590 int |
20727
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20701
diff
changeset
|
1591 merge_modifyOtherKeys(int c_arg, int *modifiers) |
18717
14d2a210fab1
patch 8.1.2350: other text for CTRL-V in Insert mode with modifyOtherKeys
Bram Moolenaar <Bram@vim.org>
parents:
18689
diff
changeset
|
1592 { |
14d2a210fab1
patch 8.1.2350: other text for CTRL-V in Insert mode with modifyOtherKeys
Bram Moolenaar <Bram@vim.org>
parents:
18689
diff
changeset
|
1593 int c = c_arg; |
14d2a210fab1
patch 8.1.2350: other text for CTRL-V in Insert mode with modifyOtherKeys
Bram Moolenaar <Bram@vim.org>
parents:
18689
diff
changeset
|
1594 |
20727
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20701
diff
changeset
|
1595 if (*modifiers & MOD_MASK_CTRL) |
18717
14d2a210fab1
patch 8.1.2350: other text for CTRL-V in Insert mode with modifyOtherKeys
Bram Moolenaar <Bram@vim.org>
parents:
18689
diff
changeset
|
1596 { |
14d2a210fab1
patch 8.1.2350: other text for CTRL-V in Insert mode with modifyOtherKeys
Bram Moolenaar <Bram@vim.org>
parents:
18689
diff
changeset
|
1597 if ((c >= '`' && c <= 0x7f) || (c >= '@' && c <= '_')) |
14d2a210fab1
patch 8.1.2350: other text for CTRL-V in Insert mode with modifyOtherKeys
Bram Moolenaar <Bram@vim.org>
parents:
18689
diff
changeset
|
1598 c &= 0x1f; |
14d2a210fab1
patch 8.1.2350: other text for CTRL-V in Insert mode with modifyOtherKeys
Bram Moolenaar <Bram@vim.org>
parents:
18689
diff
changeset
|
1599 else if (c == '6') |
14d2a210fab1
patch 8.1.2350: other text for CTRL-V in Insert mode with modifyOtherKeys
Bram Moolenaar <Bram@vim.org>
parents:
18689
diff
changeset
|
1600 // CTRL-6 is equivalent to CTRL-^ |
14d2a210fab1
patch 8.1.2350: other text for CTRL-V in Insert mode with modifyOtherKeys
Bram Moolenaar <Bram@vim.org>
parents:
18689
diff
changeset
|
1601 c = 0x1e; |
20595
3609e842f822
patch 8.2.0851: can't distinguish <M-a> from accented "a" in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20571
diff
changeset
|
1602 #ifdef FEAT_GUI_GTK |
3609e842f822
patch 8.2.0851: can't distinguish <M-a> from accented "a" in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20571
diff
changeset
|
1603 // These mappings look arbitrary at the first glance, but in fact |
3609e842f822
patch 8.2.0851: can't distinguish <M-a> from accented "a" in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20571
diff
changeset
|
1604 // resemble quite exactly the behaviour of the GTK+ 1.2 GUI on my |
3609e842f822
patch 8.2.0851: can't distinguish <M-a> from accented "a" in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20571
diff
changeset
|
1605 // machine. The only difference is BS vs. DEL for CTRL-8 (makes |
3609e842f822
patch 8.2.0851: can't distinguish <M-a> from accented "a" in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20571
diff
changeset
|
1606 // more sense and is consistent with usual terminal behaviour). |
3609e842f822
patch 8.2.0851: can't distinguish <M-a> from accented "a" in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20571
diff
changeset
|
1607 else if (c == '2') |
3609e842f822
patch 8.2.0851: can't distinguish <M-a> from accented "a" in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20571
diff
changeset
|
1608 c = NUL; |
3609e842f822
patch 8.2.0851: can't distinguish <M-a> from accented "a" in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20571
diff
changeset
|
1609 else if (c >= '3' && c <= '7') |
3609e842f822
patch 8.2.0851: can't distinguish <M-a> from accented "a" in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20571
diff
changeset
|
1610 c = c ^ 0x28; |
3609e842f822
patch 8.2.0851: can't distinguish <M-a> from accented "a" in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20571
diff
changeset
|
1611 else if (c == '8') |
3609e842f822
patch 8.2.0851: can't distinguish <M-a> from accented "a" in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20571
diff
changeset
|
1612 c = BS; |
3609e842f822
patch 8.2.0851: can't distinguish <M-a> from accented "a" in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20571
diff
changeset
|
1613 else if (c == '?') |
3609e842f822
patch 8.2.0851: can't distinguish <M-a> from accented "a" in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20571
diff
changeset
|
1614 c = DEL; |
3609e842f822
patch 8.2.0851: can't distinguish <M-a> from accented "a" in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20571
diff
changeset
|
1615 #endif |
3609e842f822
patch 8.2.0851: can't distinguish <M-a> from accented "a" in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
20571
diff
changeset
|
1616 if (c != c_arg) |
20727
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20701
diff
changeset
|
1617 *modifiers &= ~MOD_MASK_CTRL; |
18717
14d2a210fab1
patch 8.1.2350: other text for CTRL-V in Insert mode with modifyOtherKeys
Bram Moolenaar <Bram@vim.org>
parents:
18689
diff
changeset
|
1618 } |
20727
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20701
diff
changeset
|
1619 if ((*modifiers & (MOD_MASK_META | MOD_MASK_ALT)) |
18717
14d2a210fab1
patch 8.1.2350: other text for CTRL-V in Insert mode with modifyOtherKeys
Bram Moolenaar <Bram@vim.org>
parents:
18689
diff
changeset
|
1620 && c >= 0 && c <= 127) |
14d2a210fab1
patch 8.1.2350: other text for CTRL-V in Insert mode with modifyOtherKeys
Bram Moolenaar <Bram@vim.org>
parents:
18689
diff
changeset
|
1621 { |
14d2a210fab1
patch 8.1.2350: other text for CTRL-V in Insert mode with modifyOtherKeys
Bram Moolenaar <Bram@vim.org>
parents:
18689
diff
changeset
|
1622 c += 0x80; |
20727
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20701
diff
changeset
|
1623 *modifiers &= ~(MOD_MASK_META|MOD_MASK_ALT); |
18717
14d2a210fab1
patch 8.1.2350: other text for CTRL-V in Insert mode with modifyOtherKeys
Bram Moolenaar <Bram@vim.org>
parents:
18689
diff
changeset
|
1624 } |
14d2a210fab1
patch 8.1.2350: other text for CTRL-V in Insert mode with modifyOtherKeys
Bram Moolenaar <Bram@vim.org>
parents:
18689
diff
changeset
|
1625 return c; |
14d2a210fab1
patch 8.1.2350: other text for CTRL-V in Insert mode with modifyOtherKeys
Bram Moolenaar <Bram@vim.org>
parents:
18689
diff
changeset
|
1626 } |
14d2a210fab1
patch 8.1.2350: other text for CTRL-V in Insert mode with modifyOtherKeys
Bram Moolenaar <Bram@vim.org>
parents:
18689
diff
changeset
|
1627 |
14d2a210fab1
patch 8.1.2350: other text for CTRL-V in Insert mode with modifyOtherKeys
Bram Moolenaar <Bram@vim.org>
parents:
18689
diff
changeset
|
1628 /* |
7 | 1629 * Get the next input character. |
1630 * Can return a special key or a multi-byte character. | |
1631 * Can return NUL when called recursively, use safe_vgetc() if that's not | |
1632 * wanted. | |
1633 * This translates escaped K_SPECIAL and CSI bytes to a K_SPECIAL or CSI byte. | |
1634 * Collects the bytes of a multibyte character into the whole character. | |
1992 | 1635 * Returns the modifiers in the global "mod_mask". |
7 | 1636 */ |
1637 int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1638 vgetc(void) |
7 | 1639 { |
1640 int c, c2; | |
1641 int n; | |
3549 | 1642 char_u buf[MB_MAXBYTES + 1]; |
7 | 1643 int i; |
1644 | |
958 | 1645 #ifdef FEAT_EVAL |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1646 // Do garbage collection when garbagecollect() was called previously and |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1647 // we are now at the toplevel. |
958 | 1648 if (may_garbage_collect && want_garbage_collect) |
8881
ed0b39dd7fd6
commit https://github.com/vim/vim/commit/ebf7dfa6f121c82f97d2adca3d45fbaba9ad8f7e
Christian Brabandt <cb@256bit.org>
parents:
8212
diff
changeset
|
1649 garbage_collect(FALSE); |
958 | 1650 #endif |
1651 | |
7 | 1652 /* |
1653 * If a character was put back with vungetc, it was already processed. | |
1654 * Return it directly. | |
1655 */ | |
1656 if (old_char != -1) | |
1657 { | |
1658 c = old_char; | |
1659 old_char = -1; | |
1660 mod_mask = old_mod_mask; | |
4227 | 1661 mouse_row = old_mouse_row; |
1662 mouse_col = old_mouse_col; | |
7 | 1663 } |
958 | 1664 else |
7 | 1665 { |
20571
5995db0fe84a
patch 8.2.0839: dropping modifier when putting a character back in typeahead
Bram Moolenaar <Bram@vim.org>
parents:
20563
diff
changeset
|
1666 mod_mask = 0; |
5995db0fe84a
patch 8.2.0839: dropping modifier when putting a character back in typeahead
Bram Moolenaar <Bram@vim.org>
parents:
20563
diff
changeset
|
1667 vgetc_mod_mask = 0; |
5995db0fe84a
patch 8.2.0839: dropping modifier when putting a character back in typeahead
Bram Moolenaar <Bram@vim.org>
parents:
20563
diff
changeset
|
1668 vgetc_char = 0; |
15989
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1669 last_recorded_len = 0; |
20571
5995db0fe84a
patch 8.2.0839: dropping modifier when putting a character back in typeahead
Bram Moolenaar <Bram@vim.org>
parents:
20563
diff
changeset
|
1670 |
15989
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1671 for (;;) // this is done twice if there are modifiers |
7 | 1672 { |
15989
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1673 int did_inc = FALSE; |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1674 |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1675 if (mod_mask |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1676 #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1677 || im_is_preediting() |
7 | 1678 #endif |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1679 #if defined(FEAT_PROP_POPUP) |
17604
506dd2efcbb2
patch 8.1.1799: cannot avoid mapping for a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17602
diff
changeset
|
1680 || popup_no_mapping() |
506dd2efcbb2
patch 8.1.1799: cannot avoid mapping for a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17602
diff
changeset
|
1681 #endif |
15989
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1682 ) |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1683 { |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1684 // no mapping after modifier has been read |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1685 ++no_mapping; |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1686 ++allow_keys; |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1687 did_inc = TRUE; // mod_mask may change value |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1688 } |
7 | 1689 c = vgetorpeek(TRUE); |
15989
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1690 if (did_inc) |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1691 { |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1692 --no_mapping; |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1693 --allow_keys; |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1694 } |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1695 |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1696 // Get two extra bytes for special keys |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1697 if (c == K_SPECIAL |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1698 #ifdef FEAT_GUI |
19599
5eb0ead1415f
patch 8.2.0356: MS-Windows: feedkeys() with VIMDLL cannot handle CSI
Bram Moolenaar <Bram@vim.org>
parents:
19433
diff
changeset
|
1699 || (c == CSI) |
15989
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1700 #endif |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1701 ) |
7 | 1702 { |
15989
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1703 int save_allow_keys = allow_keys; |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1704 |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1705 ++no_mapping; |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1706 allow_keys = 0; // make sure BS is not found |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1707 c2 = vgetorpeek(TRUE); // no mapping for these chars |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1708 c = vgetorpeek(TRUE); |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1709 --no_mapping; |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1710 allow_keys = save_allow_keys; |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1711 if (c2 == KS_MODIFIER) |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1712 { |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1713 mod_mask = c; |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1714 continue; |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1715 } |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1716 c = TO_SPECIAL(c2, c); |
7 | 1717 |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
1718 #if defined(FEAT_GUI_MSWIN) && defined(FEAT_MENU) && defined(FEAT_TEAROFF) |
15989
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1719 // Handle K_TEAROFF here, the caller of vgetc() doesn't need to |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1720 // know that a menu was torn off |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16393
diff
changeset
|
1721 if ( |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16393
diff
changeset
|
1722 # ifdef VIMDLL |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16393
diff
changeset
|
1723 gui.in_use && |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16393
diff
changeset
|
1724 # endif |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16393
diff
changeset
|
1725 c == K_TEAROFF) |
7 | 1726 { |
15989
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1727 char_u name[200]; |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1728 int i; |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1729 |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1730 // get menu path, it ends with a <CR> |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1731 for (i = 0; (c = vgetorpeek(TRUE)) != '\r'; ) |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1732 { |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1733 name[i] = c; |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1734 if (i < 199) |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1735 ++i; |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1736 } |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1737 name[i] = NUL; |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1738 gui_make_tearoff(name); |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1739 continue; |
7 | 1740 } |
1741 #endif | |
2277
f42e0b5ff9e9
Change remaining HAVE_GTK2 to FEAT_GUI_GTK.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
1742 #if defined(FEAT_GUI) && defined(FEAT_GUI_GTK) && defined(FEAT_MENU) |
15989
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1743 // GTK: <F10> normally selects the menu, but it's passed until |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1744 // here to allow mapping it. Intercept and invoke the GTK |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1745 // behavior if it's not mapped. |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1746 if (c == K_F10 && gui.menubar != NULL) |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1747 { |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1748 gtk_menu_shell_select_first( |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1749 GTK_MENU_SHELL(gui.menubar), FALSE); |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1750 continue; |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1751 } |
36 | 1752 #endif |
7 | 1753 #ifdef FEAT_GUI |
19599
5eb0ead1415f
patch 8.2.0356: MS-Windows: feedkeys() with VIMDLL cannot handle CSI
Bram Moolenaar <Bram@vim.org>
parents:
19433
diff
changeset
|
1754 // Handle focus event here, so that the caller doesn't need to |
5eb0ead1415f
patch 8.2.0356: MS-Windows: feedkeys() with VIMDLL cannot handle CSI
Bram Moolenaar <Bram@vim.org>
parents:
19433
diff
changeset
|
1755 // know about it. Return K_IGNORE so that we loop once (needed |
5eb0ead1415f
patch 8.2.0356: MS-Windows: feedkeys() with VIMDLL cannot handle CSI
Bram Moolenaar <Bram@vim.org>
parents:
19433
diff
changeset
|
1756 // if 'lazyredraw' is set). |
5eb0ead1415f
patch 8.2.0356: MS-Windows: feedkeys() with VIMDLL cannot handle CSI
Bram Moolenaar <Bram@vim.org>
parents:
19433
diff
changeset
|
1757 if (c == K_FOCUSGAINED || c == K_FOCUSLOST) |
15989
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1758 { |
19599
5eb0ead1415f
patch 8.2.0356: MS-Windows: feedkeys() with VIMDLL cannot handle CSI
Bram Moolenaar <Bram@vim.org>
parents:
19433
diff
changeset
|
1759 ui_focus_change(c == K_FOCUSGAINED); |
5eb0ead1415f
patch 8.2.0356: MS-Windows: feedkeys() with VIMDLL cannot handle CSI
Bram Moolenaar <Bram@vim.org>
parents:
19433
diff
changeset
|
1760 c = K_IGNORE; |
15989
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1761 } |
19599
5eb0ead1415f
patch 8.2.0356: MS-Windows: feedkeys() with VIMDLL cannot handle CSI
Bram Moolenaar <Bram@vim.org>
parents:
19433
diff
changeset
|
1762 |
5eb0ead1415f
patch 8.2.0356: MS-Windows: feedkeys() with VIMDLL cannot handle CSI
Bram Moolenaar <Bram@vim.org>
parents:
19433
diff
changeset
|
1763 // Translate K_CSI to CSI. The special key is only used to |
5eb0ead1415f
patch 8.2.0356: MS-Windows: feedkeys() with VIMDLL cannot handle CSI
Bram Moolenaar <Bram@vim.org>
parents:
19433
diff
changeset
|
1764 // avoid it being recognized as the start of a special key. |
5eb0ead1415f
patch 8.2.0356: MS-Windows: feedkeys() with VIMDLL cannot handle CSI
Bram Moolenaar <Bram@vim.org>
parents:
19433
diff
changeset
|
1765 if (c == K_CSI) |
5eb0ead1415f
patch 8.2.0356: MS-Windows: feedkeys() with VIMDLL cannot handle CSI
Bram Moolenaar <Bram@vim.org>
parents:
19433
diff
changeset
|
1766 c = CSI; |
15989
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1767 #endif |
1380 | 1768 } |
15989
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1769 // a keypad or special function key was not mapped, use it like |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1770 // its ASCII equivalent |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1771 switch (c) |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1772 { |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1773 case K_KPLUS: c = '+'; break; |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1774 case K_KMINUS: c = '-'; break; |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1775 case K_KDIVIDE: c = '/'; break; |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1776 case K_KMULTIPLY: c = '*'; break; |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1777 case K_KENTER: c = CAR; break; |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1778 case K_KPOINT: |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
1779 #ifdef MSWIN |
14403
e29cbac5e8f6
patch 8.1.0216: part of file not indented properly
Christian Brabandt <cb@256bit.org>
parents:
14247
diff
changeset
|
1780 // Can be either '.' or a ',', |
e29cbac5e8f6
patch 8.1.0216: part of file not indented properly
Christian Brabandt <cb@256bit.org>
parents:
14247
diff
changeset
|
1781 // depending on the type of keypad. |
e29cbac5e8f6
patch 8.1.0216: part of file not indented properly
Christian Brabandt <cb@256bit.org>
parents:
14247
diff
changeset
|
1782 c = MapVirtualKey(VK_DECIMAL, 2); break; |
36 | 1783 #else |
14403
e29cbac5e8f6
patch 8.1.0216: part of file not indented properly
Christian Brabandt <cb@256bit.org>
parents:
14247
diff
changeset
|
1784 c = '.'; break; |
36 | 1785 #endif |
15989
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1786 case K_K0: c = '0'; break; |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1787 case K_K1: c = '1'; break; |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1788 case K_K2: c = '2'; break; |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1789 case K_K3: c = '3'; break; |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1790 case K_K4: c = '4'; break; |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1791 case K_K5: c = '5'; break; |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1792 case K_K6: c = '6'; break; |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1793 case K_K7: c = '7'; break; |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1794 case K_K8: c = '8'; break; |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1795 case K_K9: c = '9'; break; |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1796 |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1797 case K_XHOME: |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1798 case K_ZHOME: if (mod_mask == MOD_MASK_SHIFT) |
229 | 1799 { |
1800 c = K_S_HOME; | |
1801 mod_mask = 0; | |
1802 } | |
1803 else if (mod_mask == MOD_MASK_CTRL) | |
1804 { | |
1805 c = K_C_HOME; | |
1806 mod_mask = 0; | |
1807 } | |
1808 else | |
1809 c = K_HOME; | |
1810 break; | |
15989
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1811 case K_XEND: |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1812 case K_ZEND: if (mod_mask == MOD_MASK_SHIFT) |
229 | 1813 { |
1814 c = K_S_END; | |
1815 mod_mask = 0; | |
1816 } | |
1817 else if (mod_mask == MOD_MASK_CTRL) | |
1818 { | |
1819 c = K_C_END; | |
1820 mod_mask = 0; | |
1821 } | |
1822 else | |
1823 c = K_END; | |
1824 break; | |
1825 | |
15989
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1826 case K_XUP: c = K_UP; break; |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1827 case K_XDOWN: c = K_DOWN; break; |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1828 case K_XLEFT: c = K_LEFT; break; |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1829 case K_XRIGHT: c = K_RIGHT; break; |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1830 } |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1831 |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1832 // For a multi-byte character get all the bytes and return the |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1833 // converted character. |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1834 // Note: This will loop until enough bytes are received! |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1835 if (has_mbyte && (n = MB_BYTE2LEN_CHECK(c)) > 1) |
7 | 1836 { |
15989
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1837 ++no_mapping; |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1838 buf[0] = c; |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1839 for (i = 1; i < n; ++i) |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1840 { |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1841 buf[i] = vgetorpeek(TRUE); |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1842 if (buf[i] == K_SPECIAL |
7 | 1843 #ifdef FEAT_GUI |
19599
5eb0ead1415f
patch 8.2.0356: MS-Windows: feedkeys() with VIMDLL cannot handle CSI
Bram Moolenaar <Bram@vim.org>
parents:
19433
diff
changeset
|
1844 || (buf[i] == CSI) |
7 | 1845 #endif |
15989
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1846 ) |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1847 { |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1848 // Must be a K_SPECIAL - KS_SPECIAL - KE_FILLER |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1849 // sequence, which represents a K_SPECIAL (0x80), |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1850 // or a CSI - KS_EXTRA - KE_CSI sequence, which |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1851 // represents a CSI (0x9B), |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1852 // or a K_SPECIAL - KS_EXTRA - KE_CSI, which is CSI |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1853 // too. |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1854 c = vgetorpeek(TRUE); |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1855 if (vgetorpeek(TRUE) == (int)KE_CSI && c == KS_EXTRA) |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1856 buf[i] = CSI; |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1857 } |
7 | 1858 } |
15989
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1859 --no_mapping; |
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1860 c = (*mb_ptr2char)(buf); |
7 | 1861 } |
15989
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1862 |
20733
e3078150144d
patch 8.2.0919: merging modifier for modifyOtherKeys is done twice
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
1863 if (vgetc_char == 0) |
20571
5995db0fe84a
patch 8.2.0839: dropping modifier when putting a character back in typeahead
Bram Moolenaar <Bram@vim.org>
parents:
20563
diff
changeset
|
1864 { |
5995db0fe84a
patch 8.2.0839: dropping modifier when putting a character back in typeahead
Bram Moolenaar <Bram@vim.org>
parents:
20563
diff
changeset
|
1865 vgetc_mod_mask = mod_mask; |
5995db0fe84a
patch 8.2.0839: dropping modifier when putting a character back in typeahead
Bram Moolenaar <Bram@vim.org>
parents:
20563
diff
changeset
|
1866 vgetc_char = c; |
5995db0fe84a
patch 8.2.0839: dropping modifier when putting a character back in typeahead
Bram Moolenaar <Bram@vim.org>
parents:
20563
diff
changeset
|
1867 } |
18281
c67268c0398e
patch 8.1.2135: with modifyOtherKeys Alt-a does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
18279
diff
changeset
|
1868 |
15989
a14d8b4ef2b0
patch 8.1.1000: indenting is off
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1869 break; |
7 | 1870 } |
1871 } | |
958 | 1872 |
1873 #ifdef FEAT_EVAL | |
1874 /* | |
1875 * In the main loop "may_garbage_collect" can be set to do garbage | |
1876 * collection in the first next vgetc(). It's disabled after that to | |
1877 * avoid internally used Lists and Dicts to be freed. | |
1878 */ | |
1879 may_garbage_collect = FALSE; | |
1880 #endif | |
18102
0d9ec3a2821f
patch 8.1.2046: SafeState may be triggered at the wrong moment
Bram Moolenaar <Bram@vim.org>
parents:
18094
diff
changeset
|
1881 |
12871
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
12865
diff
changeset
|
1882 #ifdef FEAT_BEVAL_TERM |
17282
6f1679e1082d
patch 8.1.1640: the CursorHold autocommand takes down a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17184
diff
changeset
|
1883 if (c != K_MOUSEMOVE && c != K_IGNORE && c != K_CURSORHOLD) |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
1884 { |
18102
0d9ec3a2821f
patch 8.1.2046: SafeState may be triggered at the wrong moment
Bram Moolenaar <Bram@vim.org>
parents:
18094
diff
changeset
|
1885 // Don't trigger 'balloonexpr' unless only the mouse was moved. |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
1886 bevalexpr_due_set = FALSE; |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
1887 ui_remove_balloon(); |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
1888 } |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
1889 #endif |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1890 #ifdef FEAT_PROP_POPUP |
16880
998603a243d7
patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1891 if (popup_do_filter(c)) |
18231
25535ef50842
patch 8.1.2110: CTRL-C closes two popups instead of one
Bram Moolenaar <Bram@vim.org>
parents:
18193
diff
changeset
|
1892 { |
25535ef50842
patch 8.1.2110: CTRL-C closes two popups instead of one
Bram Moolenaar <Bram@vim.org>
parents:
18193
diff
changeset
|
1893 if (c == Ctrl_C) |
25535ef50842
patch 8.1.2110: CTRL-C closes two popups instead of one
Bram Moolenaar <Bram@vim.org>
parents:
18193
diff
changeset
|
1894 got_int = FALSE; // avoid looping |
16880
998603a243d7
patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1895 c = K_IGNORE; |
18231
25535ef50842
patch 8.1.2110: CTRL-C closes two popups instead of one
Bram Moolenaar <Bram@vim.org>
parents:
18193
diff
changeset
|
1896 } |
16880
998603a243d7
patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1897 #endif |
958 | 1898 |
18102
0d9ec3a2821f
patch 8.1.2046: SafeState may be triggered at the wrong moment
Bram Moolenaar <Bram@vim.org>
parents:
18094
diff
changeset
|
1899 // Need to process the character before we know it's safe to do something |
0d9ec3a2821f
patch 8.1.2046: SafeState may be triggered at the wrong moment
Bram Moolenaar <Bram@vim.org>
parents:
18094
diff
changeset
|
1900 // else. |
0d9ec3a2821f
patch 8.1.2046: SafeState may be triggered at the wrong moment
Bram Moolenaar <Bram@vim.org>
parents:
18094
diff
changeset
|
1901 if (c != K_IGNORE) |
18116
7f57ea9a4ba8
patch 8.1.2053: SafeStateAgain not triggered if callback uses feedkeys()
Bram Moolenaar <Bram@vim.org>
parents:
18106
diff
changeset
|
1902 state_no_longer_safe("key typed"); |
18102
0d9ec3a2821f
patch 8.1.2046: SafeState may be triggered at the wrong moment
Bram Moolenaar <Bram@vim.org>
parents:
18094
diff
changeset
|
1903 |
958 | 1904 return c; |
7 | 1905 } |
1906 | |
1907 /* | |
1908 * Like vgetc(), but never return a NUL when called recursively, get a key | |
1909 * directly from the user (ignoring typeahead). | |
1910 */ | |
1911 int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1912 safe_vgetc(void) |
7 | 1913 { |
1914 int c; | |
1915 | |
1916 c = vgetc(); | |
1917 if (c == NUL) | |
1918 c = get_keystroke(); | |
1919 return c; | |
1920 } | |
1921 | |
1922 /* | |
1389 | 1923 * Like safe_vgetc(), but loop to handle K_IGNORE. |
1924 * Also ignore scrollbar events. | |
1925 */ | |
1926 int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1927 plain_vgetc(void) |
1389 | 1928 { |
1929 int c; | |
1930 | |
1931 do | |
1932 c = safe_vgetc(); | |
16162
cd5c83115ec6
patch 8.1.1086: too many curly braces
Bram Moolenaar <Bram@vim.org>
parents:
15995
diff
changeset
|
1933 while (c == K_IGNORE || c == K_VER_SCROLLBAR || c == K_HOR_SCROLLBAR); |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10549
diff
changeset
|
1934 |
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10549
diff
changeset
|
1935 if (c == K_PS) |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1936 // Only handle the first pasted character. Drop the rest, since we |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1937 // don't know what to do with it. |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10549
diff
changeset
|
1938 c = bracketed_paste(PASTE_ONE_CHAR, FALSE, NULL); |
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10549
diff
changeset
|
1939 |
1389 | 1940 return c; |
1941 } | |
1942 | |
1943 /* | |
7 | 1944 * Check if a character is available, such that vgetc() will not block. |
1945 * If the next character is a special character or multi-byte, the returned | |
1946 * character is not valid!. | |
14909
c97b4b537572
patch 8.1.0466: autocmd test fails
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
1947 * Returns NUL if no character is available. |
7 | 1948 */ |
1949 int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1950 vpeekc(void) |
7 | 1951 { |
1952 if (old_char != -1) | |
1953 return old_char; | |
1954 return vgetorpeek(FALSE); | |
1955 } | |
1956 | |
13344
68c4fc9ae216
patch 8.0.1546: using feedkeys() in a terminal may trigger mappings
Christian Brabandt <cb@256bit.org>
parents:
13210
diff
changeset
|
1957 #if defined(FEAT_TERMRESPONSE) || defined(FEAT_TERMINAL) || defined(PROTO) |
7 | 1958 /* |
1959 * Like vpeekc(), but don't allow mapping. Do allow checking for terminal | |
1960 * codes. | |
1961 */ | |
1962 int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1963 vpeekc_nomap(void) |
7 | 1964 { |
1965 int c; | |
1966 | |
1967 ++no_mapping; | |
1968 ++allow_keys; | |
1969 c = vpeekc(); | |
1970 --no_mapping; | |
1971 --allow_keys; | |
1972 return c; | |
1973 } | |
1974 #endif | |
1975 | |
1976 /* | |
1977 * Check if any character is available, also half an escape sequence. | |
1978 * Trick: when no typeahead found, but there is something in the typeahead | |
1979 * buffer, it must be an ESC that is recognized as the start of a key code. | |
1980 */ | |
1981 int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1982 vpeekc_any(void) |
7 | 1983 { |
1984 int c; | |
1985 | |
1986 c = vpeekc(); | |
1987 if (c == NUL && typebuf.tb_len > 0) | |
1988 c = ESC; | |
1989 return c; | |
1990 } | |
1991 | |
1992 /* | |
1993 * Call vpeekc() without causing anything to be mapped. | |
1994 * Return TRUE if a character is available, FALSE otherwise. | |
1995 */ | |
1996 int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1997 char_avail(void) |
7 | 1998 { |
1999 int retval; | |
2000 | |
8011
26f555e9aab1
commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents:
7860
diff
changeset
|
2001 #ifdef FEAT_EVAL |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2002 // When test_override("char_avail", 1) was called pretend there is no |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2003 // typeahead. |
8011
26f555e9aab1
commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents:
7860
diff
changeset
|
2004 if (disable_char_avail_for_testing) |
26f555e9aab1
commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents:
7860
diff
changeset
|
2005 return FALSE; |
26f555e9aab1
commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents:
7860
diff
changeset
|
2006 #endif |
7 | 2007 ++no_mapping; |
2008 retval = vpeekc(); | |
2009 --no_mapping; | |
2010 return (retval != NUL); | |
2011 } | |
2012 | |
18094
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2013 #if defined(FEAT_EVAL) || defined(PROTO) |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2014 /* |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2015 * "getchar()" function |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2016 */ |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2017 void |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2018 f_getchar(typval_T *argvars, typval_T *rettv) |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2019 { |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2020 varnumber_T n; |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2021 int error = FALSE; |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2022 |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2023 #ifdef MESSAGE_QUEUE |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2024 // vpeekc() used to check for messages, but that caused problems, invoking |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2025 // a callback where it was not expected. Some plugins use getchar(1) in a |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2026 // loop to await a message, therefore make sure we check for messages here. |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2027 parse_queued_messages(); |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2028 #endif |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2029 |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2030 // Position the cursor. Needed after a message that ends in a space. |
18094
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2031 windgoto(msg_row, msg_col); |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2032 |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2033 ++no_mapping; |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2034 ++allow_keys; |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2035 for (;;) |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2036 { |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2037 if (argvars[0].v_type == VAR_UNKNOWN) |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2038 // getchar(): blocking wait. |
18094
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2039 n = plain_vgetc(); |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2040 else if (tv_get_number_chk(&argvars[0], &error) == 1) |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2041 // getchar(1): only check if char avail |
18094
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2042 n = vpeekc_any(); |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2043 else if (error || vpeekc_any() == NUL) |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2044 // illegal argument or getchar(0) and no char avail: return zero |
18094
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2045 n = 0; |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2046 else |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2047 // getchar(0) and char avail: return char |
18094
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2048 n = plain_vgetc(); |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2049 |
21230
e67123c115d2
patch 8.2.1166: once mouse move events are enabled getchar() returns them
Bram Moolenaar <Bram@vim.org>
parents:
20800
diff
changeset
|
2050 if (n == K_IGNORE || n == K_MOUSEMOVE) |
18094
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2051 continue; |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2052 break; |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2053 } |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2054 --no_mapping; |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2055 --allow_keys; |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2056 |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2057 set_vim_var_nr(VV_MOUSE_WIN, 0); |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2058 set_vim_var_nr(VV_MOUSE_WINID, 0); |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2059 set_vim_var_nr(VV_MOUSE_LNUM, 0); |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2060 set_vim_var_nr(VV_MOUSE_COL, 0); |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2061 |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2062 rettv->vval.v_number = n; |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2063 if (IS_SPECIAL(n) || mod_mask != 0) |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2064 { |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2065 char_u temp[10]; // modifier: 3, mbyte-char: 6, NUL: 1 |
18094
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2066 int i = 0; |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2067 |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2068 // Turn a special key into three bytes, plus modifier. |
18094
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2069 if (mod_mask != 0) |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2070 { |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2071 temp[i++] = K_SPECIAL; |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2072 temp[i++] = KS_MODIFIER; |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2073 temp[i++] = mod_mask; |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2074 } |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2075 if (IS_SPECIAL(n)) |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2076 { |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2077 temp[i++] = K_SPECIAL; |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2078 temp[i++] = K_SECOND(n); |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2079 temp[i++] = K_THIRD(n); |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2080 } |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2081 else if (has_mbyte) |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2082 i += (*mb_char2bytes)(n, temp + i); |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2083 else |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2084 temp[i++] = n; |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2085 temp[i++] = NUL; |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2086 rettv->v_type = VAR_STRING; |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2087 rettv->vval.v_string = vim_strsave(temp); |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2088 |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2089 if (is_mouse_key(n)) |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2090 { |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2091 int row = mouse_row; |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2092 int col = mouse_col; |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2093 win_T *win; |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2094 linenr_T lnum; |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2095 win_T *wp; |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2096 int winnr = 1; |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2097 |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2098 if (row >= 0 && col >= 0) |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2099 { |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2100 // Find the window at the mouse coordinates and compute the |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2101 // text position. |
18094
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2102 win = mouse_find_win(&row, &col, FIND_POPUP); |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2103 if (win == NULL) |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2104 return; |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2105 (void)mouse_comp_pos(win, &row, &col, &lnum, NULL); |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2106 #ifdef FEAT_PROP_POPUP |
18094
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2107 if (WIN_IS_POPUP(win)) |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2108 winnr = 0; |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2109 else |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18301
diff
changeset
|
2110 #endif |
18094
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2111 for (wp = firstwin; wp != win && wp != NULL; |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2112 wp = wp->w_next) |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2113 ++winnr; |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2114 set_vim_var_nr(VV_MOUSE_WIN, winnr); |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2115 set_vim_var_nr(VV_MOUSE_WINID, win->w_id); |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2116 set_vim_var_nr(VV_MOUSE_LNUM, lnum); |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2117 set_vim_var_nr(VV_MOUSE_COL, col + 1); |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2118 } |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2119 } |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2120 } |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2121 } |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2122 |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2123 /* |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2124 * "getcharmod()" function |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2125 */ |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2126 void |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2127 f_getcharmod(typval_T *argvars UNUSED, typval_T *rettv) |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2128 { |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2129 rettv->vval.v_number = mod_mask; |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2130 } |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2131 #endif // FEAT_EVAL |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2132 |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2133 #if defined(MESSAGE_QUEUE) || defined(PROTO) |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2134 # define MAX_REPEAT_PARSE 8 |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2135 |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2136 /* |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2137 * Process messages that have been queued for netbeans or clientserver. |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2138 * Also check if any jobs have ended. |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2139 * These functions can call arbitrary vimscript and should only be called when |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2140 * it is safe to do so. |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2141 */ |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2142 void |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2143 parse_queued_messages(void) |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2144 { |
18412
6208e5c2eee7
patch 8.1.2200: crash when memory allocation fails
Bram Moolenaar <Bram@vim.org>
parents:
18394
diff
changeset
|
2145 int old_curwin_id; |
6208e5c2eee7
patch 8.1.2200: crash when memory allocation fails
Bram Moolenaar <Bram@vim.org>
parents:
18394
diff
changeset
|
2146 int old_curbuf_fnum; |
18094
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2147 int i; |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2148 int save_may_garbage_collect = may_garbage_collect; |
18102
0d9ec3a2821f
patch 8.1.2046: SafeState may be triggered at the wrong moment
Bram Moolenaar <Bram@vim.org>
parents:
18094
diff
changeset
|
2149 static int entered = 0; |
18116
7f57ea9a4ba8
patch 8.1.2053: SafeStateAgain not triggered if callback uses feedkeys()
Bram Moolenaar <Bram@vim.org>
parents:
18106
diff
changeset
|
2150 int was_safe = get_was_safe_state(); |
18094
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2151 |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2152 // Do not handle messages while redrawing, because it may cause buffers to |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2153 // change or be wiped while they are being redrawn. |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2154 if (updating_screen) |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2155 return; |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2156 |
18412
6208e5c2eee7
patch 8.1.2200: crash when memory allocation fails
Bram Moolenaar <Bram@vim.org>
parents:
18394
diff
changeset
|
2157 // If memory allocation fails during startup we'll exit but curbuf or |
6208e5c2eee7
patch 8.1.2200: crash when memory allocation fails
Bram Moolenaar <Bram@vim.org>
parents:
18394
diff
changeset
|
2158 // curwin could be NULL. |
6208e5c2eee7
patch 8.1.2200: crash when memory allocation fails
Bram Moolenaar <Bram@vim.org>
parents:
18394
diff
changeset
|
2159 if (curbuf == NULL || curwin == NULL) |
6208e5c2eee7
patch 8.1.2200: crash when memory allocation fails
Bram Moolenaar <Bram@vim.org>
parents:
18394
diff
changeset
|
2160 return; |
6208e5c2eee7
patch 8.1.2200: crash when memory allocation fails
Bram Moolenaar <Bram@vim.org>
parents:
18394
diff
changeset
|
2161 |
6208e5c2eee7
patch 8.1.2200: crash when memory allocation fails
Bram Moolenaar <Bram@vim.org>
parents:
18394
diff
changeset
|
2162 old_curbuf_fnum = curbuf->b_fnum; |
6208e5c2eee7
patch 8.1.2200: crash when memory allocation fails
Bram Moolenaar <Bram@vim.org>
parents:
18394
diff
changeset
|
2163 old_curwin_id = curwin->w_id; |
6208e5c2eee7
patch 8.1.2200: crash when memory allocation fails
Bram Moolenaar <Bram@vim.org>
parents:
18394
diff
changeset
|
2164 |
18102
0d9ec3a2821f
patch 8.1.2046: SafeState may be triggered at the wrong moment
Bram Moolenaar <Bram@vim.org>
parents:
18094
diff
changeset
|
2165 ++entered; |
0d9ec3a2821f
patch 8.1.2046: SafeState may be triggered at the wrong moment
Bram Moolenaar <Bram@vim.org>
parents:
18094
diff
changeset
|
2166 |
18094
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2167 // may_garbage_collect is set in main_loop() to do garbage collection when |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2168 // blocking to wait on a character. We don't want that while parsing |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2169 // messages, a callback may invoke vgetc() while lists and dicts are in use |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2170 // in the call stack. |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2171 may_garbage_collect = FALSE; |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2172 |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2173 // Loop when a job ended, but don't keep looping forever. |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2174 for (i = 0; i < MAX_REPEAT_PARSE; ++i) |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2175 { |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2176 // For Win32 mch_breakcheck() does not check for input, do it here. |
20277
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20237
diff
changeset
|
2177 # if (defined(MSWIN) || defined(__HAIKU__)) && defined(FEAT_JOB_CHANNEL) |
18094
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2178 channel_handle_events(FALSE); |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2179 # endif |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2180 |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2181 # ifdef FEAT_NETBEANS_INTG |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2182 // Process the queued netbeans messages. |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2183 netbeans_parse_messages(); |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2184 # endif |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2185 # ifdef FEAT_JOB_CHANNEL |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2186 // Write any buffer lines still to be written. |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2187 channel_write_any_lines(); |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2188 |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2189 // Process the messages queued on channels. |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2190 channel_parse_messages(); |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2191 # endif |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2192 # if defined(FEAT_CLIENTSERVER) && defined(FEAT_X11) |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2193 // Process the queued clientserver messages. |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2194 server_parse_messages(); |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2195 # endif |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2196 # ifdef FEAT_JOB_CHANNEL |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2197 // Check if any jobs have ended. If so, repeat the above to handle |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2198 // changes, e.g. stdin may have been closed. |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2199 if (job_check_ended()) |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2200 continue; |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2201 # endif |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2202 # ifdef FEAT_TERMINAL |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2203 free_unused_terminals(); |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2204 # endif |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2205 # ifdef FEAT_SOUND_CANBERRA |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2206 if (has_sound_callback_in_queue()) |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2207 invoke_sound_callback(); |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2208 # endif |
20800
e76b83c07bd8
patch 8.2.0952: no simple way to interrupt Vim
Bram Moolenaar <Bram@vim.org>
parents:
20733
diff
changeset
|
2209 #ifdef SIGUSR1 |
e76b83c07bd8
patch 8.2.0952: no simple way to interrupt Vim
Bram Moolenaar <Bram@vim.org>
parents:
20733
diff
changeset
|
2210 if (got_sigusr1) |
e76b83c07bd8
patch 8.2.0952: no simple way to interrupt Vim
Bram Moolenaar <Bram@vim.org>
parents:
20733
diff
changeset
|
2211 { |
e76b83c07bd8
patch 8.2.0952: no simple way to interrupt Vim
Bram Moolenaar <Bram@vim.org>
parents:
20733
diff
changeset
|
2212 apply_autocmds(EVENT_SIGUSR1, NULL, NULL, FALSE, curbuf); |
e76b83c07bd8
patch 8.2.0952: no simple way to interrupt Vim
Bram Moolenaar <Bram@vim.org>
parents:
20733
diff
changeset
|
2213 got_sigusr1 = FALSE; |
e76b83c07bd8
patch 8.2.0952: no simple way to interrupt Vim
Bram Moolenaar <Bram@vim.org>
parents:
20733
diff
changeset
|
2214 } |
e76b83c07bd8
patch 8.2.0952: no simple way to interrupt Vim
Bram Moolenaar <Bram@vim.org>
parents:
20733
diff
changeset
|
2215 #endif |
18094
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2216 break; |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2217 } |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2218 |
18102
0d9ec3a2821f
patch 8.1.2046: SafeState may be triggered at the wrong moment
Bram Moolenaar <Bram@vim.org>
parents:
18094
diff
changeset
|
2219 // When not nested we'll go back to waiting for a typed character. If it |
0d9ec3a2821f
patch 8.1.2046: SafeState may be triggered at the wrong moment
Bram Moolenaar <Bram@vim.org>
parents:
18094
diff
changeset
|
2220 // was safe before then this triggers a SafeStateAgain autocommand event. |
18116
7f57ea9a4ba8
patch 8.1.2053: SafeStateAgain not triggered if callback uses feedkeys()
Bram Moolenaar <Bram@vim.org>
parents:
18106
diff
changeset
|
2221 if (entered == 1 && was_safe) |
18106
b456bba1276a
patch 8.1.2048: not clear why SafeState and SafeStateAgain are not triggered
Bram Moolenaar <Bram@vim.org>
parents:
18102
diff
changeset
|
2222 may_trigger_safestateagain(); |
18102
0d9ec3a2821f
patch 8.1.2046: SafeState may be triggered at the wrong moment
Bram Moolenaar <Bram@vim.org>
parents:
18094
diff
changeset
|
2223 |
18094
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2224 may_garbage_collect = save_may_garbage_collect; |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2225 |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2226 // If the current window or buffer changed we need to bail out of the |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2227 // waiting loop. E.g. when a job exit callback closes the terminal window. |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2228 if (curwin->w_id != old_curwin_id || curbuf->b_fnum != old_curbuf_fnum) |
20571
5995db0fe84a
patch 8.2.0839: dropping modifier when putting a character back in typeahead
Bram Moolenaar <Bram@vim.org>
parents:
20563
diff
changeset
|
2229 ins_char_typebuf(K_IGNORE, 0); |
18102
0d9ec3a2821f
patch 8.1.2046: SafeState may be triggered at the wrong moment
Bram Moolenaar <Bram@vim.org>
parents:
18094
diff
changeset
|
2230 |
0d9ec3a2821f
patch 8.1.2046: SafeState may be triggered at the wrong moment
Bram Moolenaar <Bram@vim.org>
parents:
18094
diff
changeset
|
2231 --entered; |
18094
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2232 } |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2233 #endif |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2234 |
a1396a35444c
patch 8.1.2042: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2235 |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2236 typedef enum { |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2237 map_result_fail, // failed, break loop |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2238 map_result_get, // get a character from typeahead |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2239 map_result_retry, // try to map again |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2240 map_result_nomatch // no matching mapping, get char |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2241 } map_result_T; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2242 |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2243 /* |
18394
084b28fb3d22
patch 8.1.2191: when using modifyOtherKeys CTRL-X mode may not work
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2244 * Check if the bytes at the start of the typeahead buffer are a character used |
084b28fb3d22
patch 8.1.2191: when using modifyOtherKeys CTRL-X mode may not work
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2245 * in CTRL-X mode. This includes the form with a CTRL modifier. |
084b28fb3d22
patch 8.1.2191: when using modifyOtherKeys CTRL-X mode may not work
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2246 */ |
084b28fb3d22
patch 8.1.2191: when using modifyOtherKeys CTRL-X mode may not work
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2247 static int |
084b28fb3d22
patch 8.1.2191: when using modifyOtherKeys CTRL-X mode may not work
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2248 at_ctrl_x_key(void) |
084b28fb3d22
patch 8.1.2191: when using modifyOtherKeys CTRL-X mode may not work
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2249 { |
084b28fb3d22
patch 8.1.2191: when using modifyOtherKeys CTRL-X mode may not work
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2250 char_u *p = typebuf.tb_buf + typebuf.tb_off; |
084b28fb3d22
patch 8.1.2191: when using modifyOtherKeys CTRL-X mode may not work
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2251 int c = *p; |
084b28fb3d22
patch 8.1.2191: when using modifyOtherKeys CTRL-X mode may not work
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2252 |
084b28fb3d22
patch 8.1.2191: when using modifyOtherKeys CTRL-X mode may not work
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2253 if (typebuf.tb_len > 3 |
084b28fb3d22
patch 8.1.2191: when using modifyOtherKeys CTRL-X mode may not work
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2254 && c == K_SPECIAL |
084b28fb3d22
patch 8.1.2191: when using modifyOtherKeys CTRL-X mode may not work
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2255 && p[1] == KS_MODIFIER |
084b28fb3d22
patch 8.1.2191: when using modifyOtherKeys CTRL-X mode may not work
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2256 && (p[2] & MOD_MASK_CTRL)) |
084b28fb3d22
patch 8.1.2191: when using modifyOtherKeys CTRL-X mode may not work
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2257 c = p[3] & 0x1f; |
084b28fb3d22
patch 8.1.2191: when using modifyOtherKeys CTRL-X mode may not work
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2258 return vim_is_ctrl_x_key(c); |
084b28fb3d22
patch 8.1.2191: when using modifyOtherKeys CTRL-X mode may not work
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2259 } |
084b28fb3d22
patch 8.1.2191: when using modifyOtherKeys CTRL-X mode may not work
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2260 |
084b28fb3d22
patch 8.1.2191: when using modifyOtherKeys CTRL-X mode may not work
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2261 /* |
20727
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20701
diff
changeset
|
2262 * Check if typebuf.tb_buf[] contains a modifer plus key that can be changed |
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20701
diff
changeset
|
2263 * into just a key, apply that. |
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20701
diff
changeset
|
2264 * Check from typebuf.tb_buf[typebuf.tb_off] to typebuf.tb_buf[typebuf.tb_off |
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20701
diff
changeset
|
2265 * + "max_offset"]. |
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20701
diff
changeset
|
2266 * Return the length of the replaced bytes, zero if nothing changed. |
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20701
diff
changeset
|
2267 */ |
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20701
diff
changeset
|
2268 static int |
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20701
diff
changeset
|
2269 check_simplify_modifier(int max_offset) |
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20701
diff
changeset
|
2270 { |
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20701
diff
changeset
|
2271 int offset; |
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20701
diff
changeset
|
2272 char_u *tp; |
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20701
diff
changeset
|
2273 |
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20701
diff
changeset
|
2274 for (offset = 0; offset < max_offset; ++offset) |
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20701
diff
changeset
|
2275 { |
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20701
diff
changeset
|
2276 if (offset + 3 >= typebuf.tb_len) |
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20701
diff
changeset
|
2277 break; |
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20701
diff
changeset
|
2278 tp = typebuf.tb_buf + typebuf.tb_off + offset; |
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20701
diff
changeset
|
2279 if (tp[0] == K_SPECIAL && tp[1] == KS_MODIFIER) |
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20701
diff
changeset
|
2280 { |
20733
e3078150144d
patch 8.2.0919: merging modifier for modifyOtherKeys is done twice
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
2281 // A modifier was not used for a mapping, apply it to ASCII keys. |
e3078150144d
patch 8.2.0919: merging modifier for modifyOtherKeys is done twice
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
2282 // Shift would already have been applied. |
20727
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20701
diff
changeset
|
2283 int modifier = tp[2]; |
20733
e3078150144d
patch 8.2.0919: merging modifier for modifyOtherKeys is done twice
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
2284 int c = tp[3]; |
e3078150144d
patch 8.2.0919: merging modifier for modifyOtherKeys is done twice
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
2285 int new_c = merge_modifyOtherKeys(c, &modifier); |
e3078150144d
patch 8.2.0919: merging modifier for modifyOtherKeys is done twice
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
2286 |
e3078150144d
patch 8.2.0919: merging modifier for modifyOtherKeys is done twice
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
2287 if (new_c != c) |
20727
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20701
diff
changeset
|
2288 { |
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20701
diff
changeset
|
2289 char_u new_string[MB_MAXBYTES]; |
20733
e3078150144d
patch 8.2.0919: merging modifier for modifyOtherKeys is done twice
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
2290 int len; |
e3078150144d
patch 8.2.0919: merging modifier for modifyOtherKeys is done twice
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
2291 |
e3078150144d
patch 8.2.0919: merging modifier for modifyOtherKeys is done twice
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
2292 if (offset == 0) |
e3078150144d
patch 8.2.0919: merging modifier for modifyOtherKeys is done twice
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
2293 { |
e3078150144d
patch 8.2.0919: merging modifier for modifyOtherKeys is done twice
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
2294 // At the start: remember the character and mod_mask before |
e3078150144d
patch 8.2.0919: merging modifier for modifyOtherKeys is done twice
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
2295 // merging, in some cases, e.g. at the hit-return prompt, |
e3078150144d
patch 8.2.0919: merging modifier for modifyOtherKeys is done twice
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
2296 // they are put back in the typeahead buffer. |
e3078150144d
patch 8.2.0919: merging modifier for modifyOtherKeys is done twice
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
2297 vgetc_char = c; |
e3078150144d
patch 8.2.0919: merging modifier for modifyOtherKeys is done twice
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
2298 vgetc_mod_mask = tp[2]; |
e3078150144d
patch 8.2.0919: merging modifier for modifyOtherKeys is done twice
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
2299 } |
e3078150144d
patch 8.2.0919: merging modifier for modifyOtherKeys is done twice
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
2300 len = mb_char2bytes(new_c, new_string); |
e3078150144d
patch 8.2.0919: merging modifier for modifyOtherKeys is done twice
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
2301 if (modifier == 0) |
e3078150144d
patch 8.2.0919: merging modifier for modifyOtherKeys is done twice
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
2302 { |
e3078150144d
patch 8.2.0919: merging modifier for modifyOtherKeys is done twice
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
2303 if (put_string_in_typebuf(offset, 4, new_string, len, |
20727
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20701
diff
changeset
|
2304 NULL, 0, 0) == FAIL) |
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20701
diff
changeset
|
2305 return -1; |
20733
e3078150144d
patch 8.2.0919: merging modifier for modifyOtherKeys is done twice
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
2306 } |
e3078150144d
patch 8.2.0919: merging modifier for modifyOtherKeys is done twice
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
2307 else |
e3078150144d
patch 8.2.0919: merging modifier for modifyOtherKeys is done twice
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
2308 { |
e3078150144d
patch 8.2.0919: merging modifier for modifyOtherKeys is done twice
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
2309 tp[2] = modifier; |
e3078150144d
patch 8.2.0919: merging modifier for modifyOtherKeys is done twice
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
2310 if (put_string_in_typebuf(offset + 3, 1, new_string, len, |
e3078150144d
patch 8.2.0919: merging modifier for modifyOtherKeys is done twice
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
2311 NULL, 0, 0) == FAIL) |
e3078150144d
patch 8.2.0919: merging modifier for modifyOtherKeys is done twice
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
2312 return -1; |
e3078150144d
patch 8.2.0919: merging modifier for modifyOtherKeys is done twice
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
2313 } |
20727
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20701
diff
changeset
|
2314 return len; |
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20701
diff
changeset
|
2315 } |
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20701
diff
changeset
|
2316 } |
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20701
diff
changeset
|
2317 } |
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20701
diff
changeset
|
2318 return 0; |
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20701
diff
changeset
|
2319 } |
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20701
diff
changeset
|
2320 |
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20701
diff
changeset
|
2321 /* |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2322 * Handle mappings in the typeahead buffer. |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2323 * - When something was mapped, return map_result_retry for recursive mappings. |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2324 * - When nothing mapped and typeahead has a character: return map_result_get. |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2325 * - When there is no match yet, return map_result_nomatch, need to get more |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2326 * typeahead. |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2327 */ |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2328 static int |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2329 handle_mapping( |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2330 int *keylenp, |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2331 int *timedout, |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2332 int *mapdepth) |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2333 { |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2334 mapblock_T *mp = NULL; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2335 mapblock_T *mp2; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2336 mapblock_T *mp_match; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2337 int mp_match_len = 0; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2338 int max_mlen = 0; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2339 int tb_c1; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2340 int mlen; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2341 #ifdef FEAT_LANGMAP |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2342 int nolmaplen; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2343 #endif |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2344 int keylen = *keylenp; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2345 int i; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2346 int local_State = get_real_state(); |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2347 |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2348 /* |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2349 * Check for a mappable key sequence. |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2350 * Walk through one maphash[] list until we find an entry that matches. |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2351 * |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2352 * Don't look for mappings if: |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2353 * - no_mapping set: mapping disabled (e.g. for CTRL-V) |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2354 * - maphash_valid not set: no mappings present. |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2355 * - typebuf.tb_buf[typebuf.tb_off] should not be remapped |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2356 * - in insert or cmdline mode and 'paste' option set |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2357 * - waiting for "hit return to continue" and CR or SPACE typed |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2358 * - waiting for a char with --more-- |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2359 * - in Ctrl-X mode, and we get a valid char for that mode |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2360 */ |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2361 tb_c1 = typebuf.tb_buf[typebuf.tb_off]; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2362 if (no_mapping == 0 && is_maphash_valid() |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2363 && (no_zero_mapping == 0 || tb_c1 != '0') |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2364 && (typebuf.tb_maplen == 0 |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2365 || (p_remap |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2366 && (typebuf.tb_noremap[typebuf.tb_off] |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2367 & (RM_NONE|RM_ABBR)) == 0)) |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2368 && !(p_paste && (State & (INSERT + CMDLINE))) |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2369 && !(State == HITRETURN && (tb_c1 == CAR || tb_c1 == ' ')) |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2370 && State != ASKMORE |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2371 && State != CONFIRM |
18394
084b28fb3d22
patch 8.1.2191: when using modifyOtherKeys CTRL-X mode may not work
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2372 && !((ctrl_x_mode_not_default() && at_ctrl_x_key()) |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2373 || ((compl_cont_status & CONT_LOCAL) |
17809
59f8948b7590
patch 8.1.1901: the +insert_expand feature is not always available
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
2374 && (tb_c1 == Ctrl_N || tb_c1 == Ctrl_P)))) |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2375 { |
20563
a5a24d688e11
patch 8.2.0835: Motif: mapping <C-bslash> still doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
20277
diff
changeset
|
2376 #ifdef FEAT_GUI |
a5a24d688e11
patch 8.2.0835: Motif: mapping <C-bslash> still doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
20277
diff
changeset
|
2377 if (gui.in_use && tb_c1 == CSI && typebuf.tb_len >= 2 |
a5a24d688e11
patch 8.2.0835: Motif: mapping <C-bslash> still doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
20277
diff
changeset
|
2378 && typebuf.tb_buf[typebuf.tb_off + 1] == KS_MODIFIER) |
a5a24d688e11
patch 8.2.0835: Motif: mapping <C-bslash> still doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
20277
diff
changeset
|
2379 { |
a5a24d688e11
patch 8.2.0835: Motif: mapping <C-bslash> still doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
20277
diff
changeset
|
2380 // The GUI code sends CSI KS_MODIFIER {flags}, but mappings expect |
a5a24d688e11
patch 8.2.0835: Motif: mapping <C-bslash> still doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
20277
diff
changeset
|
2381 // K_SPECIAL KS_MODIFIER {flags}. |
a5a24d688e11
patch 8.2.0835: Motif: mapping <C-bslash> still doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
20277
diff
changeset
|
2382 tb_c1 = K_SPECIAL; |
a5a24d688e11
patch 8.2.0835: Motif: mapping <C-bslash> still doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
20277
diff
changeset
|
2383 } |
a5a24d688e11
patch 8.2.0835: Motif: mapping <C-bslash> still doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
20277
diff
changeset
|
2384 #endif |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2385 #ifdef FEAT_LANGMAP |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2386 if (tb_c1 == K_SPECIAL) |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2387 nolmaplen = 2; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2388 else |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2389 { |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2390 LANGMAP_ADJUST(tb_c1, (State & (CMDLINE | INSERT)) == 0 |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2391 && get_real_state() != SELECTMODE); |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2392 nolmaplen = 0; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2393 } |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2394 #endif |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2395 // First try buffer-local mappings. |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2396 mp = get_buf_maphash_list(local_State, tb_c1); |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2397 mp2 = get_maphash_list(local_State, tb_c1); |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2398 if (mp == NULL) |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2399 { |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2400 // There are no buffer-local mappings. |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2401 mp = mp2; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2402 mp2 = NULL; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2403 } |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2404 |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2405 /* |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2406 * Loop until a partly matching mapping is found or all (local) |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2407 * mappings have been checked. |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2408 * The longest full match is remembered in "mp_match". |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2409 * A full match is only accepted if there is no partly match, so "aa" |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2410 * and "aaa" can both be mapped. |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2411 */ |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2412 mp_match = NULL; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2413 mp_match_len = 0; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2414 for ( ; mp != NULL; |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2415 mp->m_next == NULL ? (mp = mp2, mp2 = NULL) : (mp = mp->m_next)) |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2416 { |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2417 // Only consider an entry if the first character matches and it is |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2418 // for the current state. |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2419 // Skip ":lmap" mappings if keys were mapped. |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2420 if (mp->m_keys[0] == tb_c1 |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2421 && (mp->m_mode & local_State) |
20701
fbee68c6aab1
patch 8.2.0904: assuming modifyOtherKeys for rhs of mapping
Bram Moolenaar <Bram@vim.org>
parents:
20595
diff
changeset
|
2422 && !(mp->m_simplified && seenModifyOtherKeys |
fbee68c6aab1
patch 8.2.0904: assuming modifyOtherKeys for rhs of mapping
Bram Moolenaar <Bram@vim.org>
parents:
20595
diff
changeset
|
2423 && typebuf.tb_maplen == 0) |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2424 && ((mp->m_mode & LANGMAP) == 0 || typebuf.tb_maplen == 0)) |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2425 { |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2426 #ifdef FEAT_LANGMAP |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2427 int nomap = nolmaplen; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2428 int c2; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2429 #endif |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2430 // find the match length of this mapping |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2431 for (mlen = 1; mlen < typebuf.tb_len; ++mlen) |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2432 { |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2433 #ifdef FEAT_LANGMAP |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2434 c2 = typebuf.tb_buf[typebuf.tb_off + mlen]; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2435 if (nomap > 0) |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2436 --nomap; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2437 else if (c2 == K_SPECIAL) |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2438 nomap = 2; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2439 else |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2440 LANGMAP_ADJUST(c2, TRUE); |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2441 if (mp->m_keys[mlen] != c2) |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2442 #else |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2443 if (mp->m_keys[mlen] != |
20563
a5a24d688e11
patch 8.2.0835: Motif: mapping <C-bslash> still doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
20277
diff
changeset
|
2444 typebuf.tb_buf[typebuf.tb_off + mlen]) |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2445 #endif |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2446 break; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2447 } |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2448 |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2449 // Don't allow mapping the first byte(s) of a multi-byte char. |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2450 // Happens when mapping <M-a> and then changing 'encoding'. |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2451 // Beware that 0x80 is escaped. |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2452 { |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2453 char_u *p1 = mp->m_keys; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2454 char_u *p2 = mb_unescape(&p1); |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2455 |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2456 if (has_mbyte && p2 != NULL |
18251
c8a53c0daeed
patch 8.1.2120: some MB_ macros are more complicated than necessary
Bram Moolenaar <Bram@vim.org>
parents:
18231
diff
changeset
|
2457 && MB_BYTE2LEN(tb_c1) > mb_ptr2len(p2)) |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2458 mlen = 0; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2459 } |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2460 |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2461 // Check an entry whether it matches. |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2462 // - Full match: mlen == keylen |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2463 // - Partly match: mlen == typebuf.tb_len |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2464 keylen = mp->m_keylen; |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2465 if (mlen == keylen || (mlen == typebuf.tb_len |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2466 && typebuf.tb_len < keylen)) |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2467 { |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2468 char_u *s; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2469 int n; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2470 |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2471 // If only script-local mappings are allowed, check if the |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2472 // mapping starts with K_SNR. |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2473 s = typebuf.tb_noremap + typebuf.tb_off; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2474 if (*s == RM_SCRIPT |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2475 && (mp->m_keys[0] != K_SPECIAL |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2476 || mp->m_keys[1] != KS_EXTRA |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2477 || mp->m_keys[2] != (int)KE_SNR)) |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2478 continue; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2479 |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2480 // If one of the typed keys cannot be remapped, skip the |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2481 // entry. |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2482 for (n = mlen; --n >= 0; ) |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2483 if (*s++ & (RM_NONE|RM_ABBR)) |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2484 break; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2485 if (n >= 0) |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2486 continue; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2487 |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2488 if (keylen > typebuf.tb_len) |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2489 { |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2490 if (!*timedout && !(mp_match != NULL |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2491 && mp_match->m_nowait)) |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2492 { |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2493 // break at a partly match |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2494 keylen = KEYLEN_PART_MAP; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2495 break; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2496 } |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2497 } |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2498 else if (keylen > mp_match_len) |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2499 { |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2500 // found a longer match |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2501 mp_match = mp; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2502 mp_match_len = keylen; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2503 } |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2504 } |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2505 else |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2506 // No match; may have to check for termcode at next |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2507 // character. |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2508 if (max_mlen < mlen) |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2509 max_mlen = mlen; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2510 } |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2511 } |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2512 |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2513 // If no partly match found, use the longest full match. |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2514 if (keylen != KEYLEN_PART_MAP) |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2515 { |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2516 mp = mp_match; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2517 keylen = mp_match_len; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2518 } |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2519 } |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2520 |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2521 /* |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2522 * Check for match with 'pastetoggle' |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2523 */ |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2524 if (*p_pt != NUL && mp == NULL && (State & (INSERT|NORMAL))) |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2525 { |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2526 for (mlen = 0; mlen < typebuf.tb_len && p_pt[mlen]; ++mlen) |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2527 if (p_pt[mlen] != typebuf.tb_buf[typebuf.tb_off + mlen]) |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2528 break; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2529 if (p_pt[mlen] == NUL) // match |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2530 { |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2531 // write chars to script file(s) |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2532 if (mlen > typebuf.tb_maplen) |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2533 gotchars(typebuf.tb_buf + typebuf.tb_off + typebuf.tb_maplen, |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2534 mlen - typebuf.tb_maplen); |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2535 |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2536 del_typebuf(mlen, 0); // remove the chars |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2537 set_option_value((char_u *)"paste", (long)!p_paste, NULL, 0); |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2538 if (!(State & INSERT)) |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2539 { |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2540 msg_col = 0; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2541 msg_row = Rows - 1; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2542 msg_clr_eos(); // clear ruler |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2543 } |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2544 status_redraw_all(); |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2545 redraw_statuslines(); |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2546 showmode(); |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2547 setcursor(); |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2548 *keylenp = keylen; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2549 return map_result_retry; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2550 } |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2551 // Need more chars for partly match. |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2552 if (mlen == typebuf.tb_len) |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2553 keylen = KEYLEN_PART_KEY; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2554 else if (max_mlen < mlen) |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2555 // no match, may have to check for termcode at next character |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2556 max_mlen = mlen + 1; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2557 } |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2558 |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2559 if ((mp == NULL || max_mlen >= mp_match_len) && keylen != KEYLEN_PART_MAP) |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2560 { |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2561 int save_keylen = keylen; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2562 |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2563 /* |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2564 * When no matching mapping found or found a non-matching mapping that |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2565 * matches at least what the matching mapping matched: |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2566 * Check if we have a terminal code, when: |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2567 * - mapping is allowed, |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2568 * - keys have not been mapped, |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2569 * - and not an ESC sequence, not in insert mode or p_ek is on, |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2570 * - and when not timed out, |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2571 */ |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2572 if ((no_mapping == 0 || allow_keys != 0) |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2573 && (typebuf.tb_maplen == 0 |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2574 || (p_remap && typebuf.tb_noremap[ |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2575 typebuf.tb_off] == RM_YES)) |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2576 && !*timedout) |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2577 { |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2578 keylen = check_termcode(max_mlen + 1, |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2579 NULL, 0, NULL); |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2580 |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2581 // If no termcode matched but 'pastetoggle' matched partially it's |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2582 // like an incomplete key sequence. |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2583 if (keylen == 0 && save_keylen == KEYLEN_PART_KEY) |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2584 keylen = KEYLEN_PART_KEY; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2585 |
20727
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20701
diff
changeset
|
2586 // If no termcode matched, try to include the modifier into the |
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20701
diff
changeset
|
2587 // key. This for when modifyOtherKeys is working. |
20733
e3078150144d
patch 8.2.0919: merging modifier for modifyOtherKeys is done twice
Bram Moolenaar <Bram@vim.org>
parents:
20727
diff
changeset
|
2588 if (keylen == 0 && !no_reduce_keys) |
20727
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20701
diff
changeset
|
2589 keylen = check_simplify_modifier(max_mlen + 1); |
5ffe112b1afd
patch 8.2.0916: mapping with partly modifyOtherKeys code does not work
Bram Moolenaar <Bram@vim.org>
parents:
20701
diff
changeset
|
2590 |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2591 // When getting a partial match, but the last characters were not |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2592 // typed, don't wait for a typed character to complete the |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2593 // termcode. This helps a lot when a ":normal" command ends in an |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2594 // ESC. |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2595 if (keylen < 0 && typebuf.tb_len == typebuf.tb_maplen) |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2596 keylen = 0; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2597 } |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2598 else |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2599 keylen = 0; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2600 if (keylen == 0) // no matching terminal code |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2601 { |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2602 #ifdef AMIGA |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2603 // check for window bounds report |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2604 if (typebuf.tb_maplen == 0 && (typebuf.tb_buf[ |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2605 typebuf.tb_off] & 0xff) == CSI) |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2606 { |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2607 char_u *s; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2608 |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2609 for (s = typebuf.tb_buf + typebuf.tb_off + 1; |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2610 s < typebuf.tb_buf + typebuf.tb_off + typebuf.tb_len |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2611 && (VIM_ISDIGIT(*s) || *s == ';' || *s == ' '); |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2612 ++s) |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2613 ; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2614 if (*s == 'r' || *s == '|') // found one |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2615 { |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2616 del_typebuf( |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2617 (int)(s + 1 - (typebuf.tb_buf + typebuf.tb_off)), 0); |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2618 // get size and redraw screen |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2619 shell_resized(); |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2620 *keylenp = keylen; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2621 return map_result_retry; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2622 } |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2623 if (*s == NUL) // need more characters |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2624 keylen = KEYLEN_PART_KEY; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2625 } |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2626 if (keylen >= 0) |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2627 #endif |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2628 // When there was a matching mapping and no termcode could be |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2629 // replaced after another one, use that mapping (loop around). |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2630 // If there was no mapping at all use the character from the |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2631 // typeahead buffer right here. |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2632 if (mp == NULL) |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2633 { |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2634 *keylenp = keylen; |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2635 return map_result_get; // got character, break for loop |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2636 } |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2637 } |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2638 |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2639 if (keylen > 0) // full matching terminal code |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2640 { |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2641 #if defined(FEAT_GUI) && defined(FEAT_MENU) |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2642 if (typebuf.tb_len >= 2 |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2643 && typebuf.tb_buf[typebuf.tb_off] == K_SPECIAL |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2644 && typebuf.tb_buf[typebuf.tb_off + 1] == KS_MENU) |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2645 { |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2646 int idx; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2647 |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2648 // Using a menu may cause a break in undo! It's like using |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2649 // gotchars(), but without recording or writing to a script |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2650 // file. |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2651 may_sync_undo(); |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2652 del_typebuf(3, 0); |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2653 idx = get_menu_index(current_menu, local_State); |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2654 if (idx != MENU_INDEX_INVALID) |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2655 { |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2656 // In Select mode and a Visual mode menu is used: Switch |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2657 // to Visual mode temporarily. Append K_SELECT to switch |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2658 // back to Select mode. |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2659 if (VIsual_active && VIsual_select |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2660 && (current_menu->modes & VISUAL)) |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2661 { |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2662 VIsual_select = FALSE; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2663 (void)ins_typebuf(K_SELECT_STRING, |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2664 REMAP_NONE, 0, TRUE, FALSE); |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2665 } |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2666 ins_typebuf(current_menu->strings[idx], |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2667 current_menu->noremap[idx], |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2668 0, TRUE, current_menu->silent[idx]); |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2669 } |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2670 } |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2671 #endif // FEAT_GUI && FEAT_MENU |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2672 *keylenp = keylen; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2673 return map_result_retry; // try mapping again |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2674 } |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2675 |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2676 // Partial match: get some more characters. When a matching mapping |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2677 // was found use that one. |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2678 if (mp == NULL || keylen < 0) |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2679 keylen = KEYLEN_PART_KEY; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2680 else |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2681 keylen = mp_match_len; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2682 } |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2683 |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2684 /* |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2685 * complete match |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2686 */ |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2687 if (keylen >= 0 && keylen <= typebuf.tb_len) |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2688 { |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2689 char_u *map_str; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2690 |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2691 #ifdef FEAT_EVAL |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2692 int save_m_expr; |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2693 int save_m_noremap; |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2694 int save_m_silent; |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2695 char_u *save_m_keys; |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2696 char_u *save_m_str; |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2697 #else |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2698 # define save_m_noremap mp->m_noremap |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2699 # define save_m_silent mp->m_silent |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2700 #endif |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2701 |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2702 // write chars to script file(s) |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2703 if (keylen > typebuf.tb_maplen) |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2704 gotchars(typebuf.tb_buf + typebuf.tb_off + typebuf.tb_maplen, |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2705 keylen - typebuf.tb_maplen); |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2706 |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2707 cmd_silent = (typebuf.tb_silent > 0); |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2708 del_typebuf(keylen, 0); // remove the mapped keys |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2709 |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2710 /* |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2711 * Put the replacement string in front of mapstr. |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2712 * The depth check catches ":map x y" and ":map y x". |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2713 */ |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2714 if (++*mapdepth >= p_mmd) |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2715 { |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2716 emsg(_("E223: recursive mapping")); |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2717 if (State & CMDLINE) |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2718 redrawcmdline(); |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2719 else |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2720 setcursor(); |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2721 flush_buffers(FLUSH_MINIMAL); |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2722 *mapdepth = 0; // for next one |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2723 *keylenp = keylen; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2724 return map_result_fail; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2725 } |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2726 |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2727 /* |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2728 * In Select mode and a Visual mode mapping is used: Switch to Visual |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2729 * mode temporarily. Append K_SELECT to switch back to Select mode. |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2730 */ |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2731 if (VIsual_active && VIsual_select && (mp->m_mode & VISUAL)) |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2732 { |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2733 VIsual_select = FALSE; |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2734 (void)ins_typebuf(K_SELECT_STRING, REMAP_NONE, 0, TRUE, FALSE); |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2735 } |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2736 |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2737 #ifdef FEAT_EVAL |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2738 // Copy the values from *mp that are used, because evaluating the |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2739 // expression may invoke a function that redefines the mapping, thereby |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2740 // making *mp invalid. |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2741 save_m_expr = mp->m_expr; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2742 save_m_noremap = mp->m_noremap; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2743 save_m_silent = mp->m_silent; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2744 save_m_keys = NULL; // only saved when needed |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2745 save_m_str = NULL; // only saved when needed |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2746 |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2747 /* |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2748 * Handle ":map <expr>": evaluate the {rhs} as an expression. Also |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2749 * save and restore the command line for "normal :". |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2750 */ |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2751 if (mp->m_expr) |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2752 { |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2753 int save_vgetc_busy = vgetc_busy; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2754 int save_may_garbage_collect = may_garbage_collect; |
18689
8cc12c8d7842
patch 8.1.2336: when an expr mapping moves the cursor it is not restored
Bram Moolenaar <Bram@vim.org>
parents:
18683
diff
changeset
|
2755 int was_screen_col = screen_cur_col; |
8cc12c8d7842
patch 8.1.2336: when an expr mapping moves the cursor it is not restored
Bram Moolenaar <Bram@vim.org>
parents:
18683
diff
changeset
|
2756 int was_screen_row = screen_cur_row; |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2757 |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2758 vgetc_busy = 0; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2759 may_garbage_collect = FALSE; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2760 |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2761 save_m_keys = vim_strsave(mp->m_keys); |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2762 save_m_str = vim_strsave(mp->m_str); |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2763 map_str = eval_map_expr(save_m_str, NUL); |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2764 |
18689
8cc12c8d7842
patch 8.1.2336: when an expr mapping moves the cursor it is not restored
Bram Moolenaar <Bram@vim.org>
parents:
18683
diff
changeset
|
2765 // The mapping may do anything, but we expect it to take care of |
8cc12c8d7842
patch 8.1.2336: when an expr mapping moves the cursor it is not restored
Bram Moolenaar <Bram@vim.org>
parents:
18683
diff
changeset
|
2766 // redrawing. Do put the cursor back where it was. |
8cc12c8d7842
patch 8.1.2336: when an expr mapping moves the cursor it is not restored
Bram Moolenaar <Bram@vim.org>
parents:
18683
diff
changeset
|
2767 windgoto(was_screen_row, was_screen_col); |
8cc12c8d7842
patch 8.1.2336: when an expr mapping moves the cursor it is not restored
Bram Moolenaar <Bram@vim.org>
parents:
18683
diff
changeset
|
2768 out_flush(); |
8cc12c8d7842
patch 8.1.2336: when an expr mapping moves the cursor it is not restored
Bram Moolenaar <Bram@vim.org>
parents:
18683
diff
changeset
|
2769 |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2770 vgetc_busy = save_vgetc_busy; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2771 may_garbage_collect = save_may_garbage_collect; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2772 } |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2773 else |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2774 #endif |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2775 map_str = mp->m_str; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2776 |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2777 /* |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2778 * Insert the 'to' part in the typebuf.tb_buf. |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2779 * If 'from' field is the same as the start of the 'to' field, don't |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2780 * remap the first character (but do allow abbreviations). |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2781 * If m_noremap is set, don't remap the whole 'to' part. |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2782 */ |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2783 if (map_str == NULL) |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2784 i = FAIL; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2785 else |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2786 { |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2787 int noremap; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2788 |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2789 if (save_m_noremap != REMAP_YES) |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2790 noremap = save_m_noremap; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2791 else if ( |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2792 #ifdef FEAT_EVAL |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2793 STRNCMP(map_str, save_m_keys != NULL ? save_m_keys : mp->m_keys, |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2794 (size_t)keylen) |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2795 #else |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2796 STRNCMP(map_str, mp->m_keys, (size_t)keylen) |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2797 #endif |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2798 != 0) |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2799 noremap = REMAP_YES; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2800 else |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2801 noremap = REMAP_SKIP; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2802 i = ins_typebuf(map_str, noremap, |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2803 0, TRUE, cmd_silent || save_m_silent); |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2804 #ifdef FEAT_EVAL |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2805 if (save_m_expr) |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2806 vim_free(map_str); |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2807 #endif |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2808 } |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2809 #ifdef FEAT_EVAL |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2810 vim_free(save_m_keys); |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2811 vim_free(save_m_str); |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2812 #endif |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2813 *keylenp = keylen; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2814 if (i == FAIL) |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2815 return map_result_fail; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2816 return map_result_retry; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2817 } |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2818 |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2819 *keylenp = keylen; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2820 return map_result_nomatch; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2821 } |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2822 |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2823 /* |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2824 * unget one character (can only be done once!) |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2825 */ |
7 | 2826 void |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2827 vungetc(int c) |
7 | 2828 { |
2829 old_char = c; | |
2830 old_mod_mask = mod_mask; | |
4227 | 2831 old_mouse_row = mouse_row; |
2832 old_mouse_col = mouse_col; | |
7 | 2833 } |
2834 | |
2835 /* | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
2836 * Get a byte: |
7 | 2837 * 1. from the stuffbuffer |
2838 * This is used for abbreviated commands like "D" -> "d$". | |
2839 * Also used to redo a command for ".". | |
2840 * 2. from the typeahead buffer | |
2841 * Stores text obtained previously but not used yet. | |
2842 * Also stores the result of mappings. | |
2843 * Also used for the ":normal" command. | |
2844 * 3. from the user | |
2845 * This may do a blocking wait if "advance" is TRUE. | |
2846 * | |
2847 * if "advance" is TRUE (vgetc()): | |
9980
b222552cf0c4
commit https://github.com/vim/vim/commit/d29459baa61819e59961804ed258efac5733ec70
Christian Brabandt <cb@256bit.org>
parents:
9898
diff
changeset
|
2848 * Really get the character. |
7 | 2849 * KeyTyped is set to TRUE in the case the user typed the key. |
2850 * KeyStuffed is TRUE if the character comes from the stuff buffer. | |
2851 * if "advance" is FALSE (vpeekc()): | |
14909
c97b4b537572
patch 8.1.0466: autocmd test fails
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
2852 * Just look whether there is a character available. |
c97b4b537572
patch 8.1.0466: autocmd test fails
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
2853 * Return NUL if not. |
7 | 2854 * |
2855 * When "no_mapping" is zero, checks for mappings in the current mode. | |
2856 * Only returns one byte (of a multi-byte character). | |
2857 * K_SPECIAL and CSI may be escaped, need to get two more bytes then. | |
2858 */ | |
2859 static int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2860 vgetorpeek(int advance) |
7 | 2861 { |
2862 int c, c1; | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2863 int timedout = FALSE; // waited for more than 1 second |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2864 // for mapping to complete |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2865 int mapdepth = 0; // check for recursive mapping |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2866 int mode_deleted = FALSE; // set when mode has been deleted |
7 | 2867 #ifdef FEAT_CMDL_INFO |
2868 int new_wcol, new_wrow; | |
2869 #endif | |
2870 #ifdef FEAT_GUI | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2871 int shape_changed = FALSE; // adjusted cursor shape |
7 | 2872 #endif |
2873 int n; | |
2874 int old_wcol, old_wrow; | |
202 | 2875 int wait_tb_len; |
7 | 2876 |
2877 /* | |
2878 * This function doesn't work very well when called recursively. This may | |
2879 * happen though, because of: | |
2880 * 1. The call to add_to_showcmd(). char_avail() is then used to check if | |
2881 * there is a character available, which calls this function. In that | |
2882 * case we must return NUL, to indicate no character is available. | |
2883 * 2. A GUI callback function writes to the screen, causing a | |
2884 * wait_return(). | |
2885 * Using ":normal" can also do this, but it saves the typeahead buffer, | |
2886 * thus it should be OK. But don't get a key from the user then. | |
2887 */ | |
7850
10f17a228661
commit https://github.com/vim/vim/commit/e2c3810c2ae290bbc2cba18eb47cc2d44e4b9797
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2888 if (vgetc_busy > 0 && ex_normal_busy == 0) |
7 | 2889 return NUL; |
2890 | |
822 | 2891 ++vgetc_busy; |
7 | 2892 |
2893 if (advance) | |
2894 KeyStuffed = FALSE; | |
2895 | |
2896 init_typebuf(); | |
2897 start_stuff(); | |
2898 if (advance && typebuf.tb_maplen == 0) | |
14004
e124262d435e
patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents:
13950
diff
changeset
|
2899 reg_executing = 0; |
7 | 2900 do |
2901 { | |
2902 /* | |
2903 * get a character: 1. from the stuffbuffer | |
2904 */ | |
2905 if (typeahead_char != 0) | |
2906 { | |
2907 c = typeahead_char; | |
2908 if (advance) | |
2909 typeahead_char = 0; | |
2910 } | |
2911 else | |
5649 | 2912 c = read_readbuffers(advance); |
7 | 2913 if (c != NUL && !got_int) |
2914 { | |
2915 if (advance) | |
2916 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2917 // KeyTyped = FALSE; When the command that stuffed something |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2918 // was typed, behave like the stuffed command was typed. |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2919 // needed for CTRL-W CTRL-] to open a fold, for example. |
7 | 2920 KeyStuffed = TRUE; |
2921 } | |
2922 if (typebuf.tb_no_abbr_cnt == 0) | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2923 typebuf.tb_no_abbr_cnt = 1; // no abbreviations now |
7 | 2924 } |
2925 else | |
2926 { | |
2927 /* | |
2928 * Loop until we either find a matching mapped key, or we | |
2929 * are sure that it is not a mapped key. | |
2930 * If a mapped key sequence is found we go back to the start to | |
2931 * try re-mapping. | |
2932 */ | |
2933 for (;;) | |
2934 { | |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2935 long wait_time; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2936 int keylen = 0; |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2937 #ifdef FEAT_CMDL_INFO |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2938 int showcmd_idx; |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
2939 #endif |
7 | 2940 /* |
2941 * ui_breakcheck() is slow, don't use it too often when | |
2942 * inside a mapping. But call it each time for typed | |
2943 * characters. | |
2944 */ | |
2945 if (typebuf.tb_maplen) | |
2946 line_breakcheck(); | |
2947 else | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2948 ui_breakcheck(); // check for CTRL-C |
7 | 2949 if (got_int) |
2950 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2951 // flush all input |
12281
2738b0cc5f64
patch 8.0.1020: when a timer calls getchar(1) input is overwritten
Christian Brabandt <cb@256bit.org>
parents:
11577
diff
changeset
|
2952 c = inchar(typebuf.tb_buf, typebuf.tb_buflen - 1, 0L); |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2953 |
7 | 2954 /* |
2955 * If inchar() returns TRUE (script file was active) or we | |
13829
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
2956 * are inside a mapping, get out of Insert mode. |
7 | 2957 * Otherwise we behave like having gotten a CTRL-C. |
2958 * As a result typing CTRL-C in insert mode will | |
2959 * really insert a CTRL-C. | |
2960 */ | |
2961 if ((c || typebuf.tb_maplen) | |
2962 && (State & (INSERT + CMDLINE))) | |
2963 c = ESC; | |
2964 else | |
2965 c = Ctrl_C; | |
14909
c97b4b537572
patch 8.1.0466: autocmd test fails
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
2966 flush_buffers(FLUSH_INPUT); // flush all typeahead |
7 | 2967 |
988 | 2968 if (advance) |
2969 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2970 // Also record this character, it might be needed to |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2971 // get out of Insert mode. |
988 | 2972 *typebuf.tb_buf = c; |
2973 gotchars(typebuf.tb_buf, 1); | |
2974 } | |
7 | 2975 cmd_silent = FALSE; |
2976 | |
2977 break; | |
2978 } | |
2979 else if (typebuf.tb_len > 0) | |
2980 { | |
2981 /* | |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2982 * Check for a mapping in "typebuf". |
7 | 2983 */ |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2984 map_result_T result = handle_mapping( |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2985 &keylen, &timedout, &mapdepth); |
7 | 2986 |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2987 if (result == map_result_retry) |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2988 // try mapping again |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2989 continue; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2990 if (result == map_result_fail) |
7 | 2991 { |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2992 // failed, use the outer loop |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2993 c = -1; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2994 break; |
7 | 2995 } |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
2996 if (result == map_result_get) |
7 | 2997 { |
2998 /* | |
2999 * get a character: 2. from the typeahead buffer | |
3000 */ | |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3001 c = typebuf.tb_buf[typebuf.tb_off]; |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3002 if (advance) // remove chars from tb_buf |
7 | 3003 { |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
3004 cmd_silent = (typebuf.tb_silent > 0); |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
3005 if (typebuf.tb_maplen > 0) |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
3006 KeyTyped = FALSE; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
3007 else |
7 | 3008 { |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
3009 KeyTyped = TRUE; |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3010 // write char to script file(s) |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
3011 gotchars(typebuf.tb_buf |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
3012 + typebuf.tb_off, 1); |
7 | 3013 } |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
3014 KeyNoremap = typebuf.tb_noremap[ |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
3015 typebuf.tb_off]; |
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
3016 del_typebuf(1, 0); |
7 | 3017 } |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
3018 break; |
7 | 3019 } |
3020 | |
17600
ca42eb789472
patch 8.1.1797: the vgetorpeek() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
17594
diff
changeset
|
3021 // not enough characters, get more |
7 | 3022 } |
3023 | |
3024 /* | |
3025 * get a character: 3. from the user - handle <Esc> in Insert mode | |
3026 */ | |
3027 /* | |
11490
6a06738f8948
patch 8.0.0628: cursor disappears after silent mapping
Christian Brabandt <cb@256bit.org>
parents:
11486
diff
changeset
|
3028 * Special case: if we get an <ESC> in insert mode and there |
7 | 3029 * are no more characters at once, we pretend to go out of |
3030 * insert mode. This prevents the one second delay after | |
3031 * typing an <ESC>. If we get something after all, we may | |
3032 * have to redisplay the mode. That the cursor is in the wrong | |
3033 * place does not matter. | |
3034 */ | |
3035 c = 0; | |
3036 #ifdef FEAT_CMDL_INFO | |
3037 new_wcol = curwin->w_wcol; | |
3038 new_wrow = curwin->w_wrow; | |
3039 #endif | |
3040 if ( advance | |
3041 && typebuf.tb_len == 1 | |
3042 && typebuf.tb_buf[typebuf.tb_off] == ESC | |
3043 && !no_mapping | |
3044 && ex_normal_busy == 0 | |
3045 && typebuf.tb_maplen == 0 | |
3046 && (State & INSERT) | |
2672 | 3047 && (p_timeout |
3048 || (keylen == KEYLEN_PART_KEY && p_ttimeout)) | |
7 | 3049 && (c = inchar(typebuf.tb_buf + typebuf.tb_off |
12281
2738b0cc5f64
patch 8.0.1020: when a timer calls getchar(1) input is overwritten
Christian Brabandt <cb@256bit.org>
parents:
11577
diff
changeset
|
3050 + typebuf.tb_len, 3, 25L)) == 0) |
7 | 3051 { |
3052 colnr_T col = 0, vcol; | |
3053 char_u *ptr; | |
3054 | |
643 | 3055 if (mode_displayed) |
7 | 3056 { |
3057 unshowmode(TRUE); | |
3058 mode_deleted = TRUE; | |
3059 } | |
3060 #ifdef FEAT_GUI | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3061 // may show a different cursor shape |
11490
6a06738f8948
patch 8.0.0628: cursor disappears after silent mapping
Christian Brabandt <cb@256bit.org>
parents:
11486
diff
changeset
|
3062 if (gui.in_use && State != NORMAL && !cmd_silent) |
7 | 3063 { |
3064 int save_State; | |
3065 | |
3066 save_State = State; | |
3067 State = NORMAL; | |
3068 gui_update_cursor(TRUE, FALSE); | |
3069 State = save_State; | |
3070 shape_changed = TRUE; | |
3071 } | |
3072 #endif | |
3073 validate_cursor(); | |
3074 old_wcol = curwin->w_wcol; | |
3075 old_wrow = curwin->w_wrow; | |
3076 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3077 // move cursor left, if possible |
7 | 3078 if (curwin->w_cursor.col != 0) |
3079 { | |
3080 if (curwin->w_wcol > 0) | |
3081 { | |
3082 if (did_ai) | |
3083 { | |
3084 /* | |
3085 * We are expecting to truncate the trailing | |
3086 * white-space, so find the last non-white | |
3087 * character -- webb | |
3088 */ | |
3089 col = vcol = curwin->w_wcol = 0; | |
3090 ptr = ml_get_curline(); | |
3091 while (col < curwin->w_cursor.col) | |
3092 { | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11026
diff
changeset
|
3093 if (!VIM_ISWHITE(ptr[col])) |
7 | 3094 curwin->w_wcol = vcol; |
5995 | 3095 vcol += lbr_chartabsize(ptr, ptr + col, |
7 | 3096 (colnr_T)vcol); |
3097 if (has_mbyte) | |
474 | 3098 col += (*mb_ptr2len)(ptr + col); |
7 | 3099 else |
3100 ++col; | |
3101 } | |
3102 curwin->w_wrow = curwin->w_cline_row | |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
3103 + curwin->w_wcol / curwin->w_width; |
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
3104 curwin->w_wcol %= curwin->w_width; |
7 | 3105 curwin->w_wcol += curwin_col_off(); |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3106 col = 0; // no correction needed |
7 | 3107 } |
3108 else | |
3109 { | |
3110 --curwin->w_wcol; | |
3111 col = curwin->w_cursor.col - 1; | |
3112 } | |
3113 } | |
3114 else if (curwin->w_p_wrap && curwin->w_wrow) | |
3115 { | |
3116 --curwin->w_wrow; | |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
3117 curwin->w_wcol = curwin->w_width - 1; |
7 | 3118 col = curwin->w_cursor.col - 1; |
3119 } | |
3120 if (has_mbyte && col > 0 && curwin->w_wcol > 0) | |
3121 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3122 // Correct when the cursor is on the right halve |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3123 // of a double-wide character. |
7 | 3124 ptr = ml_get_curline(); |
3125 col -= (*mb_head_off)(ptr, ptr + col); | |
3126 if ((*mb_ptr2cells)(ptr + col) > 1) | |
3127 --curwin->w_wcol; | |
3128 } | |
3129 } | |
3130 setcursor(); | |
3131 out_flush(); | |
3132 #ifdef FEAT_CMDL_INFO | |
3133 new_wcol = curwin->w_wcol; | |
3134 new_wrow = curwin->w_wrow; | |
3135 #endif | |
3136 curwin->w_wcol = old_wcol; | |
3137 curwin->w_wrow = old_wrow; | |
3138 } | |
3139 if (c < 0) | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3140 continue; // end of input script reached |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3141 |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3142 // Allow mapping for just typed characters. When we get here c |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3143 // is the number of extra bytes and typebuf.tb_len is 1. |
6087 | 3144 for (n = 1; n <= c; ++n) |
3145 typebuf.tb_noremap[typebuf.tb_off + n] = RM_YES; | |
7 | 3146 typebuf.tb_len += c; |
3147 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3148 // buffer full, don't map |
7 | 3149 if (typebuf.tb_len >= typebuf.tb_maplen + MAXMAPLEN) |
3150 { | |
3151 timedout = TRUE; | |
3152 continue; | |
3153 } | |
3154 | |
3155 if (ex_normal_busy > 0) | |
3156 { | |
7850
10f17a228661
commit https://github.com/vim/vim/commit/e2c3810c2ae290bbc2cba18eb47cc2d44e4b9797
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
3157 #ifdef FEAT_CMDWIN |
7 | 3158 static int tc = 0; |
7850
10f17a228661
commit https://github.com/vim/vim/commit/e2c3810c2ae290bbc2cba18eb47cc2d44e4b9797
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
3159 #endif |
7 | 3160 |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3161 // No typeahead left and inside ":normal". Must return |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3162 // something to avoid getting stuck. When an incomplete |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3163 // mapping is present, behave like it timed out. |
7 | 3164 if (typebuf.tb_len > 0) |
3165 { | |
3166 timedout = TRUE; | |
3167 continue; | |
3168 } | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3169 // When 'insertmode' is set, ESC just beeps in Insert |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3170 // mode. Use CTRL-L to make edit() return. |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3171 // For the command line only CTRL-C always breaks it. |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3172 // For the cmdline window: Alternate between ESC and |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3173 // CTRL-C: ESC for most situations and CTRL-C to close the |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3174 // cmdline window. |
7 | 3175 if (p_im && (State & INSERT)) |
3176 c = Ctrl_L; | |
13829
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3177 #ifdef FEAT_TERMINAL |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3178 else if (terminal_is_active()) |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3179 c = K_CANCEL; |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3180 #endif |
7 | 3181 else if ((State & CMDLINE) |
7850
10f17a228661
commit https://github.com/vim/vim/commit/e2c3810c2ae290bbc2cba18eb47cc2d44e4b9797
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
3182 #ifdef FEAT_CMDWIN |
7 | 3183 || (cmdwin_type > 0 && tc == ESC) |
7850
10f17a228661
commit https://github.com/vim/vim/commit/e2c3810c2ae290bbc2cba18eb47cc2d44e4b9797
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
3184 #endif |
7 | 3185 ) |
3186 c = Ctrl_C; | |
3187 else | |
3188 c = ESC; | |
7850
10f17a228661
commit https://github.com/vim/vim/commit/e2c3810c2ae290bbc2cba18eb47cc2d44e4b9797
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
3189 #ifdef FEAT_CMDWIN |
7 | 3190 tc = c; |
7850
10f17a228661
commit https://github.com/vim/vim/commit/e2c3810c2ae290bbc2cba18eb47cc2d44e4b9797
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
3191 #endif |
19433
af9d5585cfbf
patch 8.2.0274: hang with combination of feedkeys(), Ex mode and :global
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3192 // return from main_loop() |
af9d5585cfbf
patch 8.2.0274: hang with combination of feedkeys(), Ex mode and :global
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3193 if (pending_exmode_active) |
af9d5585cfbf
patch 8.2.0274: hang with combination of feedkeys(), Ex mode and :global
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3194 exmode_active = EXMODE_NORMAL; |
af9d5585cfbf
patch 8.2.0274: hang with combination of feedkeys(), Ex mode and :global
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
3195 |
7 | 3196 break; |
3197 } | |
3198 | |
3199 /* | |
3200 * get a character: 3. from the user - update display | |
3201 */ | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3202 // In insert mode a screen update is skipped when characters |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3203 // are still available. But when those available characters |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3204 // are part of a mapping, and we are going to do a blocking |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3205 // wait here. Need to update the screen to display the |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3206 // changed text so far. Also for when 'lazyredraw' is set and |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3207 // redrawing was postponed because there was something in the |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3208 // input buffer (e.g., termresponse). |
2723 | 3209 if (((State & INSERT) != 0 || p_lz) && (State & CMDLINE) == 0 |
3210 && advance && must_redraw != 0 && !need_wait_return) | |
7 | 3211 { |
3212 update_screen(0); | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3213 setcursor(); // put cursor back where it belongs |
7 | 3214 } |
3215 | |
3216 /* | |
3217 * If we have a partial match (and are going to wait for more | |
3218 * input from the user), show the partially matched characters | |
3219 * to the user with showcmd. | |
3220 */ | |
3221 #ifdef FEAT_CMDL_INFO | |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
3222 showcmd_idx = 0; |
7 | 3223 #endif |
3224 c1 = 0; | |
3225 if (typebuf.tb_len > 0 && advance && !exmode_active) | |
3226 { | |
3227 if (((State & (NORMAL | INSERT)) || State == LANGMAP) | |
3228 && State != HITRETURN) | |
3229 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3230 // this looks nice when typing a dead character map |
7 | 3231 if (State & INSERT |
3232 && ptr2cells(typebuf.tb_buf + typebuf.tb_off | |
3233 + typebuf.tb_len - 1) == 1) | |
3234 { | |
3235 edit_putchar(typebuf.tb_buf[typebuf.tb_off | |
3236 + typebuf.tb_len - 1], FALSE); | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3237 setcursor(); // put cursor back where it belongs |
7 | 3238 c1 = 1; |
3239 } | |
3240 #ifdef FEAT_CMDL_INFO | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3241 // need to use the col and row from above here |
7 | 3242 old_wcol = curwin->w_wcol; |
3243 old_wrow = curwin->w_wrow; | |
3244 curwin->w_wcol = new_wcol; | |
3245 curwin->w_wrow = new_wrow; | |
3246 push_showcmd(); | |
3247 if (typebuf.tb_len > SHOWCMD_COLS) | |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
3248 showcmd_idx = typebuf.tb_len - SHOWCMD_COLS; |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
3249 while (showcmd_idx < typebuf.tb_len) |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
3250 (void)add_to_showcmd( |
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
3251 typebuf.tb_buf[typebuf.tb_off + showcmd_idx++]); |
7 | 3252 curwin->w_wcol = old_wcol; |
3253 curwin->w_wrow = old_wrow; | |
3254 #endif | |
3255 } | |
3256 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3257 // this looks nice when typing a dead character map |
7 | 3258 if ((State & CMDLINE) |
3259 #if defined(FEAT_CRYPT) || defined(FEAT_EVAL) | |
3260 && cmdline_star == 0 | |
3261 #endif | |
3262 && ptr2cells(typebuf.tb_buf + typebuf.tb_off | |
3263 + typebuf.tb_len - 1) == 1) | |
3264 { | |
3265 putcmdline(typebuf.tb_buf[typebuf.tb_off | |
3266 + typebuf.tb_len - 1], FALSE); | |
3267 c1 = 1; | |
3268 } | |
3269 } | |
3270 | |
3271 /* | |
3272 * get a character: 3. from the user - get it | |
3273 */ | |
14069
bc91de20ba43
patch 8.1.0052: when mapping to <Nop> times out the next mapping is skipped
Christian Brabandt <cb@256bit.org>
parents:
14009
diff
changeset
|
3274 if (typebuf.tb_len == 0) |
bc91de20ba43
patch 8.1.0052: when mapping to <Nop> times out the next mapping is skipped
Christian Brabandt <cb@256bit.org>
parents:
14009
diff
changeset
|
3275 // timedout may have been set while waiting for a mapping |
bc91de20ba43
patch 8.1.0052: when mapping to <Nop> times out the next mapping is skipped
Christian Brabandt <cb@256bit.org>
parents:
14009
diff
changeset
|
3276 // that has a <Nop> RHS. |
bc91de20ba43
patch 8.1.0052: when mapping to <Nop> times out the next mapping is skipped
Christian Brabandt <cb@256bit.org>
parents:
14009
diff
changeset
|
3277 timedout = FALSE; |
bc91de20ba43
patch 8.1.0052: when mapping to <Nop> times out the next mapping is skipped
Christian Brabandt <cb@256bit.org>
parents:
14009
diff
changeset
|
3278 |
16227
a70f0d6686c4
patch 8.1.1118: a couple of conditions are hard to understand
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
3279 if (advance) |
a70f0d6686c4
patch 8.1.1118: a couple of conditions are hard to understand
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
3280 { |
a70f0d6686c4
patch 8.1.1118: a couple of conditions are hard to understand
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
3281 if (typebuf.tb_len == 0 |
a70f0d6686c4
patch 8.1.1118: a couple of conditions are hard to understand
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
3282 || !(p_timeout |
a70f0d6686c4
patch 8.1.1118: a couple of conditions are hard to understand
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
3283 || (p_ttimeout && keylen == KEYLEN_PART_KEY))) |
a70f0d6686c4
patch 8.1.1118: a couple of conditions are hard to understand
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
3284 // blocking wait |
a70f0d6686c4
patch 8.1.1118: a couple of conditions are hard to understand
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
3285 wait_time = -1L; |
a70f0d6686c4
patch 8.1.1118: a couple of conditions are hard to understand
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
3286 else if (keylen == KEYLEN_PART_KEY && p_ttm >= 0) |
a70f0d6686c4
patch 8.1.1118: a couple of conditions are hard to understand
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
3287 wait_time = p_ttm; |
a70f0d6686c4
patch 8.1.1118: a couple of conditions are hard to understand
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
3288 else |
a70f0d6686c4
patch 8.1.1118: a couple of conditions are hard to understand
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
3289 wait_time = p_tm; |
a70f0d6686c4
patch 8.1.1118: a couple of conditions are hard to understand
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
3290 } |
a70f0d6686c4
patch 8.1.1118: a couple of conditions are hard to understand
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
3291 else |
a70f0d6686c4
patch 8.1.1118: a couple of conditions are hard to understand
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
3292 wait_time = 0; |
a70f0d6686c4
patch 8.1.1118: a couple of conditions are hard to understand
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
3293 |
202 | 3294 wait_tb_len = typebuf.tb_len; |
7 | 3295 c = inchar(typebuf.tb_buf + typebuf.tb_off + typebuf.tb_len, |
3296 typebuf.tb_buflen - typebuf.tb_off - typebuf.tb_len - 1, | |
16227
a70f0d6686c4
patch 8.1.1118: a couple of conditions are hard to understand
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
3297 wait_time); |
7 | 3298 |
3299 #ifdef FEAT_CMDL_INFO | |
17602
653ab352b019
patch 8.1.1798: warning for unused variable in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17600
diff
changeset
|
3300 if (showcmd_idx != 0) |
7 | 3301 pop_showcmd(); |
3302 #endif | |
3303 if (c1 == 1) | |
3304 { | |
3305 if (State & INSERT) | |
3306 edit_unputchar(); | |
3307 if (State & CMDLINE) | |
3308 unputcmdline(); | |
3560 | 3309 else |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3310 setcursor(); // put cursor back where it belongs |
7 | 3311 } |
3312 | |
3313 if (c < 0) | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3314 continue; // end of input script reached |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3315 if (c == NUL) // no character available |
7 | 3316 { |
3317 if (!advance) | |
3318 break; | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3319 if (wait_tb_len > 0) // timed out |
7 | 3320 { |
3321 timedout = TRUE; | |
3322 continue; | |
3323 } | |
3324 } | |
3325 else | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3326 { // allow mapping for just typed characters |
7 | 3327 while (typebuf.tb_buf[typebuf.tb_off |
3328 + typebuf.tb_len] != NUL) | |
3329 typebuf.tb_noremap[typebuf.tb_off | |
3330 + typebuf.tb_len++] = RM_YES; | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13344
diff
changeset
|
3331 #ifdef HAVE_INPUT_METHOD |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3332 // Get IM status right after getting keys, not after the |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3333 // timeout for a mapping (focus may be lost by then). |
7 | 3334 vgetc_im_active = im_get_status(); |
3335 #endif | |
3336 } | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3337 } // for (;;) |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3338 } // if (!character from stuffbuf) |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3339 |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3340 // if advance is FALSE don't loop on NULs |
13829
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13762
diff
changeset
|
3341 } while ((c < 0 && c != K_CANCEL) || (advance && c == NUL)); |
7 | 3342 |
3343 /* | |
3344 * The "INSERT" message is taken care of here: | |
3345 * if we return an ESC to exit insert mode, the message is deleted | |
3346 * if we don't return an ESC but deleted the message before, redisplay it | |
3347 */ | |
641 | 3348 if (advance && p_smd && msg_silent == 0 && (State & INSERT)) |
7 | 3349 { |
643 | 3350 if (c == ESC && !mode_deleted && !no_mapping && mode_displayed) |
7 | 3351 { |
3352 if (typebuf.tb_len && !KeyTyped) | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3353 redraw_cmdline = TRUE; // delete mode later |
7 | 3354 else |
3355 unshowmode(FALSE); | |
3356 } | |
3357 else if (c != ESC && mode_deleted) | |
3358 { | |
3359 if (typebuf.tb_len && !KeyTyped) | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3360 redraw_cmdline = TRUE; // show mode later |
7 | 3361 else |
3362 showmode(); | |
3363 } | |
3364 } | |
3365 #ifdef FEAT_GUI | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3366 // may unshow different cursor shape |
11490
6a06738f8948
patch 8.0.0628: cursor disappears after silent mapping
Christian Brabandt <cb@256bit.org>
parents:
11486
diff
changeset
|
3367 if (gui.in_use && shape_changed) |
6a06738f8948
patch 8.0.0628: cursor disappears after silent mapping
Christian Brabandt <cb@256bit.org>
parents:
11486
diff
changeset
|
3368 gui_update_cursor(TRUE, FALSE); |
7 | 3369 #endif |
15995
e7030c0c79cd
patch 8.1.1003: playing back recorded key sequence mistakes key code
Bram Moolenaar <Bram@vim.org>
parents:
15989
diff
changeset
|
3370 if (timedout && c == ESC) |
e7030c0c79cd
patch 8.1.1003: playing back recorded key sequence mistakes key code
Bram Moolenaar <Bram@vim.org>
parents:
15989
diff
changeset
|
3371 { |
e7030c0c79cd
patch 8.1.1003: playing back recorded key sequence mistakes key code
Bram Moolenaar <Bram@vim.org>
parents:
15989
diff
changeset
|
3372 char_u nop_buf[3]; |
e7030c0c79cd
patch 8.1.1003: playing back recorded key sequence mistakes key code
Bram Moolenaar <Bram@vim.org>
parents:
15989
diff
changeset
|
3373 |
e7030c0c79cd
patch 8.1.1003: playing back recorded key sequence mistakes key code
Bram Moolenaar <Bram@vim.org>
parents:
15989
diff
changeset
|
3374 // When recording there will be no timeout. Add a <Nop> after the ESC |
e7030c0c79cd
patch 8.1.1003: playing back recorded key sequence mistakes key code
Bram Moolenaar <Bram@vim.org>
parents:
15989
diff
changeset
|
3375 // to avoid that it forms a key code with following characters. |
e7030c0c79cd
patch 8.1.1003: playing back recorded key sequence mistakes key code
Bram Moolenaar <Bram@vim.org>
parents:
15989
diff
changeset
|
3376 nop_buf[0] = K_SPECIAL; |
e7030c0c79cd
patch 8.1.1003: playing back recorded key sequence mistakes key code
Bram Moolenaar <Bram@vim.org>
parents:
15989
diff
changeset
|
3377 nop_buf[1] = KS_EXTRA; |
e7030c0c79cd
patch 8.1.1003: playing back recorded key sequence mistakes key code
Bram Moolenaar <Bram@vim.org>
parents:
15989
diff
changeset
|
3378 nop_buf[2] = KE_NOP; |
e7030c0c79cd
patch 8.1.1003: playing back recorded key sequence mistakes key code
Bram Moolenaar <Bram@vim.org>
parents:
15989
diff
changeset
|
3379 gotchars(nop_buf, 3); |
e7030c0c79cd
patch 8.1.1003: playing back recorded key sequence mistakes key code
Bram Moolenaar <Bram@vim.org>
parents:
15989
diff
changeset
|
3380 } |
7 | 3381 |
822 | 3382 --vgetc_busy; |
7 | 3383 |
3384 return c; | |
3385 } | |
3386 | |
3387 /* | |
3388 * inchar() - get one character from | |
3389 * 1. a scriptfile | |
3390 * 2. the keyboard | |
3391 * | |
19195
2ef19eed524a
patch 8.2.0156: various typos in source files and tests
Bram Moolenaar <Bram@vim.org>
parents:
18781
diff
changeset
|
3392 * As many characters as we can get (up to 'maxlen') are put in "buf" and |
7 | 3393 * NUL terminated (buffer length must be 'maxlen' + 1). |
3394 * Minimum for "maxlen" is 3!!!! | |
3395 * | |
3396 * "tb_change_cnt" is the value of typebuf.tb_change_cnt if "buf" points into | |
3397 * it. When typebuf.tb_change_cnt changes (e.g., when a message is received | |
3398 * from a remote client) "buf" can no longer be used. "tb_change_cnt" is 0 | |
3399 * otherwise. | |
3400 * | |
3401 * If we got an interrupt all input is read until none is available. | |
3402 * | |
3403 * If wait_time == 0 there is no waiting for the char. | |
3404 * If wait_time == n we wait for n msec for a character to arrive. | |
3405 * If wait_time == -1 we wait forever for a character to arrive. | |
3406 * | |
3407 * Return the number of obtained characters. | |
3408 * Return -1 when end of input script reached. | |
3409 */ | |
9205
c19eb05b19df
commit https://github.com/vim/vim/commit/cda7764d8e65325d4524e5d6c3174121eeb12cad
Christian Brabandt <cb@256bit.org>
parents:
9121
diff
changeset
|
3410 static int |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3411 inchar( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3412 char_u *buf, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3413 int maxlen, |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3414 long wait_time) // milli seconds |
7 | 3415 { |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3416 int len = 0; // init for GCC |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3417 int retesc = FALSE; // return ESC with gotint |
7 | 3418 int script_char; |
12281
2738b0cc5f64
patch 8.0.1020: when a timer calls getchar(1) input is overwritten
Christian Brabandt <cb@256bit.org>
parents:
11577
diff
changeset
|
3419 int tb_change_cnt = typebuf.tb_change_cnt; |
7 | 3420 |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3421 if (wait_time == -1L || wait_time > 100L) // flush output before waiting |
7 | 3422 { |
3423 cursor_on(); | |
13150
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
12924
diff
changeset
|
3424 out_flush_cursor(FALSE, FALSE); |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
12924
diff
changeset
|
3425 #if defined(FEAT_GUI) && defined(FEAT_MOUSESHAPE) |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
12924
diff
changeset
|
3426 if (gui.in_use && postponed_mouseshape) |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
12924
diff
changeset
|
3427 update_mouseshape(-1); |
7 | 3428 #endif |
3429 } | |
3430 | |
3431 /* | |
3432 * Don't reset these when at the hit-return prompt, otherwise a endless | |
3433 * recursive loop may result (write error in swapfile, hit-return, timeout | |
3434 * on char wait, flush swapfile, write error....). | |
3435 */ | |
3436 if (State != HITRETURN) | |
3437 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3438 did_outofmem_msg = FALSE; // display out of memory message (again) |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3439 did_swapwrite_msg = FALSE; // display swap file write error again |
7 | 3440 } |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3441 undo_off = FALSE; // restart undo now |
7 | 3442 |
3443 /* | |
1462 | 3444 * Get a character from a script file if there is one. |
3445 * If interrupted: Stop reading script files, close them all. | |
7 | 3446 */ |
3447 script_char = -1; | |
1462 | 3448 while (scriptin[curscript] != NULL && script_char < 0 |
3449 #ifdef FEAT_EVAL | |
3450 && !ignore_script | |
3451 #endif | |
3452 ) | |
7 | 3453 { |
7109
fa95595fbc52
commit https://github.com/vim/vim/commit/93c88e0f6a4a8f7634ed84721daf4af46fc0d5db
Christian Brabandt <cb@256bit.org>
parents:
6907
diff
changeset
|
3454 #ifdef MESSAGE_QUEUE |
fa95595fbc52
commit https://github.com/vim/vim/commit/93c88e0f6a4a8f7634ed84721daf4af46fc0d5db
Christian Brabandt <cb@256bit.org>
parents:
6907
diff
changeset
|
3455 parse_queued_messages(); |
1618 | 3456 #endif |
3457 | |
7 | 3458 if (got_int || (script_char = getc(scriptin[curscript])) < 0) |
3459 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3460 // Reached EOF. |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3461 // Careful: closescript() frees typebuf.tb_buf[] and buf[] may |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3462 // point inside typebuf.tb_buf[]. Don't use buf[] after this! |
7 | 3463 closescript(); |
3464 /* | |
3465 * When reading script file is interrupted, return an ESC to get | |
3466 * back to normal mode. | |
3467 * Otherwise return -1, because typebuf.tb_buf[] has changed. | |
3468 */ | |
3469 if (got_int) | |
3470 retesc = TRUE; | |
3471 else | |
3472 return -1; | |
3473 } | |
3474 else | |
3475 { | |
3476 buf[0] = script_char; | |
3477 len = 1; | |
3478 } | |
3479 } | |
3480 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3481 if (script_char < 0) // did not get a character from script |
7 | 3482 { |
3483 /* | |
3484 * If we got an interrupt, skip all previously typed characters and | |
3485 * return TRUE if quit reading script file. | |
3486 * Stop reading typeahead when a single CTRL-C was read, | |
3487 * fill_input_buf() returns this when not able to read from stdin. | |
3488 * Don't use buf[] here, closescript() may have freed typebuf.tb_buf[] | |
3489 * and buf may be pointing inside typebuf.tb_buf[]. | |
3490 */ | |
3491 if (got_int) | |
3492 { | |
3493 #define DUM_LEN MAXMAPLEN * 3 + 3 | |
3494 char_u dum[DUM_LEN + 1]; | |
3495 | |
3496 for (;;) | |
3497 { | |
3498 len = ui_inchar(dum, DUM_LEN, 0L, 0); | |
3499 if (len == 0 || (len == 1 && dum[0] == 3)) | |
3500 break; | |
3501 } | |
3502 return retesc; | |
3503 } | |
3504 | |
3505 /* | |
3506 * Always flush the output characters when getting input characters | |
15629
dd2e0b83a660
patch 8.1.0822: peeking and flushing output slows down execution
Bram Moolenaar <Bram@vim.org>
parents:
15605
diff
changeset
|
3507 * from the user and not just peeking. |
7 | 3508 */ |
15629
dd2e0b83a660
patch 8.1.0822: peeking and flushing output slows down execution
Bram Moolenaar <Bram@vim.org>
parents:
15605
diff
changeset
|
3509 if (wait_time == -1L || wait_time > 10L) |
dd2e0b83a660
patch 8.1.0822: peeking and flushing output slows down execution
Bram Moolenaar <Bram@vim.org>
parents:
15605
diff
changeset
|
3510 out_flush(); |
7 | 3511 |
3512 /* | |
3513 * Fill up to a third of the buffer, because each character may be | |
3514 * tripled below. | |
3515 */ | |
3516 len = ui_inchar(buf, maxlen / 3, wait_time, tb_change_cnt); | |
3517 } | |
3518 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3519 // If the typebuf was changed further down, it is like nothing was added by |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3520 // this call. |
7 | 3521 if (typebuf_changed(tb_change_cnt)) |
3522 return 0; | |
3523 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3524 // Note the change in the typeahead buffer, this matters for when |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3525 // vgetorpeek() is called recursively, e.g. using getchar(1) in a timer |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3526 // function. |
12281
2738b0cc5f64
patch 8.0.1020: when a timer calls getchar(1) input is overwritten
Christian Brabandt <cb@256bit.org>
parents:
11577
diff
changeset
|
3527 if (len > 0 && ++typebuf.tb_change_cnt == 0) |
2738b0cc5f64
patch 8.0.1020: when a timer calls getchar(1) input is overwritten
Christian Brabandt <cb@256bit.org>
parents:
11577
diff
changeset
|
3528 typebuf.tb_change_cnt = 1; |
2738b0cc5f64
patch 8.0.1020: when a timer calls getchar(1) input is overwritten
Christian Brabandt <cb@256bit.org>
parents:
11577
diff
changeset
|
3529 |
9896
7b39615c0db1
commit https://github.com/vim/vim/commit/6bff02eb530aa29aafa2cb5627399837be7a5dd5
Christian Brabandt <cb@256bit.org>
parents:
9228
diff
changeset
|
3530 return fix_input_buffer(buf, len); |
7 | 3531 } |
3532 | |
3533 /* | |
3534 * Fix typed characters for use by vgetc() and check_termcode(). | |
16531
5c6bd4431d98
patch 8.1.1269: MS-Windows GUI: multibyte chars with a 0x80 byte do not work
Bram Moolenaar <Bram@vim.org>
parents:
16495
diff
changeset
|
3535 * "buf[]" must have room to triple the number of bytes! |
7 | 3536 * Returns the new length. |
3537 */ | |
3538 int | |
9896
7b39615c0db1
commit https://github.com/vim/vim/commit/6bff02eb530aa29aafa2cb5627399837be7a5dd5
Christian Brabandt <cb@256bit.org>
parents:
9228
diff
changeset
|
3539 fix_input_buffer(char_u *buf, int len) |
7 | 3540 { |
3541 int i; | |
3542 char_u *p = buf; | |
3543 | |
3544 /* | |
3545 * Two characters are special: NUL and K_SPECIAL. | |
3546 * When compiled With the GUI CSI is also special. | |
3547 * Replace NUL by K_SPECIAL KS_ZERO KE_FILLER | |
3548 * Replace K_SPECIAL by K_SPECIAL KS_SPECIAL KE_FILLER | |
3549 * Replace CSI by K_SPECIAL KS_EXTRA KE_CSI | |
3550 */ | |
3551 for (i = len; --i >= 0; ++p) | |
3552 { | |
3553 #ifdef FEAT_GUI | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3554 // When the GUI is used any character can come after a CSI, don't |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3555 // escape it. |
7 | 3556 if (gui.in_use && p[0] == CSI && i >= 2) |
3557 { | |
3558 p += 2; | |
3559 i -= 2; | |
3560 } | |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16393
diff
changeset
|
3561 # ifndef MSWIN |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3562 // When the GUI is not used CSI needs to be escaped. |
7 | 3563 else if (!gui.in_use && p[0] == CSI) |
3564 { | |
3565 mch_memmove(p + 3, p + 1, (size_t)i); | |
3566 *p++ = K_SPECIAL; | |
3567 *p++ = KS_EXTRA; | |
3568 *p = (int)KE_CSI; | |
3569 len += 2; | |
3570 } | |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16393
diff
changeset
|
3571 # endif |
7 | 3572 else |
3573 #endif | |
9896
7b39615c0db1
commit https://github.com/vim/vim/commit/6bff02eb530aa29aafa2cb5627399837be7a5dd5
Christian Brabandt <cb@256bit.org>
parents:
9228
diff
changeset
|
3574 if (p[0] == NUL || (p[0] == K_SPECIAL |
16531
5c6bd4431d98
patch 8.1.1269: MS-Windows GUI: multibyte chars with a 0x80 byte do not work
Bram Moolenaar <Bram@vim.org>
parents:
16495
diff
changeset
|
3575 // timeout may generate K_CURSORHOLD |
202 | 3576 && (i < 2 || p[1] != KS_EXTRA || p[2] != (int)KE_CURSORHOLD) |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16393
diff
changeset
|
3577 #if defined(MSWIN) && (!defined(FEAT_GUI) || defined(VIMDLL)) |
16531
5c6bd4431d98
patch 8.1.1269: MS-Windows GUI: multibyte chars with a 0x80 byte do not work
Bram Moolenaar <Bram@vim.org>
parents:
16495
diff
changeset
|
3578 // Win32 console passes modifiers |
5c6bd4431d98
patch 8.1.1269: MS-Windows GUI: multibyte chars with a 0x80 byte do not work
Bram Moolenaar <Bram@vim.org>
parents:
16495
diff
changeset
|
3579 && ( |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16393
diff
changeset
|
3580 # ifdef VIMDLL |
16531
5c6bd4431d98
patch 8.1.1269: MS-Windows GUI: multibyte chars with a 0x80 byte do not work
Bram Moolenaar <Bram@vim.org>
parents:
16495
diff
changeset
|
3581 gui.in_use || |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16393
diff
changeset
|
3582 # endif |
16531
5c6bd4431d98
patch 8.1.1269: MS-Windows GUI: multibyte chars with a 0x80 byte do not work
Bram Moolenaar <Bram@vim.org>
parents:
16495
diff
changeset
|
3583 (i < 2 || p[1] != KS_MODIFIER)) |
7 | 3584 #endif |
3585 )) | |
3586 { | |
3587 mch_memmove(p + 3, p + 1, (size_t)i); | |
3588 p[2] = K_THIRD(p[0]); | |
3589 p[1] = K_SECOND(p[0]); | |
3590 p[0] = K_SPECIAL; | |
3591 p += 2; | |
3592 len += 2; | |
3593 } | |
3594 } | |
16531
5c6bd4431d98
patch 8.1.1269: MS-Windows GUI: multibyte chars with a 0x80 byte do not work
Bram Moolenaar <Bram@vim.org>
parents:
16495
diff
changeset
|
3595 *p = NUL; // add trailing NUL |
7 | 3596 return len; |
3597 } | |
3598 | |
3599 #if defined(USE_INPUT_BUF) || defined(PROTO) | |
3600 /* | |
3601 * Return TRUE when bytes are in the input buffer or in the typeahead buffer. | |
3602 * Normally the input buffer would be sufficient, but the server_to_input_buf() | |
842 | 3603 * or feedkeys() may insert characters in the typeahead buffer while we are |
841 | 3604 * waiting for input to arrive. |
7 | 3605 */ |
3606 int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3607 input_available(void) |
7 | 3608 { |
3609 return (!vim_is_input_buf_empty() | |
841 | 3610 # if defined(FEAT_CLIENTSERVER) || defined(FEAT_EVAL) |
3611 || typebuf_was_filled | |
7 | 3612 # endif |
3613 ); | |
3614 } | |
3615 #endif |