diff options
-rw-r--r-- | src/option.c | 54 | ||||
-rw-r--r-- | src/testdir/test_assign.vim | 20 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 76 insertions, 0 deletions
diff --git a/src/option.c b/src/option.c index b90d5fdfa..1237d048b 100644 --- a/src/option.c +++ b/src/option.c @@ -9197,7 +9197,35 @@ get_option_value( opt_idx = findoption(name); 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; + } varp = get_varp_scope(&(options[opt_idx]), opt_flags); @@ -9455,7 +9483,33 @@ set_option_value( opt_idx = findoption(name); 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); + } else { flags = options[opt_idx].flags; diff --git a/src/testdir/test_assign.vim b/src/testdir/test_assign.vim index c1f036a0f..22aa4a1d3 100644 --- a/src/testdir/test_assign.vim +++ b/src/testdir/test_assign.vim @@ -7,3 +7,23 @@ func Test_no_type_checking() let v = 3.4 let v = 'hello' 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 diff --git a/src/version.c b/src/version.c index ffb7c6cb7..34add35ec 100644 --- a/src/version.c +++ b/src/version.c @@ -765,6 +765,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 302, +/**/ 301, /**/ 300, |