diff options
Diffstat (limited to 'src/nvim/option.c')
-rw-r--r-- | src/nvim/option.c | 539 |
1 files changed, 110 insertions, 429 deletions
diff --git a/src/nvim/option.c b/src/nvim/option.c index bf7d0d0bf3..5435a1adeb 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -77,7 +77,7 @@ #include "nvim/spell.h" #include "nvim/strings.h" #include "nvim/syntax.h" -#include "nvim/term.h" +#include "nvim/ui.h" #include "nvim/undo.h" #include "nvim/window.h" #include "nvim/os/os.h" @@ -1531,10 +1531,6 @@ static vimoption_T {"tagstack", "tgst", P_BOOL|P_VI_DEF, (char_u *)&p_tgst, PV_NONE, {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, - {"term", NULL, P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF| - P_RALL, - (char_u *)&T_NAME, PV_NONE, - {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, {"termbidi", "tbidi", P_BOOL|P_VI_DEF, (char_u *)&p_tbidi, PV_NONE, {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, @@ -1580,9 +1576,6 @@ static vimoption_T {"ttimeoutlen", "ttm", P_NUM|P_VI_DEF, (char_u *)&p_ttm, PV_NONE, {(char_u *)-1L, (char_u *)0L} SCRIPTID_INIT}, - {"ttybuiltin", "tbi", P_BOOL|P_VI_DEF, - (char_u *)&p_tbi, PV_NONE, - {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, {"ttymouse", "ttym", P_STRING|P_NODEFAULT|P_NO_MKRC|P_VI_DEF, #if defined(FEAT_MOUSE) && defined(UNIX) (char_u *)&p_ttym, PV_NONE, @@ -1590,13 +1583,6 @@ static vimoption_T (char_u *)NULL, PV_NONE, #endif {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, - {"ttyscroll", "tsl", P_NUM|P_VI_DEF, - (char_u *)&p_ttyscroll, PV_NONE, - {(char_u *)999L, (char_u *)0L} SCRIPTID_INIT}, - {"ttytype", "tty", P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF| - P_RALL, - (char_u *)&T_NAME, PV_NONE, - {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, {"undodir", "udir", P_STRING|P_EXPAND|P_COMMA|P_NODUP|P_SECURE|P_VI_DEF, (char_u *)&p_udir, PV_NONE, {(char_u *)".", (char_u *)0L} @@ -1660,9 +1646,6 @@ static vimoption_T {"warn", NULL, P_BOOL|P_VI_DEF, (char_u *)&p_warn, PV_NONE, {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, - {"weirdinvert", "wiv", P_BOOL|P_VI_DEF|P_RCLR, - (char_u *)&p_wiv, PV_NONE, - {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, {"whichwrap", "ww", P_STRING|P_VIM|P_COMMA|P_FLAGLIST, (char_u *)&p_ww, PV_NONE, {(char_u *)"", (char_u *)"b,s"} SCRIPTID_INIT}, @@ -1739,69 +1722,6 @@ static vimoption_T (char_u *)&p_wd, PV_NONE, {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, - /* terminal output codes */ -#define p_term(sss, vvv) {sss, NULL, P_STRING|P_VI_DEF|P_RALL|P_SECURE, \ - (char_u *)&vvv, PV_NONE, \ - {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, - - p_term("t_AB", T_CAB) - p_term("t_AF", T_CAF) - p_term("t_AL", T_CAL) - p_term("t_al", T_AL) - p_term("t_bc", T_BC) - p_term("t_cd", T_CD) - p_term("t_ce", T_CE) - p_term("t_cl", T_CL) - p_term("t_cm", T_CM) - p_term("t_Co", T_CCO) - p_term("t_CS", T_CCS) - p_term("t_cs", T_CS) - p_term("t_CV", T_CSV) - p_term("t_ut", T_UT) - p_term("t_da", T_DA) - p_term("t_db", T_DB) - p_term("t_DL", T_CDL) - p_term("t_dl", T_DL) - p_term("t_fs", T_FS) - p_term("t_IE", T_CIE) - p_term("t_IS", T_CIS) - p_term("t_ke", T_KE) - p_term("t_ks", T_KS) - p_term("t_le", T_LE) - p_term("t_mb", T_MB) - p_term("t_md", T_MD) - p_term("t_me", T_ME) - p_term("t_mr", T_MR) - p_term("t_ms", T_MS) - p_term("t_nd", T_ND) - p_term("t_op", T_OP) - p_term("t_RI", T_CRI) - p_term("t_RV", T_CRV) - p_term("t_u7", T_U7) - p_term("t_Sb", T_CSB) - p_term("t_Sf", T_CSF) - p_term("t_se", T_SE) - p_term("t_so", T_SO) - p_term("t_sr", T_SR) - p_term("t_ts", T_TS) - p_term("t_te", T_TE) - p_term("t_ti", T_TI) - p_term("t_ue", T_UE) - p_term("t_us", T_US) - p_term("t_vb", T_VB) - p_term("t_ve", T_VE) - p_term("t_vi", T_VI) - p_term("t_vs", T_VS) - p_term("t_WP", T_CWP) - p_term("t_WS", T_CWS) - p_term("t_SI", T_CSI) - p_term("t_EI", T_CEI) - p_term("t_xs", T_XS) - p_term("t_ZH", T_CZH) - p_term("t_ZR", T_CZR) - - /* terminal key codes are not in here */ - /* end marker */ { NULL, NULL, 0, NULL, PV_NONE, {NULL, NULL} SCRIPTID_INIT @@ -2018,7 +1938,7 @@ void set_init_1(void) * Don't set the P_ALLOCED flag, because we don't want to free the * default. */ - for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++) { + for (opt_idx = 0; options[opt_idx].fullname; opt_idx++) { if ((options[opt_idx].flags & P_GETTEXT) && options[opt_idx].var != NULL) p = (char_u *)_(*(char **)options[opt_idx].var); @@ -2183,7 +2103,7 @@ set_options_default ( int opt_flags /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */ ) { - for (int i = 0; !istermoption(&options[i]); i++) { + for (int i = 0; options[i].fullname; i++) { if (!(options[i].flags & P_NODEFAULT)) { set_option_default(i, opt_flags, p_cp); } @@ -2236,7 +2156,7 @@ void free_all_options(void) { int i; - for (i = 0; !istermoption(&options[i]); i++) { + for (i = 0; options[i].fullname; i++) { if (options[i].indir == PV_NONE) { /* global option: free value and default value. */ if (options[i].flags & P_ALLOCED && options[i].var != NULL) @@ -2278,55 +2198,11 @@ void set_init_2(void) if (!option_was_set((char_u *)"window")) p_window = Rows - 1; set_number_default("window", Rows - 1); - - /* For DOS console the default is always black. */ - /* - * If 'background' wasn't set by the user, try guessing the value, - * depending on the terminal name. Only need to check for terminals - * with a dark background, that can handle color. - */ - idx = findoption((char_u *)"bg"); - if (idx >= 0 && !(options[idx].flags & P_WAS_SET) - && *term_bg_default() == 'd') { - set_string_option_direct(NULL, idx, (char_u *)"dark", OPT_FREE, 0); - /* don't mark it as set, when starting the GUI it may be - * changed again */ - options[idx].flags &= ~P_WAS_SET; - } - parse_shape_opt(SHAPE_CURSOR); /* set cursor shapes from 'guicursor' */ (void)parse_printoptions(); /* parse 'printoptions' default value */ } /* - * Return "dark" or "light" depending on the kind of terminal. - * This is just guessing! Recognized are: - * "linux" Linux console - * "screen.linux" Linux console with screen - * "cygwin" Cygwin shell - * "putty" Putty program - * We also check the COLORFGBG environment variable, which is set by - * rxvt and derivatives. This variable contains either two or three - * values separated by semicolons; we want the last value in either - * case. If this value is 0-6 or 8, our background is dark. - */ -static char_u *term_bg_default(void) -{ - char_u *p; - - if (STRCMP(T_NAME, "linux") == 0 - || STRCMP(T_NAME, "screen.linux") == 0 - || STRCMP(T_NAME, "cygwin") == 0 - || STRCMP(T_NAME, "putty") == 0 - || ((p = (char_u *)os_getenv("COLORFGBG")) != NULL - && (p = vim_strrchr(p, ';')) != NULL - && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8') - && p[2] == NUL)) - return (char_u *)"dark"; - return (char_u *)"light"; -} - -/* * Initialize the options, part three: After reading the .vimrc */ void set_init_3(void) @@ -2435,7 +2311,6 @@ void set_helplang_default(char_u *lang) void set_title_defaults(void) { int idx1; - int val; /* * If GUI is (going to be) used, we can always set the window title and @@ -2444,15 +2319,13 @@ void set_title_defaults(void) */ idx1 = findoption((char_u *)"title"); if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET)) { - val = mch_can_restore_title(); - options[idx1].def_val[VI_DEFAULT] = (char_u *)(intptr_t)val; - p_title = val; + options[idx1].def_val[VI_DEFAULT] = (char_u *)(intptr_t)0; + p_title = 0; } idx1 = findoption((char_u *)"icon"); if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET)) { - val = mch_can_restore_icon(); - options[idx1].def_val[VI_DEFAULT] = (char_u *)(intptr_t)val; - p_icon = val; + options[idx1].def_val[VI_DEFAULT] = (char_u *)(intptr_t)0; + p_icon = 0; } } @@ -2495,7 +2368,6 @@ do_set ( int prepending; /* "opt^=arg" */ int removing; /* "opt-=arg" */ int cp_val = 0; - char_u key_name[2]; if (*arg == NUL) { showoptions(0, opt_flags); @@ -2524,8 +2396,6 @@ do_set ( } } else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE)) { - showoptions(2, opt_flags); - show_termcodes(); did_show = TRUE; arg += 7; } else { @@ -2622,13 +2492,6 @@ do_set ( varp = get_varp_scope(&(options[opt_idx]), opt_flags); } else { flags = P_STRING; - if (key < 0) { - key_name[0] = (char_u)KEY2TERMCAP0(key); - key_name[1] = KEY2TERMCAP1(key); - } else { - key_name[0] = KS_KEY; - key_name[1] = (char_u)(key & 0xff); - } } /* Skip all options that are not window-local (used when showing @@ -2716,14 +2579,8 @@ do_set ( (int)options[opt_idx].indir & PV_MASK]); } } else { - char_u *p; - - p = find_termcode(key_name); - if (p == NULL) { - errmsg = (char_u *)N_("E846: Key code not set"); - goto skip; - } else - (void)show_one_termcode(key_name, p, TRUE); + errmsg = (char_u *)N_("E846: Key code not set"); + goto skip; } if (nextchar != '?' && nextchar != NUL && !vim_iswhite(afterchar)) @@ -2867,11 +2724,6 @@ do_set ( newval = options[opt_idx].def_val[ ((flags & P_VI_DEF) || cp_val) ? VI_DEFAULT : VIM_DEFAULT]; - if ((char_u **)varp == &p_bg) { - /* guess the value of 'background' */ - newval = term_bg_default(); - } - /* expand environment variables and ~ (since the * default value was already expanded, only * required when an environment variable was set @@ -3126,25 +2978,9 @@ do_set ( /* If error detected, print the error message. */ if (errmsg != NULL) goto skip; - } else { /* key code option */ - char_u *p; - - if (nextchar == '&') { - if (add_termcap_entry(key_name, TRUE) == FAIL) - errmsg = (char_u *)N_("E522: Not found in termcap"); - } else { - ++arg; /* jump to after the '=' or ':' */ - for (p = arg; *p && !vim_iswhite(*p); ++p) - if (*p == '\\' && p[1] != NUL) - ++p; - nextchar = *p; - *p = NUL; - add_termcode(key_name, arg, FALSE); - *p = nextchar; - } - if (full_screen) - ttest(FALSE); - redraw_all_later(CLEAR); + } else { + // key code option(FIXME(tarruda): Show a warning or something + // similar) } } @@ -3199,8 +3035,8 @@ theend: silent_mode = FALSE; info_message = TRUE; /* use mch_msg(), not mch_errmsg() */ msg_putchar('\n'); - cursor_on(); /* msg_start() switches it off */ - out_flush(); + ui_cursor_on(); /* msg_start() switches it off */ + ui_flush(); silent_mode = TRUE; info_message = FALSE; /* use mch_msg(), not mch_errmsg() */ } @@ -3279,7 +3115,7 @@ static char_u *check_cedit(void) /* * When changing 'title', 'titlestring', 'icon' or 'iconstring', call * maketitle() to create and display it. - * When switching the title or icon off, call mch_restore_title() to get + * When switching the title or icon off, call ui_set_{icon,title}(NULL) to get * the old value back. */ static void @@ -3287,15 +3123,16 @@ did_set_title ( int icon /* Did set icon instead of title */ ) { - if (starting != NO_SCREEN - ) { + if (starting != NO_SCREEN) { maketitle(); if (icon) { - if (!p_icon) - mch_restore_title(2); + if (!p_icon) { + ui_set_icon(NULL); + } } else { - if (!p_title) - mch_restore_title(1); + if (!p_title) { + ui_set_title(NULL); + } } } } @@ -3549,21 +3386,6 @@ static void check_string_option(char_u **pp) } /* - * Mark a terminal option as allocated, found by a pointer into term_strings[]. - */ -void set_term_option_alloced(char_u **p) -{ - int opt_idx; - - for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++) - if (options[opt_idx].var == (char_u *)p) { - options[opt_idx].flags |= P_ALLOCED; - return; - } - return; /* cannot happen: didn't find it! */ -} - -/* * Return TRUE when option "opt" was set from a modeline or in secure mode. * Return FALSE when it wasn't. * Return -1 for an unknown option. @@ -3765,16 +3587,6 @@ did_set_string_option ( && vim_strpbrk(*varp, (char_u *)"/\\*?[|<>") != NULL) { errmsg = e_invarg; } - /* 'term' */ - else if (varp == &T_NAME) { - if (T_NAME[0] == NUL) - errmsg = (char_u *)N_("E529: Cannot set 'term' to empty string"); - else if (set_termname(T_NAME) == FAIL) - errmsg = (char_u *)N_("E522: Not found in termcap"); - else - /* Screen colors may have changed. */ - redraw_later_clear(); - } /* 'backupcopy' */ else if (gvarp == &p_bkc) { char_u *bkc = p_bkc; @@ -4155,32 +3967,6 @@ did_set_string_option ( if (*p_viminfo && errmsg == NULL && get_viminfo_parameter('\'') < 0) errmsg = (char_u *)N_("E528: Must specify a ' value"); } - /* terminal options */ - else if (istermoption(&options[opt_idx]) && full_screen) { - /* ":set t_Co=0" and ":set t_Co=1" do ":set t_Co=" */ - if (varp == &T_CCO) { - int colors = atoi((char *)T_CCO); - - /* Only reinitialize colors if t_Co value has really changed to - * avoid expensive reload of colorscheme if t_Co is set to the - * same value multiple times. */ - if (colors != t_colors) { - t_colors = colors; - if (t_colors <= 1) { - if (new_value_alloced) - free(T_CCO); - T_CCO = empty_option; - } - /* We now have a different color setup, initialize it again. */ - init_highlight(TRUE, FALSE); - } - } - ttest(FALSE); - if (varp == &T_ME) { - out_str(T_ME); - redraw_later(CLEAR); - } - } /* 'showbreak' */ else if (varp == &p_sbr) { for (s = p_sbr; *s; ) { @@ -4595,10 +4381,11 @@ did_set_string_option ( } if (varp == &p_mouse) { - if (*p_mouse == NUL) - mch_setmouse(FALSE); /* switch mouse off */ - else - setmouse(); /* in case 'mouse' changed */ + if (*p_mouse == NUL) { + ui_mouse_off(); + } else { + setmouse(); // in case 'mouse' changed + } } if (curwin->w_curswant != MAXCOL @@ -5104,16 +4891,6 @@ set_bool_option ( } else if ((int *)varp == &p_ea) { if (p_ea && !old_value) win_equal(curwin, FALSE, 0); - } else if ((int *)varp == &p_wiv) { - /* - * When 'weirdinvert' changed, set/reset 't_xs'. - * Then set 'weirdinvert' according to value of 't_xs'. - */ - if (p_wiv && !old_value) - T_XS = (char_u *)"y"; - else if (!p_wiv && old_value) - T_XS = empty_option; - p_wiv = (*T_XS != NUL); } else if ((int *)varp == &p_acd) { /* Change directories when the 'acd' option is set now. */ do_autochdir(); @@ -5712,6 +5489,64 @@ static int findoption(char_u *arg) return opt_idx; } +bool is_tty_option(char *name) +{ + return (name[0] == 't' && name[1] == '_') || !strcmp((char *)name, "term"); +} + +#define TCO_BUFFER_SIZE 8 +bool get_tty_option(char *name, char **value) +{ + if (!strcmp(name, "t_Co")) { + if (value) { + if (t_colors <= 1) { + *value = xstrdup(""); + } else { + *value = xmalloc(TCO_BUFFER_SIZE); + snprintf(*value, TCO_BUFFER_SIZE, "%d", t_colors); + } + } + return true; + } + + if (!strcmp(name, "term") || !strcmp(name, "ttytype")) { + if (value) { + *value = xstrdup("nvim"); + } + return true; + } + + if (is_tty_option(name)) { + if (value) { + *value = xstrdup(""); + } + return true; + } + + return false; +} + +bool set_tty_option(char *name, char *value) +{ + if (!strcmp(name, "t_Co")) { + int colors = atoi(value); + + // Only reinitialize colors if t_Co value has really changed to + // avoid expensive reload of colorscheme if t_Co is set to the + // same value multiple times + if (colors != t_colors) { + t_colors = colors; + // We now have a different color setup, initialize it again. + init_highlight(TRUE, FALSE); + } + + return true; + } + + return is_tty_option(name) || !strcmp(name, "term") + || !strcmp(name, "ttytype"); +} + /* * Get the value for an option. * @@ -5730,6 +5565,10 @@ get_option_value ( int opt_flags ) { + if (get_tty_option((char *)name, (char **)stringval)) { + return 0; + } + int opt_idx; char_u *varp; @@ -5785,6 +5624,10 @@ int get_option_value_strict(char *name, int opt_type, void *from) { + if (get_tty_option(name, stringval)) { + return SOPT_STRING | SOPT_GLOBAL; + } + char_u *varp = NULL; vimoption_T *p; int rv = 0; @@ -5896,6 +5739,10 @@ set_option_value ( int opt_flags /* OPT_LOCAL or 0 (both) */ ) { + if (set_tty_option((char *)name, (char *)string)) { + return NULL; + } + int opt_idx; char_u *varp; @@ -5992,7 +5839,6 @@ static int find_key_option(char_u *arg) /* * if 'all' == 0: show changed options * if 'all' == 1: show all normal options - * if 'all' == 2: show all terminal options */ static void showoptions ( @@ -6002,7 +5848,6 @@ showoptions ( { vimoption_T *p; int col; - int isterm; char_u *varp; int item_count; int run; @@ -6038,16 +5883,13 @@ showoptions ( item_count = 0; for (p = &options[0]; p->fullname != NULL; p++) { varp = NULL; - isterm = istermoption(p); if (opt_flags != 0) { - if (p->indir != PV_NONE && !isterm) + if (p->indir != PV_NONE) varp = get_varp_scope(p, opt_flags); } else varp = get_varp(p); if (varp != NULL - && ((all == 2 && isterm) - || (all == 1 && !isterm) - || (all == 0 && !optval_default(p, varp)))) { + && (all == 1 || (all == 0 && !optval_default(p, varp)))) { if (p->flags & P_BOOL) len = 1; /* a toggle option fits always */ else { @@ -6084,7 +5926,7 @@ showoptions ( showoneopt(items[i], opt_flags); col += INC; } - out_flush(); + ui_flush(); os_breakcheck(); } } @@ -6189,7 +6031,7 @@ int makeset(FILE *fd, int opt_flags, int local_only) * P_PRI_MKRC flag and once without. */ for (pri = 1; pri >= 0; --pri) { - for (p = &options[0]; !istermoption(p); p++) + for (p = &options[0]; p->fullname; p++) if (!(p->flags & P_NO_MKRC) && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0))) { /* skip global option when only doing locals */ @@ -6355,91 +6197,6 @@ static int put_setbool(FILE *fd, char *cmd, char *name, int value) } /* - * Clear all the terminal options. - * If the option has been allocated, free the memory. - * Terminal options are never hidden or indirect. - */ -void clear_termoptions(void) -{ - /* - * Reset a few things before clearing the old options. This may cause - * outputting a few things that the terminal doesn't understand, but the - * screen will be cleared later, so this is OK. - */ - mch_setmouse(FALSE); /* switch mouse off */ - mch_restore_title(3); /* restore window titles */ - - free_termoptions(); -} - -void free_termoptions(void) -{ - vimoption_T *p; - - for (p = &options[0]; p->fullname != NULL; p++) - if (istermoption(p)) { - if (p->flags & P_ALLOCED) - free_string_option(*(char_u **)(p->var)); - if (p->flags & P_DEF_ALLOCED) - free_string_option(p->def_val[VI_DEFAULT]); - *(char_u **)(p->var) = empty_option; - p->def_val[VI_DEFAULT] = empty_option; - p->flags &= ~(P_ALLOCED|P_DEF_ALLOCED); - } - clear_termcodes(); -} - -/* - * Free the string for one term option, if it was allocated. - * Set the string to empty_option and clear allocated flag. - * "var" points to the option value. - */ -void free_one_termoption(char_u *var) -{ - vimoption_T *p; - - for (p = &options[0]; p->fullname != NULL; p++) - if (p->var == var) { - if (p->flags & P_ALLOCED) - free_string_option(*(char_u **)(p->var)); - *(char_u **)(p->var) = empty_option; - p->flags &= ~P_ALLOCED; - break; - } -} - -/* - * Set the terminal option defaults to the current value. - * Used after setting the terminal name. - */ -void set_term_defaults(void) -{ - vimoption_T *p; - - for (p = &options[0]; p->fullname != NULL; p++) { - if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var)) { - if (p->flags & P_DEF_ALLOCED) { - free_string_option(p->def_val[VI_DEFAULT]); - p->flags &= ~P_DEF_ALLOCED; - } - p->def_val[VI_DEFAULT] = *(char_u **)(p->var); - if (p->flags & P_ALLOCED) { - p->flags |= P_DEF_ALLOCED; - p->flags &= ~P_ALLOCED; /* don't free the value now */ - } - } - } -} - -/* - * return TRUE if 'p' starts with 't_' - */ -static int istermoption(vimoption_T *p) -{ - return p->fullname[0] == 't' && p->fullname[1] == '_'; -} - -/* * Compute columns for ruler and shown command. 'sc_col' is also used to * decide what the maximum length of a message on the status line can be. * If there is a status line for the last window, 'sc_col' is independent @@ -7229,14 +6986,11 @@ set_context_in_set_cmd ( int ExpandSettings(expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***file) { - int num_normal = 0; /* Nr of matching non-term-code settings */ - int num_term = 0; /* Nr of matching terminal code settings */ + int num_normal = 0; // Nr of matching non-term-code settings int match; int count = 0; char_u *str; int loop; - int is_term_opt; - char_u name_buf[MAX_KEY_NAME_LEN]; static char *(names[]) = {"all", "termcap"}; int ic = regmatch->rm_ic; /* remember the ignore-case flag */ @@ -7263,99 +7017,28 @@ int ExpandSettings(expand_T *xp, regmatch_T *regmatch, int *num_file, char_u *** if (xp->xp_context == EXPAND_BOOL_SETTINGS && !(options[opt_idx].flags & P_BOOL)) continue; - is_term_opt = istermoption(&options[opt_idx]); - if (is_term_opt && num_normal > 0) - continue; match = FALSE; if (vim_regexec(regmatch, str, (colnr_T)0) || (options[opt_idx].shortname != NULL && vim_regexec(regmatch, - (char_u *)options[opt_idx].shortname, (colnr_T)0))) + (char_u *)options[opt_idx].shortname, (colnr_T)0))){ match = TRUE; - else if (is_term_opt) { - name_buf[0] = '<'; - name_buf[1] = 't'; - name_buf[2] = '_'; - name_buf[3] = str[2]; - name_buf[4] = str[3]; - name_buf[5] = '>'; - name_buf[6] = NUL; - if (vim_regexec(regmatch, name_buf, (colnr_T)0)) { - match = TRUE; - str = name_buf; - } } + if (match) { if (loop == 0) { - if (is_term_opt) - num_term++; - else - num_normal++; + num_normal++; } else (*file)[count++] = vim_strsave(str); } } - /* - * Check terminal key codes, these are not in the option table - */ - if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0) { - for (size_t opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++) { - if (!isprint(str[0]) || !isprint(str[1])) - continue; - - name_buf[0] = 't'; - name_buf[1] = '_'; - name_buf[2] = str[0]; - name_buf[3] = str[1]; - name_buf[4] = NUL; - match = FALSE; - if (vim_regexec(regmatch, name_buf, (colnr_T)0)) - match = TRUE; - else { - name_buf[0] = '<'; - name_buf[1] = 't'; - name_buf[2] = '_'; - name_buf[3] = str[0]; - name_buf[4] = str[1]; - name_buf[5] = '>'; - name_buf[6] = NUL; - - if (vim_regexec(regmatch, name_buf, (colnr_T)0)) - match = TRUE; - } - if (match) { - if (loop == 0) - num_term++; - else - (*file)[count++] = vim_strsave(name_buf); - } - } - - /* - * Check special key names. - */ - regmatch->rm_ic = TRUE; /* ignore case here */ - for (size_t opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++) { - name_buf[0] = '<'; - STRCPY(name_buf + 1, str); - STRCAT(name_buf, ">"); - - if (vim_regexec(regmatch, name_buf, (colnr_T)0)) { - if (loop == 0) - num_term++; - else - (*file)[count++] = vim_strsave(name_buf); - } - } - } if (loop == 0) { - if (num_normal > 0) + if (num_normal > 0) { *num_file = num_normal; - else if (num_term > 0) - *num_file = num_term; - else + } else { return OK; + } *file = (char_u **)xmalloc((size_t)(*num_file) * sizeof(char_u *)); } } @@ -7373,9 +7056,7 @@ void ExpandOldSetting(int *num_file, char_u ***file) * For a terminal key code expand_option_idx is < 0. */ if (expand_option_idx < 0) { - var = find_termcode(expand_option_name + 2); - if (var == NULL) - expand_option_idx = findoption(expand_option_name); + expand_option_idx = findoption(expand_option_name); } if (expand_option_idx >= 0) { |