diff --git a/runtime/doc/editing.txt b/runtime/doc/editing.txt index b29504ced25bced417397b00ca52cbb5bd60264c..dc22930bf3d6de0f907d8c4051279af76a4a6bde 100644 --- a/runtime/doc/editing.txt +++ b/runtime/doc/editing.txt @@ -334,6 +334,22 @@ CTRL-^ Edit the alternate file (equivalent to ":e #"). (For {Visual} see |Visual-mode|.) {not in VI} + *gF* +[count]gF Same as "gf", except if a number follows the file + name, then the cursor is positioned on that line in + the file. The file name and the number must be + separated by a non-filename (see 'isfname') and + non-numeric character. White space between the + filename, the separator and the number are ignored. + Examples: > + eval.c:10 + eval.c @ 20 + eval.c (30) + eval.c 40 +< + *v_gF* +{Visual}[count]gF Same as "v_gf". + These commands are used to start editing a single file. This means that the file is read into the buffer and the current file name is set. The file that is opened depends on the current directory, see |:cd|. diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 474f86332335782eba5d26ab9a8165ba680a3231..adcd6f341d2402f01c0e75f904b47651cd516e0b 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1,4 +1,4 @@ -*eval.txt* For Vim version 7.0aa. Last change: 2006 Feb 20 +*eval.txt* For Vim version 7.0aa. Last change: 2006 Feb 22 VIM REFERENCE MANUAL by Bram Moolenaar @@ -6928,7 +6928,7 @@ This is not guaranteed 100% secure, but it should block most attacks. *sandbox-option* A few options contain an expression. When this expression is evaluated it may -have to be done in the sandbox to avoid trouble. But the sandbox is +have to be done in the sandbox to avoid a security risc. But the sandbox is restrictive, thus this only happens when the option was set from an insecure location. Insecure in this context are: - sourcing a .vimrc or .exrc in the current directlry diff --git a/runtime/doc/index.txt b/runtime/doc/index.txt index b265ee61ae3de48bbb571982c2c9e60350176359..fa4eca4e383ff338c85f1519aa7223fdd3784e17 100644 --- a/runtime/doc/index.txt +++ b/runtime/doc/index.txt @@ -541,6 +541,9 @@ tag command action in Normal mode ~ the cursor |CTRL-W_f| CTRL-W f split window and edit file name under the cursor +|CTRL-W_F| CTRL-W F split window and edit file name under the + cursor and jump to the line number + following the file name. |CTRL-W_g_CTRL-]| CTRL-W g CTRL-] split window and do |:tjump| to tag under cursor |CTRL-W_g]| CTRL-W g ] split window and do |:tselect| for tag @@ -719,6 +722,9 @@ tag char note action in Normal mode ~ word |gf| gf start editing the file whose name is under the cursor +|gF| gF start editing the file whose name is under + the cursor and jump to the line number + following the filename. |gg| gg 1 cursor to line N, default first line |gh| gh start Select mode |gi| gi 2 like "i", but first move to the |'^| mark diff --git a/runtime/doc/insert.txt b/runtime/doc/insert.txt index 450f6670fd8822c41c36dcd340797c8c331a69e9..5f551312b6f6b39bf8e670157faf988ecf9d0284 100644 --- a/runtime/doc/insert.txt +++ b/runtime/doc/insert.txt @@ -1,4 +1,4 @@ -*insert.txt* For Vim version 7.0aa. Last change: 2006 Feb 14 +*insert.txt* For Vim version 7.0aa. Last change: 2006 Feb 22 VIM REFERENCE MANUAL by Bram Moolenaar @@ -993,10 +993,12 @@ items: menu extra text for the popup menu info more information about the item kind single letter indicating the type of completion + icase when not zero case is to be ignored; when omitted + the 'ignorecase' option is used -All of these must be a string. If an item does not meet these requirements -then an error message is given and further items in the list are not used. -You can mix string and Dictionary items in the returned list. +All of these except 'icase' must be a string. If an item does not meet these +requirements then an error message is given and further items in the list are +not used. You can mix string and Dictionary items in the returned list. The "menu" item is used in the popup menu and may be truncated, thus it should be relatively short. The "info" item can be longer, it may be displayed in a diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 53411ad49ccd7a6cdb2b367b21f7246f65bf8694..b8931aee3ef2b6f449330fb3391fcf9e65ac08f7 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -1,4 +1,4 @@ -*options.txt* For Vim version 7.0aa. Last change: 2006 Feb 21 +*options.txt* For Vim version 7.0aa. Last change: 2006 Feb 22 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1629,7 +1629,9 @@ A jump table for the options with a short description can be found at |Q_op|. sufficient colors are available. |ins-completion-menu| longest Only insert the longest common text of the matches. Use - CTRL-L to add more characters. + CTRL-L to add more characters. Whether case is ignored + depends on the kind of completion. For buffer text the + 'ignorecase' option is used. *'confirm'* *'cf'* *'noconfirm'* *'nocf'* @@ -2904,7 +2906,7 @@ A jump table for the options with a short description can be found at |Q_op|. |v:count| the number of lines to be formatted. When this option is empty 'formatprg' is used. Example: > - :set formatexp=mylang#Format() + :set formatexpr=mylang#Format() < This will invoke the mylang#Format() function in the autoload/mylang.vim file in 'runtimepath'. |autoload| @@ -6073,6 +6075,11 @@ A jump table for the options with a short description can be found at |Q_op|. ( - Start of item group. Can be used for setting the width and alignment of a section. Must be followed by %) somewhere. ) - End of item group. No width fields allowed. + T N For 'tabline': start of tab page N label. Use %T after the last + label. This information is used for mouse clicks. + X N For 'tabline': start of close tab N label. Use %X after the + label, e.g.: %3Xclose%X. Use %999X for a "close current tab" + mark. This information is used for mouse clicks. < - Where to truncate line if too long. Default is at the start. No width fields allowed. = - Separation point between left and right aligned items. @@ -6269,14 +6276,15 @@ A jump table for the options with a short description can be found at |Q_op|. feature} When nonempty, this option determines the content of the tab pages line at the top of the Vim window. When empty Vim will use a default - tab pages line. |tab-page| + tab pages line. See |setting-tabline| for more info. The tab pages line only appears as specified with the 'showtabline' option and only when there is no GUI implementation for tabs. The value is evaluated like with 'statusline'. You can use |tabpagenr()|, |tabpagewinnr()| and |tabpagebuflist()| to figure out - the text to be displayed. See |setting-tabline| for more info. + the text to be displayed. Use "%1T" for the first label, "%2T" for + the second one, etc. Use "%X" items for closing labels. Keep in mind that only one of the tab pages is the current one, others are invisible and you can't jump to their windows. diff --git a/runtime/doc/tabpage.txt b/runtime/doc/tabpage.txt index e0e8b17ede2bbf11d95a8982bd0cec61515051ed..2db521efa38ef88b4665eaf3e9e1e0f98429db24 100644 --- a/runtime/doc/tabpage.txt +++ b/runtime/doc/tabpage.txt @@ -1,4 +1,4 @@ -*tabpage.txt* For Vim version 7.0aa. Last change: 2006 Feb 21 +*tabpage.txt* For Vim version 7.0aa. Last change: 2006 Feb 22 VIM REFERENCE MANUAL by Bram Moolenaar @@ -164,14 +164,28 @@ pages and define labels for them. Then get the label for each tab page. > function MyTabLine() let s = '' for i in range(tabpagenr('$')) + " select the highlighting if i + 1 == tabpagenr() let s .= '%#TabLineSel#' else let s .= '%#TabLine#' endif + + " set the tab page number (for mouse clicks) + let s .= '%' . (i + 1) . 'T' + + " the label is made by MyTabLabel() let s .= ' %{MyTabLabel(' . (i + 1) . ')} ' endfor - let s .= '%#TabLineFill#' + + " after the last tab fill with TabLineFill and reset tab page nr + let s .= '%#TabLineFill#%T' + + " right-align the label to close the current tab page + if tabpagenr('$') > 1 + let s .= '%=%#TabLine#%999Xclose' + endif + return s endfunction @@ -187,7 +201,6 @@ This is just a simplistic example that results in a tab pages line that resembles the default, but without adding a + for a modified buffer or trunctating the names. You will want to reduce the width of labels in a clever way when there is not enough room. Check the 'columns' option for the -space available, keeping in mind that the "X" at the right will take one more -position. +space available. vim:tw=78:ts=8:ft=help:norl: diff --git a/runtime/doc/tags b/runtime/doc/tags index 630e0f880d62dc36d013f76176d3c4c50dd1e0e7..278e1ba9a2016dcc83cf8f2b0525b1beaac01ec5 100644 --- a/runtime/doc/tags +++ b/runtime/doc/tags @@ -3078,6 +3078,7 @@ CTRL-W_CTRL-Z windows.txt /*CTRL-W_CTRL-Z* CTRL-W_CTRL-] windows.txt /*CTRL-W_CTRL-]* CTRL-W_CTRL-^ windows.txt /*CTRL-W_CTRL-^* CTRL-W_CTRL-_ windows.txt /*CTRL-W_CTRL-_* +CTRL-W_F windows.txt /*CTRL-W_F* CTRL-W_H windows.txt /*CTRL-W_H* CTRL-W_J windows.txt /*CTRL-W_J* CTRL-W_K windows.txt /*CTRL-W_K* @@ -5285,6 +5286,7 @@ g?g? change.txt /*g?g?* g@ map.txt /*g@* gD pattern.txt /*gD* gE motion.txt /*gE* +gF editing.txt /*gF* gH visual.txt /*gH* gI insert.txt /*gI* gJ change.txt /*gJ* @@ -7283,6 +7285,7 @@ v_b_r_example visual.txt /*v_b_r_example* v_c change.txt /*v_c* v_d change.txt /*v_d* v_g? change.txt /*v_g?* +v_gF editing.txt /*v_gF* v_gJ change.txt /*v_gJ* v_gV visual.txt /*v_gV* v_g] tagsrch.txt /*v_g]* diff --git a/runtime/doc/todo.txt b/runtime/doc/todo.txt index 230ec6efcceec6e37f67dc43d84b17e1fe34f5e1..f50d04fbc1cc80737b0cf3e98f4aed230a0112be 100644 --- a/runtime/doc/todo.txt +++ b/runtime/doc/todo.txt @@ -1,4 +1,4 @@ -*todo.txt* For Vim version 7.0aa. Last change: 2006 Feb 21 +*todo.txt* For Vim version 7.0aa. Last change: 2006 Feb 22 VIM REFERENCE MANUAL by Bram Moolenaar @@ -30,18 +30,6 @@ be worked on, but only if you sponsor Vim development. See |sponsor|. *known-bugs* -------------------- Known bugs and current work ----------------------- -Remove resetting "bold" from screen_start_highlight()? - -Using 'tabline' breaks using mouse to select a tab. How to do that? -See suggestion from Tony Mechelynck. - -P_INSECURE should be remembered for local option values separately. - -Completion: <Up> and <Down> don't insert completion, <PageUp> and <PageDown> -shouldn't either. - -Completion: case sensitiveness when typing BS: make it an option? - Completion: When back at the original word behave like after BS. Completion: When to get out of the BS state when the user keeps on typing? @@ -89,11 +77,16 @@ windows. Let's call them "tab pages". Crash with X command server (Ciaran McCreesh). +Make virtcol([lnum, col]) work? + "dip" in end empty lines at end of file leaves one line. (Matt Mzyzik) Ctags still hasn't included the patch. Darren is looking for someone to do maintanance. +Script ID is only remembered for global options. Should remember it for every +local option separately. + "fsutil hardlink" can create a hard link on an NTFS file system. (Daniel Einspanjer) What library function can detect that? diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt index 62b6a917f96c09cd6a1699843540d26922388d08..c8c70559b61a356735582248ed2e98afe4fe7f17 100644 --- a/runtime/doc/usr_41.txt +++ b/runtime/doc/usr_41.txt @@ -1,4 +1,4 @@ -*usr_41.txt* For Vim version 7.0aa. Last change: 2005 Nov 30 +*usr_41.txt* For Vim version 7.0aa. Last change: 2006 Feb 22 VIM USER MANUAL - by Bram Moolenaar @@ -834,7 +834,7 @@ For people who like short functions, this does the same thing: > : return a:num2 :endfunction -A user defined function is called in exactly the same way as a builtin +A user defined function is called in exactly the same way as a built-in function. Only the name is different. The Min function can be used like this: > @@ -2245,7 +2245,7 @@ organize your functions in library scripts. But you must use function names where the part before the '#' matches the script name. Otherwise Vim would not know what script to load. -If you get really enthousiastic and write lots of library scripts, you may +If you get really enthusiastic and write lots of library scripts, you may want to use subdirectories. Example: > call netlib#ftp#read('somefile') diff --git a/runtime/doc/version7.txt b/runtime/doc/version7.txt index 4d9fd51c1b74552dffe553c46b18644e8cac1b82..addb5a223411986eb980705b281dfc22bd52d9dc 100644 --- a/runtime/doc/version7.txt +++ b/runtime/doc/version7.txt @@ -1,4 +1,4 @@ -*version7.txt* For Vim version 7.0aa. Last change: 2006 Feb 21 +*version7.txt* For Vim version 7.0aa. Last change: 2006 Feb 22 VIM REFERENCE MANUAL by Bram Moolenaar @@ -388,6 +388,14 @@ CTRL-W <Enter> In the quickfix window: opens a new window to show the <A-RightMouse> ('mousemodel' "extend") Make a blockwise selection. |<A-LeftMouse>| +gF Start editing the filename under the cursor and jump + to the line number following the file name. + (Yegappan Lakshmanan) + +CTRL-W F Start editing the filename under the cursor in a new + window and jump to the line number following the file + name. (Yegappan Lakshmanan) + Insert mode commands: ~ CTRL-\ CTRL-O Execute a Normal mode command. Like CTRL-O but @@ -800,9 +808,6 @@ upper case. Add color support to the builtin vt320 terminal codes. For the '%' item in 'viminfo', allow a number to set a maximum for the number of buffers. -The 'statusline' option can be local to the window, so that each window can -have a different value. (partly by Yegappan Lakshmanan) - When a file looks like a shell script, check for an "exec" command that starts the tcl interpreter. (suggested by Alexios Zavras) @@ -1018,12 +1023,20 @@ Insert mode completion for whole lines now also searches unloaded buffers. The colortest.vim script can now be invoked directly with ":source" or ":runtime". +The 'statusline' option can be local to the window, so that each window can +have a different value. (partly by Yegappan Lakshmanan) + The 'statusline' option and other options that support the same format can now use these new features: - When it starts with "%!" the value is first evaluated as an expression before parsing the value. - "%#HLname#" can be used to start highlighting with HLname. +When 'statusline' is set to something that causes an error message then it is +made empty to avoid an endless redraw loop. Also for other options, such at +'tabline'. ":verbose set statusline" will mention that it was set in an error +handler. + ============================================================================== COMPILE TIME CHANGES *compile-changes-7* @@ -1722,4 +1735,8 @@ When editing in an xterm with a different number of colors than expected the screen would be cleared and redrawn, causing the message about the edited file to be cleared. Now set "keep_msg" to redraw the last message. +For a color terminal: When the Normal HL uses bold, possibly to make the color +lighter, and another HL group specifies a color it might become light as well. +Now reset bold if a HL group doesn't specify bold itself. + vim:tw=78:ts=8:ft=help:norl: diff --git a/runtime/doc/windows.txt b/runtime/doc/windows.txt index a83bdd2968db56c7fc04d6cf0f9d8f4454372af7..97e015e0c342920fedf54ab6717e031a3bfe22e1 100644 --- a/runtime/doc/windows.txt +++ b/runtime/doc/windows.txt @@ -714,6 +714,11 @@ CTRL-W CTRL-F Split current window in two. Edit file name under cursor. {not available when the |+file_in_path| feature was disabled at compile time} +CTRL-W F *CTRL-W_F* + Split current window in two. Edit file name under cursor and + jump to the line number following the file name. See |gF| for + details on how the line number is obtained. + Also see |CTRL-W_CTRL-I|: open window for an included file that includes the keyword under the cursor. diff --git a/src/buffer.c b/src/buffer.c index 12ee1b3b53665c276975765f3cd7f03bbf85569e..101d33f831771157fa6932af8e99fc1e0702a8a8 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 7170835d4b7d767807685e651ae5057635d33481..b28e127ccfae327129f812d3e0ac5a7af5557ad1 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 b57b56707eba69be98def2d52d78f5e3633d8e80..d159911bb0b1b67cf304ee7dfde26437512a53f5 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. @@ -2162,6 +2163,21 @@ ins_compl_add(str, len, fname, extra, cdir, flags) return OK; } +/* + * 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". */ @@ -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. */ @@ -3890,6 +3936,29 @@ ins_compl_key2count(c) return 1; } +/* + * 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. @@ -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 506cfa5bb5bf3a06c5a9977cf3ee5f0307c660ac..fef09d02f7dd32f0e6a42f991ba9e624523be483 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 15b695a4be390cd36aefaca90b7669eb2742933e..235a6b13da3f8cfeab3b88505711ca854f089dc3 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 b2a9327f14b380894e0b286682878f0797d888f7..575a185f377e9f1229a8aed11f3c4288a10c2c35 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 5798250d722884384fd63aa0df58a3b30ce8d0c4..73bf420f60cf8fa0b7f5a9479eba341d09dc8a05 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 ed5a653d9bd5484ad36b54ee580b0b7e789b92db..60c62d57949e4e3092b55b71fd7453ed07a0074e 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 e1dda7e3e815bb8469a14cd69d1dd7901ba4e81d..4e23d6335962d5590f40575b80129005a6b3b317 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 5162b78c873f7ec31efc77a5235882dd3cba89a9..d46b10c3c120251c8ea01778ac1cec96d4b29227 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 0047a26a32cb21e65aa93275765b0e5c9999efd9..3a1b31cdd11764ed03c4b38f14bc1d7c5c3a2a64 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 a8eac10a30dfe4019c5a4be635b1c5a4dc92641a..0bcd023fe0d80e37dedc7ad8e7171217a9d1fa02 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 61905b0a7a6268b7fdbd2785293d1346e01e0eca..a467bbcad52a3c4873860df251bdbb0305a694b4 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 755f74ef2f72435c72dd2f28bf1ebf7f79bbfa52..705acf5ef4898e2e109e6544c2d5e63fc8db2a5b 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 1b33091a9447d1f5f38f661f97e8ec320d2710bf..323f1a0077ab735d718852a12f10318a4d546ad1 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 a3b2d3ce3bfe0fdcd62a663ca589567f85c55054..09b9ab1dc1628869ba97a116077f03406cca3dcc 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 79a5174ab95cdc2f5f4ad52dcb33f5892481b5c6..9a2f06d01969a3fae994b37198370dcf9fd66303 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 d910bbe869b46a5a2774608c1f7e0c4b5e80e168..07857f5baf43d64b67c23fef5b7851954a8411cc 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 a48b6be64c44fc9d13ee259eb420275ce0e6a871..c9a4dd2a70c5c7c3fce4d43cab04e9967eab39d1 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 bc53237eba35d8b250750c084cf5930482b7a7e1..192500010fdb0c91a4e128b546bcc6d95d9edeb4 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 57da84222459367cd305a97445ee6fde8c3c25b4..ebf154b5afdceb0a54447143d8942b020c693ddc 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 07ec64c06c42831c84d0f37c84caa32689a4d5c2..73ad5306e1ce52db789216030e87fe91653e27a9 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 5434b1c1b3e2e4908bb40bc30236c5ac25a0f106..66df8f590c55c7f96a422b9902f0c652e30b52b4 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 4a49d892167c5465b03520eb1c0a41065465f1b3..fbe2f095a973a513d648f2d1c67a13abcf81ebcd 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 cda7b060d5b6149620c37730a73c99593d26077c..ca0de7a28a7721074bee73ebc92c707071b96a85 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 2ffce40a81094f73711a5c2c3eae146a8ac5258d..a29f0678457f68ecb9083cc4657d6f6b8b299595 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 33037cfa725be8a8b410c8789287f1e274d33312..07cf99145f655eb43f5ea234aac56614c6c18363 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 d50634465382f7b0853d1e16942a65d35e9e4d44..c0be23ba77690b73ec2e10b82c743cc6a4e0bd7f 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 98d7ea912632444d52078fe3a79a9476fb738729..4d1928e894196f5a78700a4f7e3782ce6a25624a 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 94125a8fe81595a99634235bc45a8cb21fd6f647..f9d6d2dd9502c2650a5a01def2b89db98b2e2fd3 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 9e8fe2dbb8f8622ac35dac096cb998af9b930df3..0ebd781e6ddf67336d65dea66ba01a3269ec275a 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 e4e26df6c1209f575b830dadde81a05205d4ffc9..2a4a8cfb978b1d7f70638ae009540ec889e5d58f 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 3419a01e0fe935b1342f4971f48442cb838d9fc9..548113dfc087511080d385c11c1115d82329578b 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; }