summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2006-02-22 21:25:37 +0000
committerBram Moolenaar <Bram@vim.org>2006-02-22 21:25:37 +0000
commitd1f56e68f1315687ff5b913e2577f11b0b620573 (patch)
treeadbac0a00c07ee933058543eb3f251a83e707624 /src
parent238a564935abe36832b267f32b5487556c640d00 (diff)
downloadvim-git-d1f56e68f1315687ff5b913e2577f11b0b620573.tar.gz
updated for version 7.0204v7.0204
Diffstat (limited to 'src')
-rw-r--r--src/buffer.c72
-rw-r--r--src/diff.c6
-rw-r--r--src/edit.c151
-rw-r--r--src/eval.c8
-rw-r--r--src/ex_cmds.c6
-rw-r--r--src/ex_cmds2.c10
-rw-r--r--src/ex_docmd.c2
-rw-r--r--src/fileio.c10
-rw-r--r--src/fold.c2
-rw-r--r--src/globals.h9
-rw-r--r--src/gui.c3
-rw-r--r--src/gui_beval.c2
-rw-r--r--src/hardcopy.c4
-rw-r--r--src/main.c5
-rw-r--r--src/mbyte.c5
-rw-r--r--src/misc1.c3
-rw-r--r--src/misc2.c5
-rw-r--r--src/normal.c53
-rw-r--r--src/ops.c5
-rw-r--r--src/option.c93
-rw-r--r--src/option.h2
-rw-r--r--src/proto/buffer.pro2
-rw-r--r--src/proto/edit.pro4
-rw-r--r--src/proto/option.pro3
-rw-r--r--src/proto/window.pro6
-rw-r--r--src/quickfix.c5
-rw-r--r--src/screen.c105
-rw-r--r--src/search.c4
-rw-r--r--src/structs.h12
-rw-r--r--src/term.c6
-rw-r--r--src/version.h4
-rw-r--r--src/vim.h1
-rw-r--r--src/window.c54
33 files changed, 514 insertions, 148 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 12ee1b3b5..101d33f83 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -3018,12 +3018,12 @@ maketitle()
int use_sandbox = FALSE;
# ifdef FEAT_EVAL
- use_sandbox = was_set_insecurely((char_u *)"titlestring");
+ use_sandbox = was_set_insecurely((char_u *)"titlestring", 0);
# endif
if (stl_syntax & STL_IN_TITLE)
build_stl_str_hl(curwin, t_str, sizeof(buf),
p_titlestring, use_sandbox,
- 0, maxlen, NULL);
+ 0, maxlen, NULL, NULL);
else
#endif
t_str = p_titlestring;
@@ -3115,12 +3115,12 @@ maketitle()
int use_sandbox = FALSE;
# ifdef FEAT_EVAL
- use_sandbox = was_set_insecurely((char_u *)"iconstring");
+ use_sandbox = was_set_insecurely((char_u *)"iconstring", 0);
# endif
if (stl_syntax & STL_IN_ICON)
build_stl_str_hl(curwin, i_str, sizeof(buf),
p_iconstring, use_sandbox,
- 0, 0, NULL);
+ 0, 0, NULL, NULL);
else
#endif
i_str = p_iconstring;
@@ -3213,7 +3213,7 @@ free_titles()
* or truncated if too long, fillchar is used for all whitespace.
*/
int
-build_stl_str_hl(wp, out, outlen, fmt, use_sandbox, fillchar, maxwidth, hl)
+build_stl_str_hl(wp, out, outlen, fmt, use_sandbox, fillchar, maxwidth, hltab, tabtab)
win_T *wp;
char_u *out; /* buffer to write into */
size_t outlen; /* length of out[] */
@@ -3221,7 +3221,8 @@ build_stl_str_hl(wp, out, outlen, fmt, use_sandbox, fillchar, maxwidth, hl)
int use_sandbox; /* "fmt" was set insecurely, use sandbox */
int fillchar;
int maxwidth;
- struct stl_hlrec *hl;
+ struct stl_hlrec *hltab; /* return: HL attributes (can be NULL) */
+ struct stl_hlrec *tabtab; /* return: tab page nrs (can be NULL) */
{
char_u *p;
char_u *s;
@@ -3258,6 +3259,7 @@ build_stl_str_hl(wp, out, outlen, fmt, use_sandbox, fillchar, maxwidth, hl)
Group,
Middle,
Highlight,
+ TabPage,
Trunc
} type;
} item[STL_MAX_ITEM];
@@ -3269,6 +3271,7 @@ build_stl_str_hl(wp, out, outlen, fmt, use_sandbox, fillchar, maxwidth, hl)
#define TMPLEN 70
char_u tmp[TMPLEN];
char_u *usefmt = fmt;
+ struct stl_hlrec *sp;
#ifdef FEAT_EVAL
/*
@@ -3452,6 +3455,32 @@ build_stl_str_hl(wp, out, outlen, fmt, use_sandbox, fillchar, maxwidth, hl)
curitem++;
continue;
}
+ if (*s == STL_TABPAGENR || *s == STL_TABCLOSENR)
+ {
+ if (*s == STL_TABCLOSENR)
+ {
+ if (minwid == 0)
+ {
+ /* %X ends the close label, go back to the previously
+ * define tab label nr. */
+ for (n = curitem - 1; n >= 0; --n)
+ if (item[n].type == TabPage && item[n].minwid >= 0)
+ {
+ minwid = item[n].minwid;
+ break;
+ }
+ }
+ else
+ /* close nrs are stored as negative values */
+ minwid = - minwid;
+ }
+ item[curitem].type = TabPage;
+ item[curitem].start = p;
+ item[curitem].minwid = minwid;
+ s++;
+ curitem++;
+ continue;
+ }
if (*s == '.')
{
s++;
@@ -3953,19 +3982,38 @@ build_stl_str_hl(wp, out, outlen, fmt, use_sandbox, fillchar, maxwidth, hl)
}
}
- if (hl != NULL)
+ /* Store the info about highlighting. */
+ if (hltab != NULL)
{
+ sp = hltab;
for (l = 0; l < itemcnt; l++)
{
if (item[l].type == Highlight)
{
- hl->start = item[l].start;
- hl->userhl = item[l].minwid;
- hl++;
+ sp->start = item[l].start;
+ sp->userhl = item[l].minwid;
+ sp++;
+ }
+ }
+ sp->start = NULL;
+ sp->userhl = 0;
+ }
+
+ /* Store the info about tab pages labels. */
+ if (tabtab != NULL)
+ {
+ sp = tabtab;
+ for (l = 0; l < itemcnt; l++)
+ {
+ if (item[l].type == TabPage)
+ {
+ sp->start = item[l].start;
+ sp->userhl = item[l].minwid;
+ sp++;
}
}
- hl->start = NULL;
- hl->userhl = 0;
+ sp->start = NULL;
+ sp->userhl = 0;
}
return width;
diff --git a/src/diff.c b/src/diff.c
index 7170835d4..b28e127cc 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -1078,6 +1078,9 @@ diff_win_options(wp, addbuf)
curbuf = curwin->w_buffer;
set_string_option_direct((char_u *)"fdm", -1, (char_u *)"diff",
OPT_LOCAL|OPT_FREE);
+# ifdef FEAT_EVAL
+ set_option_scriptID((char_u *)"fdm", current_SID);
+# endif
curwin = old_curwin;
curbuf = curwin->w_buffer;
wp->w_p_fdc = 2;
@@ -1125,6 +1128,9 @@ ex_diffoff(eap)
curbuf = curwin->w_buffer;
set_string_option_direct((char_u *)"fdm", -1,
(char_u *)"manual", OPT_LOCAL|OPT_FREE);
+# ifdef FEAT_EVAL
+ set_option_scriptID((char_u *)"fdm", current_SID);
+# endif
curwin = old_curwin;
curbuf = curwin->w_buffer;
wp->w_p_fdc = 0;
diff --git a/src/edit.c b/src/edit.c
index b57b56707..d159911bb 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -62,12 +62,13 @@ static char_u e_hitend[] = N_("Hit end of paragraph");
/*
* Structure used to store one match for insert completion.
*/
-typedef struct Completion compl_T;
-struct Completion
+typedef struct compl_S compl_T;
+struct compl_S
{
compl_T *cp_next;
compl_T *cp_prev;
char_u *cp_str; /* matched text */
+ char cp_icase; /* TRUE or FALSE: ignore case */
char_u *cp_extra; /* extra menu text (allocated, can be NULL) */
char_u *cp_info; /* verbose info (can be NULL) */
char_u cp_kind; /* kind of match, single letter, or NUL */
@@ -121,8 +122,9 @@ static expand_T compl_xp;
static void ins_ctrl_x __ARGS((void));
static int has_compl_option __ARGS((int dict_opt));
+static int ins_compl_equal __ARGS((compl_T *match, char_u *str, int len));
static void ins_compl_longest_match __ARGS((compl_T *match));
-static void ins_compl_add_matches __ARGS((int num_matches, char_u **matches));
+static void ins_compl_add_matches __ARGS((int num_matches, char_u **matches, int icase));
static int ins_compl_make_cyclic __ARGS((void));
static void ins_compl_upd_pum __ARGS((void));
static void ins_compl_del_pum __ARGS((void));
@@ -144,6 +146,7 @@ static int ins_compl_next __ARGS((int allow_get_expansion, int count, int inser
static int ins_compl_key2dir __ARGS((int c));
static int ins_compl_pum_key __ARGS((int c));
static int ins_compl_key2count __ARGS((int c));
+static int ins_compl_use_match __ARGS((int c));
static int ins_complete __ARGS((int c));
static int quote_meta __ARGS((char_u *dest, char_u *str, int len));
#endif /* FEAT_INS_EXPAND */
@@ -1982,9 +1985,10 @@ vim_is_ctrl_x_key(c)
* TODO: make this work for multi-byte characters.
*/
int
-ins_compl_add_infercase(str, len, fname, dir, flags)
+ins_compl_add_infercase(str, len, icase, fname, dir, flags)
char_u *str;
int len;
+ int icase;
char_u *fname;
int dir;
int flags;
@@ -2038,26 +2042,22 @@ ins_compl_add_infercase(str, len, fname, dir, flags)
/* Copy the original case of the part we typed */
STRNCPY(IObuff, compl_orig_text, compl_length);
- return ins_compl_add(IObuff, len, fname, NULL, dir, flags);
+ return ins_compl_add(IObuff, len, icase, fname, NULL, dir, flags);
}
- return ins_compl_add(str, len, fname, NULL, dir, flags);
+ return ins_compl_add(str, len, icase, fname, NULL, dir, flags);
}
/*
* Add a match to the list of matches.
* If the given string is already in the list of completions, then return
- * FAIL, otherwise add it to the list and return OK. If there is an error,
- * maybe because alloc() returns NULL, then RET_ERROR is returned -- webb.
- *
- * New:
- * If the given string is already in the list of completions, then return
* NOTDONE, otherwise add it to the list and return OK. If there is an error,
- * maybe because alloc() returns NULL, then FAIL is returned -- webb.
+ * maybe because alloc() returns NULL, then FAIL is returned.
*/
int
-ins_compl_add(str, len, fname, extra, cdir, flags)
+ins_compl_add(str, len, icase, fname, extra, cdir, flags)
char_u *str;
int len;
+ int icase;
char_u *fname;
char_u *extra; /* extra text for popup menu or NULL */
int cdir;
@@ -2081,7 +2081,7 @@ ins_compl_add(str, len, fname, extra, cdir, flags)
do
{
if ( !(match->cp_flags & ORIGINAL_TEXT)
- && STRNCMP(match->cp_str, str, (size_t)len) == 0
+ && ins_compl_equal(match, str, len)
&& match->cp_str[len] == NUL)
return NOTDONE;
match = match->cp_next;
@@ -2109,6 +2109,7 @@ ins_compl_add(str, len, fname, extra, cdir, flags)
vim_free(match);
return FAIL;
}
+ match->cp_icase = icase;
/* match-fname is:
* - compl_curr_match->cp_fname if it is a string equal to fname.
@@ -2163,6 +2164,21 @@ ins_compl_add(str, len, fname, extra, cdir, flags)
}
/*
+ * Return TRUE if "str[len]" matches with match->cp_str, considering
+ * match->cp_icase.
+ */
+ static int
+ins_compl_equal(match, str, len)
+ compl_T *match;
+ char_u *str;
+ int len;
+{
+ if (match->cp_icase)
+ return STRNICMP(match->cp_str, str, (size_t)len) == 0;
+ return STRNCMP(match->cp_str, str, (size_t)len) == 0;
+}
+
+/*
* Reduce the longest common string for match "match".
*/
static void
@@ -2170,7 +2186,7 @@ ins_compl_longest_match(match)
compl_T *match;
{
char_u *p, *s;
- int l;
+ int c1, c2;
int had_match;
if (compl_leader == NULL)
@@ -2179,21 +2195,36 @@ ins_compl_longest_match(match)
else
{
/* Reduce the text if this match differs from compl_leader. */
- for (p = compl_leader, s = match->cp_str; *p != NUL; p += l, s += l)
+ p = compl_leader;
+ s = match->cp_str;
+ while (*p != NUL)
{
#ifdef FEAT_MBYTE
if (has_mbyte)
{
- l = mb_ptr2len(p);
- if (STRNICMP(p, s, l) != 0)
- break;
+ c1 = mb_ptr2char(p);
+ c2 = mb_ptr2char(s);
}
else
#endif
{
- if (MB_TOLOWER(*p) != MB_TOLOWER(*s))
- break;
- l = 1;
+ c1 = *p;
+ c2 = *s;
+ }
+ if (match->cp_icase ? (MB_TOLOWER(c1) != MB_TOLOWER(c2))
+ : (c1 != c2))
+ break;
+#ifdef FEAT_MBYTE
+ if (has_mbyte)
+ {
+ mb_ptr_adv(p);
+ mb_ptr_adv(s);
+ }
+ else
+#endif
+ {
+ ++p;
+ ++s;
}
}
@@ -2221,16 +2252,18 @@ ins_compl_longest_match(match)
* Frees matches[].
*/
static void
-ins_compl_add_matches(num_matches, matches)
+ins_compl_add_matches(num_matches, matches, icase)
int num_matches;
char_u **matches;
+ int icase;
{
int i;
int add_r = OK;
int dir = compl_direction;
for (i = 0; i < num_matches && add_r != FAIL; i++)
- if ((add_r = ins_compl_add(matches[i], -1, NULL, NULL, dir, 0)) == OK)
+ if ((add_r = ins_compl_add(matches[i], -1, icase,
+ NULL, NULL, dir, 0)) == OK)
/* if dir was BACKWARD then honor it just once */
dir = FORWARD;
FreeWild(num_matches, matches);
@@ -2376,7 +2409,7 @@ ins_compl_show_pum()
{
if ((compl->cp_flags & ORIGINAL_TEXT) == 0
&& (compl_leader == NULL
- || STRNCMP(compl->cp_str, compl_leader, lead_len) == 0))
+ || ins_compl_equal(compl, compl_leader, lead_len)))
++compl_match_arraysize;
compl = compl->cp_next;
} while (compl != NULL && compl != compl_first_match);
@@ -2393,8 +2426,7 @@ ins_compl_show_pum()
{
if ((compl->cp_flags & ORIGINAL_TEXT) == 0
&& (compl_leader == NULL
- || STRNCMP(compl->cp_str, compl_leader,
- lead_len) == 0))
+ || ins_compl_equal(compl, compl_leader, lead_len)))
{
if (!shown_match_ok)
{
@@ -2560,7 +2592,7 @@ ins_compl_dictionaries(dict, pat, flags, thesaurus)
ptr = find_word_end(ptr);
add_r = ins_compl_add_infercase(regmatch.startp[0],
(int)(ptr - regmatch.startp[0]),
- files[i], dir, 0);
+ p_ic, files[i], dir, 0);
if (thesaurus)
{
char_u *wstart;
@@ -2595,7 +2627,8 @@ ins_compl_dictionaries(dict, pat, flags, thesaurus)
#endif
ptr = find_word_end(ptr);
add_r = ins_compl_add_infercase(wstart,
- (int)(ptr - wstart), files[i], dir, 0);
+ (int)(ptr - wstart),
+ p_ic, files[i], dir, 0);
}
}
if (add_r == OK)
@@ -3170,6 +3203,7 @@ expand_by_function(type, base)
pos_T pos;
int dir = compl_direction;
char_u *x;
+ int icase;
funcname = (type == CTRL_X_FUNCTION) ? curbuf->b_p_cfu : curbuf->b_p_ofu;
if (*funcname == NUL)
@@ -3192,6 +3226,12 @@ expand_by_function(type, base)
{
p = get_dict_string(li->li_tv.vval.v_dict, (char_u *)"word", FALSE);
x = get_dict_string(li->li_tv.vval.v_dict, (char_u *)"menu", FALSE);
+ if (get_dict_string(li->li_tv.vval.v_dict, (char_u *)"icase",
+ FALSE) == NULL)
+ icase = p_ic;
+ else
+ icase = get_dict_number(li->li_tv.vval.v_dict,
+ (char_u *)"icase");
}
else
{
@@ -3200,7 +3240,7 @@ expand_by_function(type, base)
}
if (p != NULL && *p != NUL)
{
- if (ins_compl_add(p, -1, NULL, x, dir, 0) == OK)
+ if (ins_compl_add(p, -1, icase, NULL, x, dir, 0) == OK)
/* if dir was BACKWARD then honor it just once */
dir = FORWARD;
}
@@ -3399,7 +3439,7 @@ ins_compl_get_exp(ini)
TAG_INS_COMP | (ctrl_x_mode ? TAG_VERBOSE : 0),
TAG_MANY, curbuf->b_ffname) == OK && num_matches > 0)
{
- ins_compl_add_matches(num_matches, matches);
+ ins_compl_add_matches(num_matches, matches, p_ic);
}
p_ic = save_p_ic;
break;
@@ -3411,7 +3451,13 @@ ins_compl_get_exp(ini)
/* May change home directory back to "~". */
tilde_replace(compl_pattern, num_matches, matches);
- ins_compl_add_matches(num_matches, matches);
+ ins_compl_add_matches(num_matches, matches,
+#ifdef CASE_INSENSITIVE_FILENAME
+ TRUE
+#else
+ FALSE
+#endif
+ );
}
break;
@@ -3419,7 +3465,7 @@ ins_compl_get_exp(ini)
if (expand_cmdline(&compl_xp, compl_pattern,
(int)STRLEN(compl_pattern),
&num_matches, &matches) == EXPAND_OK)
- ins_compl_add_matches(num_matches, matches);
+ ins_compl_add_matches(num_matches, matches, FALSE);
break;
#ifdef FEAT_COMPL_FUNC
@@ -3434,7 +3480,7 @@ ins_compl_get_exp(ini)
num_matches = expand_spelling(first_match_pos.lnum,
first_match_pos.col, compl_pattern, &matches);
if (num_matches > 0)
- ins_compl_add_matches(num_matches, matches);
+ ins_compl_add_matches(num_matches, matches, FALSE);
#endif
break;
@@ -3568,7 +3614,7 @@ ins_compl_get_exp(ini)
continue;
}
}
- if (ins_compl_add_infercase(ptr, len,
+ if (ins_compl_add_infercase(ptr, len, p_ic,
ins_buf == curbuf ? NULL : ins_buf->b_sfname,
0, flags) != NOTDONE)
{
@@ -3687,8 +3733,8 @@ ins_compl_next(allow_get_expansion, count, insert_match)
{
/* Set "compl_shown_match" to the actually shown match, it may differ
* when "compl_leader" is used to omit some of the matches. */
- while (STRNCMP(compl_shown_match->cp_str,
- compl_leader, STRLEN(compl_leader)) != 0
+ while (!ins_compl_equal(compl_shown_match,
+ compl_leader, STRLEN(compl_leader))
&& compl_shown_match->cp_next != NULL
&& compl_shown_match->cp_next != compl_first_match)
compl_shown_match = compl_shown_match->cp_next;
@@ -3732,8 +3778,8 @@ ins_compl_next(allow_get_expansion, count, insert_match)
}
if ((compl_shown_match->cp_flags & ORIGINAL_TEXT) == 0
&& compl_leader != NULL
- && STRNCMP(compl_shown_match->cp_str,
- compl_leader, STRLEN(compl_leader)) != 0)
+ && !ins_compl_equal(compl_shown_match,
+ compl_leader, STRLEN(compl_leader)))
++todo;
else
/* Remember a matching item. */
@@ -3891,6 +3937,29 @@ ins_compl_key2count(c)
}
/*
+ * Return TRUE if completion with "c" should insert the match, FALSE if only
+ * to change the currently selected completion.
+ */
+ static int
+ins_compl_use_match(c)
+ int c;
+{
+ switch (c)
+ {
+ case K_UP:
+ case K_DOWN:
+ case K_PAGEDOWN:
+ case K_KPAGEDOWN:
+ case K_S_DOWN:
+ case K_PAGEUP:
+ case K_KPAGEUP:
+ case K_S_UP:
+ return FALSE;
+ }
+ return TRUE;
+}
+
+/*
* Do Insert mode completion.
* Called when character "c" was typed, which has a meaning for completion.
* Returns OK if completion was done, FAIL if something failed (out of mem).
@@ -4252,7 +4321,7 @@ ins_complete(c)
* when the list of matches is freed. */
compl_orig_text = vim_strnsave(line + compl_col, compl_length);
if (compl_orig_text == NULL || ins_compl_add(compl_orig_text,
- -1, NULL, NULL, 0, ORIGINAL_TEXT) != OK)
+ -1, FALSE, NULL, NULL, 0, ORIGINAL_TEXT) != OK)
{
vim_free(compl_pattern);
compl_pattern = NULL;
@@ -4278,7 +4347,7 @@ ins_complete(c)
/*
* Find next match (and following matches).
*/
- n = ins_compl_next(TRUE, ins_compl_key2count(c), c != K_UP && c != K_DOWN);
+ n = ins_compl_next(TRUE, ins_compl_key2count(c), ins_compl_use_match(c));
/* may undisplay the popup menu */
ins_compl_upd_pum();
diff --git a/src/eval.c b/src/eval.c
index 506cfa5bb..fef09d02f 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1580,7 +1580,8 @@ eval_foldexpr(arg, cp)
typval_T tv;
int retval;
char_u *s;
- int use_sandbox = was_set_insecurely((char_u *)"foldexpr");
+ int use_sandbox = was_set_insecurely((char_u *)"foldexpr",
+ OPT_LOCAL);
++emsg_off;
if (use_sandbox)
@@ -8036,6 +8037,7 @@ f_complete_add(argvars, rettv)
{
char_u *word;
char_u *extra = NULL;
+ int icase = FALSE;
if (argvars[0].v_type == VAR_DICT && argvars[0].vval.v_dict != NULL)
{
@@ -8043,11 +8045,13 @@ f_complete_add(argvars, rettv)
(char_u *)"word", FALSE);
extra = get_dict_string(argvars[0].vval.v_dict,
(char_u *)"menu", FALSE);
+ icase = get_dict_number(argvars[0].vval.v_dict, (char_u *)"icase");
}
else
word = get_tv_string_chk(&argvars[0]);
if (word != NULL)
- rettv->vval.v_number = ins_compl_add(word, -1, NULL, extra, 0, 0);
+ rettv->vval.v_number = ins_compl_add(word, -1, icase,
+ NULL, extra, 0, 0);
}
/*
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index 15b695a4b..235a6b13d 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -3266,6 +3266,9 @@ do_ecmd(fnum, ffname, sfname, eap, newlnum, flags)
#ifdef FEAT_QUICKFIX
set_string_option_direct((char_u *)"buftype", -1,
(char_u *)"help", OPT_FREE|OPT_LOCAL);
+# ifdef FEAT_EVAL
+ set_option_scriptID((char_u *)"buftype", current_SID);
+# endif
#endif
/*
@@ -3285,6 +3288,9 @@ do_ecmd(fnum, ffname, sfname, eap, newlnum, flags)
{
set_string_option_direct((char_u *)"isk", -1, p,
OPT_FREE|OPT_LOCAL);
+# ifdef FEAT_EVAL
+ set_option_scriptID((char_u *)"isk", current_SID);
+# endif
check_buf_options(curbuf);
(void)buf_init_chartab(curbuf, FALSE);
}
diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c
index b2a9327f1..575a185f3 100644
--- a/src/ex_cmds2.c
+++ b/src/ex_cmds2.c
@@ -3077,13 +3077,15 @@ get_scriptname(id)
scid_T id;
{
if (id == SID_MODELINE)
- return (char_u *)"modeline";
+ return (char_u *)_("modeline");
if (id == SID_CMDARG)
- return (char_u *)"--cmd argument";
+ return (char_u *)_("--cmd argument");
if (id == SID_CARG)
- return (char_u *)"-c argument";
+ return (char_u *)_("-c argument");
if (id == SID_ENV)
- return (char_u *)"environment variable";
+ return (char_u *)_("environment variable");
+ if (id == SID_ERROR)
+ return (char_u *)_("error handler");
return SCRIPT_ITEM(id).sn_name;
}
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 5798250d7..73bf420f6 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -9225,7 +9225,7 @@ eval_vars(src, usedlen, lnump, errormsg, srcstart)
#ifdef FEAT_SEARCHPATH
case SPEC_CFILE: /* file name under cursor */
- result = file_name_at_cursor(FNAME_MESS|FNAME_HYP, 1L);
+ result = file_name_at_cursor(FNAME_MESS|FNAME_HYP, 1L, NULL);
if (result == NULL)
{
*errormsg = (char_u *)"";
diff --git a/src/fileio.c b/src/fileio.c
index ed5a653d9..60c62d579 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -583,8 +583,13 @@ readfile(fname, sfname, from, lines_to_skip, lines_to_read, eap, flags)
/* set forced 'fileencoding' */
fenc = enc_canonize(eap->cmd + eap->force_enc);
if (fenc != NULL)
+ {
set_string_option_direct((char_u *)"fenc", -1,
fenc, OPT_FREE|OPT_LOCAL);
+# ifdef FEAT_EVAL
+ set_option_scriptID((char_u *)"fenc", current_SID);
+# endif
+ }
vim_free(fenc);
}
#endif
@@ -2108,8 +2113,13 @@ failed:
#ifdef FEAT_MBYTE
/* If editing a new file: set 'fenc' for the current buffer. */
if (newfile)
+ {
set_string_option_direct((char_u *)"fenc", -1, fenc,
OPT_FREE|OPT_LOCAL);
+# ifdef FEAT_EVAL
+ set_option_scriptID((char_u *)"fenc", current_SID);
+# endif
+ }
if (fenc_alloced)
vim_free(fenc);
# ifdef USE_ICONV
diff --git a/src/fold.c b/src/fold.c
index e1dda7e3e..4e23d6335 100644
--- a/src/fold.c
+++ b/src/fold.c
@@ -1939,7 +1939,7 @@ get_foldtext(wp, lnum, lnume, foldinfo, buf)
++emsg_off;
text = eval_to_string_safe(wp->w_p_fdt, NULL,
- was_set_insecurely((char_u *)"foldtext"));
+ was_set_insecurely((char_u *)"foldtext", OPT_LOCAL));
--emsg_off;
curwin = save_curwin;
diff --git a/src/globals.h b/src/globals.h
index 5162b78c8..d46b10c3c 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -62,7 +62,14 @@ EXTERN schar_T *ScreenLines2 INIT(= NULL);
#endif
#ifdef FEAT_WINDOWS
-EXTERN char_u *TabPageIdxs INIT(= NULL); /* indexes for tab page line */
+/*
+ * Indexes for tab page line:
+ * N > 0 for label of tab page N
+ * N == 0 for no label
+ * N < 0 for closing tab page -N
+ * N == -999 for closing current tab page
+ */
+EXTERN short *TabPageIdxs INIT(= NULL);
#endif
EXTERN int screen_Rows INIT(= 0); /* actual size of ScreenLines[] */
diff --git a/src/gui.c b/src/gui.c
index 0047a26a3..3a1b31cdd 100644
--- a/src/gui.c
+++ b/src/gui.c
@@ -786,6 +786,9 @@ set_guifontwide(name)
gui.wide_font = font;
set_string_option_direct((char_u *)"gfw", -1,
wide_name, OPT_FREE);
+# ifdef FEAT_EVAL
+ set_option_scriptID((char_u *)"gfw", current_SID);
+# endif
}
}
break;
diff --git a/src/gui_beval.c b/src/gui_beval.c
index a8eac10a3..0bcd023fe 100644
--- a/src/gui_beval.c
+++ b/src/gui_beval.c
@@ -55,7 +55,7 @@ general_beval_cb(beval, state)
set_vim_var_string(VV_BEVAL_TEXT, text, -1);
vim_free(text);
- use_sandbox = was_set_insecurely((char_u *)"balloonexpr");
+ use_sandbox = was_set_insecurely((char_u *)"balloonexpr", 0);
if (use_sandbox)
++sandbox;
++textlock;
diff --git a/src/hardcopy.c b/src/hardcopy.c
index 61905b0a7..a467bbcad 100644
--- a/src/hardcopy.c
+++ b/src/hardcopy.c
@@ -492,11 +492,11 @@ prt_header(psettings, pagenum, lnum)
printer_page_num = pagenum;
# ifdef FEAT_EVAL
- use_sandbox = was_set_insecurely((char_u *)"printheader");
+ use_sandbox = was_set_insecurely((char_u *)"printheader", 0);
# endif
build_stl_str_hl(curwin, tbuf, (size_t)(width + IOSIZE),
p_header, use_sandbox,
- ' ', width, NULL);
+ ' ', width, NULL, NULL);
/* Reset line numbers */
curwin->w_cursor.lnum = tmp_lnum;
diff --git a/src/main.c b/src/main.c
index 755f74ef2..705acf5ef 100644
--- a/src/main.c
+++ b/src/main.c
@@ -635,8 +635,13 @@ main
if (params.edit_type == EDIT_QF)
{
if (params.use_ef != NULL)
+ {
set_string_option_direct((char_u *)"ef", -1,
params.use_ef, OPT_FREE);
+# ifdef FEAT_EVAL
+ set_option_scriptID((char_u *)"ef", SID_CARG);
+# endif
+ }
if (qf_init(NULL, p_ef, p_efm, TRUE) < 0)
{
out_char('\n');
diff --git a/src/mbyte.c b/src/mbyte.c
index 1b33091a9..323f1a007 100644
--- a/src/mbyte.c
+++ b/src/mbyte.c
@@ -731,8 +731,13 @@ codepage_invalid:
/* When using Unicode, set default for 'fileencodings'. */
if (enc_utf8 && !option_was_set((char_u *)"fencs"))
+ {
set_string_option_direct((char_u *)"fencs", -1,
(char_u *)"ucs-bom,utf-8,default,latin1", OPT_FREE);
+# ifdef FEAT_EVAL
+ set_option_scriptID((char_u *)"fencs", current_SID);
+# endif
+ }
#if defined(HAVE_BIND_TEXTDOMAIN_CODESET) && defined(FEAT_GETTEXT)
/* GNU gettext 0.10.37 supports this feature: set the codeset used for
* translated messages independently from the current locale. */
diff --git a/src/misc1.c b/src/misc1.c
index a3b2d3ce3..09b9ab1dc 100644
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -7677,7 +7677,8 @@ get_expr_indent()
int indent;
pos_T pos;
int save_State;
- int use_sandbox = was_set_insecurely((char_u *)"indentexpr");
+ int use_sandbox = was_set_insecurely((char_u *)"indentexpr",
+ OPT_LOCAL);
pos = curwin->w_cursor;
set_vim_var_nr(VV_LNUM, curwin->w_cursor.lnum);
diff --git a/src/misc2.c b/src/misc2.c
index 79a5174ab..9a2f06d01 100644
--- a/src/misc2.c
+++ b/src/misc2.c
@@ -2793,8 +2793,13 @@ set_fileformat(t, opt_flags)
break;
}
if (p != NULL)
+ {
set_string_option_direct((char_u *)"ff", -1, (char_u *)p,
OPT_FREE | opt_flags);
+# ifdef FEAT_EVAL
+ set_option_scriptID((char_u *)"ff", current_SID);
+# endif
+ }
#ifdef FEAT_WINDOWS
/* This may cause the buffer to become (un)modified. */
check_status(curbuf);
diff --git a/src/normal.c b/src/normal.c
index d910bbe86..07857f5ba 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -2427,28 +2427,43 @@ do_mouse(oap, c, dir, count, fixindent)
{
got_click = FALSE; /* ignore mouse-up and drag events */
- /* click in last column closes the current tab page. */
- if (mouse_col == Columns - 1 && first_tabpage->tp_next != NULL)
- {
- tabpage_close(FALSE);
- return TRUE;
- }
-
/* click in a tab selects that tab page */
if (is_click
# ifdef FEAT_CMDWIN
&& cmdwin_type == 0
# endif
- && mouse_col < Columns && TabPageIdxs[mouse_col] != 0xff)
+ && mouse_col < Columns)
{
- goto_tabpage(TabPageIdxs[mouse_col]);
+ c1 = TabPageIdxs[mouse_col];
+ if (c1 >= 0)
+ {
+ /* Go to specified tab page, or next one if not clicking on a
+ * label. */
+ goto_tabpage(c1);
- /* It's like clicking on the status line of a window. */
- if (curwin != old_curwin)
- end_visual_mode();
- return TRUE;
+ /* It's like clicking on the status line of a window. */
+ if (curwin != old_curwin)
+ end_visual_mode();
+ }
+ else if (c1 < 0)
+ {
+ tabpage_T *tp;
+
+ /* Close the current or specified tab page. */
+ if (c1 == -999)
+ tp = curtab;
+ else
+ tp = find_tabpage(-c1);
+ if (tp == curtab)
+ {
+ if (first_tabpage->tp_next != NULL)
+ tabpage_close(FALSE);
+ }
+ else if (tp != NULL)
+ tabpage_close_other(tp, FALSE);
+ }
}
- return FALSE;
+ return TRUE;
}
#endif
@@ -5785,6 +5800,7 @@ nv_gotofile(cap)
cmdarg_T *cap;
{
char_u *ptr;
+ linenr_T lnum = -1;
if (text_locked())
{
@@ -5793,7 +5809,7 @@ nv_gotofile(cap)
return;
}
- ptr = grab_file_name(cap->count1);
+ ptr = grab_file_name(cap->count1, &lnum);
if (ptr != NULL)
{
@@ -5803,6 +5819,12 @@ nv_gotofile(cap)
setpcmark();
(void)do_ecmd(0, ptr, NULL, NULL, ECMD_LAST,
P_HID(curbuf) ? ECMD_HIDE : 0);
+ if (cap->nchar == 'F' && lnum >= 0)
+ {
+ curwin->w_cursor.lnum = lnum;
+ check_cursor_lnum();
+ beginline(BL_SOL | BL_FIX);
+ }
vim_free(ptr);
}
else
@@ -7720,6 +7742,7 @@ nv_g_cmd(cap)
* "]f" and "[f": can also be used.
*/
case 'f':
+ case 'F':
nv_gotofile(cap);
break;
#endif
diff --git a/src/ops.c b/src/ops.c
index a48b6be64..c9a4dd2a7 100644
--- a/src/ops.c
+++ b/src/ops.c
@@ -1439,7 +1439,7 @@ get_spec_reg(regname, argp, allocated, errmsg)
if (!errmsg)
return FALSE;
*argp = file_name_at_cursor(FNAME_MESS | FNAME_HYP
- | (regname == Ctrl_P ? FNAME_EXP : 0), 1L);
+ | (regname == Ctrl_P ? FNAME_EXP : 0), 1L, NULL);
*allocated = TRUE;
return TRUE;
#endif
@@ -4334,7 +4334,8 @@ fex_format(lnum, count)
linenr_T lnum;
long count;
{
- int use_sandbox = was_set_insecurely((char_u *)"formatexpr");
+ int use_sandbox = was_set_insecurely((char_u *)"formatexpr",
+ OPT_LOCAL);
int r;
/*
diff --git a/src/option.c b/src/option.c
index bc53237eb..192500010 100644
--- a/src/option.c
+++ b/src/option.c
@@ -2673,6 +2673,11 @@ static void did_set_title __ARGS((int icon));
static char_u *option_expand __ARGS((int opt_idx, char_u *val));
static void didset_options __ARGS((void));
static void check_string_option __ARGS((char_u **pp));
+#if defined(FEAT_EVAL) || defined(PROTO)
+static long_u *insecure_flag __ARGS((int opt_idx, int opt_flags));
+#else
+# define insecure_flag(opt_idx, opt_flags) (&options[opt_idx].flags)
+#endif
static void set_string_option_global __ARGS((int opt_idx, char_u **varp));
static void set_string_option __ARGS((int opt_idx, char_u *value, int opt_flags));
static char_u *did_set_string_option __ARGS((int opt_idx, char_u **varp, int new_value_alloced, char_u *oldval, char_u *errbuf, int opt_flags));
@@ -3143,6 +3148,7 @@ set_option_default(opt_idx, opt_flags, compatible)
char_u *varp; /* pointer to variable for current option */
int dvi; /* index in def_val[] */
long_u flags;
+ long_u *flagsp;
int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags);
@@ -3188,10 +3194,9 @@ set_option_default(opt_idx, opt_flags, compatible)
*(int *)varp;
}
- /* The default value is not insecure. But if there are local values
- * we can't be sure. */
- if (options[opt_idx].indir == PV_NONE)
- options[opt_idx].flags &= ~P_INSECURE;
+ /* The default value is not insecure. */
+ flagsp = insecure_flag(opt_idx, opt_flags);
+ *flagsp = *flagsp & ~P_INSECURE;
}
#ifdef FEAT_EVAL
@@ -4467,19 +4472,22 @@ did_set_option(opt_idx, opt_flags, new_value)
int opt_flags; /* possibly with OPT_MODELINE */
int new_value; /* value was replaced completely */
{
+ long_u *p;
+
options[opt_idx].flags |= P_WAS_SET;
/* When an option is set in the sandbox, from a modeline or in secure mode
* set the P_INSECURE flag. Otherwise, if a new value is stored reset the
- * flag. But not when there are local values. */
+ * flag. */
+ p = insecure_flag(opt_idx, opt_flags);
if (secure
#ifdef HAVE_SANDBOX
|| sandbox != 0
#endif
|| (opt_flags & OPT_MODELINE))
- options[opt_idx].flags |= P_INSECURE;
- else if (new_value && options[opt_idx].indir == PV_NONE)
- options[opt_idx].flags &= ~P_INSECURE;
+ *p = *p | P_INSECURE;
+ else if (new_value)
+ *p = *p & ~P_INSECURE;
}
static char_u *
@@ -4924,16 +4932,55 @@ set_term_option_alloced(p)
* Return -1 for an unknown option.
*/
int
-was_set_insecurely(opt)
- char_u *opt;
+was_set_insecurely(opt, opt_flags)
+ char_u *opt;
+ int opt_flags;
{
int idx = findoption(opt);
+ long_u *flagp;
if (idx >= 0)
- return (options[idx].flags & P_INSECURE) != 0;
+ {
+ flagp = insecure_flag(idx, opt_flags);
+ return (*flagp & P_INSECURE) != 0;
+ }
EMSG2(_(e_intern2), "was_set_insecurely()");
return -1;
}
+
+/*
+ * Get a pointer to the flags used for the P_INSECURE flag of option
+ * "opt_idx". For some local options a local flags field is used.
+ */
+ static long_u *
+insecure_flag(opt_idx, opt_flags)
+ int opt_idx;
+ int opt_flags;
+{
+ if (opt_flags & OPT_LOCAL)
+ switch ((int)options[opt_idx].indir)
+ {
+#ifdef FEAT_STL_OPT
+ case OPT_BOTH(PV_STL): return &curwin->w_p_stl_flags;
+#endif
+#ifdef FEAT_EVAL
+ case PV_FDE: return &curwin->w_p_fde_flags;
+ case PV_FDT: return &curwin->w_p_fdt_flags;
+#endif
+#if defined(FEAT_EVAL)
+# if defined(FEAT_CINDENT)
+ case PV_INDE: return &curbuf->b_p_inde_flags;
+# endif
+ case PV_FEX: return &curbuf->b_p_fex_flags;
+# ifdef FEAT_FIND_ID
+ case PV_INEX: return &curbuf->b_p_inex_flags;
+# endif
+#endif
+ }
+
+ /* Nothing special, return global flags field. */
+ return &options[opt_idx].flags;
+}
#endif
/*
@@ -6657,6 +6704,24 @@ compile_cap_prog(buf)
}
#endif
+#if defined(FEAT_EVAL) || defined(PROTO)
+/*
+ * Set the script ID of option "name" to "id".
+ */
+ void
+set_option_scriptID(name, id)
+ char_u *name;
+ int id;
+{
+ int opt_idx = findoption(name);
+
+ if (opt_idx == -1) /* not found (should not happen) */
+ EMSG2(_(e_intern2), "set_option_scriptID()");
+ else
+ options[opt_idx].scriptID = id;
+}
+#endif
+
/*
* Set the value of a boolean option, and take care of side effects.
* Returns NULL for success, or an error message for an error.
@@ -6766,6 +6831,9 @@ set_bool_option(opt_idx, varp, value, opt_flags)
STRCPY(IObuff, p_shm);
STRCAT(IObuff, "s");
set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE);
+# ifdef FEAT_EVAL
+ set_option_scriptID((char_u *)"shm", current_SID);
+# endif
}
/* remove 's' from p_shm */
else if (!p_terse && p != NULL)
@@ -6851,6 +6919,9 @@ set_bool_option(opt_idx, varp, value, opt_flags)
set_string_option_direct((char_u *)"ffs", -1,
p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"",
OPT_FREE | opt_flags);
+# ifdef FEAT_EVAL
+ set_option_scriptID((char_u *)"ffs", current_SID);
+# endif
}
/*
diff --git a/src/option.h b/src/option.h
index 57da84222..ebf154b5a 100644
--- a/src/option.h
+++ b/src/option.h
@@ -288,6 +288,8 @@
#define STL_TRUNCMARK '<' /* truncation mark if line is too long*/
#define STL_USER_HL '*' /* highlight from (User)1..9 or 0 */
#define STL_HIGHLIGHT '#' /* highlight name */
+#define STL_TABPAGENR 'T' /* tab page label nr */
+#define STL_TABCLOSENR 'X' /* tab page close nr */
#define STL_ALL ((char_u *) "fFtcvVlLknoObBrRhHmYyWwMpPaN{#")
/* flags used for parsed 'wildmode' */
diff --git a/src/proto/buffer.pro b/src/proto/buffer.pro
index 07ec64c06..73ad5306e 100644
--- a/src/proto/buffer.pro
+++ b/src/proto/buffer.pro
@@ -40,7 +40,7 @@ void col_print __ARGS((char_u *buf, int col, int vcol));
void maketitle __ARGS((void));
void resettitle __ARGS((void));
void free_titles __ARGS((void));
-int build_stl_str_hl __ARGS((win_T *wp, char_u *out, size_t outlen, char_u *fmt, int insecure, int fillchar, int maxwidth, struct stl_hlrec *hl));
+int build_stl_str_hl __ARGS((win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use_sandbox, int fillchar, int maxwidth, struct stl_hlrec *hltab, struct stl_hlrec *tabtab));
void get_rel_pos __ARGS((win_T *wp, char_u *str));
int append_arg_number __ARGS((win_T *wp, char_u *buf, int add_file, int maxlen));
char_u *fix_fname __ARGS((char_u *fname));
diff --git a/src/proto/edit.pro b/src/proto/edit.pro
index 5434b1c1b..66df8f590 100644
--- a/src/proto/edit.pro
+++ b/src/proto/edit.pro
@@ -7,8 +7,8 @@ void change_indent __ARGS((int type, int amount, int round, int replaced));
void truncate_spaces __ARGS((char_u *line));
void backspace_until_column __ARGS((int col));
int vim_is_ctrl_x_key __ARGS((int c));
-int ins_compl_add_infercase __ARGS((char_u *str, int len, char_u *fname, int dir, int flags));
-int ins_compl_add __ARGS((char_u *str, int len, char_u *fname, char_u *extra, int cdir, int flags));
+int ins_compl_add_infercase __ARGS((char_u *str, int len, int icase, char_u *fname, int dir, int flags));
+int ins_compl_add __ARGS((char_u *str, int len, int icase, char_u *fname, char_u *extra, int cdir, int flags));
void ins_compl_show_pum __ARGS((void));
char_u *find_word_start __ARGS((char_u *ptr));
char_u *find_word_end __ARGS((char_u *ptr));
diff --git a/src/proto/option.pro b/src/proto/option.pro
index 4a49d8921..fbe2f095a 100644
--- a/src/proto/option.pro
+++ b/src/proto/option.pro
@@ -17,9 +17,10 @@ void check_buf_options __ARGS((buf_T *buf));
void free_string_option __ARGS((char_u *p));
void clear_string_option __ARGS((char_u **pp));
void set_term_option_alloced __ARGS((char_u **p));
-int was_set_insecurely __ARGS((char_u *opt));
+int was_set_insecurely __ARGS((char_u *opt, int opt_flags));
void set_string_option_direct __ARGS((char_u *name, int opt_idx, char_u *val, int opt_flags));
char_u *check_stl_option __ARGS((char_u *s));
+void set_option_scriptID __ARGS((char_u *name, int id));
int get_option_value __ARGS((char_u *name, long *numval, char_u **stringval, int opt_flags));
void set_option_value __ARGS((char_u *name, long number, char_u *string, int opt_flags));
char_u *get_term_code __ARGS((char_u *tname));
diff --git a/src/proto/window.pro b/src/proto/window.pro
index cda7b060d..ca0de7a28 100644
--- a/src/proto/window.pro
+++ b/src/proto/window.pro
@@ -41,9 +41,9 @@ void win_comp_scroll __ARGS((win_T *wp));
void command_height __ARGS((long old_p_ch));
void last_status __ARGS((int morewin));
int tabpageline_height __ARGS((void));
-char_u *grab_file_name __ARGS((long count));
-char_u *file_name_at_cursor __ARGS((int options, long count));
-char_u *file_name_in_line __ARGS((char_u *line, int col, int options, long count, char_u *rel_fname));
+char_u *grab_file_name __ARGS((long count, linenr_T *file_lnum));
+char_u *file_name_at_cursor __ARGS((int options, long count, linenr_T *file_lnum));
+char_u *file_name_in_line __ARGS((char_u *line, int col, int options, long count, char_u *rel_fname, linenr_T *file_lnum));
char_u *find_file_name_in_path __ARGS((char_u *ptr, int len, int options, long count, char_u *rel_fname));
int path_with_url __ARGS((char_u *fname));
int vim_isAbsName __ARGS((char_u *name));
diff --git a/src/quickfix.c b/src/quickfix.c
index 2ffce40a8..a29f06784 100644
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -2839,7 +2839,12 @@ ex_cfile(eap)
wp = curwin;
if (*eap->arg != NUL)
+ {
set_string_option_direct((char_u *)"ef", -1, eap->arg, OPT_FREE);
+# ifdef FEAT_EVAL
+ set_option_scriptID((char_u *)"ef", current_SID);
+# endif
+ }
/*
* This function is used by the :cfile, :cgetfile and :caddfile
diff --git a/src/screen.c b/src/screen.c
index 33037cfa7..07cf99145 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -5474,9 +5474,14 @@ redraw_custum_statusline(wp)
called_emsg = FALSE;
win_redr_custom(wp, FALSE);
if (called_emsg)
+ {
set_string_option_direct((char_u *)"statusline", -1,
(char_u *)"", OPT_FREE | (*wp->w_p_stl != NUL
? OPT_LOCAL : OPT_GLOBAL));
+# ifdef FEAT_EVAL
+ set_option_scriptID((char_u *)"statusline", SID_ERROR);
+# endif
+ }
called_emsg |= save_called_emsg;
}
#endif
@@ -5586,7 +5591,8 @@ win_redr_custom(wp, draw_ruler)
int fillchar;
char_u buf[MAXPATHL];
char_u *p;
- struct stl_hlrec hl[STL_MAX_ITEM];
+ struct stl_hlrec hltab[STL_MAX_ITEM];
+ struct stl_hlrec tabtab[STL_MAX_ITEM];
int use_sandbox = FALSE;
/* setup environment for the task at hand */
@@ -5599,7 +5605,7 @@ win_redr_custom(wp, draw_ruler)
attr = hl_attr(HLF_TPF);
maxwidth = Columns;
# ifdef FEAT_EVAL
- use_sandbox = was_set_insecurely((char_u *)"tabline");
+ use_sandbox = was_set_insecurely((char_u *)"tabline", 0);
# endif
}
else
@@ -5643,7 +5649,7 @@ win_redr_custom(wp, draw_ruler)
}
# ifdef FEAT_EVAL
- use_sandbox = was_set_insecurely((char_u *)"rulerformat");
+ use_sandbox = was_set_insecurely((char_u *)"rulerformat", 0);
# endif
}
else
@@ -5653,7 +5659,8 @@ win_redr_custom(wp, draw_ruler)
else
p = p_stl;
# ifdef FEAT_EVAL
- use_sandbox = was_set_insecurely((char_u *)"statusline");
+ use_sandbox = was_set_insecurely((char_u *)"statusline",
+ *wp->w_p_stl == NUL ? 0 : OPT_LOCAL);
# endif
}
@@ -5668,7 +5675,7 @@ win_redr_custom(wp, draw_ruler)
width = build_stl_str_hl(wp == NULL ? curwin : wp,
buf, sizeof(buf),
p, use_sandbox,
- fillchar, maxwidth, hl);
+ fillchar, maxwidth, hltab, tabtab);
len = STRLEN(buf);
while (width < maxwidth && len < sizeof(buf) - 1)
@@ -5682,27 +5689,49 @@ win_redr_custom(wp, draw_ruler)
}
buf[len] = NUL;
+ /*
+ * Draw each snippet with the specified highlighting.
+ */
curattr = attr;
p = buf;
- for (n = 0; hl[n].start != NULL; n++)
+ for (n = 0; hltab[n].start != NULL; n++)
{
- len = (int)(hl[n].start - p);
+ len = (int)(hltab[n].start - p);
screen_puts_len(p, len, row, col, curattr);
col += vim_strnsize(p, len);
- p = hl[n].start;
+ p = hltab[n].start;
- if (hl[n].userhl == 0)
+ if (hltab[n].userhl == 0)
curattr = attr;
- else if (hl[n].userhl < 0)
- curattr = syn_id2attr(-hl[n].userhl);
+ else if (hltab[n].userhl < 0)
+ curattr = syn_id2attr(-hltab[n].userhl);
#ifdef FEAT_WINDOWS
else if (wp != NULL && wp != curwin && wp->w_status_height != 0)
- curattr = highlight_stlnc[hl[n].userhl - 1];
+ curattr = highlight_stlnc[hltab[n].userhl - 1];
#endif
else
- curattr = highlight_user[hl[n].userhl - 1];
+ curattr = highlight_user[hltab[n].userhl - 1];
}
screen_puts(p, row, col, curattr);
+
+ if (wp == NULL)
+ {
+ /* Fill the TabPageIdxs[] array for clicking in the tab pagesline. */
+ col = 0;
+ len = 0;
+ p = buf;
+ fillchar = 0;
+ for (n = 0; tabtab[n].start != NULL; n++)
+ {
+ len += vim_strnsize(p, (int)(tabtab[n].start - p));
+ while (col < len)
+ TabPageIdxs[col++] = fillchar;
+ p = tabtab[n].start;
+ fillchar = tabtab[n].userhl;
+ }
+ while (col < Columns)
+ TabPageIdxs[col++] = fillchar;
+ }
}
#endif /* FEAT_STL_OPT */
@@ -6198,7 +6227,8 @@ screen_start_highlight(attr)
{
char buf[20];
- sprintf(buf, IF_EB("\033|%dh", ESC_STR "|%dh"), attr); /* internal GUI code */
+ /* The GUI handles this internally. */
+ sprintf(buf, IF_EB("\033|%dh", ESC_STR "|%dh"), attr);
OUT_STR(buf);
}
else
@@ -6207,14 +6237,7 @@ screen_start_highlight(attr)
if (attr > HL_ALL) /* special HL attr. */
{
if (t_colors > 1)
- {
aep = syn_cterm_attr2entry(attr);
- /* If the Normal FG color has BOLD attribute and the new
- * HL has a FG color defined, clear BOLD. */
- if (aep != NULL && aep->ae_u.cterm.fg_color
- && cterm_normal_fg_bold)
- out_str(T_ME);
- }
else
aep = syn_term_attr2entry(attr);
if (aep == NULL) /* did ":syntax clear" */
@@ -6224,6 +6247,11 @@ screen_start_highlight(attr)
}
if ((attr & HL_BOLD) && T_MD != NULL) /* bold */
out_str(T_MD);
+ else if (aep != NULL && t_colors > 1 && aep->ae_u.cterm.fg_color
+ && cterm_normal_fg_bold)
+ /* If the Normal FG color has BOLD attribute and the new HL
+ * has a FG color defined, clear BOLD. */
+ out_str(T_ME);
if ((attr & HL_STANDOUT) && T_SO != NULL) /* standout */
out_str(T_SO);
if ((attr & (HL_UNDERLINE | HL_UNDERCURL)) && T_US != NULL)
@@ -6808,7 +6836,7 @@ screenalloc(clear)
unsigned *new_LineOffset;
char_u *new_LineWraps;
#ifdef FEAT_WINDOWS
- char_u *new_TabPageIdxs;
+ short *new_TabPageIdxs;
tabpage_T *tp;
#endif
static int entered = FALSE; /* avoid recursiveness */
@@ -6885,7 +6913,7 @@ screenalloc(clear)
Rows * sizeof(unsigned)), FALSE);
new_LineWraps = (char_u *)lalloc((long_u)(Rows * sizeof(char_u)), FALSE);
#ifdef FEAT_WINDOWS
- new_TabPageIdxs = (char_u *)lalloc((long_u)(Columns * sizeof(char_u)), FALSE);
+ new_TabPageIdxs = (short *)lalloc((long_u)(Columns * sizeof(short)), FALSE);
#endif
FOR_ALL_TAB_WINDOWS(tp, wp)
@@ -8553,6 +8581,11 @@ draw_tabline()
return;
#if defined(FEAT_STL_OPT)
+
+ /* Init TabPageIdxs[] to zero: Clicking outside of tabs has no effect. */
+ for (scol = 0; scol < Columns; ++scol)
+ TabPageIdxs[scol] = 0;
+
/* Use the 'tabline' option if it's set. */
if (*p_tal != NUL)
{
@@ -8563,8 +8596,13 @@ draw_tabline()
called_emsg = FALSE;
win_redr_custom(NULL, FALSE);
if (called_emsg)
+ {
set_string_option_direct((char_u *)"tabline", -1,
(char_u *)"", OPT_FREE);
+# ifdef FEAT_EVAL
+ set_option_scriptID((char_u *)"tabline", SID_ERROR);
+# endif
+ }
called_emsg |= save_called_emsg;
}
else
@@ -8579,6 +8617,7 @@ draw_tabline()
attr = attr_nosel;
tabcount = 0;
+ scol = 0;
for (tp = first_tabpage; tp != NULL && col < Columns; tp = tp->tp_next)
{
scol = col;
@@ -8671,15 +8710,14 @@ draw_tabline()
else
c = ' ';
screen_fill(0, 1, col, (int)Columns, c, c, attr_fill);
- }
- /* Put an "X" for closing the current tab if there are several. */
- if (first_tabpage->tp_next != NULL)
- screen_putchar('X', 0, (int)Columns - 1, attr_nosel);
-
- /* Clicking outside of tabs has no effect. */
- while (scol < Columns)
- TabPageIdxs[scol++] = 0xff;
+ /* Put an "X" for closing the current tab if there are several. */
+ if (first_tabpage->tp_next != NULL)
+ {
+ screen_putchar('X', 0, (int)Columns - 1, attr_nosel);
+ TabPageIdxs[Columns - 1] = -999;
+ }
+ }
}
#endif
@@ -8852,8 +8890,13 @@ win_redr_ruler(wp, always)
called_emsg = FALSE;
win_redr_custom(wp, TRUE);
if (called_emsg)
+ {
set_string_option_direct((char_u *)"rulerformat", -1,
(char_u *)"", OPT_FREE);
+# ifdef FEAT_EVAL
+ set_option_scriptID((char_u *)"rulerformat", SID_ERROR);
+# endif
+ }
called_emsg |= save_called_emsg;
return;
}
diff --git a/src/search.c b/src/search.c
index d50634465..c0be23ba7 100644
--- a/src/search.c
+++ b/src/search.c
@@ -4499,7 +4499,7 @@ find_pattern_in_path(ptr, dir, len, whole, skip_comments,
else
/* Use text after match with 'include'. */
new_fname = file_name_in_line(incl_regmatch.endp[0], 0,
- FNAME_EXP|FNAME_INCL|FNAME_REL, 1L, p_fname);
+ FNAME_EXP|FNAME_INCL|FNAME_REL, 1L, p_fname, NULL);
already_searched = FALSE;
if (new_fname != NULL)
{
@@ -4829,7 +4829,7 @@ search_line:
goto exit_matched;
}
- add_r = ins_compl_add_infercase(aux, i,
+ add_r = ins_compl_add_infercase(aux, i, p_ic,
curr_fname == curbuf->b_fname ? NULL : curr_fname,
dir, reuse);
if (add_r == OK)
diff --git a/src/structs.h b/src/structs.h
index 98d7ea912..4d1928e89 100644
--- a/src/structs.h
+++ b/src/structs.h
@@ -1324,14 +1324,17 @@ struct file_buffer
char_u *b_p_inc; /* 'include' */
# ifdef FEAT_EVAL
char_u *b_p_inex; /* 'includeexpr' */
+ long_u b_p_inex_flags; /* flags for 'includeexpr' */
# endif
#endif
#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
char_u *b_p_inde; /* 'indentexpr' */
+ long_u b_p_inde_flags; /* flags for 'indentexpr' */
char_u *b_p_indk; /* 'indentkeys' */
#endif
#if defined(FEAT_EVAL)
char_u *b_p_fex; /* 'formatexpr' */
+ long_u b_p_fex_flags; /* flags for 'formatexpr' */
#endif
#ifdef FEAT_CRYPT
char_u *b_p_key; /* 'key' */
@@ -1826,6 +1829,15 @@ struct window_S
winopt_T w_onebuf_opt;
winopt_T w_allbuf_opt;
+ /* A few options have local flags for P_INSECURE. */
+#ifdef FEAT_STL_OPT
+ long_u w_p_stl_flags; /* flags for 'statusline' */
+#endif
+#ifdef FEAT_EVAL
+ long_u w_p_fde_flags; /* flags for 'foldexpr' */
+ long_u w_p_fdt_flags; /* flags for 'foldtext' */
+#endif
+
/* transform a pointer to a "onebuf" option into a "allbuf" option */
#define GLOBAL_WO(p) ((char *)p + sizeof(winopt_T))
diff --git a/src/term.c b/src/term.c
index 94125a8fe..f9d6d2dd9 100644
--- a/src/term.c
+++ b/src/term.c
@@ -1562,6 +1562,9 @@ set_color_count(nr)
else
*nr_colors = NUL;
set_string_option_direct((char_u *)"t_Co", -1, nr_colors, OPT_FREE);
+# ifdef FEAT_EVAL
+ set_option_scriptID((char_u *)"t_Co", current_SID);
+# endif
}
#endif
@@ -2501,6 +2504,9 @@ termcapinit(name)
if (term == NULL || *term == NUL)
term = DEFAULT_TERM;
set_string_option_direct((char_u *)"term", -1, term, OPT_FREE);
+# ifdef FEAT_EVAL
+ set_option_scriptID((char_u *)"term", current_SID);
+# endif
/* Set the default terminal name. */
set_string_default("term", term);
diff --git a/src/version.h b/src/version.h
index 9e8fe2dbb..0ebd781e6 100644
--- a/src/version.h
+++ b/src/version.h
@@ -36,5 +36,5 @@
#define VIM_VERSION_NODOT "vim70aa"
#define VIM_VERSION_SHORT "7.0aa"
#define VIM_VERSION_MEDIUM "7.0aa ALPHA"
-#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2006 Feb 21)"
-#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2006 Feb 21, compiled "
+#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2006 Feb 22)"
+#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2006 Feb 22, compiled "
diff --git a/src/vim.h b/src/vim.h
index e4e26df6c..2a4a8cfb9 100644
--- a/src/vim.h
+++ b/src/vim.h
@@ -1035,6 +1035,7 @@ extern char *(*dyn_libintl_textdomain)(const char *domainname);
#define SID_CMDARG -2 /* for "--cmd" argument */
#define SID_CARG -3 /* for "-c" argument */
#define SID_ENV -4 /* for sourcing environment variable */
+#define SID_ERROR -5 /* option was reset because of an error */
/*
* Events for autocommands.
diff --git a/src/window.c b/src/window.c
index 3419a01e0..548113dfc 100644
--- a/src/window.c
+++ b/src/window.c
@@ -105,6 +105,7 @@ do_window(nchar, Prenum, xchar)
win_T *wp;
#if defined(FEAT_SEARCHPATH) || defined(FEAT_FIND_ID)
char_u *ptr;
+ linenr_T lnum = -1;
#endif
#ifdef FEAT_FIND_ID
int type = FIND_DEFINE;
@@ -478,10 +479,11 @@ newwindow:
#ifdef FEAT_SEARCHPATH
/* edit file name under cursor in a new window */
case 'f':
+ case 'F':
case Ctrl_F:
CHECK_CMDWIN
- ptr = grab_file_name(Prenum1);
+ ptr = grab_file_name(Prenum1, &lnum);
if (ptr != NULL)
{
#ifdef FEAT_GUI
@@ -493,8 +495,13 @@ newwindow:
# ifdef FEAT_SCROLLBIND
curwin->w_p_scb = FALSE;
# endif
- (void)do_ecmd(0, ptr, NULL, NULL, ECMD_LASTL,
- ECMD_HIDE);
+ (void)do_ecmd(0, ptr, NULL, NULL, ECMD_LASTL, ECMD_HIDE);
+ if (nchar == 'F' && lnum >= 0)
+ {
+ curwin->w_cursor.lnum = lnum;
+ check_cursor_lnum();
+ beginline(BL_SOL | BL_FIX);
+ }
}
vim_free(ptr);
}
@@ -5081,8 +5088,9 @@ tabpageline_height()
* Returns the name in allocated memory, NULL for failure.
*/
char_u *
-grab_file_name(count)
- long count;
+grab_file_name(count, file_lnum)
+ long count;
+ linenr_T *file_lnum;
{
# ifdef FEAT_VISUAL
if (VIsual_active)
@@ -5096,7 +5104,9 @@ grab_file_name(count)
FNAME_MESS|FNAME_EXP|FNAME_REL, count, curbuf->b_ffname);
}
# endif
- return file_name_at_cursor(FNAME_MESS|FNAME_HYP|FNAME_EXP|FNAME_REL, count);
+ return file_name_at_cursor(FNAME_MESS|FNAME_HYP|FNAME_EXP|FNAME_REL, count,
+ file_lnum);
+
}
/*
@@ -5113,12 +5123,14 @@ grab_file_name(count)
* FNAME_INCL apply "includeexpr"
*/
char_u *
-file_name_at_cursor(options, count)
- int options;
- long count;
+file_name_at_cursor(options, count, file_lnum)
+ int options;
+ long count;
+ linenr_T *file_lnum;
{
return file_name_in_line(ml_get_curline(),
- curwin->w_cursor.col, options, count, curbuf->b_ffname);
+ curwin->w_cursor.col, options, count, curbuf->b_ffname,
+ file_lnum);
}
/*
@@ -5126,12 +5138,13 @@ file_name_at_cursor(options, count)
* Otherwise like file_name_at_cursor().
*/
char_u *
-file_name_in_line(line, col, options, count, rel_fname)
+file_name_in_line(line, col, options, count, rel_fname, file_lnum)
char_u *line;
int col;
int options;
long count;
char_u *rel_fname; /* file we are searching relative to */
+ linenr_T *file_lnum; /* line number after the file name */
{
char_u *ptr;
int len;
@@ -5189,6 +5202,23 @@ file_name_in_line(line, col, options, count, rel_fname)
&& ptr[len - 2] != '.')
--len;
+ if (file_lnum != NULL)
+ {
+ char_u *p;
+
+ /* Get the number after the file name and a separator character */
+ p = ptr + len;
+ p = skipwhite(p);
+ if (*p != NUL)
+ {
+ if (!isdigit(*p))
+ ++p; /* skip the separator */
+ p = skipwhite(p);
+ if (isdigit(*p))
+ *file_lnum = (int)getdigits(&p);
+ }
+ }
+
return find_file_name_in_path(ptr, len, options, count, rel_fname);
}
@@ -5204,7 +5234,7 @@ eval_includeexpr(ptr, len)
set_vim_var_string(VV_FNAME, ptr, len);
res = eval_to_string_safe(curbuf->b_p_inex, NULL,
- was_set_insecurely((char_u *)"includeexpr"));
+ was_set_insecurely((char_u *)"includeexpr", OPT_LOCAL));
set_vim_var_string(VV_FNAME, NULL, 0);
return res;
}