0
0
mirror of https://github.com/vim/vim.git synced 2025-09-29 04:34:16 -04:00

patch 8.0.0302: cannot set terminal key codes with :let

Problem:    Cannot set terminal key codes with :let.
Solution:   Make it work.
This commit is contained in:
Bram Moolenaar
2017-02-04 19:49:16 +01:00
parent 698f8b207b
commit e353c402e6
3 changed files with 76 additions and 0 deletions

View File

@@ -9197,7 +9197,35 @@ get_option_value(
opt_idx = findoption(name); opt_idx = findoption(name);
if (opt_idx < 0) /* unknown option */ if (opt_idx < 0) /* unknown option */
{
int key;
if (STRLEN(name) == 4 && name[0] == 't' && name[1] == '_'
&& (key = find_key_option(name)) != 0)
{
char_u key_name[2];
char_u *p;
if (key < 0)
{
key_name[0] = KEY2TERMCAP0(key);
key_name[1] = KEY2TERMCAP1(key);
}
else
{
key_name[0] = KS_KEY;
key_name[1] = (key & 0xff);
}
p = find_termcode(key_name);
if (p != NULL)
{
if (stringval != NULL)
*stringval = vim_strsave(p);
return 0;
}
}
return -3; return -3;
}
varp = get_varp_scope(&(options[opt_idx]), opt_flags); varp = get_varp_scope(&(options[opt_idx]), opt_flags);
@@ -9455,7 +9483,33 @@ set_option_value(
opt_idx = findoption(name); opt_idx = findoption(name);
if (opt_idx < 0) if (opt_idx < 0)
{
int key;
if (STRLEN(name) == 4 && name[0] == 't' && name[1] == '_'
&& (key = find_key_option(name)) != 0)
{
char_u key_name[2];
if (key < 0)
{
key_name[0] = KEY2TERMCAP0(key);
key_name[1] = KEY2TERMCAP1(key);
}
else
{
key_name[0] = KS_KEY;
key_name[1] = (key & 0xff);
}
add_termcode(key_name, string, FALSE);
if (full_screen)
ttest(FALSE);
redraw_all_later(CLEAR);
return NULL;
}
EMSG2(_("E355: Unknown option: %s"), name); EMSG2(_("E355: Unknown option: %s"), name);
}
else else
{ {
flags = options[opt_idx].flags; flags = options[opt_idx].flags;

View File

@@ -7,3 +7,23 @@ func Test_no_type_checking()
let v = 3.4 let v = 3.4
let v = 'hello' let v = 'hello'
endfunc endfunc
func Test_let_termcap()
" Terminal code
let old_t_te = &t_te
let &t_te = "\<Esc>[yes;"
call assert_match('t_te.*^[[yes;', execute("set termcap"))
let &t_te = old_t_te
" Key code
let old_t_k1 = &t_k1
let &t_k1 = "that"
call assert_match('t_k1.*that', execute("set termcap"))
let &t_k1 = old_t_k1
call assert_fails('let x = &t_xx', 'E15')
let &t_xx = "yes"
call assert_equal("yes", &t_xx)
let &t_xx = ""
call assert_fails('let x = &t_xx', 'E15')
endfunc

View File

@@ -764,6 +764,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
302,
/**/ /**/
301, 301,
/**/ /**/