Compare commits

...

3 Commits

Author SHA1 Message Date
Bram Moolenaar
b8bf541f89 updated for version 7.3.284
Problem:    The str2special() function doesn't handle multi-byte characters
            properly.
Solution:   Recognize multi-byte characters. (partly by Vladimir Vichniakov)
2011-08-17 20:33:22 +02:00
Bram Moolenaar
f6f4a01ab1 updated for version 7.3.283
Problem:    An expression mapping with a multi-byte character containing a
            0x80 byte gets messed up. (ZyX)
Solution:   Unescape the expression before evaluating it (Yukihiro Nakadaira)
2011-08-17 17:18:20 +02:00
Bram Moolenaar
1db1f77d4a updated for version 7.3.282
Problem:    When using input() and :echo in a loop the displayed text is
            incorrect. (Benjamin Fritz)
Solution:   Only restore the cursor position when there is a command line.
            (Ben Schmidt)
2011-08-17 16:25:48 +02:00
5 changed files with 86 additions and 24 deletions

View File

@@ -1969,8 +1969,12 @@ getcmdline_prompt(firstc, prompt, attr, xp_context, xp_arg)
# endif
s = getcmdline(firstc, 1L, 0);
restore_cmdline(&save_ccline);
/* Restore msg_col, the prompt from input() may have changed it. */
msg_col = msg_col_save;
/* Restore msg_col, the prompt from input() may have changed it.
* But only if called recursively and the commandline is therefore being
* restored to an old one; if not, the input() prompt stays on the screen,
* so we need its modified msg_col left intact. */
if (ccline.cmdbuff != NULL)
msg_col = msg_col_save;
return s;
}

View File

@@ -3262,9 +3262,9 @@ do_map(maptype, arg, mode, abbrev)
validate_maphash();
/*
* find end of keys and skip CTRL-Vs (and backslashes) in it
* Find end of keys and skip CTRL-Vs (and backslashes) in it.
* Accept backslash like CTRL-V when 'cpoptions' does not contain 'B'.
* with :unmap white space is included in the keys, no argument possible
* with :unmap white space is included in the keys, no argument possible.
*/
p = keys;
do_backslash = (vim_strchr(p_cpo, CPO_BSLASH) == NULL);
@@ -3964,7 +3964,17 @@ showmap(mp, local)
if (*mp->m_str == NUL)
msg_puts_attr((char_u *)"<Nop>", hl_attr(HLF_8));
else
msg_outtrans_special(mp->m_str, FALSE);
{
/* Remove escaping of CSI, because "m_str" is in a format to be used
* as typeahead. */
char_u *s = vim_strsave(mp->m_str);
if (s != NULL)
{
vim_unescape_csi(s);
msg_outtrans_special(s, FALSE);
vim_free(s);
}
}
#ifdef FEAT_EVAL
if (p_verbose > 0)
last_set_msg(mp->m_script_ID);
@@ -4506,12 +4516,23 @@ eval_map_expr(str, c)
{
char_u *res;
char_u *p;
char_u *expr;
char_u *save_cmd;
pos_T save_cursor;
/* Remove escaping of CSI, because "str" is in a format to be used as
* typeahead. */
expr = vim_strsave(str);
if (expr == NULL)
return NULL;
vim_unescape_csi(expr);
save_cmd = save_cmdline_alloc();
if (save_cmd == NULL)
{
vim_free(expr);
return NULL;
}
/* Forbid changing text or using ":normal" to avoid most of the bad side
* effects. Also restore the cursor position. */
@@ -4521,7 +4542,7 @@ eval_map_expr(str, c)
#endif
set_vim_var_char(c); /* set v:char to the typed character */
save_cursor = curwin->w_cursor;
p = eval_to_string(str, NULL, FALSE);
p = eval_to_string(expr, NULL, FALSE);
--textlock;
#ifdef FEAT_EX_EXTRA
--ex_normal_lock;
@@ -4529,8 +4550,11 @@ eval_map_expr(str, c)
curwin->w_cursor = save_cursor;
restore_cmdline_alloc(save_cmd);
vim_free(expr);
if (p == NULL)
return NULL;
/* Escape CSI in the result to be able to use the string as typeahead. */
res = vim_strsave_escape_csi(p);
vim_free(p);

View File

@@ -1547,16 +1547,27 @@ str2special(sp, from)
if (IS_SPECIAL(c) || modifiers) /* special key */
special = TRUE;
}
*sp = str + 1;
#ifdef FEAT_MBYTE
/* For multi-byte characters check for an illegal byte. */
if (has_mbyte && MB_BYTE2LEN(*str) > (*mb_ptr2len)(str))
if (has_mbyte && !IS_SPECIAL(c))
{
transchar_nonprint(buf, c);
return buf;
int len = (*mb_ptr2len)(str);
/* For multi-byte characters check for an illegal byte. */
if (has_mbyte && MB_BYTE2LEN(*str) > len)
{
transchar_nonprint(buf, c);
*sp = str + 1;
return buf;
}
/* Since 'special' is TRUE the multi-byte character 'c' will be
* processed by get_special_key_name() */
c = (*mb_ptr2char)(str);
*sp = str + len;
}
else
#endif
*sp = str + 1;
/* Make unprintable characters in <> form, also <M-Space> and <Tab>.
* Use <Space> only for lhs of a mapping. */

View File

@@ -2754,6 +2754,7 @@ find_special_key(srcp, modp, keycode, keep_x_key)
int bit;
int key;
unsigned long n;
int l;
src = *srcp;
if (src[0] != '<')
@@ -2766,8 +2767,17 @@ find_special_key(srcp, modp, keycode, keep_x_key)
if (*bp == '-')
{
last_dash = bp;
if (bp[1] != NUL && bp[2] == '>')
++bp; /* anything accepted, like <C-?> */
if (bp[1] != NUL)
{
#ifdef FEAT_MBYTE
if (has_mbyte)
l = mb_ptr2len(bp + 1);
else
#endif
l = 1;
if (bp[l + 1] == '>')
bp += l; /* anything accepted, like <C-?> */
}
}
if (bp[0] == 't' && bp[1] == '_' && bp[2] && bp[3])
bp += 3; /* skip t_xx, xx may be '-' or '>' */
@@ -2777,15 +2787,6 @@ find_special_key(srcp, modp, keycode, keep_x_key)
{
end_of_name = bp + 1;
if (STRNICMP(src + 1, "char-", 5) == 0 && VIM_ISDIGIT(src[6]))
{
/* <Char-123> or <Char-033> or <Char-0x33> */
vim_str2nr(src + 6, NULL, NULL, TRUE, TRUE, NULL, &n);
*modp = 0;
*srcp = end_of_name;
return (int)n;
}
/* Which modifiers are given? */
modifiers = 0x0;
for (bp = src + 1; bp < last_dash; bp++)
@@ -2804,11 +2805,27 @@ find_special_key(srcp, modp, keycode, keep_x_key)
*/
if (bp >= last_dash)
{
if (STRNICMP(last_dash + 1, "char-", 5) == 0
&& VIM_ISDIGIT(last_dash[6]))
{
/* <Char-123> or <Char-033> or <Char-0x33> */
vim_str2nr(last_dash + 6, NULL, NULL, TRUE, TRUE, NULL, &n);
*modp = modifiers;
*srcp = end_of_name;
return (int)n;
}
/*
* Modifier with single letter, or special key name.
*/
if (modifiers != 0 && last_dash[2] == '>')
key = last_dash[1];
#ifdef FEAT_MBYTE
if (has_mbyte)
l = mb_ptr2len(last_dash + 1);
else
#endif
l = 1;
if (modifiers != 0 && last_dash[l + 1] == '>')
key = PTR2CHAR(last_dash + 1);
else
{
key = get_special_key_code(last_dash + 1);

View File

@@ -709,6 +709,12 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
284,
/**/
283,
/**/
282,
/**/
281,
/**/