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: The str2special() function doesn't handle multi-byte characters
13 Solution: Recognize multi-byte characters. (partly by Vladimir Vichniakov)
14 Files: src/getchar.c, src/message.c, src/misc2.c
17 *** ../vim-7.3.283/src/getchar.c 2011-08-17 17:18:14.000000000 +0200
18 --- src/getchar.c 2011-08-17 20:11:58.000000000 +0200
21 if (*mp->m_str == NUL)
22 msg_puts_attr((char_u *)"<Nop>", hl_attr(HLF_8));
24 ! msg_outtrans_special(mp->m_str, FALSE);
27 last_set_msg(mp->m_script_ID);
29 if (*mp->m_str == NUL)
30 msg_puts_attr((char_u *)"<Nop>", hl_attr(HLF_8));
33 ! /* Remove escaping of CSI, because "m_str" is in a format to be used
35 ! char_u *s = vim_strsave(mp->m_str);
38 ! vim_unescape_csi(s);
39 ! msg_outtrans_special(s, FALSE);
45 last_set_msg(mp->m_script_ID);
46 *** ../vim-7.3.283/src/message.c 2011-03-22 13:07:19.000000000 +0100
47 --- src/message.c 2011-08-17 18:40:10.000000000 +0200
50 if (IS_SPECIAL(c) || modifiers) /* special key */
56 ! /* For multi-byte characters check for an illegal byte. */
57 ! if (has_mbyte && MB_BYTE2LEN(*str) > (*mb_ptr2len)(str))
59 ! transchar_nonprint(buf, c);
64 /* Make unprintable characters in <> form, also <M-Space> and <Tab>.
65 * Use <Space> only for lhs of a mapping. */
67 if (IS_SPECIAL(c) || modifiers) /* special key */
72 ! if (has_mbyte && !IS_SPECIAL(c))
74 ! int len = (*mb_ptr2len)(str);
76 ! /* For multi-byte characters check for an illegal byte. */
77 ! if (has_mbyte && MB_BYTE2LEN(*str) > len)
79 ! transchar_nonprint(buf, c);
83 ! /* Since 'special' is TRUE the multi-byte character 'c' will be
84 ! * processed by get_special_key_name() */
85 ! c = (*mb_ptr2char)(str);
92 /* Make unprintable characters in <> form, also <M-Space> and <Tab>.
93 * Use <Space> only for lhs of a mapping. */
94 *** ../vim-7.3.283/src/misc2.c 2011-07-27 17:31:42.000000000 +0200
95 --- src/misc2.c 2011-08-17 20:27:30.000000000 +0200
111 ! if (bp[1] != NUL && bp[2] == '>')
112 ! ++bp; /* anything accepted, like <C-?> */
114 if (bp[0] == 't' && bp[1] == '_' && bp[2] && bp[3])
115 bp += 3; /* skip t_xx, xx may be '-' or '>' */
124 ! l = mb_ptr2len(bp + 1);
128 ! if (bp[l + 1] == '>')
129 ! bp += l; /* anything accepted, like <C-?> */
132 if (bp[0] == 't' && bp[1] == '_' && bp[2] && bp[3])
133 bp += 3; /* skip t_xx, xx may be '-' or '>' */
137 end_of_name = bp + 1;
139 - if (STRNICMP(src + 1, "char-", 5) == 0 && VIM_ISDIGIT(src[6]))
141 - /* <Char-123> or <Char-033> or <Char-0x33> */
142 - vim_str2nr(src + 6, NULL, NULL, TRUE, TRUE, NULL, &n);
144 - *srcp = end_of_name;
148 /* Which modifiers are given? */
150 for (bp = src + 1; bp < last_dash; bp++)
158 * Modifier with single letter, or special key name.
160 ! if (modifiers != 0 && last_dash[2] == '>')
161 ! key = last_dash[1];
164 key = get_special_key_code(last_dash + 1);
169 + if (STRNICMP(last_dash + 1, "char-", 5) == 0
170 + && VIM_ISDIGIT(last_dash[6]))
172 + /* <Char-123> or <Char-033> or <Char-0x33> */
173 + vim_str2nr(last_dash + 6, NULL, NULL, TRUE, TRUE, NULL, &n);
175 + *srcp = end_of_name;
180 * Modifier with single letter, or special key name.
184 ! l = mb_ptr2len(last_dash + 1);
188 ! if (modifiers != 0 && last_dash[l + 1] == '>')
189 ! key = PTR2CHAR(last_dash + 1);
192 key = get_special_key_code(last_dash + 1);
193 *** ../vim-7.3.283/src/version.c 2011-08-17 17:18:14.000000000 +0200
194 --- src/version.c 2011-08-17 20:27:47.000000000 +0200
198 { /* Add new patch number below this line */
204 Snoring is prohibited unless all bedroom windows are closed and securely
206 [real standing law in Massachusetts, United States of America]
208 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
209 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
210 \\\ an exciting new programming language -- http://www.Zimbu.org ///
211 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///