diff options
Diffstat (limited to 'src/nvim/option.c')
-rw-r--r-- | src/nvim/option.c | 89 |
1 files changed, 73 insertions, 16 deletions
diff --git a/src/nvim/option.c b/src/nvim/option.c index 3ccc67eb14..e48ed201e8 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -133,6 +133,7 @@ static char_u *p_cms; static char_u *p_cpt; static char_u *p_cfu; static char_u *p_ofu; +static char_u *p_tfu; static int p_eol; static int p_fixeol; static int p_et; @@ -2183,6 +2184,7 @@ static void didset_options(void) (void)opt_strings_flags(p_tc, p_tc_values, &tc_flags, false); (void)opt_strings_flags(p_ve, p_ve_values, &ve_flags, true); (void)opt_strings_flags(p_wop, p_wop_values, &wop_flags, true); + (void)opt_strings_flags(p_jop, p_jop_values, &jop_flags, true); (void)spell_check_msm(); (void)spell_check_sps(); (void)compile_cap_prog(curwin->w_s); @@ -2204,10 +2206,10 @@ static void didset_options2(void) (void)opt_strings_flags(p_cb, p_cb_values, &cb_flags, true); // Parse default for 'fillchars'. - (void)set_chars_option(curwin, &curwin->w_p_fcs); + (void)set_chars_option(curwin, &curwin->w_p_fcs, true); // Parse default for 'listchars'. - (void)set_chars_option(curwin, &curwin->w_p_lcs); + (void)set_chars_option(curwin, &curwin->w_p_lcs, true); // Parse default for 'wildmode'. check_opt_wim(); @@ -2273,6 +2275,7 @@ void check_buf_options(buf_T *buf) check_string_option(&buf->b_p_ep); check_string_option(&buf->b_p_path); check_string_option(&buf->b_p_tags); + check_string_option(&buf->b_p_tfu); check_string_option(&buf->b_p_tc); check_string_option(&buf->b_p_dict); check_string_option(&buf->b_p_tsr); @@ -2630,6 +2633,10 @@ did_set_string_option( if (strcmp((char *)(*varp), HIGHLIGHT_INIT) != 0) { errmsg = e_unsupportedoption; } + } else if (varp == &p_jop) { // 'jumpoptions' + if (opt_strings_flags(p_jop, p_jop_values, &jop_flags, true) != OK) { + errmsg = e_invarg; + } } else if (gvarp == &p_nf) { // 'nrformats' if (check_opt_strings(*varp, p_nf_values, true) != OK) { errmsg = e_invarg; @@ -2661,11 +2668,11 @@ did_set_string_option( errmsg = e_invarg; } else { FOR_ALL_TAB_WINDOWS(tp, wp) { - if (set_chars_option(wp, &wp->w_p_lcs) != NULL) { + if (set_chars_option(wp, &wp->w_p_lcs, true) != NULL) { errmsg = (char_u *)_("E834: Conflicts with value of 'listchars'"); goto ambw_end; } - if (set_chars_option(wp, &wp->w_p_fcs) != NULL) { + if (set_chars_option(wp, &wp->w_p_fcs, true) != NULL) { errmsg = (char_u *)_("E835: Conflicts with value of 'fillchars'"); goto ambw_end; } @@ -2866,10 +2873,26 @@ ambw_end: } s = skip_to_option_part(s); } - } else if (varp == &curwin->w_p_lcs) { // 'listchars' - errmsg = set_chars_option(curwin, varp); - } else if (varp == &curwin->w_p_fcs) { // 'fillchars' - errmsg = set_chars_option(curwin, varp); + } else if (varp == &p_lcs) { // 'listchars' + errmsg = set_chars_option(curwin, varp, false); + if (!errmsg) { + FOR_ALL_TAB_WINDOWS(tp, wp) { + set_chars_option(wp, &wp->w_p_lcs, true); + } + } + redraw_all_later(NOT_VALID); + } else if (varp == &curwin->w_p_lcs) { // local 'listchars' + errmsg = set_chars_option(curwin, varp, true); + } else if (varp == &p_fcs) { // 'fillchars' + errmsg = set_chars_option(curwin, varp, false); + if (!errmsg) { + FOR_ALL_TAB_WINDOWS(tp, wp) { + set_chars_option(wp, &wp->w_p_fcs, true); + } + } + redraw_all_later(NOT_VALID); + } else if (varp == &curwin->w_p_fcs) { // local 'fillchars' + errmsg = set_chars_option(curwin, varp, true); } else if (varp == &p_cedit) { // 'cedit' errmsg = check_cedit(); } else if (varp == &p_vfile) { // 'verbosefile' @@ -3499,7 +3522,7 @@ skip: /// /// @param varp either &curwin->w_p_lcs or &curwin->w_p_fcs /// @return error message, NULL if it's OK. -static char_u *set_chars_option(win_T *wp, char_u **varp) +static char_u *set_chars_option(win_T *wp, char_u **varp, bool set) { int round, i, len, entries; char_u *p, *s; @@ -3534,12 +3557,18 @@ static char_u *set_chars_option(win_T *wp, char_u **varp) { &wp->w_p_lcs_chars.conceal, "conceal", NUL }, }; - if (varp == &wp->w_p_lcs) { + if (varp == &p_lcs || varp == &wp->w_p_lcs) { tab = lcs_tab; entries = ARRAY_SIZE(lcs_tab); + if (varp == &wp->w_p_lcs && wp->w_p_lcs[0] == NUL) { + varp = &p_lcs; + } } else { tab = fcs_tab; entries = ARRAY_SIZE(fcs_tab); + if (varp == &wp->w_p_fcs && wp->w_p_fcs[0] == NUL) { + varp = &p_fcs; + } if (*p_ambw == 'd') { // XXX: If ambiwidth=double then "|" and "ยท" take 2 columns, which is // forbidden (TUI limitation?). Set old defaults. @@ -3552,7 +3581,7 @@ static char_u *set_chars_option(win_T *wp, char_u **varp) } // first round: check for valid value, second round: assign values - for (round = 0; round <= 1; round++) { + for (round = 0; round <= set ? 1 : 0; round++) { if (round > 0) { // After checking that the value is valid: set defaults for (i = 0; i < entries; i++) { @@ -3560,7 +3589,7 @@ static char_u *set_chars_option(win_T *wp, char_u **varp) *(tab[i].cp) = tab[i].def; } } - if (varp == &wp->w_p_lcs) { + if (varp == &p_lcs || varp == &wp->w_p_lcs) { wp->w_p_lcs_chars.tab1 = NUL; wp->w_p_lcs_chars.tab3 = NUL; } @@ -4306,6 +4335,10 @@ static char *set_num_option(int opt_idx, char_u *varp, long value, if (value < 0) { errmsg = e_positive; } + } else if (pp == &p_wd) { + if (value < 0) { + errmsg = e_positive; + } } // Don't change the value and return early if validation failed. @@ -5167,6 +5200,13 @@ void ui_refresh_options(void) } ui_call_option_set(name, value); } + if (p_mouse != NULL) { + if (*p_mouse == NUL) { + ui_call_mouse_off(); + } else { + setmouse(); + } + } } /* @@ -5556,6 +5596,16 @@ void unset_global_local_option(char *name, void *from) case PV_MENC: clear_string_option(&buf->b_p_menc); break; + case PV_LCS: + clear_string_option(&((win_T *)from)->w_p_lcs); + set_chars_option((win_T *)from, &((win_T *)from)->w_p_lcs, true); + redraw_win_later((win_T *)from, NOT_VALID); + break; + case PV_FCS: + clear_string_option(&((win_T *)from)->w_p_fcs); + set_chars_option((win_T *)from, &((win_T *)from)->w_p_fcs, true); + redraw_win_later((win_T *)from, NOT_VALID); + break; } } @@ -5586,11 +5636,14 @@ static char_u *get_varp_scope(vimoption_T *p, int opt_flags) case PV_INC: return (char_u *)&(curbuf->b_p_inc); case PV_DICT: return (char_u *)&(curbuf->b_p_dict); case PV_TSR: return (char_u *)&(curbuf->b_p_tsr); + case PV_TFU: return (char_u *)&(curbuf->b_p_tfu); case PV_STL: return (char_u *)&(curwin->w_p_stl); case PV_UL: return (char_u *)&(curbuf->b_p_ul); case PV_LW: return (char_u *)&(curbuf->b_p_lw); case PV_BKC: return (char_u *)&(curbuf->b_p_bkc); case PV_MENC: return (char_u *)&(curbuf->b_p_menc); + case PV_FCS: return (char_u *)&(curwin->w_p_fcs); + case PV_LCS: return (char_u *)&(curwin->w_p_lcs); } return NULL; // "cannot happen" } @@ -5649,6 +5702,10 @@ static char_u *get_varp(vimoption_T *p) ? (char_u *)&(curbuf->b_p_lw) : p->var; case PV_MENC: return *curbuf->b_p_menc != NUL ? (char_u *)&(curbuf->b_p_menc) : p->var; + case PV_FCS: return *curwin->w_p_fcs != NUL + ? (char_u *)&(curwin->w_p_fcs) : p->var; + case PV_LCS: return *curwin->w_p_lcs != NUL + ? (char_u *)&(curwin->w_p_lcs) : p->var; case PV_ARAB: return (char_u *)&(curwin->w_p_arab); case PV_LIST: return (char_u *)&(curwin->w_p_list); @@ -5738,6 +5795,7 @@ static char_u *get_varp(vimoption_T *p) case PV_SPF: return (char_u *)&(curwin->w_s->b_p_spf); case PV_SPL: return (char_u *)&(curwin->w_s->b_p_spl); case PV_SW: return (char_u *)&(curbuf->b_p_sw); + case PV_TFU: return (char_u *)&(curbuf->b_p_tfu); case PV_TS: return (char_u *)&(curbuf->b_p_ts); case PV_TW: return (char_u *)&(curbuf->b_p_tw); case PV_UDF: return (char_u *)&(curbuf->b_p_udf); @@ -5745,8 +5803,6 @@ static char_u *get_varp(vimoption_T *p) case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap); case PV_SCL: return (char_u *)&(curwin->w_p_scl); case PV_WINHL: return (char_u *)&(curwin->w_p_winhl); - case PV_FCS: return (char_u *)&(curwin->w_p_fcs); - case PV_LCS: return (char_u *)&(curwin->w_p_lcs); case PV_WINBL: return (char_u *)&(curwin->w_p_winbl); default: IEMSG(_("E356: get_varp ERROR")); } @@ -5888,8 +5944,8 @@ void didset_window_options(win_T *wp) { check_colorcolumn(wp); briopt_check(wp); - set_chars_option(wp, &wp->w_p_fcs); - set_chars_option(wp, &wp->w_p_lcs); + set_chars_option(wp, &wp->w_p_fcs, true); + set_chars_option(wp, &wp->w_p_lcs, true); parse_winhl_opt(wp); // sets w_hl_needs_update also for w_p_winbl wp->w_grid.blending = wp->w_p_winbl > 0; } @@ -6000,6 +6056,7 @@ void buf_copy_options(buf_T *buf, int flags) buf->b_p_cpt = vim_strsave(p_cpt); buf->b_p_cfu = vim_strsave(p_cfu); buf->b_p_ofu = vim_strsave(p_ofu); + buf->b_p_tfu = vim_strsave(p_tfu); buf->b_p_sts = p_sts; buf->b_p_sts_nopaste = p_sts_nopaste; buf->b_p_com = vim_strsave(p_com); |