1 To: vim_dev@googlegroups.com
4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
11 Problem: "vim -w foo" writes special key codes for removed escape
12 sequences. (Josh Triplett)
13 Solution: Don't write K_IGNORE codes.
14 Files: src/getchar.c, src/misc1.c, src/term.c, src/vim.h
17 *** ../vim-7.3.090/src/getchar.c 2010-10-27 17:39:00.000000000 +0200
18 --- src/getchar.c 2010-12-30 12:16:36.000000000 +0100
24 - #define KL_PART_KEY -1 /* keylen value for incomplete key-code */
25 - #define KL_PART_MAP -2 /* keylen value for incomplete mapping */
28 * Get the next input character.
29 * Can return a special key or a multi-byte character.
35 /* break at a partly match */
36 ! keylen = KL_PART_MAP;
43 /* break at a partly match */
44 ! keylen = KEYLEN_PART_MAP;
51 /* If no partly match found, use the longest full
53 ! if (keylen != KL_PART_MAP)
56 keylen = mp_match_len;
59 /* If no partly match found, use the longest full
61 ! if (keylen != KEYLEN_PART_MAP)
64 keylen = mp_match_len;
68 /* Need more chars for partly match. */
69 if (mlen == typebuf.tb_len)
70 ! keylen = KL_PART_KEY;
71 else if (max_mlen < mlen)
72 /* no match, may have to check for termcode at
76 /* Need more chars for partly match. */
77 if (mlen == typebuf.tb_len)
78 ! keylen = KEYLEN_PART_KEY;
79 else if (max_mlen < mlen)
80 /* no match, may have to check for termcode at
86 if ((mp == NULL || max_mlen >= mp_match_len)
87 ! && keylen != KL_PART_MAP)
89 int save_keylen = keylen;
94 if ((mp == NULL || max_mlen >= mp_match_len)
95 ! && keylen != KEYLEN_PART_MAP)
97 int save_keylen = keylen;
101 /* If no termcode matched but 'pastetoggle'
102 * matched partially it's like an incomplete key
104 ! if (keylen == 0 && save_keylen == KL_PART_KEY)
105 ! keylen = KL_PART_KEY;
108 * When getting a partial match, but the last
110 /* If no termcode matched but 'pastetoggle'
111 * matched partially it's like an incomplete key
113 ! if (keylen == 0 && save_keylen == KEYLEN_PART_KEY)
114 ! keylen = KEYLEN_PART_KEY;
117 * When getting a partial match, but the last
122 if (*s == NUL) /* need more characters */
123 ! keylen = KL_PART_KEY;
130 if (*s == NUL) /* need more characters */
131 ! keylen = KEYLEN_PART_KEY;
137 if (keylen > 0) /* full matching terminal code */
139 #if defined(FEAT_GUI) && defined(FEAT_MENU)
140 ! if (typebuf.tb_buf[typebuf.tb_off] == K_SPECIAL
141 && typebuf.tb_buf[typebuf.tb_off + 1]
145 if (keylen > 0) /* full matching terminal code */
147 #if defined(FEAT_GUI) && defined(FEAT_MENU)
148 ! if (typebuf.tb_len >= 2
149 ! && typebuf.tb_buf[typebuf.tb_off] == K_SPECIAL
150 && typebuf.tb_buf[typebuf.tb_off + 1]
155 /* Partial match: get some more characters. When a
156 * matching mapping was found use that one. */
157 if (mp == NULL || keylen < 0)
158 ! keylen = KL_PART_KEY;
160 keylen = mp_match_len;
163 /* Partial match: get some more characters. When a
164 * matching mapping was found use that one. */
165 if (mp == NULL || keylen < 0)
166 ! keylen = KEYLEN_PART_KEY;
168 keylen = mp_match_len;
173 && typebuf.tb_maplen == 0
175 ! && (p_timeout || (keylen == KL_PART_KEY && p_ttimeout))
176 && (c = inchar(typebuf.tb_buf + typebuf.tb_off
177 + typebuf.tb_len, 3, 25L,
178 typebuf.tb_change_cnt)) == 0)
181 && typebuf.tb_maplen == 0
184 ! || (keylen == KEYLEN_PART_KEY && p_ttimeout))
185 && (c = inchar(typebuf.tb_buf + typebuf.tb_off
186 + typebuf.tb_len, 3, 25L,
187 typebuf.tb_change_cnt)) == 0)
191 : ((typebuf.tb_len == 0
192 || !(p_timeout || (p_ttimeout
193 ! && keylen == KL_PART_KEY)))
195 ! : ((keylen == KL_PART_KEY && p_ttm >= 0)
197 : p_tm)), typebuf.tb_change_cnt);
201 : ((typebuf.tb_len == 0
202 || !(p_timeout || (p_ttimeout
203 ! && keylen == KEYLEN_PART_KEY)))
205 ! : ((keylen == KEYLEN_PART_KEY && p_ttm >= 0)
207 : p_tm)), typebuf.tb_change_cnt);
209 *** ../vim-7.3.090/src/misc1.c 2010-12-02 16:01:23.000000000 +0100
210 --- src/misc1.c 2010-12-30 12:28:59.000000000 +0100
213 && (!p_ttimeout || waited * 100L < (p_ttm < 0 ? p_tm : p_ttm)))
216 ! /* found a termcode: adjust length */
219 ! if (len == 0) /* nothing typed yet */
222 /* Handle modifier and/or special key code. */
224 && (!p_ttimeout || waited * 100L < (p_ttm < 0 ? p_tm : p_ttm)))
227 ! if (n == KEYLEN_REMOVED) /* key code removed */
229 ! if (n > 0) /* found a termcode: adjust length */
231 ! if (len == 0) /* nothing typed yet */
234 /* Handle modifier and/or special key code. */
235 *** ../vim-7.3.090/src/term.c 2010-08-15 21:57:32.000000000 +0200
236 --- src/term.c 2010-12-30 12:14:48.000000000 +0100
240 * Check from typebuf.tb_buf[typebuf.tb_off] to typebuf.tb_buf[typebuf.tb_off
242 * Return 0 for no match, -1 for partial match, > 0 for full match.
243 + * Return KEYLEN_REMOVED when a key code was deleted.
244 * With a match, the match is removed, the replacement code is inserted in
245 * typebuf.tb_buf[] and the number of characters in typebuf.tb_buf[] is
250 int slen = 0; /* init for GCC */
261 string[new_slen++] = key_name[1];
263 + else if (new_slen == 0 && key_name[0] == KS_EXTRA
264 + && key_name[1] == KE_IGNORE)
266 + /* Do not put K_IGNORE into the buffer, do return KEYLEN_REMOVED
267 + * to indicate what happened. */
268 + retval = KEYLEN_REMOVED;
272 string[new_slen++] = K_SPECIAL;
275 (size_t)(buflen - offset));
276 mch_memmove(buf + offset, string, (size_t)new_slen);
278 ! return (len + extra + offset);
281 return 0; /* no match found */
283 (size_t)(buflen - offset));
284 mch_memmove(buf + offset, string, (size_t)new_slen);
286 ! return retval == 0 ? (len + extra + offset) : retval;
289 return 0; /* no match found */
290 *** ../vim-7.3.090/src/vim.h 2010-12-17 20:23:56.000000000 +0100
291 --- src/vim.h 2010-12-30 12:06:45.000000000 +0100
296 #define MSCR_RIGHT -2
298 + #define KEYLEN_PART_KEY -1 /* keylen value for incomplete key-code */
299 + #define KEYLEN_PART_MAP -2 /* keylen value for incomplete mapping */
300 + #define KEYLEN_REMOVED 9999 /* keylen value for removed sequence */
303 *** ../vim-7.3.090/src/version.c 2010-12-30 11:41:05.000000000 +0100
304 --- src/version.c 2010-12-30 12:24:56.000000000 +0100
308 { /* Add new patch number below this line */
314 hundred-and-one symptoms of being an internet addict:
315 56. You leave the modem speaker on after connecting because you think it
316 sounds like the ocean wind...the perfect soundtrack for "surfing the net".
318 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
319 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
320 \\\ an exciting new programming language -- http://www.Zimbu.org ///
321 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///