Mercurial > vim
comparison src/option.c @ 14867:cf4d6489c9eb v8.1.0445
patch 8.1.0445: setting 'term' does not store location for termcap options
commit https://github.com/vim/vim/commit/35bc7d6c52f516b60d683bf9f0f57266d86e25b9
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Oct 2 14:45:10 2018 +0200
patch 8.1.0445: setting 'term' does not store location for termcap options
Problem: Setting 'term' does not store location for termcap options.
Solution: Set the script context for termcap options that are changed when
'term' is set.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 02 Oct 2018 15:00:07 +0200 |
parents | 27b9a84395b5 |
children | dc54785f9a1d |
comparison
equal
deleted
inserted
replaced
14866:2cc6cfa2b804 | 14867:cf4d6489c9eb |
---|---|
1753 #endif | 1753 #endif |
1754 (char_u *)0L} SCTX_INIT}, | 1754 (char_u *)0L} SCTX_INIT}, |
1755 {"langmap", "lmap", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_SECURE, | 1755 {"langmap", "lmap", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_SECURE, |
1756 #ifdef FEAT_LANGMAP | 1756 #ifdef FEAT_LANGMAP |
1757 (char_u *)&p_langmap, PV_NONE, | 1757 (char_u *)&p_langmap, PV_NONE, |
1758 {(char_u *)"", /* unmatched } */ | 1758 {(char_u *)"", (char_u *)0L} |
1759 #else | 1759 #else |
1760 (char_u *)NULL, PV_NONE, | 1760 (char_u *)NULL, PV_NONE, |
1761 {(char_u *)NULL, | 1761 {(char_u *)NULL, (char_u *)0L} |
1762 #endif | 1762 #endif |
1763 (char_u *)0L} SCTX_INIT}, | 1763 SCTX_INIT}, |
1764 {"langmenu", "lm", P_STRING|P_VI_DEF|P_NFNAME, | 1764 {"langmenu", "lm", P_STRING|P_VI_DEF|P_NFNAME, |
1765 #if defined(FEAT_MENU) && defined(FEAT_MULTI_LANG) | 1765 #if defined(FEAT_MENU) && defined(FEAT_MULTI_LANG) |
1766 (char_u *)&p_lm, PV_NONE, | 1766 (char_u *)&p_lm, PV_NONE, |
1767 #else | 1767 #else |
1768 (char_u *)NULL, PV_NONE, | 1768 (char_u *)NULL, PV_NONE, |
5788 if (*pp == NULL) | 5788 if (*pp == NULL) |
5789 *pp = empty_option; | 5789 *pp = empty_option; |
5790 } | 5790 } |
5791 | 5791 |
5792 /* | 5792 /* |
5793 * Mark a terminal option as allocated, found by a pointer into term_strings[]. | 5793 * Return the option index found by a pointer into term_strings[]. |
5794 * Return -1 if not found. | |
5794 */ | 5795 */ |
5795 void | 5796 int |
5796 set_term_option_alloced(char_u **p) | 5797 get_term_opt_idx(char_u **p) |
5797 { | 5798 { |
5798 int opt_idx; | 5799 int opt_idx; |
5799 | 5800 |
5800 for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++) | 5801 for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++) |
5801 if (options[opt_idx].var == (char_u *)p) | 5802 if (options[opt_idx].var == (char_u *)p) |
5802 { | 5803 return opt_idx; |
5803 options[opt_idx].flags |= P_ALLOCED; | 5804 return -1; // cannot happen: didn't find it! |
5804 return; | 5805 } |
5805 } | 5806 |
5806 return; /* cannot happen: didn't find it! */ | 5807 /* |
5808 * Mark a terminal option as allocated, found by a pointer into term_strings[]. | |
5809 * Return the option index or -1 if not found. | |
5810 */ | |
5811 int | |
5812 set_term_option_alloced(char_u **p) | |
5813 { | |
5814 int opt_idx = get_term_opt_idx(p); | |
5815 | |
5816 if (opt_idx >= 0) | |
5817 options[opt_idx].flags |= P_ALLOCED; | |
5818 return opt_idx; | |
5807 } | 5819 } |
5808 | 5820 |
5809 #if defined(FEAT_EVAL) || defined(PROTO) | 5821 #if defined(FEAT_EVAL) || defined(PROTO) |
5810 /* | 5822 /* |
5811 * Return TRUE when option "opt" was set from a modeline or in secure mode. | 5823 * Return TRUE when option "opt" was set from a modeline or in secure mode. |
8235 curbuf->b_p_script_ctx[indir & PV_MASK] = new_script_ctx; | 8247 curbuf->b_p_script_ctx[indir & PV_MASK] = new_script_ctx; |
8236 else if (indir & PV_WIN) | 8248 else if (indir & PV_WIN) |
8237 curwin->w_p_script_ctx[indir & PV_MASK] = new_script_ctx; | 8249 curwin->w_p_script_ctx[indir & PV_MASK] = new_script_ctx; |
8238 } | 8250 } |
8239 } | 8251 } |
8252 | |
8253 /* | |
8254 * Set the script_ctx for a termcap option. | |
8255 * "name" must be the two character code, e.g. "RV". | |
8256 * When "name" is NULL use "opt_idx". | |
8257 */ | |
8258 void | |
8259 set_term_option_sctx_idx(char *name, int opt_idx) | |
8260 { | |
8261 char_u buf[5]; | |
8262 int idx; | |
8263 | |
8264 if (name == NULL) | |
8265 idx = opt_idx; | |
8266 else | |
8267 { | |
8268 buf[0] = 't'; | |
8269 buf[1] = '_'; | |
8270 buf[2] = name[0]; | |
8271 buf[3] = name[1]; | |
8272 buf[4] = 0; | |
8273 idx = findoption(buf); | |
8274 } | |
8275 if (idx >= 0) | |
8276 set_option_sctx_idx(idx, OPT_GLOBAL, current_sctx); | |
8277 } | |
8240 #endif | 8278 #endif |
8241 | 8279 |
8242 /* | 8280 /* |
8243 * Set the value of a boolean option, and take care of side effects. | 8281 * Set the value of a boolean option, and take care of side effects. |
8244 * Returns NULL for success, or an error message for an error. | 8282 * Returns NULL for success, or an error message for an error. |
10443 void | 10481 void |
10444 free_termoptions(void) | 10482 free_termoptions(void) |
10445 { | 10483 { |
10446 struct vimoption *p; | 10484 struct vimoption *p; |
10447 | 10485 |
10448 for (p = &options[0]; p->fullname != NULL; p++) | 10486 for (p = options; p->fullname != NULL; p++) |
10449 if (istermoption(p)) | 10487 if (istermoption(p)) |
10450 { | 10488 { |
10451 if (p->flags & P_ALLOCED) | 10489 if (p->flags & P_ALLOCED) |
10452 free_string_option(*(char_u **)(p->var)); | 10490 free_string_option(*(char_u **)(p->var)); |
10453 if (p->flags & P_DEF_ALLOCED) | 10491 if (p->flags & P_DEF_ALLOCED) |
10454 free_string_option(p->def_val[VI_DEFAULT]); | 10492 free_string_option(p->def_val[VI_DEFAULT]); |
10455 *(char_u **)(p->var) = empty_option; | 10493 *(char_u **)(p->var) = empty_option; |
10456 p->def_val[VI_DEFAULT] = empty_option; | 10494 p->def_val[VI_DEFAULT] = empty_option; |
10457 p->flags &= ~(P_ALLOCED|P_DEF_ALLOCED); | 10495 p->flags &= ~(P_ALLOCED|P_DEF_ALLOCED); |
10496 #ifdef FEAT_EVAL | |
10497 // remember where the option was cleared | |
10498 set_option_sctx_idx((int)(p - options), OPT_GLOBAL, current_sctx); | |
10499 #endif | |
10458 } | 10500 } |
10459 clear_termcodes(); | 10501 clear_termcodes(); |
10460 } | 10502 } |
10461 | 10503 |
10462 /* | 10504 /* |