Permalink
Browse files

patch 8.0.0302: cannot set terminal key codes with :let

Problem:    Cannot set terminal key codes with :let.
Solution:   Make it work.
  • Loading branch information...
brammool committed Feb 4, 2017
1 parent 698f8b2 commit e353c402e63b9b0a0bc06acf390e352d9e7eeaeb
Showing with 76 additions and 0 deletions.
  1. +54 −0 src/option.c
  2. +20 −0 src/testdir/test_assign.vim
  3. +2 −0 src/version.c
View
@@ -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;
@@ -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
View
@@ -764,6 +764,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 302,
/**/
301,
/**/

0 comments on commit e353c40

Please sign in to comment.