mirror of
https://github.com/vim/vim.git
synced 2025-07-04 23:07:33 -04:00
updated for version 7.0052
This commit is contained in:
parent
5313dcb75a
commit
05159a0c6a
@ -1,4 +1,4 @@
|
||||
*change.txt* For Vim version 7.0aa. Last change: 2005 Feb 21
|
||||
*change.txt* For Vim version 7.0aa. Last change: 2005 Feb 23
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@ -527,7 +527,7 @@ comment (starting with '"') after the ":!" command.
|
||||
|
||||
4.2 Substitute *:substitute*
|
||||
*:s* *:su*
|
||||
:[range]s[ubstitute]/{pattern}/{string}/[&][#][c][e][g][p][r][i][I] [count]
|
||||
:[range]s[ubstitute]/{pattern}/{string}/[flags] [count]
|
||||
For each line in [range] replace a match of {pattern}
|
||||
with {string}.
|
||||
For the {pattern} see |pattern|.
|
||||
@ -539,31 +539,31 @@ comment (starting with '"') after the ":!" command.
|
||||
starting with the last line in [range]. When [range]
|
||||
is omitted start in the current line.
|
||||
Also see |cmdline-ranges|.
|
||||
See |:s_flags| for the flags.
|
||||
See |:s_flags| for [flags].
|
||||
|
||||
:[range]s[ubstitute] [#][c][e][g][p][r][i][I] [count]
|
||||
:[range]&[&][#][c][e][g][p][r][i][I] [count] *:&*
|
||||
:[range]s[ubstitute] [flags] [count]
|
||||
:[range]&[&][flags] [count] *:&*
|
||||
Repeat last :substitute with same search pattern and
|
||||
substitute string, but without the same flags. You
|
||||
may add extra flags (see |:s_flags|).
|
||||
may add [flags], see |:s_flags|.
|
||||
Note that after ":substitute" the '&' flag can't be
|
||||
used, it's recognized as a pattern separator.
|
||||
The space between ":substitute" and the 'c', 'g' and
|
||||
'r' flags isn't required, but in scripts it's a good
|
||||
idea to keep it to avoid confusion.
|
||||
|
||||
:[range]~[&][#][c][e][g][p][r][i][I] [count] *:~*
|
||||
:[range]~[&][flags] [count] *:~*
|
||||
Repeat last substitute with same substitute string
|
||||
but with last used search pattern. This is like
|
||||
":&r". See |:s_flags| for the flags.
|
||||
":&r". See |:s_flags| for [flags].
|
||||
|
||||
*&*
|
||||
*&*
|
||||
& Synonym for ":s//~/" (repeat last substitute). Note
|
||||
that the flags are not remembered, thus it might
|
||||
actually work differently. You can use ":&&" to keep
|
||||
the flags.
|
||||
|
||||
*g&*
|
||||
*g&*
|
||||
g& Synonym for ":%s//~/&" (repeat last substitute on all
|
||||
lines with the same flags).
|
||||
Mnemonic: global substitute. {not in Vi}
|
||||
@ -629,6 +629,10 @@ The flags that you can use for the substitute commands:
|
||||
options are not used.
|
||||
{not in Vi}
|
||||
|
||||
[n] Report the number of matches, do not actually substitute. The [c]
|
||||
flag is ignored. The matches are reported as if 'report' is zero.
|
||||
Useful to |count-items|.
|
||||
|
||||
[p] Print the line containing the last substitute.
|
||||
|
||||
[#] Like [p] and prepend the line number.
|
||||
|
@ -1,4 +1,4 @@
|
||||
*debugger.txt* For Vim version 7.0aa. Last change: 2005 Jan 29
|
||||
*debugger.txt* For Vim version 7.0aa. Last change: 2005 Feb 23
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Gordon Prieur
|
||||
@ -90,8 +90,8 @@ was to allow Sun's Visual WorkShop debugger to display expression evaluations.
|
||||
However, the feature was implemented in as general a manner as possible and
|
||||
could be used for displaying other information as well.
|
||||
|
||||
The Balloon Evaluation has some settable parameters too. The font list and
|
||||
colors can be set via X resources (XmNballoonEvalFontList,
|
||||
The Balloon Evaluation has some settable parameters too. For Motif the font
|
||||
list and colors can be set via X resources (XmNballoonEvalFontList,
|
||||
XmNballoonEvalBackground, and XmNballoonEvalForeground).
|
||||
The 'balloondelay' option sets the delay before an attempt is made to show a
|
||||
balloon.
|
||||
|
@ -1,4 +1,4 @@
|
||||
*eval.txt* For Vim version 7.0aa. Last change: 2005 Feb 21
|
||||
*eval.txt* For Vim version 7.0aa. Last change: 2005 Feb 26
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@ -961,7 +961,7 @@ variable internal variable
|
||||
See below |internal-variables|.
|
||||
|
||||
|
||||
function call *expr-function* *E116* *E117* *E118* *E119* *E120*
|
||||
function call *expr-function* *E116* *E118* *E119* *E120*
|
||||
-------------
|
||||
function(expr1, ...) function call
|
||||
See below |functions|.
|
||||
@ -1270,6 +1270,10 @@ v:prevcount The count given for the last but one Normal mode command.
|
||||
:vmap % <Esc>:call MyFilter(v:prevcount)<CR>
|
||||
< Read-only.
|
||||
|
||||
*v:profiling* *profiling-variable*
|
||||
v:profiling Normally zero. Set to one after using ":profile start".
|
||||
See |profiling|.
|
||||
|
||||
*v:progname* *progname-variable*
|
||||
v:progname Contains the name (with path removed) with which Vim was
|
||||
invoked. Allows you to do special initialisations for "view",
|
||||
@ -1396,6 +1400,7 @@ did_filetype() Number TRUE if FileType autocommand event used
|
||||
diff_filler( {lnum}) Number diff filler lines about {lnum}
|
||||
diff_hlID( {lnum}, {col}) Number diff highlighting at {lnum}/{col}
|
||||
empty( {expr}) Number TRUE if {expr} is empty
|
||||
errorlist() List list of quickfix items
|
||||
escape( {string}, {chars}) String escape {chars} in {string} with '\'
|
||||
eval( {string}) any evaluate {string} into its value
|
||||
eventhandler( ) Number TRUE if inside an event handler
|
||||
@ -1965,6 +1970,28 @@ empty({expr}) *empty()*
|
||||
For a long List this is much faster then comparing the length
|
||||
with zero.
|
||||
|
||||
errorlist() *errorlist()*
|
||||
Returns a list with all the current quickfix errors. Each
|
||||
list item is a dictionary with these entries:
|
||||
bufnr number of buffer that has the file name, use
|
||||
bufname() to get the name
|
||||
lnum line number in the buffer (first line is 1)
|
||||
col column number (first column is 1)
|
||||
vcol non-zero: column number is visual column
|
||||
zero: column number is byte index
|
||||
nr error number
|
||||
text description of the error
|
||||
type type of the error, 'E', '1', etc.
|
||||
valid non-zero: recognized error message
|
||||
|
||||
Useful application: Find pattern matches in multiple files and
|
||||
do something with them: >
|
||||
:vimgrep /theword/jg *.c
|
||||
:for d in errorlist()
|
||||
: echo bufname(d.bufnr) ':' d.lnum '=' d.text
|
||||
:endfor
|
||||
|
||||
|
||||
escape({string}, {chars}) *escape()*
|
||||
Escape the characters in {chars} that occur in {string} with a
|
||||
backslash. Example: >
|
||||
@ -3031,7 +3058,14 @@ match({expr}, {pat}[, {start}[, {count}]]) *match()*
|
||||
:echo match("testing", "ing") " results in 4
|
||||
:echo match([1, 'x'], '\a') " results in 2
|
||||
< See |string-match| for how {pat} is used.
|
||||
|
||||
*strpbrk()*
|
||||
Vim doesn't have a strpbrk() function. But you can do: >
|
||||
:let sepidx = match(line, '[.,;: \t]')
|
||||
< *strcasestr()*
|
||||
Vim doesn't have a strcasestr() function. But you can add
|
||||
"\c" to the pattern to ignore case: >
|
||||
:let idx = match(haystack, '\cneedle')
|
||||
<
|
||||
When {count} is given use the {count}'th match. When a match
|
||||
is found in a String the search for the next one starts on
|
||||
character further. Thus this example results in 1: >
|
||||
@ -3063,6 +3097,13 @@ matchend({expr}, {pat}[, {start}[, {count}]]) *matchend()*
|
||||
the match. Example: >
|
||||
:echo matchend("testing", "ing")
|
||||
< results in "7".
|
||||
*strspn()* *strcspn()*
|
||||
Vim doesn't have a strspn() or strcspn() function, but you can
|
||||
do it with matchend(): >
|
||||
:let span = matchend(line, '[a-zA-Z]')
|
||||
:let span = matchend(line, '[^a-zA-Z]')
|
||||
< Except that -1 is returned when there are no matches.
|
||||
|
||||
The {start}, if given, has the same meaning as for match(). >
|
||||
:echo matchend("testing", "ing", 2)
|
||||
< results in "7". >
|
||||
@ -3620,7 +3661,10 @@ stridx({haystack}, {needle} [, {start}]) *stridx()*
|
||||
:echo stridx("An Example", "Example") 3
|
||||
:echo stridx("Starting point", "Start") 0
|
||||
:echo stridx("Starting point", "start") -1
|
||||
<
|
||||
< *strstr()* *strchr()*
|
||||
stridx() works similar to the C function strstr(). When used
|
||||
with a single character it works similar to strchr().
|
||||
|
||||
*string()*
|
||||
string({expr}) Return {expr} converted to a String. If {expr} is a Number,
|
||||
String or a composition of them, then the result can be parsed
|
||||
@ -3673,7 +3717,10 @@ strridx({haystack}, {needle} [, {start}]) *strridx()*
|
||||
If the {needle} is empty the length of {haystack} is returned.
|
||||
See also |stridx()|. Examples: >
|
||||
:echo strridx("an angry armadillo", "an") 3
|
||||
<
|
||||
< *strrchr()*
|
||||
When used with a single character it works similar to the C
|
||||
function strrchr().
|
||||
|
||||
strtrans({expr}) *strtrans()*
|
||||
The result is a String, which is {expr} with all unprintable
|
||||
characters translated into printable characters |'isprint'|.
|
||||
@ -3769,7 +3816,7 @@ system({expr} [, {input}]) *system()* *E677*
|
||||
When {input} is given, this string is written to a file and
|
||||
passed as stdin to the command. The string is written as-is,
|
||||
you need to take care of using the correct line separators
|
||||
yourself.
|
||||
yourself. Pipes are not used.
|
||||
Note: newlines in {expr} may cause the command to fail. The
|
||||
characters in 'shellquote' and 'shellxquote' may also cause
|
||||
trouble.
|
||||
@ -4081,6 +4128,7 @@ path_extra Compiled with up/downwards search in 'path' and 'tags'
|
||||
perl Compiled with Perl interface.
|
||||
postscript Compiled with PostScript file printing.
|
||||
printer Compiled with |:hardcopy| support.
|
||||
profile Compiled with |:profile| support.
|
||||
python Compiled with Python interface.
|
||||
qnx QNX version of Vim.
|
||||
quickfix Compiled with |quickfix| support.
|
||||
@ -4384,6 +4432,8 @@ the "autoload" directory in 'runtimepath'.
|
||||
|
||||
Using an autocommand ~
|
||||
|
||||
This is introduced in the user manual, section |41.14|.
|
||||
|
||||
The autocommand is useful if you have a plugin that is a long Vim script file.
|
||||
You can define the autocommand and quickly quit the script with |:finish|.
|
||||
That makes Vim startup faster. The autocommand should then load the same file
|
||||
@ -4400,6 +4450,8 @@ The file "~/vim/bufnetfuncs.vim" should then define functions that start with
|
||||
|
||||
Using an autoload script ~
|
||||
*autoload* *E746*
|
||||
This is introduced in the user manual, section |41.15|.
|
||||
|
||||
Using a script in the "autoload" directory is simpler, but requires using
|
||||
exactly the right file name. A function that can be autoloaded has a name
|
||||
like this: >
|
||||
|
@ -1,4 +1,4 @@
|
||||
*indent.txt* For Vim version 7.0aa. Last change: 2004 Sep 02
|
||||
*indent.txt* For Vim version 7.0aa. Last change: 2005 Feb 24
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@ -485,6 +485,20 @@ to get do loops indented in .f90 files and left alone in Fortran files with
|
||||
other extensions such as .for.
|
||||
|
||||
|
||||
PYTHON *python-indent*
|
||||
|
||||
The amount of indent can be set for the following situations. The examples
|
||||
given are de the defaults. Note that the variables are set to an expression,
|
||||
so that you can change the value of 'shiftwidth' later.
|
||||
|
||||
Indent after an open paren: >
|
||||
let g:pyindent_open_paren = '&sw * 2'
|
||||
Indent after a nested paren: >
|
||||
let g:pyindent_nested_paren = '&sw'
|
||||
Indent for a continuation line: >
|
||||
let g:pyindent_continue = '&sw * 2'
|
||||
|
||||
|
||||
VERILOG *verilog-indent*
|
||||
|
||||
General block statements such as if, for, case, always, initial, function,
|
||||
|
@ -1,4 +1,4 @@
|
||||
*index.txt* For Vim version 7.0aa. Last change: 2005 Jan 31
|
||||
*index.txt* For Vim version 7.0aa. Last change: 2005 Feb 25
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@ -1258,10 +1258,13 @@ The commands are sorted on the non-optional part of their name.
|
||||
|:options| :opt[ions] open the options-window
|
||||
|:ounmap| :ou[nmap] like ":unmap" but for Operator-pending mode
|
||||
|:ounmenu| :ounme[nu] remove menu for Operator-pending mode
|
||||
|:print| :p[rint] print lines
|
||||
|:pclose| :pc[lose] close preview window
|
||||
|:pedit| :ped[it] edit file in the preview window
|
||||
|:perl| :pe[rl] execute Perl command
|
||||
|:print| :p[rint] print lines
|
||||
|:profile| :prof[ile] profiling functions and scripts
|
||||
|:promptfind| :pro[mtfind] open GUI dialog for searching
|
||||
|:promptrepl| :promtr[epl] open GUI dialog for search/replace
|
||||
|:perldo| :perld[o] execute Perl command for each line
|
||||
|:pop| :po[p] jump to older entry in tag stack
|
||||
|:popup| :pop[up] popup a menu by name
|
||||
|
@ -1,4 +1,4 @@
|
||||
*options.txt* For Vim version 7.0aa. Last change: 2005 Feb 21
|
||||
*options.txt* For Vim version 7.0aa. Last change: 2005 Feb 23
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@ -2986,7 +2986,8 @@ A jump table for the options with a short description can be found at |Q_op|.
|
||||
font names a list can be specified, font names separated with commas.
|
||||
The first valid font is used.
|
||||
|
||||
When 'guifontset' is not empty, 'guifont' is not used.
|
||||
On systems where 'guifontset' is supported (X11) and 'guifontset' is
|
||||
not empty, then 'guifont' is not used.
|
||||
|
||||
Spaces after a comma are ignored. To include a comma in a font name
|
||||
precede it with a backslash. Setting an option requires an extra
|
||||
@ -3003,7 +3004,7 @@ A jump table for the options with a short description can be found at |Q_op|.
|
||||
the case of X). The font names given should be "normal" fonts. Vim
|
||||
will try to find the related bold and italic fonts.
|
||||
|
||||
For Win32, GTK and Photon only: >
|
||||
For Win32, GTK, Mac OS and Photon: >
|
||||
:set guifont=*
|
||||
< will bring up a font requester, where you can pick the font you want.
|
||||
|
||||
@ -3013,7 +3014,10 @@ A jump table for the options with a short description can be found at |Q_op|.
|
||||
For the GTK+ 2 GUI the font name looks like this: >
|
||||
:set guifont=Andale\ Mono\ 11
|
||||
< That's all. XLFDs are no longer accepted.
|
||||
*E236*
|
||||
|
||||
For Mac OSX you can use something like this: >
|
||||
:set guifont=Monaco:h10
|
||||
< *E236*
|
||||
Note that the fonts must be mono-spaced (all characters have the same
|
||||
width). An exception is GTK 2: all fonts are accepted, but
|
||||
mono-spaced fonts look best.
|
||||
|
@ -1,4 +1,4 @@
|
||||
*quickfix.txt* For Vim version 7.0aa. Last change: 2005 Feb 06
|
||||
*quickfix.txt* For Vim version 7.0aa. Last change: 2005 Feb 24
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@ -30,6 +30,11 @@ The idea is to save the error messages from the compiler in a file and use Vim
|
||||
to jump to the errors one by one. You can examine each problem and fix it,
|
||||
without having to remember all the error messages.
|
||||
|
||||
In Vim the quickfix commands are used more generally to find a list of
|
||||
positions in files. For example, |:vimgrep| finds pattern matches. You can
|
||||
use the positions in a script with the |errorlist()| function. Thus you can
|
||||
do a lot more than the edit/compile/fix cycle!
|
||||
|
||||
If you are using Manx's Aztec C compiler on the Amiga look here for how to use
|
||||
it with Vim: |quickfix-manx|. If you are using another compiler you should
|
||||
save the error messages in a file and start Vim with "vim -q filename". An
|
||||
@ -170,12 +175,14 @@ height manually (e.g., by dragging the status line above it with the mouse).
|
||||
|
||||
In the quickfix window, each line is one error. The line number is equal to
|
||||
the error number. You can use ":.cc" to jump to the error under the cursor.
|
||||
Hitting the <CR> key or double-clicking the mouse on a line has the same
|
||||
Hitting the <Enter> key or double-clicking the mouse on a line has the same
|
||||
effect. The file containing the error is opened in the window above the
|
||||
quickfix window. If there already is a window for that file, it is used
|
||||
instead. If the buffer in the used window has changed, and the error is in
|
||||
another file, jumping to the error will fail. You will first have to make
|
||||
sure the window contains a buffer which can be abandoned.
|
||||
*CTRL-W_<Enter>* *CTRL-W_<CR>*
|
||||
You can use CTRL-W <Enter> to open a new window and jump to the error there.
|
||||
|
||||
When the quickfix window has been filled, two autocommand events are
|
||||
triggered. First the 'filetype' option is set to "qf", which triggers the
|
||||
@ -303,16 +310,25 @@ advantages are:
|
||||
5.1 using Vim's internal grep
|
||||
|
||||
*:vim* *:vimgrep* *E682* *E683*
|
||||
:vim[grep][!] /{pattern}/ {file} ...
|
||||
:vim[grep][!] /{pattern}/[g][j] {file} ...
|
||||
Search for {pattern} in the files {file} ... and set
|
||||
the error list to the matches.
|
||||
{pattern} if a Vim search pattern. Instead of
|
||||
enclosing it in / any non-ID character |'isident'|
|
||||
can be used, so long as it does not appear in
|
||||
{pattern}.
|
||||
'ignorecase' applies. To overrule it use |/\c| to
|
||||
ignore case or |/\C| to match case. 'smartcase' is
|
||||
not used.
|
||||
Without the 'g' flag each line is added only once.
|
||||
With 'g' every match is added.
|
||||
|
||||
{pattern} is a Vim search pattern. Instead of
|
||||
enclosing it in / any non-ID character (see
|
||||
|'isident'|) can be used, so long as it does not
|
||||
appear in {pattern}.
|
||||
'ignorecase' applies. To overrule it put |/\c| in the
|
||||
pattern to ignore case or |/\C| to match case.
|
||||
'smartcase' is not used.
|
||||
|
||||
Without the 'j' flag Vim jumps to the first match.
|
||||
With 'j' only the quickfix list is updated.
|
||||
With the [!] any changes in the current buffer are
|
||||
abandoned.
|
||||
|
||||
Every second or so the searched file name is displayed
|
||||
to give you an idea of the progress made.
|
||||
Examples: >
|
||||
@ -327,7 +343,8 @@ advantages are:
|
||||
:vimgrep Error *.c
|
||||
<
|
||||
*:vimgrepa* *:vimgrepadd*
|
||||
:vimgrepa[dd][!] [/]{pattern}[/] {file} ...
|
||||
:vimgrepa[dd][!] /{pattern}/[g][j] {file} ...
|
||||
:vimgrepa[dd][!] {pattern} {file} ...
|
||||
Just like ":vimgrep", but instead of making a new list
|
||||
of errors the matches are appended to the current
|
||||
list.
|
||||
@ -462,7 +479,7 @@ not "b:current_compiler". What the command actually does is the following:
|
||||
- Execute ":runtime! compiler/{name}.vim". The plugins are expected to set
|
||||
options with "CompilerSet" and set the "current_compiler" variable to the
|
||||
name of the compiler.
|
||||
- Delete the "CompilerSet user command.
|
||||
- Delete the "CompilerSet" user command.
|
||||
- Set "b:current_compiler" to the value of "current_compiler".
|
||||
- Without "!" the old value of "current_compiler" is restored.
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
*repeat.txt* For Vim version 7.0aa. Last change: 2005 Feb 19
|
||||
*repeat.txt* For Vim version 7.0aa. Last change: 2005 Feb 26
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@ -13,6 +13,7 @@ Chapter 26 of the user manual introduces repeating |usr_26.txt|.
|
||||
3. Complex repeats |complex-repeat|
|
||||
4. Using Vim scripts |using-scripts|
|
||||
5. Debugging scripts |debug-scripts|
|
||||
6. Profiling |profiling|
|
||||
|
||||
==============================================================================
|
||||
1. Single repeats *single-repeat*
|
||||
@ -483,6 +484,7 @@ DEFINING BREAKPOINTS
|
||||
The [lnum] is the line number of the breakpoint. Vim will stop at or after
|
||||
this line. When omitted line 1 is used.
|
||||
|
||||
*:debug-name*
|
||||
{name} is a pattern that is matched with the file or function name. The
|
||||
pattern is like what is used for autocommands. There must be a full match (as
|
||||
if the pattern starts with "^" and ends in "$"). A "*" matches any sequence
|
||||
@ -547,4 +549,88 @@ OBSCURE
|
||||
Undo ":debuggreedy": get debug mode commands directly from the
|
||||
user, don't use typeahead for debug commands.
|
||||
|
||||
==============================================================================
|
||||
6. Profiling *profile* *profiling*
|
||||
|
||||
Profiling means that Vim measures the time that is spend on executing
|
||||
functions and/or scripts. The |+profile| feature is required for this.
|
||||
It is only included when Vim was compiled with "huge" features.
|
||||
{Vi does not have profiling}
|
||||
|
||||
:prof[ile] start {fname} *:prof* *:profile* *E750*
|
||||
Start profiling, write the output in {fname} upon exit.
|
||||
If {fname} already exists it will be overwritten.
|
||||
The variable |v:profiling| is set to one.
|
||||
|
||||
:prof[ile] func {pattern}
|
||||
Profile function that matches the pattern {pattern}.
|
||||
See |:debug-name| for how {pattern} is used.
|
||||
|
||||
:prof[ile][!] file {pattern}
|
||||
Profile script file that matches the pattern {pattern}.
|
||||
See |:debug-name| for how {pattern} is used.
|
||||
This only profiles the script itself, not the functions
|
||||
defined in it.
|
||||
When the [!] is added then all functions defined in the script
|
||||
will also be profiled.
|
||||
|
||||
|
||||
You must always start with a ":profile start fname" command. The resulting
|
||||
file is written when Vim exits. Here is an example of the output, with line
|
||||
numbers prepended for the explanation:
|
||||
|
||||
1 FUNCTION Test2() ~
|
||||
2 Called 1 time ~
|
||||
3 Total time: 0.155251 ~
|
||||
4 Self time: 0.002006 ~
|
||||
5 ~
|
||||
6 count total (s) self (s) ~
|
||||
7 9 0.000096 for i in range(8) ~
|
||||
8 8 0.153655 0.000410 call Test3() ~
|
||||
9 8 0.000070 endfor ~
|
||||
10 " Ask a question ~
|
||||
11 1 0.001341 echo input("give me an answer: ") ~
|
||||
|
||||
The header (lines 1-4) gives the time for the whole function. The "Total"
|
||||
time is the time passed while the function was executing. The "Self" time is
|
||||
the "Total" time reduced by time spent in:
|
||||
- other user defined functions
|
||||
- sourced scripts
|
||||
- executed autocommands
|
||||
- external (shell) commands
|
||||
|
||||
Lines 7-11 show the time spent in each executed line. Lines that are not
|
||||
executed do not count. Thus a comment line is never counted.
|
||||
|
||||
The Count column shows how many times a line was executed. Note that the
|
||||
"for" command in line 7 is executed one more time as the following lines.
|
||||
That is because the line is also executed to detect the end of the loop.
|
||||
|
||||
The time Vim spends waiting for user input isn't counted at all. Thus how
|
||||
long you take to respond to the input() prompt is irrelevant.
|
||||
|
||||
Profiling should give a good indication of where time is spent, but keep in
|
||||
mind there are various things that may clobber the results:
|
||||
|
||||
- The accuracy of the time measured depends on the gettimeofday() system
|
||||
function. It may only be as accurate as 1/100 second, even though the times
|
||||
are displayed in micro seconds.
|
||||
|
||||
- Real elapsed time is measured, if other processes are busy they may cause
|
||||
delays at unpredictable moments. You may want to run the profiling several
|
||||
times and use the lowest results.
|
||||
|
||||
- If you have several commands in one line you only get one time. Split the
|
||||
line to see the time for the individual commands.
|
||||
|
||||
- The time of the lines added up is mostly less than the time of the whole
|
||||
function. There is some overhead in between.
|
||||
|
||||
- Functions that are deleted before Vim exits will not produce profiling
|
||||
information. You can check the |v:profiling| variable if needed: >
|
||||
:if !v:profiling
|
||||
: delfunc MyFunc
|
||||
:endif
|
||||
<
|
||||
|
||||
vim:tw=78:ts=8:ft=help:norl:
|
||||
|
@ -1539,6 +1539,8 @@ $VIMRUNTIME starting.txt /*$VIMRUNTIME*
|
||||
41.11 usr_41.txt /*41.11*
|
||||
41.12 usr_41.txt /*41.12*
|
||||
41.13 usr_41.txt /*41.13*
|
||||
41.14 usr_41.txt /*41.14*
|
||||
41.15 usr_41.txt /*41.15*
|
||||
41.2 usr_41.txt /*41.2*
|
||||
41.3 usr_41.txt /*41.3*
|
||||
41.4 usr_41.txt /*41.4*
|
||||
@ -1824,6 +1826,7 @@ $VIMRUNTIME starting.txt /*$VIMRUNTIME*
|
||||
:d change.txt /*:d*
|
||||
:de change.txt /*:de*
|
||||
:debug repeat.txt /*:debug*
|
||||
:debug-name repeat.txt /*:debug-name*
|
||||
:debugg repeat.txt /*:debugg*
|
||||
:debuggreedy repeat.txt /*:debuggreedy*
|
||||
:del change.txt /*:del*
|
||||
@ -2207,6 +2210,8 @@ $VIMRUNTIME starting.txt /*$VIMRUNTIME*
|
||||
:previous editing.txt /*:previous*
|
||||
:print various.txt /*:print*
|
||||
:pro change.txt /*:pro*
|
||||
:prof repeat.txt /*:prof*
|
||||
:profile repeat.txt /*:profile*
|
||||
:promptfind change.txt /*:promptfind*
|
||||
:promptr change.txt /*:promptr*
|
||||
:promptrepl change.txt /*:promptrepl*
|
||||
@ -2860,7 +2865,9 @@ CTRL-W_+ windows.txt /*CTRL-W_+*
|
||||
CTRL-W_- windows.txt /*CTRL-W_-*
|
||||
CTRL-W_< windows.txt /*CTRL-W_<*
|
||||
CTRL-W_<BS> windows.txt /*CTRL-W_<BS>*
|
||||
CTRL-W_<CR> quickfix.txt /*CTRL-W_<CR>*
|
||||
CTRL-W_<Down> windows.txt /*CTRL-W_<Down>*
|
||||
CTRL-W_<Enter> quickfix.txt /*CTRL-W_<Enter>*
|
||||
CTRL-W_<Left> windows.txt /*CTRL-W_<Left>*
|
||||
CTRL-W_<Right> windows.txt /*CTRL-W_<Right>*
|
||||
CTRL-W_<Up> windows.txt /*CTRL-W_<Up>*
|
||||
@ -2977,7 +2984,6 @@ E113 eval.txt /*E113*
|
||||
E114 eval.txt /*E114*
|
||||
E115 eval.txt /*E115*
|
||||
E116 eval.txt /*E116*
|
||||
E117 eval.txt /*E117*
|
||||
E118 eval.txt /*E118*
|
||||
E119 eval.txt /*E119*
|
||||
E12 message.txt /*E12*
|
||||
@ -3667,6 +3673,7 @@ E747 syntax.txt /*E747*
|
||||
E748 repeat.txt /*E748*
|
||||
E749 eval.txt /*E749*
|
||||
E75 vi_diff.txt /*E75*
|
||||
E750 repeat.txt /*E750*
|
||||
E76 pattern.txt /*E76*
|
||||
E77 message.txt /*E77*
|
||||
E78 motion.txt /*E78*
|
||||
@ -4596,6 +4603,7 @@ docbkxml-syntax syntax.txt /*docbkxml-syntax*
|
||||
docbkxml.vim syntax.txt /*docbkxml.vim*
|
||||
docbook syntax.txt /*docbook*
|
||||
documentation-6 version6.txt /*documentation-6*
|
||||
donate uganda.txt /*donate*
|
||||
dos os_dos.txt /*dos*
|
||||
dos-:cd os_dos.txt /*dos-:cd*
|
||||
dos-CTRL-Break os_dos.txt /*dos-CTRL-Break*
|
||||
@ -4659,6 +4667,7 @@ errorformat-javac quickfix.txt /*errorformat-javac*
|
||||
errorformat-multi-line quickfix.txt /*errorformat-multi-line*
|
||||
errorformat-separate-filename quickfix.txt /*errorformat-separate-filename*
|
||||
errorformats quickfix.txt /*errorformats*
|
||||
errorlist() eval.txt /*errorlist()*
|
||||
escape intro.txt /*escape*
|
||||
escape() eval.txt /*escape()*
|
||||
escape-bar version4.txt /*escape-bar*
|
||||
@ -5890,6 +5899,8 @@ print.txt print.txt /*print.txt*
|
||||
printcap-syntax syntax.txt /*printcap-syntax*
|
||||
printing print.txt /*printing*
|
||||
printing-formfeed print.txt /*printing-formfeed*
|
||||
profile repeat.txt /*profile*
|
||||
profiling repeat.txt /*profiling*
|
||||
progname-variable eval.txt /*progname-variable*
|
||||
progress-syntax syntax.txt /*progress-syntax*
|
||||
progress.vim syntax.txt /*progress.vim*
|
||||
@ -5907,6 +5918,7 @@ python-current if_pyth.txt /*python-current*
|
||||
python-error if_pyth.txt /*python-error*
|
||||
python-eval if_pyth.txt /*python-eval*
|
||||
python-examples if_pyth.txt /*python-examples*
|
||||
python-indent indent.txt /*python-indent*
|
||||
python-input if_pyth.txt /*python-input*
|
||||
python-output if_pyth.txt /*python-output*
|
||||
python-range if_pyth.txt /*python-range*
|
||||
@ -6200,13 +6212,20 @@ startup-terminal term.txt /*startup-terminal*
|
||||
static-tag tagsrch.txt /*static-tag*
|
||||
status-line windows.txt /*status-line*
|
||||
statusmsg-variable eval.txt /*statusmsg-variable*
|
||||
strcasestr() eval.txt /*strcasestr()*
|
||||
strchr() eval.txt /*strchr()*
|
||||
strcspn() eval.txt /*strcspn()*
|
||||
strftime() eval.txt /*strftime()*
|
||||
stridx() eval.txt /*stridx()*
|
||||
string() eval.txt /*string()*
|
||||
string-match eval.txt /*string-match*
|
||||
strlen() eval.txt /*strlen()*
|
||||
strpart() eval.txt /*strpart()*
|
||||
strpbrk() eval.txt /*strpbrk()*
|
||||
strrchr() eval.txt /*strrchr()*
|
||||
strridx() eval.txt /*strridx()*
|
||||
strspn() eval.txt /*strspn()*
|
||||
strstr() eval.txt /*strstr()*
|
||||
strtrans() eval.txt /*strtrans()*
|
||||
style-changes develop.txt /*style-changes*
|
||||
style-examples develop.txt /*style-examples*
|
||||
@ -6902,8 +6921,10 @@ write-compiler-plugin usr_41.txt /*write-compiler-plugin*
|
||||
write-device editing.txt /*write-device*
|
||||
write-fail editing.txt /*write-fail*
|
||||
write-filetype-plugin usr_41.txt /*write-filetype-plugin*
|
||||
write-library-script usr_41.txt /*write-library-script*
|
||||
write-local-help usr_41.txt /*write-local-help*
|
||||
write-plugin usr_41.txt /*write-plugin*
|
||||
write-plugin-quickload usr_41.txt /*write-plugin-quickload*
|
||||
write-quit editing.txt /*write-quit*
|
||||
write-readonly editing.txt /*write-readonly*
|
||||
writefile() eval.txt /*writefile()*
|
||||
|
@ -1,4 +1,4 @@
|
||||
*tips.txt* For Vim version 7.0aa. Last change: 2004 Feb 17
|
||||
*tips.txt* For Vim version 7.0aa. Last change: 2005 Feb 23
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@ -201,21 +201,22 @@ abbreviations that correct them. For example: >
|
||||
==============================================================================
|
||||
Counting words, lines, etc. *count-items*
|
||||
|
||||
To count how often any pattern occurs in a buffer, set 'report' to 0, and use
|
||||
the substitute command to replace the pattern with itself. The reported
|
||||
number of substitutions is the number of items. Examples: >
|
||||
To count how often any pattern occurs in the current buffer use the substitute
|
||||
command and add the 'n' flag to avoid the substitution. The reported number
|
||||
of substitutions is the number of items. Examples: >
|
||||
|
||||
:set report=0
|
||||
:%s/./&/g characters
|
||||
:%s/\i\+/&/g words
|
||||
:%s/^ lines
|
||||
:%s/the/&/g "the" anywhere
|
||||
:%s/\<the\>/&/g "the" as a word
|
||||
:%s/./&/gn characters
|
||||
:%s/\i\+/&/gn words
|
||||
:%s/^//n lines
|
||||
:%s/the/&/gn "the" anywhere
|
||||
:%s/\<the\>/&/gn "the" as a word
|
||||
|
||||
You might want to reset 'hlsearch' or do ":nohlsearch".
|
||||
Add the 'e' flag if you don't want an error when there are no matches.
|
||||
|
||||
This does not work if the 'modifiable' option is off. An alternative is using
|
||||
|v_g_CTRL-G| in Visual mode.
|
||||
An alternative is using |v_g_CTRL-G| in Visual mode.
|
||||
|
||||
If you want to find matches in multiple files use |:vimgrep|.
|
||||
|
||||
*count-bytes*
|
||||
If you want to count bytes, you can use this:
|
||||
|
@ -1,4 +1,4 @@
|
||||
*todo.txt* For Vim version 7.0aa. Last change: 2005 Feb 21
|
||||
*todo.txt* For Vim version 7.0aa. Last change: 2005 Feb 26
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@ -30,14 +30,21 @@ be worked on, but only if you sponsor Vim development. See |sponsor|.
|
||||
*known-bugs*
|
||||
-------------------- Known bugs and current work -----------------------
|
||||
|
||||
Test11 sometimes fails. Must be a problem with fork() and pipes.
|
||||
|
||||
'sw' is sometimes 8 when using :vimgrep.
|
||||
|
||||
Mingw can use setjmp()? Move code from os_unix.c to common file, adjust
|
||||
#ifdefs. Try with example from Michaelis.
|
||||
|
||||
Russian helpfile doesn't show up correctly when 'encoding' is koi8-r.
|
||||
(Vassily Ragosin 2005 Feb 16)
|
||||
|
||||
Mac unicode patch (Da Woon Jung):
|
||||
- default font is ugly
|
||||
- typing doesn't work
|
||||
- selecting proportional font breaks display
|
||||
|
||||
autoload:
|
||||
- Add docs in user manual: one for using one script and FuncUndefined and one
|
||||
for using autoload with two scripts.
|
||||
- Add a Vim script in $VIMRUNTIME/tools that takes a file with a list of
|
||||
script names and a help file and produces a script that can be sourced to
|
||||
install the scripts in the user's directories.
|
||||
@ -48,20 +55,13 @@ autoload:
|
||||
helpfile doc/myscript.txt
|
||||
For the "helpfile" item ":helptags" is run.
|
||||
|
||||
Patch for 'balloonexpr' option. Sergey Khorev, Feb 26.
|
||||
|
||||
Awaiting response:
|
||||
- Patch for mch_FullName() also in Vim 6.3? os_mswin.c
|
||||
- Win32: tearoff menu window should have a scrollbar when it's taller than
|
||||
the screen.
|
||||
|
||||
Improvements for Python indent script: Peter Wilson.
|
||||
|
||||
Win32: when 'encoding' is "utf-8" getenv() should convert from the active
|
||||
codepage to utf-8, putenv() the other way around. Or use _wgetenv() (but that
|
||||
duplicates the environment).
|
||||
|
||||
Russian helpfile doesn't show up correctly when 'encoding' is koi8-r.
|
||||
(Vassily Ragosin 2005 Feb 16)
|
||||
|
||||
|
||||
PLANNED FOR VERSION 7.0:
|
||||
|
||||
@ -309,9 +309,6 @@ Awaiting updated patches:
|
||||
layout and 'c' for console dialog. (Haegg)
|
||||
Flemming Madsen has a patch for the 'c' flag
|
||||
(2003 May 13)
|
||||
system({cmd}, {expr}) Filter {expr} through the shell command
|
||||
{cmd} and return the result.
|
||||
(Patch from Yegappan Lakshmanan)
|
||||
raisewin() raise gvim window (see HierAssist patch for
|
||||
Tcl implementation ~/vim/HierAssist/ )
|
||||
7 Add patch from Benoit Cerrina to integrate Vim and Perl functions
|
||||
@ -1594,11 +1591,12 @@ Built-in script language:
|
||||
mapname({idx}, mode) return the name of the idx'th mapping.
|
||||
Patch by Ilya Sher, 2004 Mar 4.
|
||||
Return a list instead.
|
||||
sprintf(format, arg, ..) How to prevent a crash???
|
||||
printf(format, arg, ..) How to prevent a crash???
|
||||
char2hex() convert char string to hex string.
|
||||
attributes() return file protection flags "drwxrwxrwx"
|
||||
copy(from, to) Copy a file
|
||||
perl(cmd) call Perl and return string
|
||||
filecopy(from, to) Copy a file
|
||||
shorten(fname) shorten a file name, like home_replace()
|
||||
perl(cmd) call Perl and return string
|
||||
input(prompt, complete) like input() but do specified completion
|
||||
inputrl() like input() but right-to-left
|
||||
virtualmode() add argument to obtain whether "$" was used in
|
||||
@ -1608,14 +1606,10 @@ Built-in script language:
|
||||
getbufline() get line from any buffer
|
||||
deletebufline() delete line in any buffer
|
||||
appendbufline() append line in any buffer
|
||||
sort() Sort a newline-separated string. Also:
|
||||
":sort".
|
||||
libcall() Allow more than one argument.
|
||||
libcallext() Like libcall(), but using a callback function
|
||||
to allow the library to execute a command or
|
||||
evaluate an expression.
|
||||
char2hex() convert char string to hex string. XX
|
||||
hex2char() convert hex string to char string. XX
|
||||
7 Make bufname("'0") return the buffer name from mark '0. How to get the
|
||||
column and line number? col("'0") currently returns zero.
|
||||
8 argc() returns 0 when using "vim -t tag". How to detect that no file was
|
||||
@ -2440,7 +2434,8 @@ Text objects:
|
||||
(Scott Graham) "ac" and "au"?
|
||||
8 Add a text object for any kind of quoting, also with multi-byte
|
||||
characters. Option to specify what quotes are recognized (default: all)
|
||||
use "aq" and "iq".
|
||||
use "aq" and "iq". Use 'quotepairs' to define pairs of quotes, like
|
||||
'matchpairs'?
|
||||
8 Add text object for any kind of parens, also multi-byte ones.
|
||||
7 Add text object for current search pattern: "a/" and "i/". Makes it
|
||||
possible to turn text highlighted for 'hlsearch' into a Visual area.
|
||||
|
@ -1,4 +1,4 @@
|
||||
*uganda.txt* For Vim version 7.0aa. Last change: 2004 Aug 29
|
||||
*uganda.txt* For Vim version 7.0aa. Last change: 2005 Feb 24
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@ -172,7 +172,7 @@ There is a small clinic at the project, which provides children and their
|
||||
family with medical help. When needed, transport to a hospital is offered.
|
||||
Immunization programs are carried out and help is provided when an epidemic is
|
||||
breaking out (measles and cholera have been a problem).
|
||||
|
||||
*donate*
|
||||
Summer 1994 to summer 1995 I spent a whole year at the centre, working as a
|
||||
volunteer. I have helped to expand the centre and worked in the area of water
|
||||
and sanitation. I learned that the help that the KCC provides really helps.
|
||||
|
@ -1,4 +1,4 @@
|
||||
*usr_41.txt* For Vim version 7.0aa. Last change: 2005 Feb 08
|
||||
*usr_41.txt* For Vim version 7.0aa. Last change: 2005 Feb 23
|
||||
|
||||
VIM USER MANUAL - by Bram Moolenaar
|
||||
|
||||
@ -22,6 +22,8 @@ script. There are a lot of them, thus this is a long chapter.
|
||||
|41.11| Writing a plugin
|
||||
|41.12| Writing a filetype plugin
|
||||
|41.13| Writing a compiler plugin
|
||||
|41.14| Writing a plugin that loads quickly
|
||||
|41.15| Writing library scripts
|
||||
|
||||
Next chapter: |usr_42.txt| Add new menus
|
||||
Previous chapter: |usr_40.txt| Make new commands
|
||||
@ -663,6 +665,7 @@ System functions and manipulation of files:
|
||||
executable() check if an executable program exists
|
||||
filereadable() check if a file can be read
|
||||
filewritable() check if a file can be written to
|
||||
mkdir() create a new directory
|
||||
isdirectory() check if a directory exists
|
||||
getcwd() get the current working directory
|
||||
getfsize() get the size of a file
|
||||
@ -742,6 +745,7 @@ Various:
|
||||
maparg() get rhs of a mapping
|
||||
exists() check if a variable, function, etc. exists
|
||||
has() check if a feature is supported in Vim
|
||||
errorlist() list of quickfix errors
|
||||
cscope_connection() check if a cscope connection exists
|
||||
did_filetype() check if a FileType autocommand was used
|
||||
eventhandler() check if invoked by an event handler
|
||||
@ -2128,6 +2132,143 @@ don't check "current_compiler". This plugin is supposed to be loaded
|
||||
last, thus it should be in a directory at the end of 'runtimepath'. For Unix
|
||||
that could be ~/.vim/after/compiler.
|
||||
|
||||
==============================================================================
|
||||
*41.14* Writing a plugin that loads quickly *write-plugin-quickload*
|
||||
|
||||
A plugin may grow and become quite long. The startup delay may become
|
||||
noticable, while you hardly every use the plugin. Then it's time for a
|
||||
quickload plugin.
|
||||
|
||||
The basic idea is that the plugin is loaded twice. The first time user
|
||||
commands and mappings are defined that offer the functionality. The second
|
||||
time the functions that implement the functionality are defined.
|
||||
|
||||
It may sound surprising that quickload means loading a script twice. What we
|
||||
mean is that it loads quickly the first time, postponing the bulk of the
|
||||
script to the second time, which only happens when you actually use it. When
|
||||
you always use the functionality it actually gets slower!
|
||||
|
||||
The following example shows how it's done: >
|
||||
|
||||
" Vim global plugin for demonstrating quick loading
|
||||
" Last Change: 2005 Feb 25
|
||||
" Maintainer: Bram Moolenaar <Bram@vim.org>
|
||||
" License: This file is placed in the public domain.
|
||||
|
||||
if !exists("s:did_load")
|
||||
command -nargs=* BNRead call BufNetRead(<f-args>)
|
||||
map <F19> :call BufNetWrite('something')<CR>
|
||||
|
||||
let s:did_load = 1
|
||||
exe 'au FuncUndefined BufNet* source ' . expand('<sfile>')
|
||||
finish
|
||||
endif
|
||||
|
||||
function BufNetRead(...)
|
||||
echo 'BufNetRead(' . string(a:000) . ')'
|
||||
" read functionality here
|
||||
endfunction
|
||||
|
||||
function BufNetWrite(...)
|
||||
echo 'BufNetWrite(' . string(a:000) . ')'
|
||||
" write functionality here
|
||||
endfunction
|
||||
|
||||
When the script is first loaded "s:did_load" is not set. The commands between
|
||||
the "if" and "endif" will be executed. This ends in a |:finish| command, thus
|
||||
the rest of the script is not executed.
|
||||
|
||||
The second time the script is loaded "s:did_load" exists and the commands
|
||||
after the "endif" are executed. This defines the (possible long)
|
||||
BufNetRead() and BufNetWrite() functions.
|
||||
|
||||
If you drop this script in your plugin directory Vim will execute it on
|
||||
startup. This is the sequence of events that happens:
|
||||
|
||||
1. The "BNRead" command is defined and the <F19> key is mapped when the script
|
||||
is sourced at startup. A |FuncUndefined| autocommand is defined. The
|
||||
":finish" command causes the script to terminate early.
|
||||
|
||||
2. The user types the BNRead command or presses the <F19> key. The
|
||||
BufNetRead() or BufNetWrite() function will be called.
|
||||
|
||||
3. Vim can't find the function and triggers the |FuncUndefined| autocommand
|
||||
event. Since the pattern "BufNet*" matches the invoked function, the
|
||||
command "source fname" will be executed. "fname" will be equal to the name
|
||||
of the script, no matter where it is located, because it comes from
|
||||
expanding "<sfile>" (see |expand()|).
|
||||
|
||||
4. The script is sourced again, the "s:did_load" variable exists and the
|
||||
functions are defined.
|
||||
|
||||
Notice that the functions that are loaded afterwards match the pattern in the
|
||||
|FuncUndefined| autocommand. You must make sure that no other plugin defines
|
||||
functions that match this pattern.
|
||||
|
||||
==============================================================================
|
||||
*41.15* Writing library scripts *write-library-script*
|
||||
|
||||
Some functionality will be required in several places. When this becomes more
|
||||
than a few lines you will want to put it in one script and use it from many
|
||||
scripts. We will call that one script a library script.
|
||||
|
||||
Manually loading a library script is possible, so long as you avoid loading it
|
||||
when it's already done. You can do this with the |exists()| function.
|
||||
Example: >
|
||||
|
||||
if !exists('*MyLibFunction')
|
||||
runtime library/mylibscript.vim
|
||||
endif
|
||||
call MyLibFunction(arg)
|
||||
|
||||
Here you need to know that MyLibFunction() is defined in a script
|
||||
"library/mylibscript.vim" in one of the directories in 'runtimepath'.
|
||||
|
||||
To make this a bit simpler Vim offers the autoload mechanism. Then the
|
||||
example looks like this: >
|
||||
|
||||
call mylib:myfunction(arg)
|
||||
|
||||
That's a lot simpler, isn't it? Vim will recognize the function name and when
|
||||
it's not defined search for the script "autoload/mylib.vim" in 'runtimepath'.
|
||||
That script must define the "mylib:myfunction()" function.
|
||||
|
||||
You can put many other functions in the mylib.vim script, you are free to
|
||||
organize your functions in library scripts. But you must use function names
|
||||
where the part before the colon 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
|
||||
want to use subdirectories. Example: >
|
||||
|
||||
call netlib:ftp:read('somefile')
|
||||
|
||||
For Unix the library script used for this could be:
|
||||
|
||||
~/.vim/autoload/netlib/ftp.vim
|
||||
|
||||
Where the function is defined like this: >
|
||||
|
||||
function netlib:ftp:read(fname)
|
||||
" Read the file fname through ftp
|
||||
endfunction
|
||||
|
||||
Notice that the name the function is defined with is exactly the same as the
|
||||
name used for calling the function. And the part before the last colon
|
||||
exactly matches the subdirectory and script name.
|
||||
|
||||
You can use the same mechanism for variables: >
|
||||
|
||||
let weekdays = dutch:weekdays
|
||||
|
||||
This will load the script "autoload/dutch.vim", which should contain something
|
||||
like: >
|
||||
|
||||
let dutch:weekdays = ['zondag', 'maandag', 'dinsdag', 'woensdag',
|
||||
\ 'donderdag', 'vrijdag', 'zaterdag']
|
||||
|
||||
Further reading: |autoload|.
|
||||
|
||||
==============================================================================
|
||||
|
||||
Next chapter: |usr_42.txt| Add new menus
|
||||
|
@ -1,4 +1,4 @@
|
||||
*usr_toc.txt* For Vim version 7.0aa. Last change: 2005 Feb 06
|
||||
*usr_toc.txt* For Vim version 7.0aa. Last change: 2005 Feb 22
|
||||
|
||||
VIM USER MANUAL - by Bram Moolenaar
|
||||
|
||||
@ -292,6 +292,8 @@ Make Vim work as you like it.
|
||||
|41.11| Writing a plugin
|
||||
|41.12| Writing a filetype plugin
|
||||
|41.13| Writing a compiler plugin
|
||||
|41.14| Writing a plugin that loads quickly
|
||||
|41.15| Writing library scripts
|
||||
|
||||
|usr_42.txt| Add new menus
|
||||
|42.1| Introduction
|
||||
|
@ -1,4 +1,4 @@
|
||||
*version7.txt* For Vim version 7.0aa. Last change: 2005 Feb 21
|
||||
*version7.txt* For Vim version 7.0aa. Last change: 2005 Feb 24
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@ -161,6 +161,9 @@ better portability, handling of different file encodings and using multi-line
|
||||
patterns, this also allows grepping in compressed and remote files.
|
||||
|:vimgrep|.
|
||||
|
||||
If you want to use the search results in a script you can use the
|
||||
|errorlist()| function.
|
||||
|
||||
|
||||
POSIX compatibility *new-posix*
|
||||
-------------------
|
||||
@ -216,6 +219,9 @@ Normal mode commands: ~
|
||||
a", a' and a` New text objects to select quoted strings. |a'|
|
||||
i", i' and i' (Taro Muraoka)
|
||||
|
||||
CTRL-W <Enter> In the quickfix window: opens a new window to show the
|
||||
location of the error under the cursor.
|
||||
|
||||
Options: ~
|
||||
|
||||
'completefunc' The name of a function used for user-specified Insert
|
||||
@ -272,6 +278,7 @@ New functions: ~
|
||||
|count()| count nr of times a value is in a List or Dictionary
|
||||
|deepcopy()| make a full copy of a List or Dictionary
|
||||
|empty()| check if List or Dictionary is empty
|
||||
|errorlist()| list of quickfix errors
|
||||
|extend()| append one List to another or add items from one
|
||||
Dictionary to another
|
||||
|filter()| remove selected items from a List or Dictionary
|
||||
@ -283,7 +290,7 @@ New functions: ~
|
||||
|getfontname()| Get actual font name being used.
|
||||
|getfperm()| Get file permission string. (Nikolai Weibull)
|
||||
|getftype()| Get type of file. (Nikolai Weibull)
|
||||
|getline()| get List with buffer lines
|
||||
|getline()| With second argument: get List with buffer lines
|
||||
|has_key()| check whether a key appears in a Dictionary
|
||||
|insert()| insert an item somewhere in a List
|
||||
|items()| get List of Dictionary key-value pairs
|
||||
@ -367,6 +374,8 @@ The Ukranian messages are now also available in cp1251.
|
||||
|
||||
Irish message translations. (Kevin Patrick Scannell)
|
||||
|
||||
Vietnamese message translations and menu. (Phan Vinh Thinh)
|
||||
|
||||
|
||||
Others: ~
|
||||
|
||||
@ -520,6 +529,12 @@ ignored.
|
||||
When "beep" is included in 'debug' a function or script that causes a beep
|
||||
will result in a message with the source of the error.
|
||||
|
||||
When completing buffer names, match with "\(^\|[\/]\)" instead of "^", so that
|
||||
":buf stor<Tab>" finds both "include/storage.h" and "storage/main.c".
|
||||
|
||||
To count items (pattern matches) without changing the buffer the 'n' flag has
|
||||
been added to |:substitute|. See |count-items|.
|
||||
|
||||
==============================================================================
|
||||
COMPILE TIME CHANGES *compile-changes-7*
|
||||
|
||||
@ -605,6 +620,9 @@ When 'comments' includes multi-byte characters inserting the middle part and
|
||||
alignment may go wrong. 'cindent' also suffers from this for right-aligned
|
||||
items.
|
||||
|
||||
Win32: when 'encoding' is set to "utf-8" getenv() still returns strings in the
|
||||
active codepage. Convert to utf-8. Also for $HOME.
|
||||
|
||||
The default for 'helplang' was "zh" for both "zh_cn" and "zh_tw". Now use
|
||||
"cn" or "tw" as intended.
|
||||
|
||||
@ -868,4 +886,9 @@ Lakshmanan)
|
||||
It was not possible to use a NL after a backslash in Ex mode. This is
|
||||
sometimes used to feed multiple lines to a shell command.
|
||||
|
||||
When 'cmdheight' is set to 2 in .vimrc and the GUI uses the number of lines
|
||||
from the terminal we actually get 3 lines for the cmdline in gvim.
|
||||
|
||||
When setting $HOME allocated memory would leak.
|
||||
|
||||
vim:tw=78:ts=8:ft=help:norl:
|
||||
|
@ -492,9 +492,17 @@ System wide
|
||||
.B Vim
|
||||
initializations.
|
||||
.TP
|
||||
~/.vimrc
|
||||
Your personal
|
||||
.B Vim
|
||||
initializations.
|
||||
.TP
|
||||
/usr/local/lib/vim/gvimrc
|
||||
System wide gvim initializations.
|
||||
.TP
|
||||
~/.gvimrc
|
||||
Your personal gvim initializations.
|
||||
.TP
|
||||
/usr/local/lib/vim/optwin.vim
|
||||
Script used for the ":options" command, a nice way to view and set options.
|
||||
.TP
|
||||
|
@ -370,9 +370,13 @@ FILES
|
||||
/usr/local/lib/vim/vimrc
|
||||
System wide Vim initializations.
|
||||
|
||||
~/.vimrc Your personal Vim initializations.
|
||||
|
||||
/usr/local/lib/vim/gvimrc
|
||||
System wide gvim initializations.
|
||||
|
||||
~/.gvimrc Your personal gvim initializations.
|
||||
|
||||
/usr/local/lib/vim/optwin.vim
|
||||
Script used for the ":options" command, a nice way to
|
||||
view and set options.
|
||||
|
@ -2,7 +2,7 @@
|
||||
" Language: Python
|
||||
" Maintainer: Bram Moolenaar <Bram@vim.org>
|
||||
" Original Author: David Bustos <bustos@caltech.edu>
|
||||
" Last Change: 2005 Feb 08
|
||||
" Last Change: 2005 Feb 24
|
||||
|
||||
" Only load this indent file when no other was loaded.
|
||||
if exists("b:did_indent")
|
||||
@ -22,16 +22,19 @@ if exists("*GetPythonIndent")
|
||||
finish
|
||||
endif
|
||||
|
||||
" Come here when loading the script the first time.
|
||||
|
||||
let s:maxoff = 50 " maximum number of lines to look backwards for ()
|
||||
|
||||
function GetPythonIndent(lnum)
|
||||
|
||||
" If this line is explicitly joined: If the previous line was also joined,
|
||||
" line it up with that one, otherwise add two 'shiftwidth'
|
||||
if getline(a:lnum - 1) =~ '\\$'
|
||||
if a:lnum > 1 && getline(a:lnum - 2) =~ '\\$'
|
||||
return indent(a:lnum - 1)
|
||||
endif
|
||||
return indent(a:lnum - 1) + (&sw * 2)
|
||||
return indent(a:lnum - 1) + (exists("g:pyindent_continue") ? eval(g:pyindent_continue) : (&sw * 2))
|
||||
endif
|
||||
|
||||
" If the start of the line is in a string don't change the indent.
|
||||
@ -84,9 +87,9 @@ function GetPythonIndent(lnum)
|
||||
\ . " synIDattr(synID(line('.'), col('.'), 1), 'name')"
|
||||
\ . " =~ '\\(Comment\\|String\\)$'")
|
||||
if pp > 0
|
||||
return indent(plnum) + &sw
|
||||
return indent(plnum) + (exists("g:pyindent_nested_paren") ? eval(g:pyindent_nested_paren) : &sw)
|
||||
endif
|
||||
return indent(plnum) + (&sw * 2)
|
||||
return indent(plnum) + (exists("g:pyindent_open_paren") ? eval(g:pyindent_open_paren) : (&sw * 2))
|
||||
endif
|
||||
if plnumstart == p
|
||||
return indent(plnum)
|
||||
|
@ -1,7 +1,7 @@
|
||||
" Vim indent file
|
||||
" Language: Vim script
|
||||
" Maintainer: Bram Moolenaar <Bram@vim.org>
|
||||
" Last Change: 2004 Sep 02
|
||||
" Last Change: 2005 Feb 25
|
||||
|
||||
" Only load this indent file when no other was loaded.
|
||||
if exists("b:did_indent")
|
||||
@ -44,7 +44,7 @@ function GetVimIndent()
|
||||
else
|
||||
let ind = ind + &sw * 3
|
||||
endif
|
||||
elseif getline(lnum) =~ '\(^\||\)\s*\(if\|wh\%[ile]\|try\|cat\%[ch]\|fina\%[lly]\|fu\%[nction]\|el\%[seif]\)\>'
|
||||
elseif getline(lnum) =~ '\(^\||\)\s*\(if\|wh\%[ile]\|for\|try\|cat\%[ch]\|fina\%[lly]\|fu\%[nction]\|el\%[seif]\)\>'
|
||||
let ind = ind + &sw
|
||||
elseif getline(lnum) =~ '^\s*aug\%[roup]' && getline(lnum) !~ '^\s*aug\%[roup]\s*!\=\s\+END'
|
||||
let ind = ind + &sw
|
||||
|
294
runtime/lang/menu_vi_vn.vim
Normal file
294
runtime/lang/menu_vi_vn.vim
Normal file
@ -0,0 +1,294 @@
|
||||
" Menu Translations: Vietnamese
|
||||
" Maintainer: Phan Vinh Thinh <teppi@vnlinux.org>
|
||||
" Last Change: 23 Feb 2005
|
||||
" URL: http://iatp.vspu.ac.ru/phan/vietvim/lang/menu_vi_VN.vim
|
||||
"
|
||||
"
|
||||
" Adopted for VietVim project by Phan Vinh Thinh.
|
||||
" First translation: Phan Vinh Thinh <teppi@vnlinux.org>
|
||||
"
|
||||
"
|
||||
" Quit when menu translations have already been done.
|
||||
"
|
||||
if exists("did_menu_trans")
|
||||
finish
|
||||
endif
|
||||
let did_menu_trans = 1
|
||||
|
||||
scriptencoding utf-8
|
||||
|
||||
" Top
|
||||
menutrans &File &Tập\ tin
|
||||
menutrans &Edit &Soạn\ thảo
|
||||
menutrans &Tools &Công\ cụ
|
||||
menutrans &Syntax Cú\ &pháp
|
||||
menutrans &Buffers &Bộ\ đệm
|
||||
menutrans &Window Cử&a\ sổ
|
||||
menutrans &Help Trợ\ &giúp
|
||||
"
|
||||
"
|
||||
"
|
||||
" Help menu
|
||||
menutrans &Overview<Tab><F1> &Tổng\ quan<Tab><F1>
|
||||
menutrans &User\ Manual &Hướng\ dẫn\ sử\ dụng
|
||||
menutrans &How-to\ links &Làm\ như\ thế\ nào
|
||||
menutrans &Find\.\.\. Tìm\ &kiếm\.\.\.
|
||||
"--------------------
|
||||
menutrans &Credits Lời\ &cảm\ ơn
|
||||
menutrans Co&pying &Bản\ quyền
|
||||
menutrans &Sponsor/Register &Giúp\ đỡ/Đăng\ ký
|
||||
menutrans O&rphans Trẻ\ &mồ\ côi
|
||||
"--------------------
|
||||
menutrans &Version &Phiên\ bản
|
||||
menutrans &About &Về\ Vim
|
||||
"
|
||||
"
|
||||
" File menu
|
||||
menutrans &Open\.\.\.<Tab>:e &Mở\.\.\.<Tab>:e
|
||||
menutrans Sp&lit-Open\.\.\.<Tab>:sp &Chia-Mở\.\.\.<Tab>:sp
|
||||
menutrans &New<Tab>:enew Mớ&i<Tab>:enew
|
||||
menutrans &Close<Tab>:close Đó&ng<Tab>:close
|
||||
"--------------------
|
||||
menutrans &Save<Tab>:w &Ghi\ nhớ<Tab>:w
|
||||
menutrans Save\ &As\.\.\.<Tab>:sav Ghi\ n&hư\.\.\.<Tab>:sav
|
||||
"--------------------
|
||||
menutrans Split\ &Diff\ with\.\.\. &So\ sánh\ với\.\.\.
|
||||
menutrans Split\ Patched\ &By\.\.\. So\ sánh\ đã\ vá\ lỗi\ &bởi\.\.\.
|
||||
"--------------------
|
||||
menutrans &Print &In
|
||||
menutrans Sa&ve-Exit<Tab>:wqa Ghi\ nhớ\ rồ&i\ thoát <Tab>:wqa
|
||||
menutrans E&xit<Tab>:qa Th&oát<Tab>:qa
|
||||
"
|
||||
"
|
||||
" Edit menu
|
||||
menutrans &Undo<Tab>u &Hủy\ bước<Tab>u
|
||||
menutrans &Redo<Tab>^R &Làm\ lại<Tab>^R
|
||||
menutrans Rep&eat<Tab>\. Lặ&p lại<Tab>\.
|
||||
"--------------------
|
||||
menutrans Cu&t<Tab>"+x &Cắt<Tab>"+x
|
||||
menutrans &Copy<Tab>"+y &Sao chép<Tab>"+y
|
||||
menutrans &Paste<Tab>"+gP &Dán<Tab>"+gP
|
||||
menutrans Put\ &Before<Tab>[p Dán\ trướ&c<Tab>[p
|
||||
menutrans Put\ &After<Tab>]p Dán\ sa&u<Tab>]p
|
||||
menutrans &Delete<Tab>x &Xóa<Tab>x
|
||||
menutrans &Select\ All<Tab>ggVG Chọ&n\ tất\ cả<Tab>ggVG
|
||||
"--------------------
|
||||
menutrans &Find\.\.\.<Tab>/ &Tìm\ kiếm\.\.\.<Tab>/
|
||||
menutrans Find\ and\ Rep&lace\.\.\. Tìm\ &kiếm\ và\ thay\ thế\.\.\.
|
||||
menutrans Find\ and\ Rep&lace\.\.\.<Tab>:%s Tìm\ &kiếm\ và\ thay\ thế\.\.\.<Tab>:%s
|
||||
menutrans Find\ and\ Rep&lace\.\.\.<Tab>:s Tìm\ &kiếm\ và\ thay\ thế\.\.\<Tab>:s
|
||||
"--------------------
|
||||
menutrans Settings\ &Window &Cửa\ sổ\ thiết\ lập
|
||||
menutrans &Global\ Settings Thiết\ &lập\ toàn\ cầu
|
||||
menutrans F&ile\ Settings Thiết\ lập\ tập\ t&in
|
||||
menutrans C&olor\ Scheme Phối\ hợp\ màu\ &sắc
|
||||
menutrans &Keymap Sơ\ đồ\ &bàn\ phím
|
||||
menutrans Select\ Fo&nt\.\.\. Chọn\ &phông\ chữ\.\.\.
|
||||
">>>----------------- Edit/Global settings
|
||||
menutrans Toggle\ Pattern\ &Highlight<Tab>:set\ hls! &Chiếu\ sáng\ từ\ tìm\ thấy <Tab>:set\ hls!
|
||||
menutrans Toggle\ &Ignore-case<Tab>:set\ ic! &Lờ\ đi\ kiểu\ chữ<Tab>:set\ ic!
|
||||
menutrans Toggle\ &Showmatch<Tab>:set\ sm! Cho\ &biết\ phần\ tử\ có\ cặp<Tab>:set\ sm!
|
||||
menutrans &Context\ lines &Dòng\ quanh\ con\ trỏ
|
||||
menutrans &Virtual\ Edit &Soạn\ thảo\ ảo
|
||||
menutrans Toggle\ Insert\ &Mode<Tab>:set\ im! C&hế\ độ\ chèn<Tab>:set\ im!
|
||||
menutrans Toggle\ Vi\ C&ompatible<Tab>:set\ cp! Tương\ thích\ với\ &Vi<Tab>:set\ cp!
|
||||
menutrans Search\ &Path\.\.\. Đường\ dẫn\ tìm\ &kiếm\.\.\.
|
||||
menutrans Ta&g\ Files\.\.\. Tập\ tin\ thẻ\ &ghi\.\.\.
|
||||
"
|
||||
menutrans Toggle\ &Toolbar Thanh\ côn&g\ cụ
|
||||
menutrans Toggle\ &Bottom\ Scrollbar Thanh\ kéo\ ở\ &dưới
|
||||
menutrans Toggle\ &Left\ Scrollbar Thanh\ kéo\ ở\ &bên trái
|
||||
menutrans Toggle\ &Right\ Scrollbar Thanh\ kéo\ ở\ &bên phải
|
||||
">>>->>>------------- Edit/Global settings/Virtual edit
|
||||
menutrans Never Tắt
|
||||
menutrans Block\ Selection Khi\ chọn\ khối
|
||||
menutrans Insert\ mode Trong\ chế\ độ\ Chèn
|
||||
menutrans Block\ and\ Insert Khi\ chọn\ khối\ và\ Chèn
|
||||
menutrans Always Luôn\ luôn\ bật
|
||||
">>>----------------- Edit/File settings
|
||||
menutrans Toggle\ Line\ &Numbering<Tab>:set\ nu! Đánh\ số\ &dòng<Tab>:set\ nu!
|
||||
menutrans Toggle\ &List\ Mode<Tab>:set\ list! &Chế\ độ\ danh\ sách<Tab>:set\ list!
|
||||
menutrans Toggle\ Line\ &Wrap<Tab>:set\ wrap! &Ngắt\ những\ dòng\ dài<Tab>:set\ wrap!
|
||||
menutrans Toggle\ W&rap\ at\ word<Tab>:set\ lbr! Ngắt\ từ\ nguyên\ &vẹn<Tab>:set\ lbr!
|
||||
menutrans Toggle\ &expand-tab<Tab>:set\ et! Dấ&u\ trắng\ thay\ cho\ tab<Tab>:set\ et!
|
||||
menutrans Toggle\ &auto-indent<Tab>:set\ ai! Tự\ độn&g\ thụt\ dòng<Tab>:set\ ai!
|
||||
menutrans Toggle\ &C-indenting<Tab>:set\ cin! T&hụt\ dòng\ kiểu\ C<Tab>:set\ cin!
|
||||
">>>---
|
||||
menutrans &Shiftwidth Chiều\ &rộng\ thụt\ dòng
|
||||
menutrans Soft\ &Tabstop Chiều\ rộng\ T&ab
|
||||
menutrans Te&xt\ Width\.\.\. Chiều\ rộng\ &văn\ bản\.\.\.
|
||||
menutrans &File\ Format\.\.\. Định\ dạng\ tập\ t&in\.\.\.
|
||||
"
|
||||
"
|
||||
"
|
||||
" Tools menu
|
||||
menutrans &Jump\ to\ this\ tag<Tab>g^] &Nhảy\ tới\ thẻ\ ghi<Tab>g^]
|
||||
menutrans Jump\ &back<Tab>^T &Quay\ lại<Tab>^T
|
||||
menutrans Build\ &Tags\ File &Tạo\ tập\ tin\ thẻ\ ghi
|
||||
"-------------------
|
||||
menutrans &Folding Nếp\ &gấp
|
||||
menutrans &Diff &Khác\ biệt (diff)
|
||||
"-------------------
|
||||
menutrans &Make<Tab>:make &Biên\ dịch<Tab>:make
|
||||
menutrans &List\ Errors<Tab>:cl &Danh\ sách\ lỗi<Tab>:cl
|
||||
menutrans L&ist\ Messages<Tab>:cl! Danh\ &sách\ thông\ báo<Tab>:cl!
|
||||
menutrans &Next\ Error<Tab>:cn &Lỗi\ tiếp\ theo<Tab>:cn
|
||||
menutrans &Previous\ Error<Tab>:cp Lỗi\ t&rước<Tab>:cp
|
||||
menutrans &Older\ List<Tab>:cold Danh\ sách\ &cũ\ hơn<Tab>:cold
|
||||
menutrans N&ewer\ List<Tab>:cnew Danh\ sách\ &mới\ hơn<Tab>:cnew
|
||||
menutrans Error\ &Window Cửa\ sổ\ &lỗi
|
||||
menutrans &Set\ Compiler Chọn\ trình\ biên\ &dịch
|
||||
"-------------------
|
||||
menutrans &Convert\ to\ HEX<Tab>:%!xxd &Chuyển\ thành\ HEX<Tab>:%!xxd
|
||||
menutrans Conve&rt\ back<Tab>:%!xxd\ -r Chuyển\ từ\ HE&X<Tab>:%!xxd\ -r
|
||||
">>>---------------- Folds
|
||||
menutrans &Enable/Disable\ folds<Tab>zi Bật/tắt\ nếp\ &gấp<Tab>zi
|
||||
menutrans &View\ Cursor\ Line<Tab>zv Xe&m\ dòng\ có\ con\ trỏ<Tab>zv
|
||||
menutrans Vie&w\ Cursor\ Line\ only<Tab>zMzx Chỉ\ &xem\ dòng\ có\ con\ trỏ<Tab>zMzx
|
||||
menutrans C&lose\ more\ folds<Tab>zm Đóng\ &nhiều\ nếp\ gấp\ hơn<Tab>zm
|
||||
menutrans &Close\ all\ folds<Tab>zM Đóng\ mọi\ nếp\ &gấp<Tab>zM
|
||||
menutrans &Open\ all\ folds<Tab>zR &Mở\ mọi\ nếp\ gấp<Tab>zR
|
||||
menutrans O&pen\ more\ folds<Tab>zr Отк&рыть\ больше\ складок<Tab>zr
|
||||
menutrans Fold\ Met&hod &Phương\ pháp\ gấp
|
||||
menutrans Create\ &Fold<Tab>zf &Tạo\ nếp\ gấp<Tab>zf
|
||||
menutrans &Delete\ Fold<Tab>zd &Xóa\ nếp\ gấp<Tab>zd
|
||||
menutrans Delete\ &All\ Folds<Tab>zD Xóa\ mọ&i\ nếp\ gấp<Tab>zD
|
||||
menutrans Fold\ col&umn\ width &Chiều\ rộng\ cột\ nếp\ gấp
|
||||
">>>->>>----------- Tools/Folds/Fold Method
|
||||
menutrans M&anual &Thủ\ công
|
||||
menutrans I&ndent Thụt\ &dòng
|
||||
menutrans E&xpression &Biểu\ thức
|
||||
menutrans S&yntax &Cú\ pháp
|
||||
menutrans Ma&rker &Dấu\ hiệu
|
||||
">>>--------------- Tools/Diff
|
||||
menutrans &Update &Cập\ nhật
|
||||
menutrans &Get\ Block &Thay\ đổi\ bộ\ đệm\ này
|
||||
menutrans &Put\ Block T&hay\ đổi\ bộ\ đệm\ khác
|
||||
">>>--------------- Tools/Diff/Error window
|
||||
menutrans &Update<Tab>:cwin &Cập\ nhật<Tab>:cwin
|
||||
menutrans &Close<Tab>:cclose Đón&g<Tab>:cclose
|
||||
menutrans &Open<Tab>:copen &Mở<Tab>:copen
|
||||
"
|
||||
"
|
||||
" Syntax menu
|
||||
"
|
||||
menutrans &Show\ filetypes\ in\ menu &Hiển\ thị\ loại\ tập\ tin\ trong\ trình\ đơn
|
||||
menutrans Set\ '&syntax'\ only &Chỉ\ thay\ đổi\ giá\ trị\ 'syntax'
|
||||
menutrans Set\ '&filetype'\ too Th&ay\ đổi\ cả\ giá\ trị\ 'filetype'
|
||||
menutrans &Off &Tắt
|
||||
menutrans &Manual &Bằng\ tay
|
||||
menutrans A&utomatic Tự\ độ&ng
|
||||
menutrans on/off\ for\ &This\ file Bật\ tắt\ &cho\ tập\ tin\ này
|
||||
menutrans Co&lor\ test &Kiểm\ tra\ màu\ sắc
|
||||
menutrans &Highlight\ test Kiểm\ tra\ c&hiếu\ sáng
|
||||
menutrans &Convert\ to\ HTML &Chuyển\ thành\ HTML
|
||||
"
|
||||
"
|
||||
" Buffers menu
|
||||
"
|
||||
menutrans &Refresh\ menu &Cập\ nhật\ trình\ đơn
|
||||
menutrans Delete &Xóa
|
||||
menutrans &Alternate Xen\ &kẽ
|
||||
menutrans &Next Tiế&p\ theo
|
||||
menutrans &Previous &Trước
|
||||
menutrans [No\ File] [Không\ có\ tập\ tin]
|
||||
"
|
||||
"
|
||||
" Window menu
|
||||
"
|
||||
menutrans &New<Tab>^Wn &Mới<Tab>^Wn
|
||||
menutrans S&plit<Tab>^Ws &Chia\ đôi<Tab>^Ws
|
||||
menutrans Sp&lit\ To\ #<Tab>^W^^ Chia &tới #<Tab>^W^^
|
||||
menutrans Split\ &Vertically<Tab>^Wv Chia\ &dọc<Tab>^Wv
|
||||
menutrans Split\ File\ E&xplorer &Mở\ trình\ duyệt\ tập\ tin
|
||||
"
|
||||
menutrans &Close<Tab>^Wc Đó&ng<Tab>^Wc
|
||||
menutrans Close\ &Other(s)<Tab>^Wo Đóng\ các\ cửa\ sổ\ &khác<Tab>^Wo
|
||||
"
|
||||
menutrans Move\ &To Ch&uyển tới
|
||||
menutrans Rotate\ &Up<Tab>^WR &Lên\ trên<Tab>^WR
|
||||
menutrans Rotate\ &Down<Tab>^Wr &Xuống\ dưới<Tab>^Wr
|
||||
"
|
||||
menutrans &Equal\ Size<Tab>^W= Cân\ bằng\ &kích\ thước<Tab>^W=
|
||||
menutrans &Max\ Height<Tab>^W_ Chiều\ c&ao\ lớn\ nhất<Tab>^W_
|
||||
menutrans M&in\ Height<Tab>^W1_ Chiều\ ca&o\ nhỏ\ nhất<Tab>^W1_
|
||||
menutrans Max\ &Width<Tab>^W\| Chiều\ &rộng\ lớn\ nhất<Tab>^W\|
|
||||
menutrans Min\ Widt&h<Tab>^W1\| Chiề&u\ rộng\ nhỏ\ nhất<Tab>^W1\|
|
||||
">>>----------------- Window/Move To
|
||||
menutrans &Top<Tab>^WK Đầ&u<Tab>^WK
|
||||
menutrans &Bottom<Tab>^WJ &Cuối<Tab>^WJ
|
||||
menutrans &Left\ side<Tab>^WH &Trái<Tab>^WH
|
||||
menutrans &Right\ side<Tab>^WL &Phải<Tab>^WL
|
||||
"
|
||||
"
|
||||
" The popup menu
|
||||
"
|
||||
"
|
||||
menutrans &Undo &Hủy\ bước
|
||||
menutrans Cu&t &Cắt
|
||||
menutrans &Copy &Sao\ chép
|
||||
menutrans &Paste &Dán
|
||||
menutrans &Delete &Xóa
|
||||
menutrans Select\ Blockwise Chọn\ &theo\ khối
|
||||
menutrans Select\ &Word Chọ&n\ từ
|
||||
menutrans Select\ &Line Chọn\ dòn&g
|
||||
menutrans Select\ &Block Chọn\ &khối
|
||||
menutrans Select\ &All Chọn\ tất\ &cả
|
||||
"
|
||||
" The GUI toolbar
|
||||
"
|
||||
if has("toolbar")
|
||||
if exists("*Do_toolbar_tmenu")
|
||||
delfun Do_toolbar_tmenu
|
||||
endif
|
||||
fun Do_toolbar_tmenu()
|
||||
tmenu ToolBar.Open Mở tập tin
|
||||
tmenu ToolBar.Save Ghi nhớ tập tin
|
||||
tmenu ToolBar.SaveAll Ghi nhớ tất cả
|
||||
tmenu ToolBar.Print In
|
||||
tmenu ToolBar.Undo Hủy bước
|
||||
tmenu ToolBar.Redo Làm lại
|
||||
tmenu ToolBar.Cut Cắt
|
||||
tmenu ToolBar.Copy Sao chép
|
||||
tmenu ToolBar.Paste Dán
|
||||
tmenu ToolBar.Find Tìm...
|
||||
tmenu ToolBar.FindNext Tìm tiếp theo
|
||||
tmenu ToolBar.FindPrev Tìm ngược lại
|
||||
tmenu ToolBar.Replace Thay thế...
|
||||
tmenu ToolBar.LoadSesn Nạp buổi làm việc
|
||||
tmenu ToolBar.SaveSesn Ghi nhớ buổi làm việc
|
||||
tmenu ToolBar.RunScript Chạy script của Vim
|
||||
tmenu ToolBar.Make Biên dịch
|
||||
tmenu ToolBar.Shell Shell
|
||||
tmenu ToolBar.RunCtags Tạo tập tin thẻ ghi
|
||||
tmenu ToolBar.TagJump Chuyển tới thẻ ghi
|
||||
tmenu ToolBar.Help Trợ giúp
|
||||
tmenu ToolBar.FindHelp Tìm trong trợ giúp
|
||||
endfun
|
||||
endif
|
||||
"
|
||||
"
|
||||
" Dialog texts
|
||||
"
|
||||
" Find in help dialog
|
||||
"
|
||||
let g:menutrans_help_dialog = "Hãy nhập câu lệnh hoặc từ khóa tìm kiếm:\n\nThêm i_ để tìm kiếm câu lệnh của chế độ Nhập Input (Ví dụ, i_CTRL-X)\nThêm c_ để tìm kiếm câu lệnh của chế độ soạn thảo dòng lệnh (Ví dụ, с_<Del>)\nThêm ' để tìm kiếm trợ giúp cho một tùy chọn (ví dụ, 'shiftwidth')"
|
||||
"
|
||||
" Searh path dialog
|
||||
"
|
||||
let g:menutrans_path_dialog = "Hãy chỉ ra đường dẫn để tìm kiếm tập tin.\nTên của thư mục phân cách nhau bởi dấu phẩy."
|
||||
"
|
||||
" Tag files dialog
|
||||
"
|
||||
let g:menutrans_tags_dialog = "Nhập tên tập tin thẻ ghi (phân cách bởi dấu phẩy).\n"
|
||||
"
|
||||
" Text width dialog
|
||||
"
|
||||
let g:menutrans_textwidth_dialog = "Hãy nhập chiều rộng văn bản mới.\nNhập 0 để hủy bỏ."
|
||||
"
|
||||
" File format dialog
|
||||
"
|
||||
let g:menutrans_fileformat_dialog = "Hãy chọn định dạng tập tin."
|
||||
let g:menutrans_fileformat_choices = "&Unix\n&Dos\n&Mac\n&Hủy bỏ"
|
||||
"
|
||||
let menutrans_no_file = "[không có tập tin]"
|
@ -2,7 +2,7 @@
|
||||
" You can also use this as a start for your own set of menus.
|
||||
"
|
||||
" Maintainer: Bram Moolenaar <Bram@vim.org>
|
||||
" Last Change: 2005 Feb 03
|
||||
" Last Change: 2005 Feb 24
|
||||
|
||||
" Note that ":an" (short for ":anoremenu") is often used to make a menu work
|
||||
" in all modes and avoid side effects from mappings defined by the user.
|
||||
@ -54,7 +54,7 @@ if exists("v:lang") || &langmenu != ""
|
||||
" There is no exact match, try matching with a wildcard added
|
||||
" (e.g. find menu_de_de.iso_8859-1.vim if s:lang == de_DE).
|
||||
let s:lang = substitute(s:lang, '\.[^.]*', "", "")
|
||||
exe "runtime! lang/menu_" . s:lang . "[^a-z]*.vim"
|
||||
exe "runtime! lang/menu_" . s:lang . "[^a-z]*vim"
|
||||
|
||||
if !exists("did_menu_trans") && strlen($LANG) > 1
|
||||
" On windows locale names are complicated, try using $LANG, it might
|
||||
|
@ -1,6 +1,6 @@
|
||||
" Vim syntax support file
|
||||
" Maintainer: Bram Moolenaar <Bram@vim.org>
|
||||
" Last Change: 2004 Dec 14
|
||||
" Last Change: 2005 Feb 26
|
||||
" (modified by David Ne\v{c}as (Yeti) <yeti@physics.muni.cz>)
|
||||
" (XHTML support by Panagiotis Issaris <takis@lumumba.luc.ac.be>)
|
||||
|
||||
@ -400,7 +400,6 @@ while s:lnum <= s:end
|
||||
exe "normal! a" . s:new . s:HtmlEndline . "\n\e"
|
||||
exe s:orgwin . "wincmd w"
|
||||
let s:lnum = s:lnum + 1
|
||||
+
|
||||
endwhile
|
||||
" Finish with the last line
|
||||
exe s:newwin . "wincmd w"
|
||||
@ -515,11 +514,13 @@ unlet s:old_et s:old_paste s:old_icon s:old_report s:old_title s:old_search
|
||||
unlet s:whatterm s:idlist s:lnum s:end s:fgc s:bgc s:old_magic
|
||||
unlet! s:col s:id s:attr s:len s:line s:new s:expandedtab s:numblines
|
||||
unlet s:orgwin s:newwin s:orgbufnr
|
||||
delfunc s:HtmlColor
|
||||
delfunc s:HtmlFormat
|
||||
delfunc s:CSS1
|
||||
if !exists("html_use_css")
|
||||
delfunc s:HtmlOpening
|
||||
delfunc s:HtmlClosing
|
||||
if !v:profiling
|
||||
delfunc s:HtmlColor
|
||||
delfunc s:HtmlFormat
|
||||
delfunc s:CSS1
|
||||
if !exists("html_use_css")
|
||||
delfunc s:HtmlOpening
|
||||
delfunc s:HtmlClosing
|
||||
endif
|
||||
endif
|
||||
silent! unlet s:diffattr s:difffillchar s:foldfillchar s:HtmlSpace s:HtmlEndline
|
||||
|
@ -1,8 +1,8 @@
|
||||
" Vim syntax file
|
||||
" Language: Vim 7.0 script
|
||||
" Maintainer: Dr. Charles E. Campbell, Jr. <NdrOchipS@PcampbellAfamily.Mbiz>
|
||||
" Last Change: Feb 14, 2005
|
||||
" Version: 7.0-05
|
||||
" Last Change: February 22, 2005
|
||||
" Version: 7.0-07
|
||||
" Automatically generated keyword lists: {{{1
|
||||
|
||||
" Quit when a syntax file was already loaded {{{2
|
||||
@ -16,7 +16,7 @@ syn keyword vimTodo contained COMBAK NOT RELEASED TODO WIP
|
||||
syn cluster vimCommentGroup contains=vimTodo
|
||||
|
||||
" regular vim commands {{{2
|
||||
syn keyword vimCommand contained ab[breviate] abc[lear] abo[veleft] al[l] arga[dd] argd[elete] argdo arge[dit] argg[lobal] argl[ocal] ar[gs] argu[ment] as[cii] bad[d] ba[ll] bd[elete] be bel[owright] bf[irst] bl[ast] bm[odified] bn[ext] bN[ext] bo[tright] bp[revious] brea[k] breaka[dd] breakd[el] breakl[ist] br[ewind] bro[wse] bufdo b[uffer] buffers bun[load] bw[ipeout] ca[bbrev] cabc[lear] cal[l] cat[ch] cb[uffer] cc ccl[ose] cd ce[nter] cf[ile] cfir[st] cg[etfile] c[hange] changes chd[ir] che[ckpath] checkt[ime] cla[st] cl[ist] clo[se] cmapc[lear] cnew[er] cn[ext] cN[ext] cnf[ile] cNf[ile] cnorea[bbrev] col[der] colo[rscheme] comc[lear] comp[iler] conf[irm] con[tinue] cope[n] co[py] cpf[ile] cp[revious] cq[uit] cr[ewind] cuna[bbrev] cu[nmap] cw[indow] debugg[reedy] delc[ommand] d[elete] DeleteFirst delf[unction] delm[arks] diffg[et] diffoff diffpatch diffpu[t] diffsplit diffthis dig[raphs] di[splay] dj[ump] dl[ist] dr[op] ds[earch] dsp[lit] echoe[rr] echom[sg] echon e[dit] el[se] elsei[f] em[enu] emenu* endfo[r] endf[unction] en[dif] endt[ry] endw[hile] ene[w] ex exi[t] exu[sage] f[ile] files filetype fina[lly] fin[d] fini[sh] fir[st] fix[del] fo[ld] foldc[lose] folddoc[losed] foldd[oopen] foldo[pen] for fu[nction] g[lobal] go[to] gr[ep] grepa[dd] ha[rdcopy] h[elp] helpf[ind] helpg[rep] helpt[ags] hid[e] his[tory] I ia[bbrev] iabc[lear] if ij[ump] il[ist] imapc[lear] inorea[bbrev] is[earch] isp[lit] iuna[bbrev] iu[nmap] j[oin] ju[mps] k keepalt keepj[umps] kee[pmarks] lan[guage] la[st] lc[d] lch[dir] le[ft] lefta[bove] l[ist] lm[ap] lmapc[lear] ln[oremap] lo[adview] loc[kmarks] lockv[ar] ls lu[nmap] mak[e] ma[rk] marks mat[ch] menut[ranslate] mk[exrc] mks[ession] mkvie[w] mkv[imrc] mod[e] m[ove] mzf[ile] mz[scheme] nbkey new n[ext] N[ext] nmapc[lear] noh[lsearch] norea[bbrev] Nread nu[mber] nun[map] Nw omapc[lear] on[ly] o[pen] opt[ions] ou[nmap] pc[lose] ped[it] pe[rl] perld[o] po[p] popu popu[p] pp[op] pre[serve] prev[ious] p[rint] P[rint] prompt promptf[ind] promptr[epl] ps[earch] pta[g] ptf[irst] ptj[ump] ptl[ast] ptn[ext] ptN[ext] ptp[revious] ptr[ewind] pts[elect] pu[t] pw[d] pyf[ile] py[thon] qa[ll] q[uit] quita[ll] r[ead] rec[over] redi[r] red[o] redr[aw] redraws[tatus] reg[isters] res[ize] ret[ab] retu[rn] rew[ind] ri[ght] rightb[elow] rub[y] rubyd[o] rubyf[ile] ru[ntime] rv[iminfo] sal[l] sandbox sa[rgument] sav[eas] sba[ll] sbf[irst] sbl[ast] sbm[odified] sbn[ext] sbN[ext] sbp[revious] sbr[ewind] sb[uffer] scripte[ncoding] scrip[tnames] se[t] setf[iletype] setg[lobal] setl[ocal] sf[ind] sfir[st] sh[ell] sign sil[ent] sim[alt] sla[st] sl[eep] sm[agic] sn[ext] sN[ext] sni[ff] sno[magic] so[urce] sp[lit] spr[evious] sre[wind] sta[g] star[tinsert] startr[eplace] stj[ump] st[op] stopi[nsert] sts[elect] sun[hide] sus[pend] sv[iew] syncbind t ta[g] tags tc[l] tcld[o] tclf[ile] te[aroff] tf[irst] the th[row] tj[ump] tl[ast] tm tm[enu] tn[ext] tN[ext] to[pleft] tp[revious] tr[ewind] try ts[elect] tu tu[nmenu] una[bbreviate] u[ndo] unh[ide] unlo[ckvar] unm[ap] up[date] verb[ose] ve[rsion] vert[ical] v[global] vie[w] vim[grep] vimgrepa[dd] vi[sual] viu[sage] vmapc[lear] vne[w] vs[plit] vu[nmap] wa[ll] wh[ile] winc[md] windo winp[os] winpos* win[size] wn[ext] wN[ext] wp[revious] wq wqa[ll] w[rite] ws[verb] wv[iminfo] X xa[ll] x[it] y[ank]
|
||||
syn keyword vimCommand contained ab[breviate] abc[lear] abo[veleft] al[l] arga[dd] argd[elete] argdo arge[dit] argg[lobal] argl[ocal] ar[gs] argu[ment] as[cii] bad[d] ba[ll] bd[elete] be bel[owright] bf[irst] bl[ast] bm[odified] bn[ext] bN[ext] bo[tright] bp[revious] brea[k] breaka[dd] breakd[el] breakl[ist] br[ewind] bro[wse] bufdo b[uffer] buffers bun[load] bw[ipeout] ca[bbrev] cabc[lear] cal[l] cat[ch] cb[uffer] cc ccl[ose] cd ce[nter] cf[ile] cfir[st] cg[etfile] c[hange] changes chd[ir] che[ckpath] checkt[ime] cla[st] cl[ist] clo[se] cmapc[lear] cnew[er] cn[ext] cN[ext] cnf[ile] cNf[ile] cnorea[bbrev] col[der] colo[rscheme] comc[lear] comp[iler] conf[irm] con[tinue] cope[n] co[py] cpf[ile] cp[revious] cq[uit] cr[ewind] cuna[bbrev] cu[nmap] cw[indow] debugg[reedy] delc[ommand] d[elete] DeleteFirst delf[unction] delm[arks] diffg[et] diffoff diffpatch diffpu[t] diffsplit diffthis dig[raphs] di[splay] dj[ump] dl[ist] dr[op] ds[earch] dsp[lit] echoe[rr] echom[sg] echon e[dit] el[se] elsei[f] em[enu] emenu* endfo[r] endf[unction] en[dif] endt[ry] endw[hile] ene[w] ex exi[t] exu[sage] f[ile] files filetype fina[lly] fin[d] fini[sh] fir[st] fix[del] fo[ld] foldc[lose] folddoc[losed] foldd[oopen] foldo[pen] for fu[nction] g[lobal] go[to] gr[ep] grepa[dd] ha[rdcopy] h[elp] helpf[ind] helpg[rep] helpt[ags] hid[e] his[tory] I ia[bbrev] iabc[lear] if ij[ump] il[ist] imapc[lear] inorea[bbrev] is[earch] isp[lit] iuna[bbrev] iu[nmap] j[oin] ju[mps] k keepalt keepj[umps] kee[pmarks] lan[guage] la[st] lc[d] lch[dir] le[ft] lefta[bove] l[ist] lm[ap] lmapc[lear] ln[oremap] lo[adview] loc[kmarks] lockv[ar] ls lu[nmap] mak[e] ma[rk] marks mat[ch] menut[ranslate] mk[exrc] mks[ession] mkvie[w] mkv[imrc] mod[e] m[ove] mzf[ile] mz[scheme] nbkey new n[ext] N[ext] nmapc[lear] noh[lsearch] norea[bbrev] Nread nu[mber] nun[map] Nw omapc[lear] on[ly] o[pen] opt[ions] ou[nmap] pc[lose] ped[it] pe[rl] perld[o] po[p] popu popu[p] pp[op] pre[serve] prev[ious] p[rint] P[rint] prompt promptf[ind] promptr[epl] ps[earch] pta[g] ptf[irst] ptj[ump] ptl[ast] ptn[ext] ptN[ext] ptp[revious] ptr[ewind] pts[elect] pu[t] pw[d] pyf[ile] py[thon] qa[ll] q[uit] quita[ll] r[ead] rec[over] redi[r] red[o] redr[aw] redraws[tatus] reg[isters] res[ize] ret[ab] retu[rn] rew[ind] ri[ght] rightb[elow] rub[y] rubyd[o] rubyf[ile] ru[ntime] rv[iminfo] sal[l] sandbox sa[rgument] sav[eas] sba[ll] sbf[irst] sbl[ast] sbm[odified] sbn[ext] sbN[ext] sbp[revious] sbr[ewind] sb[uffer] scripte[ncoding] scrip[tnames] se[t] setf[iletype] setg[lobal] setl[ocal] sf[ind] sfir[st] sh[ell] sign sil[ent] sim[alt] sla[st] sl[eep] sm[agic] sn[ext] sN[ext] sni[ff] sno[magic] so[urce] sp[lit] spr[evious] sre[wind] sta[g] star[tinsert] startr[eplace] stj[ump] st[op] stopi[nsert] sts[elect] sun[hide] sus[pend] sv[iew] syncbind t ta[g] tags tc[l] tcld[o] tclf[ile] te[aroff] tf[irst] the th[row] tj[ump] tl[ast] tm tm[enu] tn[ext] tN[ext] to[pleft] tp[revious] tr[ewind] try ts[elect] tu tu[nmenu] una[bbreviate] u[ndo] unh[ide] unlo[ckvar] unm[ap] up[date] verb[ose] ve[rsion] vert[ical] v[global] vie[w] vim[grep] vimgrepa[dd] vi[sual] viu[sage] vmapc[lear] vne[w] vs[plit] vu[nmap] wa[ll] wh[ile] winc[md] windo winp[os] win[size] wn[ext] wN[ext] wp[revious] wq wqa[ll] w[rite] ws[verb] wv[iminfo] X xa[ll] x[it] y[ank]
|
||||
syn match vimCommand contained "\<z[-+^.=]"
|
||||
|
||||
" vimOptions are caught only when contained in a vimSet {{{2
|
||||
@ -316,6 +316,11 @@ syn match vimFunc "\%([sS]:\|<[sS][iI][dD]>\)\=\I\i*\ze\s*(" contains=vimFuncNa
|
||||
syn match vimUserFunc contained "\%([sS]:\|<[sS][iI][dD]>\)\i\+\|\<\u\i*\>\|\<if\>" contains=vimNotation,vimCommand
|
||||
syn match vimNotFunc contained "\<[aiAIrR]("
|
||||
|
||||
" Norm
|
||||
" ====
|
||||
syn match vimNorm "\<norm\%[al]!\=" skipwhite nextgroup=vimNormCmds
|
||||
syn match vimNormCmds contained ".*$"
|
||||
|
||||
" Syntax {{{2
|
||||
"=======
|
||||
syn match vimGroupList contained "@\=[^ \t,]*" contains=vimGroupSpecial,vimPatSep
|
||||
@ -592,6 +597,7 @@ hi def link vimMarkNumber vimNumber
|
||||
hi def link vimMenuMod vimMapMod
|
||||
hi def link vimMenuNameMore vimMenuName
|
||||
hi def link vimMtchComment vimComment
|
||||
hi def link vimNorm vimCommand
|
||||
hi def link vimNotFunc vimCommand
|
||||
hi def link vimNotPatSep vimString
|
||||
hi def link vimPatSepR vimPatSep
|
||||
|
44
src/buffer.c
44
src/buffer.c
@ -2082,25 +2082,38 @@ ExpandBufnames(pat, num_file, file, options)
|
||||
char_u *p;
|
||||
int attempt;
|
||||
regprog_T *prog;
|
||||
char_u *patc;
|
||||
|
||||
*num_file = 0; /* return values in case of FAIL */
|
||||
*file = NULL;
|
||||
|
||||
/*
|
||||
* attempt == 1: try match with '^', match at start
|
||||
* attempt == 2: try match without '^', match anywhere
|
||||
*/
|
||||
for (attempt = 1; attempt <= 2; ++attempt)
|
||||
/* Make a copy of "pat" and change "^" to "\(^\|[\/]\)". */
|
||||
if (*pat == '^')
|
||||
{
|
||||
if (attempt == 2)
|
||||
{
|
||||
if (*pat != '^') /* there's no '^', no need to try again */
|
||||
break;
|
||||
++pat; /* skip the '^' */
|
||||
}
|
||||
prog = vim_regcomp(pat, p_magic ? RE_MAGIC : 0);
|
||||
if (prog == NULL)
|
||||
patc = alloc((unsigned)STRLEN(pat) + 11);
|
||||
if (patc == NULL)
|
||||
return FAIL;
|
||||
STRCPY(patc, "\\(^\\|[\\/]\\)");
|
||||
STRCPY(patc + 11, pat + 1);
|
||||
}
|
||||
else
|
||||
patc = pat;
|
||||
|
||||
/*
|
||||
* attempt == 0: try match with '\<', match at start of word
|
||||
* attempt == 2: try match without '\<', match anywhere
|
||||
*/
|
||||
for (attempt = 0; attempt <= 2; attempt += 2)
|
||||
{
|
||||
if (attempt == 2 && patc == pat)
|
||||
break; /* there was no anchor, no need to try again */
|
||||
prog = vim_regcomp(patc + attempt, RE_MAGIC);
|
||||
if (prog == NULL)
|
||||
{
|
||||
if (patc != pat)
|
||||
vim_free(patc);
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
/*
|
||||
* round == 1: Count the matches.
|
||||
@ -2136,6 +2149,8 @@ ExpandBufnames(pat, num_file, file, options)
|
||||
if (*file == NULL)
|
||||
{
|
||||
vim_free(prog);
|
||||
if (patc != pat)
|
||||
vim_free(patc);
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
@ -2145,6 +2160,9 @@ ExpandBufnames(pat, num_file, file, options)
|
||||
break;
|
||||
}
|
||||
|
||||
if (patc != pat)
|
||||
vim_free(patc);
|
||||
|
||||
*num_file = count;
|
||||
return (count == 0 ? FAIL : OK);
|
||||
}
|
||||
|
452
src/eval.c
452
src/eval.c
@ -106,6 +106,7 @@ static char *e_funcdict = N_("E717: Dictionary entry already exists");
|
||||
static char *e_funcref = N_("E718: Funcref required");
|
||||
static char *e_dictrange = N_("E719: Cannot use [:] with a Dictionary");
|
||||
static char *e_letwrong = N_("E734: Wrong variable type for %s=");
|
||||
static char *e_nofunc = N_("E130: Unknown function: %s");
|
||||
|
||||
/*
|
||||
* All user-defined global variables are stored in dictionary "globvardict".
|
||||
@ -153,6 +154,24 @@ struct ufunc
|
||||
int uf_calls; /* nr of active calls */
|
||||
garray_T uf_args; /* arguments */
|
||||
garray_T uf_lines; /* function lines */
|
||||
#ifdef FEAT_PROFILE
|
||||
int uf_profiling; /* TRUE when func is being profiled */
|
||||
/* profiling the function as a whole */
|
||||
int uf_tm_count; /* nr of calls */
|
||||
proftime_T uf_tm_total; /* time spend in function + children */
|
||||
proftime_T uf_tm_self; /* time spend in function itself */
|
||||
proftime_T uf_tm_start; /* time at function call */
|
||||
proftime_T uf_tm_children; /* time spent in children this call */
|
||||
/* profiling the function per line */
|
||||
int *uf_tml_count; /* nr of times line was executed */
|
||||
proftime_T *uf_tml_total; /* time spend in a line + children */
|
||||
proftime_T *uf_tml_self; /* time spend in a line itself */
|
||||
proftime_T uf_tml_start; /* start time for current line */
|
||||
proftime_T uf_tml_children; /* time spent in children for this line */
|
||||
proftime_T uf_tml_wait; /* start wait time for current line */
|
||||
int uf_tml_idx; /* index of line being timed; -1 if none */
|
||||
int uf_tml_execed; /* line being timed was executed */
|
||||
#endif
|
||||
scid_T uf_script_ID; /* ID of script where function was defined,
|
||||
used for s: variables */
|
||||
int uf_refcount; /* for numbered function: reference count */
|
||||
@ -205,6 +224,9 @@ typedef struct funccall_S
|
||||
linenr_T breakpoint; /* next line with breakpoint or zero */
|
||||
int dbg_tick; /* debug_tick when breakpoint was set */
|
||||
int level; /* top nesting level of executed function */
|
||||
#ifdef FEAT_PROFILE
|
||||
proftime_T prof_child; /* time spent in a child */
|
||||
#endif
|
||||
} funccall_T;
|
||||
|
||||
/*
|
||||
@ -293,6 +315,7 @@ static struct vimvar
|
||||
{VV_NAME("insertmode", VAR_STRING), VV_RO},
|
||||
{VV_NAME("val", VAR_UNKNOWN), VV_RO},
|
||||
{VV_NAME("key", VAR_UNKNOWN), VV_RO},
|
||||
{VV_NAME("profiling", VAR_NUMBER), VV_RO},
|
||||
};
|
||||
|
||||
/* shorthand */
|
||||
@ -345,7 +368,6 @@ static void list_remove __ARGS((list_T *l, listitem_T *item, listitem_T *item2))
|
||||
static char_u *list2string __ARGS((typval_T *tv));
|
||||
static int list_join __ARGS((garray_T *gap, list_T *l, char_u *sep, int echo));
|
||||
|
||||
static dict_T *dict_alloc __ARGS((void));
|
||||
static void dict_unref __ARGS((dict_T *d));
|
||||
static void dict_free __ARGS((dict_T *d));
|
||||
static dictitem_T *dictitem_alloc __ARGS((char_u *key));
|
||||
@ -399,6 +421,7 @@ static void f_did_filetype __ARGS((typval_T *argvars, typval_T *rettv));
|
||||
static void f_diff_filler __ARGS((typval_T *argvars, typval_T *rettv));
|
||||
static void f_diff_hlID __ARGS((typval_T *argvars, typval_T *rettv));
|
||||
static void f_empty __ARGS((typval_T *argvars, typval_T *rettv));
|
||||
static void f_errorlist __ARGS((typval_T *argvars, typval_T *rettv));
|
||||
static void f_escape __ARGS((typval_T *argvars, typval_T *rettv));
|
||||
static void f_eval __ARGS((typval_T *argvars, typval_T *rettv));
|
||||
static void f_eventhandler __ARGS((typval_T *argvars, typval_T *rettv));
|
||||
@ -582,6 +605,9 @@ static void cat_func_name __ARGS((char_u *buf, ufunc_T *fp));
|
||||
static ufunc_T *find_func __ARGS((char_u *name));
|
||||
static int function_exists __ARGS((char_u *name));
|
||||
static int builtin_function __ARGS((char_u *name));
|
||||
#ifdef FEAT_PROFILE
|
||||
static void func_do_profile __ARGS((ufunc_T *fp));
|
||||
#endif
|
||||
static int script_autoload __ARGS((char_u *name));
|
||||
static char_u *autoload_name __ARGS((char_u *name));
|
||||
static void func_free __ARGS((ufunc_T *fp));
|
||||
@ -1170,20 +1196,60 @@ call_vim_function(func, argc, argv, safe)
|
||||
void *
|
||||
save_funccal()
|
||||
{
|
||||
funccall_T *fc;
|
||||
funccall_T *fc = current_funccal;
|
||||
|
||||
fc = current_funccal;
|
||||
current_funccal = NULL;
|
||||
return (void *)fc;
|
||||
}
|
||||
|
||||
void
|
||||
restore_funccal(fc)
|
||||
void *fc;
|
||||
restore_funccal(vfc)
|
||||
void *vfc;
|
||||
{
|
||||
current_funccal = (funccall_T *)fc;
|
||||
funccall_T *fc = (funccall_T *)vfc;
|
||||
|
||||
current_funccal = fc;
|
||||
}
|
||||
|
||||
#if defined(FEAT_PROFILE) || defined(PROTO)
|
||||
/*
|
||||
* Prepare profiling for entering a child or something else that is not
|
||||
* counted for the script/function itself.
|
||||
* Should always be called in pair with prof_child_exit().
|
||||
*/
|
||||
void
|
||||
prof_child_enter(tm)
|
||||
proftime_T *tm; /* place to store waittime */
|
||||
{
|
||||
funccall_T *fc = current_funccal;
|
||||
|
||||
if (fc != NULL && fc->func->uf_profiling)
|
||||
profile_start(&fc->prof_child);
|
||||
script_prof_save(tm);
|
||||
}
|
||||
|
||||
/*
|
||||
* Take care of time spent in a child.
|
||||
* Should always be called after prof_child_enter().
|
||||
*/
|
||||
void
|
||||
prof_child_exit(tm)
|
||||
proftime_T *tm; /* where waittime was stored */
|
||||
{
|
||||
funccall_T *fc = current_funccal;
|
||||
|
||||
if (fc != NULL && fc->func->uf_profiling)
|
||||
{
|
||||
profile_end(&fc->prof_child);
|
||||
profile_sub_wait(tm, &fc->prof_child); /* don't count waiting time */
|
||||
profile_add(&fc->func->uf_tm_children, &fc->prof_child);
|
||||
profile_add(&fc->func->uf_tml_children, &fc->prof_child);
|
||||
}
|
||||
script_prof_restore(tm);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef FEAT_FOLDING
|
||||
/*
|
||||
* Evaluate 'foldexpr'. Returns the foldlevel, and any character preceding
|
||||
@ -5020,12 +5086,33 @@ list_append_tv(l, tv)
|
||||
list_T *l;
|
||||
typval_T *tv;
|
||||
{
|
||||
listitem_T *ni = listitem_alloc();
|
||||
listitem_T *li = listitem_alloc();
|
||||
|
||||
if (ni == NULL)
|
||||
if (li == NULL)
|
||||
return FAIL;
|
||||
copy_tv(tv, &ni->li_tv);
|
||||
list_append(l, ni);
|
||||
copy_tv(tv, &li->li_tv);
|
||||
list_append(l, li);
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add a dictionary to a list. Used by errorlist().
|
||||
* Return FAIL when out of memory.
|
||||
*/
|
||||
int
|
||||
list_append_dict(list, dict)
|
||||
list_T *list;
|
||||
dict_T *dict;
|
||||
{
|
||||
listitem_T *li = listitem_alloc();
|
||||
|
||||
if (li == NULL)
|
||||
return FAIL;
|
||||
li->li_tv.v_type = VAR_DICT;
|
||||
li->li_tv.v_lock = 0;
|
||||
li->li_tv.vval.v_dict = dict;
|
||||
list_append(list, li);
|
||||
++dict->dv_refcount;
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -5266,7 +5353,7 @@ list_join(gap, l, sep, echo)
|
||||
/*
|
||||
* Allocate an empty header for a dictionary.
|
||||
*/
|
||||
static dict_T *
|
||||
dict_T *
|
||||
dict_alloc()
|
||||
{
|
||||
dict_T *d;
|
||||
@ -5469,6 +5556,42 @@ dict_add(d, item)
|
||||
return hash_add(&d->dv_hashtab, item->di_key);
|
||||
}
|
||||
|
||||
/*
|
||||
* Add a number or string entry to dictionary "d".
|
||||
* When "str" is NULL use number "nr", otherwise use "str".
|
||||
* Returns FAIL when out of memory and when key already exists.
|
||||
*/
|
||||
int
|
||||
dict_add_nr_str(d, key, nr, str)
|
||||
dict_T *d;
|
||||
char *key;
|
||||
long nr;
|
||||
char_u *str;
|
||||
{
|
||||
dictitem_T *item;
|
||||
|
||||
item = dictitem_alloc((char_u *)key);
|
||||
if (item == NULL)
|
||||
return FAIL;
|
||||
item->di_tv.v_lock = 0;
|
||||
if (str == NULL)
|
||||
{
|
||||
item->di_tv.v_type = VAR_NUMBER;
|
||||
item->di_tv.vval.v_number = nr;
|
||||
}
|
||||
else
|
||||
{
|
||||
item->di_tv.v_type = VAR_STRING;
|
||||
item->di_tv.vval.v_string = vim_strsave(str);
|
||||
}
|
||||
if (dict_add(d, item) == FAIL)
|
||||
{
|
||||
dictitem_free(item);
|
||||
return FAIL;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the number of items in a Dictionary.
|
||||
*/
|
||||
@ -5844,6 +5967,7 @@ get_env_tv(arg, rettv, evaluate)
|
||||
int len;
|
||||
int cc;
|
||||
char_u *name;
|
||||
int mustfree = FALSE;
|
||||
|
||||
++*arg;
|
||||
name = *arg;
|
||||
@ -5854,12 +5978,18 @@ get_env_tv(arg, rettv, evaluate)
|
||||
{
|
||||
cc = name[len];
|
||||
name[len] = NUL;
|
||||
/* first try mch_getenv(), fast for normal environment vars */
|
||||
string = mch_getenv(name);
|
||||
/* first try vim_getenv(), fast for normal environment vars */
|
||||
string = vim_getenv(name, &mustfree);
|
||||
if (string != NULL && *string != NUL)
|
||||
string = vim_strsave(string);
|
||||
{
|
||||
if (!mustfree)
|
||||
string = vim_strsave(string);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mustfree)
|
||||
vim_free(string);
|
||||
|
||||
/* next try expanding things like $VIM and ${HOME} */
|
||||
string = expand_env_save(name - 1);
|
||||
if (string != NULL && *string == '$')
|
||||
@ -5923,6 +6053,7 @@ static struct fst
|
||||
{"diff_filler", 1, 1, f_diff_filler},
|
||||
{"diff_hlID", 2, 2, f_diff_hlID},
|
||||
{"empty", 1, 1, f_empty},
|
||||
{"errorlist", 0, 0, f_errorlist},
|
||||
{"escape", 2, 2, f_escape},
|
||||
{"eval", 1, 1, f_eval},
|
||||
{"eventhandler", 0, 0, f_eventhandler},
|
||||
@ -7420,6 +7551,36 @@ f_empty(argvars, rettv)
|
||||
rettv->vval.v_number = n;
|
||||
}
|
||||
|
||||
/*
|
||||
* "errorlist()" function
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
static void
|
||||
f_errorlist(argvars, rettv)
|
||||
typval_T *argvars;
|
||||
typval_T *rettv;
|
||||
{
|
||||
#ifdef FEAT_QUICKFIX
|
||||
list_T *l;
|
||||
#endif
|
||||
|
||||
rettv->vval.v_number = FALSE;
|
||||
#ifdef FEAT_QUICKFIX
|
||||
l = list_alloc();
|
||||
if (l != NULL)
|
||||
{
|
||||
if (get_errorlist(l) != FAIL)
|
||||
{
|
||||
rettv->vval.v_list = l;
|
||||
rettv->v_type = VAR_LIST;
|
||||
++l->lv_refcount;
|
||||
}
|
||||
else
|
||||
list_free(l);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* "escape({string}, {chars})" function
|
||||
*/
|
||||
@ -9212,6 +9373,9 @@ f_has(argvars, rettv)
|
||||
#ifdef FEAT_PRINTER
|
||||
"printer",
|
||||
#endif
|
||||
#ifdef FEAT_PROFILE
|
||||
"profile",
|
||||
#endif
|
||||
#ifdef FEAT_QUICKFIX
|
||||
"quickfix",
|
||||
#endif
|
||||
@ -12651,25 +12815,27 @@ f_strridx(argvars, rettv)
|
||||
needle = get_tv_string(&argvars[1]);
|
||||
haystack = get_tv_string_buf(&argvars[0], buf);
|
||||
haystack_len = STRLEN(haystack);
|
||||
if (argvars[2].v_type != VAR_UNKNOWN)
|
||||
{
|
||||
/* Third argument: upper limit for index */
|
||||
end_idx = get_tv_number(&argvars[2]);
|
||||
if (end_idx < 0)
|
||||
{
|
||||
/* can never find a match */
|
||||
rettv->vval.v_number = -1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
end_idx = haystack_len;
|
||||
|
||||
if (*needle == NUL)
|
||||
{
|
||||
/* Empty string matches past the end. */
|
||||
lastmatch = haystack + haystack_len;
|
||||
lastmatch = haystack + end_idx;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (argvars[2].v_type != VAR_UNKNOWN)
|
||||
{
|
||||
/* Third argument: upper limit for index */
|
||||
end_idx = get_tv_number(&argvars[2]);
|
||||
if (end_idx < 0)
|
||||
{
|
||||
/* can never find a match */
|
||||
rettv->vval.v_number = -1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
end_idx = haystack_len;
|
||||
|
||||
for (rest = haystack; *rest != '\0'; ++rest)
|
||||
{
|
||||
rest = (char_u *)strstr((char *)rest, (char *)needle);
|
||||
@ -15625,6 +15791,14 @@ ex_function(eap)
|
||||
}
|
||||
fp->uf_args = newargs;
|
||||
fp->uf_lines = newlines;
|
||||
#ifdef FEAT_PROFILE
|
||||
fp->uf_tml_count = NULL;
|
||||
fp->uf_tml_total = NULL;
|
||||
fp->uf_tml_self = NULL;
|
||||
fp->uf_profiling = FALSE;
|
||||
if (prof_def_func())
|
||||
func_do_profile(fp);
|
||||
#endif
|
||||
fp->uf_varargs = varargs;
|
||||
fp->uf_flags = flags;
|
||||
fp->uf_calls = 0;
|
||||
@ -15912,6 +16086,92 @@ builtin_function(name)
|
||||
return ASCII_ISLOWER(name[0]) && vim_strchr(name, ':') == NULL;
|
||||
}
|
||||
|
||||
#if defined(FEAT_PROFILE) || defined(PROTO)
|
||||
/*
|
||||
* Start profiling function "fp".
|
||||
*/
|
||||
static void
|
||||
func_do_profile(fp)
|
||||
ufunc_T *fp;
|
||||
{
|
||||
fp->uf_tm_count = 0;
|
||||
profile_zero(&fp->uf_tm_self);
|
||||
profile_zero(&fp->uf_tm_total);
|
||||
if (fp->uf_tml_count == NULL)
|
||||
fp->uf_tml_count = (int *)alloc_clear((unsigned)
|
||||
(sizeof(int) * fp->uf_lines.ga_len));
|
||||
if (fp->uf_tml_total == NULL)
|
||||
fp->uf_tml_total = (proftime_T *)alloc_clear((unsigned)
|
||||
(sizeof(proftime_T) * fp->uf_lines.ga_len));
|
||||
if (fp->uf_tml_self == NULL)
|
||||
fp->uf_tml_self = (proftime_T *)alloc_clear((unsigned)
|
||||
(sizeof(proftime_T) * fp->uf_lines.ga_len));
|
||||
fp->uf_tml_idx = -1;
|
||||
if (fp->uf_tml_count == NULL || fp->uf_tml_total == NULL
|
||||
|| fp->uf_tml_self == NULL)
|
||||
return; /* out of memory */
|
||||
|
||||
fp->uf_profiling = TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Dump the profiling results for all functions in file "fd".
|
||||
*/
|
||||
void
|
||||
func_dump_profile(fd)
|
||||
FILE *fd;
|
||||
{
|
||||
hashitem_T *hi;
|
||||
int todo;
|
||||
ufunc_T *fp;
|
||||
int i;
|
||||
|
||||
todo = func_hashtab.ht_used;
|
||||
for (hi = func_hashtab.ht_array; todo > 0; ++hi)
|
||||
{
|
||||
if (!HASHITEM_EMPTY(hi))
|
||||
{
|
||||
--todo;
|
||||
fp = HI2UF(hi);
|
||||
if (fp->uf_profiling)
|
||||
{
|
||||
if (fp->uf_name[0] == K_SPECIAL)
|
||||
fprintf(fd, "FUNCTION <SNR>%s()\n", fp->uf_name + 3);
|
||||
else
|
||||
fprintf(fd, "FUNCTION %s()\n", fp->uf_name);
|
||||
if (fp->uf_tm_count == 1)
|
||||
fprintf(fd, "Called 1 time\n");
|
||||
else
|
||||
fprintf(fd, "Called %d times\n", fp->uf_tm_count);
|
||||
fprintf(fd, "Total time: %s\n", profile_msg(&fp->uf_tm_total));
|
||||
fprintf(fd, " Self time: %s\n", profile_msg(&fp->uf_tm_self));
|
||||
fprintf(fd, "\n");
|
||||
fprintf(fd, "count total (s) self (s)\n");
|
||||
|
||||
for (i = 0; i < fp->uf_lines.ga_len; ++i)
|
||||
{
|
||||
if (fp->uf_tml_count[i] > 0)
|
||||
{
|
||||
fprintf(fd, "%5d ", fp->uf_tml_count[i]);
|
||||
if (profile_equal(&fp->uf_tml_total[i],
|
||||
&fp->uf_tml_self[i]))
|
||||
fprintf(fd, " ");
|
||||
else
|
||||
fprintf(fd, "%s ",
|
||||
profile_msg(&fp->uf_tml_total[i]));
|
||||
fprintf(fd, "%s ", profile_msg(&fp->uf_tml_self[i]));
|
||||
}
|
||||
else
|
||||
fprintf(fd, " ");
|
||||
fprintf(fd, "%s\n", FUNCLINE(fp, i));
|
||||
}
|
||||
fprintf(fd, "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* If "name" has a package name try autoloading the script for it.
|
||||
* Return TRUE if a package was loaded.
|
||||
@ -16065,7 +16325,7 @@ ex_delfunction(eap)
|
||||
{
|
||||
if (fp == NULL)
|
||||
{
|
||||
EMSG2(_("E130: Undefined function: %s"), eap->arg);
|
||||
EMSG2(_(e_nofunc), eap->arg);
|
||||
return;
|
||||
}
|
||||
if (fp->uf_calls > 0)
|
||||
@ -16097,6 +16357,11 @@ func_free(fp)
|
||||
/* clear this function */
|
||||
ga_clear_strings(&(fp->uf_args));
|
||||
ga_clear_strings(&(fp->uf_lines));
|
||||
#ifdef FEAT_PROFILE
|
||||
vim_free(fp->uf_tml_count);
|
||||
vim_free(fp->uf_tml_total);
|
||||
vim_free(fp->uf_tml_self);
|
||||
#endif
|
||||
|
||||
/* remove the function from the function hashtable */
|
||||
hi = hash_find(&func_hashtab, UF2HIKEY(fp));
|
||||
@ -16178,6 +16443,9 @@ call_user_func(fp, argcount, argvars, rettv, firstline, lastline, selfdict)
|
||||
int ai;
|
||||
char_u numbuf[NUMBUFLEN];
|
||||
char_u *name;
|
||||
#ifdef FEAT_PROFILE
|
||||
proftime_T wait_start;
|
||||
#endif
|
||||
|
||||
/* If depth of calling is getting too high, don't execute the function */
|
||||
if (depth >= p_mfd)
|
||||
@ -16341,6 +16609,22 @@ call_user_func(fp, argcount, argvars, rettv, firstline, lastline, selfdict)
|
||||
--no_wait_return;
|
||||
}
|
||||
}
|
||||
#ifdef FEAT_PROFILE
|
||||
if (do_profiling)
|
||||
{
|
||||
if (!fp->uf_profiling && has_profiling(FALSE, fp->uf_name, NULL))
|
||||
func_do_profile(fp);
|
||||
if (fp->uf_profiling
|
||||
|| (save_fcp != NULL && &save_fcp->func->uf_profiling))
|
||||
{
|
||||
++fp->uf_tm_count;
|
||||
profile_start(&fp->uf_tm_start);
|
||||
profile_zero(&fp->uf_tm_children);
|
||||
}
|
||||
script_prof_save(&wait_start);
|
||||
}
|
||||
#endif
|
||||
|
||||
save_current_SID = current_SID;
|
||||
current_SID = fp->uf_script_ID;
|
||||
save_did_emsg = did_emsg;
|
||||
@ -16360,6 +16644,22 @@ call_user_func(fp, argcount, argvars, rettv, firstline, lastline, selfdict)
|
||||
rettv->vval.v_number = -1;
|
||||
}
|
||||
|
||||
#ifdef FEAT_PROFILE
|
||||
if (fp->uf_profiling || (save_fcp != NULL && &save_fcp->func->uf_profiling))
|
||||
{
|
||||
profile_end(&fp->uf_tm_start);
|
||||
profile_sub_wait(&wait_start, &fp->uf_tm_start);
|
||||
profile_add(&fp->uf_tm_total, &fp->uf_tm_start);
|
||||
profile_add(&fp->uf_tm_self, &fp->uf_tm_start);
|
||||
profile_sub(&fp->uf_tm_self, &fp->uf_tm_children);
|
||||
if (save_fcp != NULL && &save_fcp->func->uf_profiling)
|
||||
{
|
||||
profile_add(&save_fcp->func->uf_tm_children, &fp->uf_tm_start);
|
||||
profile_add(&save_fcp->func->uf_tml_children, &fp->uf_tm_start);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* when being verbose, mention the return value */
|
||||
if (p_verbose >= 12)
|
||||
{
|
||||
@ -16398,6 +16698,10 @@ call_user_func(fp, argcount, argvars, rettv, firstline, lastline, selfdict)
|
||||
sourcing_name = save_sourcing_name;
|
||||
sourcing_lnum = save_sourcing_lnum;
|
||||
current_SID = save_current_SID;
|
||||
#ifdef FEAT_PROFILE
|
||||
if (do_profiling)
|
||||
script_prof_restore(&wait_start);
|
||||
#endif
|
||||
|
||||
if (p_verbose >= 12 && sourcing_name != NULL)
|
||||
{
|
||||
@ -16624,19 +16928,24 @@ get_func_line(c, cookie, indent)
|
||||
int indent; /* not used */
|
||||
{
|
||||
funccall_T *fcp = (funccall_T *)cookie;
|
||||
char_u *retval;
|
||||
garray_T *gap; /* growarray with function lines */
|
||||
ufunc_T *fp = fcp->func;
|
||||
char_u *retval;
|
||||
garray_T *gap; /* growarray with function lines */
|
||||
|
||||
/* If breakpoints have been added/deleted need to check for it. */
|
||||
if (fcp->dbg_tick != debug_tick)
|
||||
{
|
||||
fcp->breakpoint = dbg_find_breakpoint(FALSE, fcp->func->uf_name,
|
||||
fcp->breakpoint = dbg_find_breakpoint(FALSE, fp->uf_name,
|
||||
sourcing_lnum);
|
||||
fcp->dbg_tick = debug_tick;
|
||||
}
|
||||
#ifdef FEAT_PROFILE
|
||||
if (do_profiling)
|
||||
func_line_end(cookie);
|
||||
#endif
|
||||
|
||||
gap = &fcp->func->uf_lines;
|
||||
if ((fcp->func->uf_flags & FC_ABORT) && did_emsg && !aborted_in_try())
|
||||
gap = &fp->uf_lines;
|
||||
if ((fp->uf_flags & FC_ABORT) && did_emsg && !aborted_in_try())
|
||||
retval = NULL;
|
||||
else if (fcp->returned || fcp->linenr >= gap->ga_len)
|
||||
retval = NULL;
|
||||
@ -16644,14 +16953,18 @@ get_func_line(c, cookie, indent)
|
||||
{
|
||||
retval = vim_strsave(((char_u **)(gap->ga_data))[fcp->linenr++]);
|
||||
sourcing_lnum = fcp->linenr;
|
||||
#ifdef FEAT_PROFILE
|
||||
if (do_profiling)
|
||||
func_line_start(cookie);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Did we encounter a breakpoint? */
|
||||
if (fcp->breakpoint != 0 && fcp->breakpoint <= sourcing_lnum)
|
||||
{
|
||||
dbg_breakpoint(fcp->func->uf_name, sourcing_lnum);
|
||||
dbg_breakpoint(fp->uf_name, sourcing_lnum);
|
||||
/* Find next breakpoint. */
|
||||
fcp->breakpoint = dbg_find_breakpoint(FALSE, fcp->func->uf_name,
|
||||
fcp->breakpoint = dbg_find_breakpoint(FALSE, fp->uf_name,
|
||||
sourcing_lnum);
|
||||
fcp->dbg_tick = debug_tick;
|
||||
}
|
||||
@ -16659,6 +16972,71 @@ get_func_line(c, cookie, indent)
|
||||
return retval;
|
||||
}
|
||||
|
||||
#if defined(FEAT_PROFILE) || defined(PROTO)
|
||||
/*
|
||||
* Called when starting to read a function line.
|
||||
* "sourcing_lnum" must be correct!
|
||||
* When skipping lines it may not actually be executed, but we won't find out
|
||||
* until later and we need to store the time now.
|
||||
*/
|
||||
void
|
||||
func_line_start(cookie)
|
||||
void *cookie;
|
||||
{
|
||||
funccall_T *fcp = (funccall_T *)cookie;
|
||||
ufunc_T *fp = fcp->func;
|
||||
|
||||
if (fp->uf_profiling && sourcing_lnum >= 1
|
||||
&& sourcing_lnum <= fp->uf_lines.ga_len)
|
||||
{
|
||||
fp->uf_tml_idx = sourcing_lnum - 1;
|
||||
fp->uf_tml_execed = FALSE;
|
||||
profile_start(&fp->uf_tml_start);
|
||||
profile_zero(&fp->uf_tml_children);
|
||||
profile_get_wait(&fp->uf_tml_wait);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Called when actually executing a function line.
|
||||
*/
|
||||
void
|
||||
func_line_exec(cookie)
|
||||
void *cookie;
|
||||
{
|
||||
funccall_T *fcp = (funccall_T *)cookie;
|
||||
ufunc_T *fp = fcp->func;
|
||||
|
||||
if (fp->uf_profiling && fp->uf_tml_idx >= 0)
|
||||
fp->uf_tml_execed = TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Called when done with a function line.
|
||||
*/
|
||||
void
|
||||
func_line_end(cookie)
|
||||
void *cookie;
|
||||
{
|
||||
funccall_T *fcp = (funccall_T *)cookie;
|
||||
ufunc_T *fp = fcp->func;
|
||||
|
||||
if (fp->uf_profiling && fp->uf_tml_idx >= 0)
|
||||
{
|
||||
if (fp->uf_tml_execed)
|
||||
{
|
||||
++fp->uf_tml_count[fp->uf_tml_idx];
|
||||
profile_end(&fp->uf_tml_start);
|
||||
profile_sub_wait(&fp->uf_tml_wait, &fp->uf_tml_start);
|
||||
profile_add(&fp->uf_tml_self[fp->uf_tml_idx], &fp->uf_tml_start);
|
||||
profile_add(&fp->uf_tml_total[fp->uf_tml_idx], &fp->uf_tml_start);
|
||||
profile_sub(&fp->uf_tml_self[fp->uf_tml_idx], &fp->uf_tml_children);
|
||||
}
|
||||
fp->uf_tml_idx = -1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Return TRUE if the currently active function should be ended, because a
|
||||
* return was encountered or an error occured. Used inside a ":while".
|
||||
|
@ -30,7 +30,7 @@ static int check_readonly __ARGS((int *forceit, buf_T *buf));
|
||||
#ifdef FEAT_AUTOCMD
|
||||
static void delbuf_msg __ARGS((char_u *name));
|
||||
#endif
|
||||
static int do_sub_msg __ARGS((void));
|
||||
static int do_sub_msg __ARGS((int count_only));
|
||||
static int
|
||||
#ifdef __BORLANDC__
|
||||
_RTLENTRYF
|
||||
@ -3661,6 +3661,7 @@ do_sub(eap)
|
||||
regmmatch_T regmatch;
|
||||
static int do_all = FALSE; /* do multiple substitutions per line */
|
||||
static int do_ask = FALSE; /* ask for confirmation */
|
||||
static int do_count = FALSE; /* count only */
|
||||
static int do_error = TRUE; /* if false, ignore errors */
|
||||
static int do_print = FALSE; /* print last line with subs. */
|
||||
static int do_list = FALSE; /* list last line with subs. */
|
||||
@ -3684,6 +3685,7 @@ do_sub(eap)
|
||||
linenr_T sub_firstlnum; /* nr of first sub line */
|
||||
char_u *sub_firstline; /* allocated copy of first sub line */
|
||||
int endcolumn = FALSE; /* cursor in last column when done */
|
||||
pos_T old_cursor = curwin->w_cursor;
|
||||
|
||||
cmd = eap->arg;
|
||||
if (!global_busy)
|
||||
@ -3822,6 +3824,8 @@ do_sub(eap)
|
||||
do_all = !do_all;
|
||||
else if (*cmd == 'c')
|
||||
do_ask = !do_ask;
|
||||
else if (*cmd == 'n')
|
||||
do_count = TRUE;
|
||||
else if (*cmd == 'e')
|
||||
do_error = !do_error;
|
||||
else if (*cmd == 'r') /* use last used regexp */
|
||||
@ -3846,6 +3850,8 @@ do_sub(eap)
|
||||
break;
|
||||
++cmd;
|
||||
}
|
||||
if (do_count)
|
||||
do_ask = FALSE;
|
||||
|
||||
/*
|
||||
* check for a trailing count
|
||||
@ -4030,8 +4036,25 @@ do_sub(eap)
|
||||
prev_matchcol = matchcol;
|
||||
|
||||
/*
|
||||
* 2. If do_ask is set, ask for confirmation.
|
||||
* 2. If do_count is set only increase the counter.
|
||||
* If do_ask is set, ask for confirmation.
|
||||
*/
|
||||
if (do_count)
|
||||
{
|
||||
/* For a multi-line match, put matchcol at the NUL at
|
||||
* the end of the line and set nmatch to one, so that
|
||||
* we continue looking for a match on the next line.
|
||||
* Avoids that ":s/\nB\@=//gc" get stuck. */
|
||||
if (nmatch > 1)
|
||||
{
|
||||
matchcol = STRLEN(sub_firstline);
|
||||
nmatch = 1;
|
||||
}
|
||||
sub_nsubs++;
|
||||
did_sub = TRUE;
|
||||
goto skip;
|
||||
}
|
||||
|
||||
if (do_ask)
|
||||
{
|
||||
/* change State to CONFIRM, so that the mouse works
|
||||
@ -4064,9 +4087,9 @@ do_sub(eap)
|
||||
curwin->w_cursor.col = regmatch.endpos[0].col - 1;
|
||||
getvcol(curwin, &curwin->w_cursor, NULL, NULL, &ec);
|
||||
msg_start();
|
||||
for (i = 0; i < sc; ++i)
|
||||
for (i = 0; i < (long)sc; ++i)
|
||||
msg_putchar(' ');
|
||||
for ( ; i <= ec; ++i)
|
||||
for ( ; i <= (long)ec; ++i)
|
||||
msg_putchar('^');
|
||||
|
||||
resp = getexmodeline('?', NULL, 0);
|
||||
@ -4458,6 +4481,11 @@ skip:
|
||||
|
||||
outofmem:
|
||||
vim_free(sub_firstline); /* may have to free allocated copy of the line */
|
||||
|
||||
/* ":s/pat//n" doesn't move the cursor */
|
||||
if (do_count)
|
||||
curwin->w_cursor = old_cursor;
|
||||
|
||||
if (sub_nsubs)
|
||||
{
|
||||
/* Set the '[ and '] marks. */
|
||||
@ -4471,7 +4499,7 @@ outofmem:
|
||||
coladvance((colnr_T)MAXCOL);
|
||||
else
|
||||
beginline(BL_WHITE | BL_FIX);
|
||||
if (!do_sub_msg() && do_ask)
|
||||
if (!do_sub_msg(do_count) && do_ask)
|
||||
MSG("");
|
||||
}
|
||||
else
|
||||
@ -4498,7 +4526,8 @@ outofmem:
|
||||
* Return TRUE if a message was given.
|
||||
*/
|
||||
static int
|
||||
do_sub_msg()
|
||||
do_sub_msg(count_only)
|
||||
int count_only; /* used 'n' flag for ":s" */
|
||||
{
|
||||
/*
|
||||
* Only report substitutions when:
|
||||
@ -4506,8 +4535,8 @@ do_sub_msg()
|
||||
* - command was typed by user, or number of changed lines > 'report'
|
||||
* - giving messages is not disabled by 'lazyredraw'
|
||||
*/
|
||||
if (sub_nsubs > p_report
|
||||
&& (KeyTyped || sub_nlines > 1 || p_report < 1)
|
||||
if (((sub_nsubs > p_report && (KeyTyped || sub_nlines > 1 || p_report < 1))
|
||||
|| count_only)
|
||||
&& messaging())
|
||||
{
|
||||
if (got_int)
|
||||
@ -4515,9 +4544,10 @@ do_sub_msg()
|
||||
else
|
||||
msg_buf[0] = NUL;
|
||||
if (sub_nsubs == 1)
|
||||
STRCAT(msg_buf, _("1 substitution"));
|
||||
STRCAT(msg_buf, count_only ? _("1 match") : _("1 substitution"));
|
||||
else
|
||||
sprintf((char *)msg_buf + STRLEN(msg_buf), _("%ld substitutions"),
|
||||
sprintf((char *)msg_buf + STRLEN(msg_buf),
|
||||
count_only ? _("%ld matches") : _("%ld substitutions"),
|
||||
sub_nsubs);
|
||||
if (sub_nlines == 1)
|
||||
STRCAT(msg_buf, _(" on 1 line"));
|
||||
@ -4561,7 +4591,7 @@ ex_global(eap)
|
||||
exarg_T *eap;
|
||||
{
|
||||
linenr_T lnum; /* line number according to old situation */
|
||||
int ndone;
|
||||
int ndone = 0;
|
||||
int type; /* first char of cmd: 'v' or 'g' */
|
||||
char_u *cmd; /* command argument */
|
||||
|
||||
@ -4633,10 +4663,29 @@ ex_global(eap)
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef HAVE_SETJMP_H
|
||||
/*
|
||||
* Matching with a regexp may cause a very deep recursive call of
|
||||
* regmatch(). Vim will crash when running out of stack space.
|
||||
* Catch this here if the system supports it.
|
||||
* It's a bit slow, thus do it outside of the loop.
|
||||
*/
|
||||
mch_startjmp();
|
||||
if (SETJMP(lc_jump_env) != 0)
|
||||
{
|
||||
mch_didjmp();
|
||||
# ifdef SIGHASARG
|
||||
if (lc_signal != SIGINT)
|
||||
# endif
|
||||
EMSG(_(e_complex));
|
||||
got_int = TRUE;
|
||||
goto jumpend;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* pass 1: set marks for each (not) matching line
|
||||
*/
|
||||
ndone = 0;
|
||||
for (lnum = eap->line1; lnum <= eap->line2 && !got_int; ++lnum)
|
||||
{
|
||||
/* a match on this line? */
|
||||
@ -4649,6 +4698,11 @@ ex_global(eap)
|
||||
line_breakcheck();
|
||||
}
|
||||
|
||||
#ifdef HAVE_SETJMP_H
|
||||
jumpend:
|
||||
mch_endjmp();
|
||||
#endif
|
||||
|
||||
/*
|
||||
* pass 2: execute the command for each line that has been marked
|
||||
*/
|
||||
@ -4719,7 +4773,7 @@ global_exe(cmd)
|
||||
|
||||
/* If subsitutes done, report number of substitues, otherwise report
|
||||
* number of extra or deleted lines. */
|
||||
if (!do_sub_msg())
|
||||
if (!do_sub_msg(FALSE))
|
||||
msgmore(curbuf->b_ml.ml_line_count - old_lcount);
|
||||
}
|
||||
|
||||
|
@ -609,6 +609,8 @@ EX(CMD_promptfind, "promptfind", gui_mch_find_dialog,
|
||||
EXTRA|NOTRLCOM|CMDWIN),
|
||||
EX(CMD_promptrepl, "promptrepl", gui_mch_replace_dialog,
|
||||
EXTRA|NOTRLCOM|CMDWIN),
|
||||
EX(CMD_profile, "profile", ex_profile,
|
||||
BANG|EXTRA|TRLBAR|CMDWIN),
|
||||
EX(CMD_psearch, "psearch", ex_psearch,
|
||||
BANG|RANGE|WHOLEFOLD|DFLALL|EXTRA),
|
||||
EX(CMD_ptag, "ptag", ex_ptag,
|
||||
@ -850,9 +852,9 @@ EX(CMD_visual, "visual", ex_edit,
|
||||
EX(CMD_view, "view", ex_edit,
|
||||
BANG|FILE1|EDITCMD|ARGOPT|TRLBAR),
|
||||
EX(CMD_vimgrep, "vimgrep", ex_vimgrep,
|
||||
NEEDARG|EXTRA|NOTRLCOM|TRLBAR|XFILE),
|
||||
BANG|NEEDARG|EXTRA|NOTRLCOM|TRLBAR|XFILE),
|
||||
EX(CMD_vimgrepadd, "vimgrepadd", ex_vimgrep,
|
||||
NEEDARG|EXTRA|NOTRLCOM|TRLBAR|XFILE),
|
||||
BANG|NEEDARG|EXTRA|NOTRLCOM|TRLBAR|XFILE),
|
||||
EX(CMD_viusage, "viusage", ex_viusage,
|
||||
TRLBAR),
|
||||
EX(CMD_vmap, "vmap", ex_map,
|
||||
|
750
src/ex_cmds2.c
750
src/ex_cmds2.c
@ -25,6 +25,54 @@
|
||||
|
||||
static void cmd_source __ARGS((char_u *fname, exarg_T *eap));
|
||||
|
||||
#ifdef FEAT_EVAL
|
||||
/* Growarray to store the names of sourced scripts.
|
||||
* For Unix also store the dev/ino, so that we don't have to stat() each
|
||||
* script when going through the list. */
|
||||
typedef struct scriptitem_S
|
||||
{
|
||||
char_u *sn_name;
|
||||
# ifdef UNIX
|
||||
int sn_dev;
|
||||
ino_t sn_ino;
|
||||
# endif
|
||||
# ifdef FEAT_PROFILE
|
||||
int sn_prof_on; /* TRUE when script is/was profiled */
|
||||
int sn_pr_force; /* forceit: profile defined functions */
|
||||
proftime_T sn_pr_child; /* time set when going into first child */
|
||||
int sn_pr_nest; /* nesting for sn_pr_child */
|
||||
/* profiling the script as a whole */
|
||||
int sn_pr_count; /* nr of times sourced */
|
||||
proftime_T sn_pr_total; /* time spend in script + children */
|
||||
proftime_T sn_pr_self; /* time spend in script itself */
|
||||
proftime_T sn_pr_start; /* time at script start */
|
||||
proftime_T sn_pr_children; /* time in children after script start */
|
||||
/* profiling the script per line */
|
||||
garray_T sn_prl_ga; /* things stored for every line */
|
||||
proftime_T sn_prl_start; /* start time for current line */
|
||||
proftime_T sn_prl_children; /* time spent in children for this line */
|
||||
proftime_T sn_prl_wait; /* wait start time for current line */
|
||||
int sn_prl_idx; /* index of line being timed; -1 if none */
|
||||
int sn_prl_execed; /* line being timed was executed */
|
||||
# endif
|
||||
} scriptitem_T;
|
||||
|
||||
static garray_T script_items = {0, 0, sizeof(scriptitem_T), 4, NULL};
|
||||
#define SCRIPT_ITEM(id) (((scriptitem_T *)script_items.ga_data)[(id) - 1])
|
||||
|
||||
# ifdef FEAT_PROFILE
|
||||
/* Struct used in sn_prl_ga for every line of a script. */
|
||||
typedef struct sn_prl_S
|
||||
{
|
||||
int snp_count; /* nr of times line was executed */
|
||||
proftime_T sn_prl_total; /* time spend in a line + children */
|
||||
proftime_T sn_prl_self; /* time spend in a line itself */
|
||||
} sn_prl_T;
|
||||
|
||||
# define PRL_ITEM(si, idx) (((sn_prl_T *)(si)->sn_prl_ga.ga_data)[(idx)])
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(FEAT_EVAL) || defined(PROTO)
|
||||
static int debug_greedy = FALSE; /* batch mode debugging: don't save
|
||||
and restore typeahead. */
|
||||
@ -352,41 +400,54 @@ struct debuggy
|
||||
char_u *dbg_name; /* function or file name */
|
||||
regprog_T *dbg_prog; /* regexp program */
|
||||
linenr_T dbg_lnum; /* line number in function or file */
|
||||
int dbg_forceit; /* ! used */
|
||||
};
|
||||
|
||||
static garray_T dbg_breakp = {0, 0, sizeof(struct debuggy), 4, NULL};
|
||||
#define BREAKP(idx) (((struct debuggy *)dbg_breakp.ga_data)[idx])
|
||||
#define BREAKP(idx) (((struct debuggy *)dbg_breakp.ga_data)[idx])
|
||||
#define DEBUGGY(gap, idx) (((struct debuggy *)gap->ga_data)[idx])
|
||||
static int last_breakp = 0; /* nr of last defined breakpoint */
|
||||
|
||||
#ifdef FEAT_PROFILE
|
||||
/* Profiling uses file and func names similar to breakpoints. */
|
||||
static garray_T prof_ga = {0, 0, sizeof(struct debuggy), 4, NULL};
|
||||
#endif
|
||||
#define DBG_FUNC 1
|
||||
#define DBG_FILE 2
|
||||
|
||||
static int dbg_parsearg __ARGS((char_u *arg));
|
||||
static int dbg_parsearg __ARGS((char_u *arg, garray_T *gap));
|
||||
static linenr_T debuggy_find __ARGS((int file,char_u *fname, linenr_T after, garray_T *gap, int *fp));
|
||||
|
||||
/*
|
||||
* Parse the arguments of ":breakadd" or ":breakdel" and put them in the entry
|
||||
* just after the last one in dbg_breakp. Note that "dbg_name" is allocated.
|
||||
* Parse the arguments of ":profile", ":breakadd" or ":breakdel" and put them
|
||||
* in the entry just after the last one in dbg_breakp. Note that "dbg_name"
|
||||
* is allocated.
|
||||
* Returns FAIL for failure.
|
||||
*/
|
||||
static int
|
||||
dbg_parsearg(arg)
|
||||
dbg_parsearg(arg, gap)
|
||||
char_u *arg;
|
||||
garray_T *gap; /* either &dbg_breakp or &prof_ga */
|
||||
{
|
||||
char_u *p = arg;
|
||||
char_u *q;
|
||||
struct debuggy *bp;
|
||||
int here = FALSE;
|
||||
|
||||
if (ga_grow(&dbg_breakp, 1) == FAIL)
|
||||
if (ga_grow(gap, 1) == FAIL)
|
||||
return FAIL;
|
||||
bp = &BREAKP(dbg_breakp.ga_len);
|
||||
bp = &DEBUGGY(gap, gap->ga_len);
|
||||
|
||||
/* Find "func" or "file". */
|
||||
if (STRNCMP(p, "func", 4) == 0)
|
||||
bp->dbg_type = DBG_FUNC;
|
||||
else if (STRNCMP(p, "file", 4) == 0)
|
||||
bp->dbg_type = DBG_FILE;
|
||||
else if (STRNCMP(p, "here", 4) == 0)
|
||||
else if (
|
||||
#ifdef FEAT_PROFILE
|
||||
gap != &prof_ga &&
|
||||
#endif
|
||||
STRNCMP(p, "here", 4) == 0)
|
||||
{
|
||||
if (curbuf->b_ffname == NULL)
|
||||
{
|
||||
@ -406,7 +467,11 @@ dbg_parsearg(arg)
|
||||
/* Find optional line number. */
|
||||
if (here)
|
||||
bp->dbg_lnum = curwin->w_cursor.lnum;
|
||||
else if (VIM_ISDIGIT(*p))
|
||||
else if (
|
||||
#ifdef FEAT_PROFILE
|
||||
gap != &prof_ga &&
|
||||
#endif
|
||||
VIM_ISDIGIT(*p))
|
||||
{
|
||||
bp->dbg_lnum = getdigits(&p);
|
||||
p = skipwhite(p);
|
||||
@ -474,10 +539,19 @@ ex_breakadd(eap)
|
||||
{
|
||||
struct debuggy *bp;
|
||||
char_u *pat;
|
||||
garray_T *gap;
|
||||
|
||||
if (dbg_parsearg(eap->arg) == OK)
|
||||
gap = &dbg_breakp;
|
||||
#ifdef FEAT_PROFILE
|
||||
if (eap->cmdidx == CMD_profile)
|
||||
gap = &prof_ga;
|
||||
#endif
|
||||
|
||||
if (dbg_parsearg(eap->arg, gap) == OK)
|
||||
{
|
||||
bp = &BREAKP(dbg_breakp.ga_len);
|
||||
bp = &DEBUGGY(gap, gap->ga_len);
|
||||
bp->dbg_forceit = eap->forceit;
|
||||
|
||||
pat = file_pat_to_reg_pat(bp->dbg_name, NULL, NULL, FALSE);
|
||||
if (pat != NULL)
|
||||
{
|
||||
@ -490,8 +564,14 @@ ex_breakadd(eap)
|
||||
{
|
||||
if (bp->dbg_lnum == 0) /* default line number is 1 */
|
||||
bp->dbg_lnum = 1;
|
||||
BREAKP(dbg_breakp.ga_len++).dbg_nr = ++last_breakp;
|
||||
++debug_tick;
|
||||
#ifdef FEAT_PROFILE
|
||||
if (eap->cmdidx != CMD_profile)
|
||||
#endif
|
||||
{
|
||||
DEBUGGY(gap, gap->ga_len).dbg_nr = ++last_breakp;
|
||||
++debug_tick;
|
||||
}
|
||||
++gap->ga_len;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -536,7 +616,7 @@ ex_breakdel(eap)
|
||||
else
|
||||
{
|
||||
/* ":breakdel {func|file} [lnum] {name}" */
|
||||
if (dbg_parsearg(eap->arg) == FAIL)
|
||||
if (dbg_parsearg(eap->arg, &dbg_breakp) == FAIL)
|
||||
return;
|
||||
bp = &BREAKP(dbg_breakp.ga_len);
|
||||
for (i = 0; i < dbg_breakp.ga_len; ++i)
|
||||
@ -604,6 +684,35 @@ dbg_find_breakpoint(file, fname, after)
|
||||
int file; /* TRUE for a file, FALSE for a function */
|
||||
char_u *fname; /* file or function name */
|
||||
linenr_T after; /* after this line number */
|
||||
{
|
||||
return debuggy_find(file, fname, after, &dbg_breakp, NULL);
|
||||
}
|
||||
|
||||
#if defined(FEAT_PROFILE) || defined(PROTO)
|
||||
/*
|
||||
* Return TRUE if profiling is on for a function or sourced file.
|
||||
*/
|
||||
int
|
||||
has_profiling(file, fname, fp)
|
||||
int file; /* TRUE for a file, FALSE for a function */
|
||||
char_u *fname; /* file or function name */
|
||||
int *fp; /* return: forceit */
|
||||
{
|
||||
return (debuggy_find(file, fname, (linenr_T)0, &prof_ga, fp)
|
||||
!= (linenr_T)0);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Common code for dbg_find_breakpoint() and has_profiling().
|
||||
*/
|
||||
static linenr_T
|
||||
debuggy_find(file, fname, after, gap, fp)
|
||||
int file; /* TRUE for a file, FALSE for a function */
|
||||
char_u *fname; /* file or function name */
|
||||
linenr_T after; /* after this line number */
|
||||
garray_T *gap; /* either &dbg_breakp or &prof_ga */
|
||||
int *fp; /* if not NULL: return forceit */
|
||||
{
|
||||
struct debuggy *bp;
|
||||
int i;
|
||||
@ -612,6 +721,10 @@ dbg_find_breakpoint(file, fname, after)
|
||||
char_u *name = fname;
|
||||
int prev_got_int;
|
||||
|
||||
/* Return quickly when there are no breakpoints. */
|
||||
if (gap->ga_len == 0)
|
||||
return (linenr_T)0;
|
||||
|
||||
/* Replace K_SNR in function name with "<SNR>". */
|
||||
if (!file && fname[0] == K_SPECIAL)
|
||||
{
|
||||
@ -625,26 +738,32 @@ dbg_find_breakpoint(file, fname, after)
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < dbg_breakp.ga_len; ++i)
|
||||
for (i = 0; i < gap->ga_len; ++i)
|
||||
{
|
||||
/* skip entries that are not useful or are for a line that is beyond
|
||||
* an already found breakpoint */
|
||||
bp = &BREAKP(i);
|
||||
if ((bp->dbg_type == DBG_FILE) == file
|
||||
&& bp->dbg_lnum > after
|
||||
&& (lnum == 0 || bp->dbg_lnum < lnum))
|
||||
/* Skip entries that are not useful or are for a line that is beyond
|
||||
* an already found breakpoint. */
|
||||
bp = &DEBUGGY(gap, i);
|
||||
if (((bp->dbg_type == DBG_FILE) == file && (
|
||||
#ifdef FEAT_PROFILE
|
||||
gap == &prof_ga ||
|
||||
#endif
|
||||
(bp->dbg_lnum > after && (lnum == 0 || bp->dbg_lnum < lnum)))))
|
||||
{
|
||||
regmatch.regprog = bp->dbg_prog;
|
||||
regmatch.rm_ic = FALSE;
|
||||
/*
|
||||
* Save the value of got_int and reset it. We don't want a previous
|
||||
* interruption cancel matching, only hitting CTRL-C while matching
|
||||
* should abort it.
|
||||
* Save the value of got_int and reset it. We don't want a
|
||||
* previous interruption cancel matching, only hitting CTRL-C
|
||||
* while matching should abort it.
|
||||
*/
|
||||
prev_got_int = got_int;
|
||||
got_int = FALSE;
|
||||
if (vim_regexec(®match, name, (colnr_T)0))
|
||||
{
|
||||
lnum = bp->dbg_lnum;
|
||||
if (fp != NULL)
|
||||
*fp = bp->dbg_forceit;
|
||||
}
|
||||
got_int |= prev_got_int;
|
||||
}
|
||||
}
|
||||
@ -666,6 +785,339 @@ dbg_breakpoint(name, lnum)
|
||||
debug_breakpoint_name = name;
|
||||
debug_breakpoint_lnum = lnum;
|
||||
}
|
||||
|
||||
|
||||
# if defined(FEAT_PROFILE) || defined(PROTO)
|
||||
/*
|
||||
* Functions for profiling.
|
||||
*/
|
||||
static void script_do_profile __ARGS((scriptitem_T *si));
|
||||
static void script_dump_profile __ARGS((FILE *fd));
|
||||
static proftime_T prof_wait_time;
|
||||
|
||||
/*
|
||||
* Set the time in "tm" to zero.
|
||||
*/
|
||||
void
|
||||
profile_zero(tm)
|
||||
proftime_T *tm;
|
||||
{
|
||||
tm->tv_usec = 0;
|
||||
tm->tv_sec = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Store the current time in "tm".
|
||||
*/
|
||||
void
|
||||
profile_start(tm)
|
||||
proftime_T *tm;
|
||||
{
|
||||
gettimeofday(tm, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Compute the elapsed time from "tm" till now and store in "tm".
|
||||
*/
|
||||
void
|
||||
profile_end(tm)
|
||||
proftime_T *tm;
|
||||
{
|
||||
proftime_T now;
|
||||
|
||||
gettimeofday(&now, NULL);
|
||||
tm->tv_usec = now.tv_usec - tm->tv_usec;
|
||||
tm->tv_sec = now.tv_sec - tm->tv_sec;
|
||||
if (tm->tv_usec < 0)
|
||||
{
|
||||
tm->tv_usec += 1000000;
|
||||
--tm->tv_sec;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Subtract the time "tm2" from "tm".
|
||||
*/
|
||||
void
|
||||
profile_sub(tm, tm2)
|
||||
proftime_T *tm, *tm2;
|
||||
{
|
||||
tm->tv_usec -= tm2->tv_usec;
|
||||
tm->tv_sec -= tm2->tv_sec;
|
||||
if (tm->tv_usec < 0)
|
||||
{
|
||||
tm->tv_usec += 1000000;
|
||||
--tm->tv_sec;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Add the time "tm2" to "tm".
|
||||
*/
|
||||
void
|
||||
profile_add(tm, tm2)
|
||||
proftime_T *tm, *tm2;
|
||||
{
|
||||
tm->tv_usec += tm2->tv_usec;
|
||||
tm->tv_sec += tm2->tv_sec;
|
||||
if (tm->tv_usec >= 1000000)
|
||||
{
|
||||
tm->tv_usec -= 1000000;
|
||||
++tm->tv_sec;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the current waittime.
|
||||
*/
|
||||
void
|
||||
profile_get_wait(tm)
|
||||
proftime_T *tm;
|
||||
{
|
||||
*tm = prof_wait_time;
|
||||
}
|
||||
|
||||
/*
|
||||
* Subtract the passed waittime since "tm" from "tma".
|
||||
*/
|
||||
void
|
||||
profile_sub_wait(tm, tma)
|
||||
proftime_T *tm, *tma;
|
||||
{
|
||||
proftime_T tm3 = prof_wait_time;
|
||||
|
||||
profile_sub(&tm3, tm);
|
||||
profile_sub(tma, &tm3);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return TRUE if "tm1" and "tm2" are equal.
|
||||
*/
|
||||
int
|
||||
profile_equal(tm1, tm2)
|
||||
proftime_T *tm1, *tm2;
|
||||
{
|
||||
return (tm1->tv_usec == tm2->tv_usec && tm1->tv_sec == tm2->tv_sec);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return a string that represents a time.
|
||||
* Uses a static buffer!
|
||||
*/
|
||||
char *
|
||||
profile_msg(tm)
|
||||
proftime_T *tm;
|
||||
{
|
||||
static char buf[50];
|
||||
|
||||
sprintf(buf, "%3ld.%06ld", (long)tm->tv_sec, (long)tm->tv_usec);
|
||||
return buf;
|
||||
}
|
||||
|
||||
static char_u *profile_fname = NULL;
|
||||
|
||||
/*
|
||||
* ":profile cmd args"
|
||||
*/
|
||||
void
|
||||
ex_profile(eap)
|
||||
exarg_T *eap;
|
||||
{
|
||||
char_u *e;
|
||||
int len;
|
||||
|
||||
e = skiptowhite(eap->arg);
|
||||
len = e - eap->arg;
|
||||
e = skipwhite(e);
|
||||
|
||||
if (len == 5 && STRNCMP(eap->arg, "start", 5) == 0 && *e != NUL)
|
||||
{
|
||||
vim_free(profile_fname);
|
||||
profile_fname = vim_strsave(e);
|
||||
do_profiling = TRUE;
|
||||
profile_zero(&prof_wait_time);
|
||||
set_vim_var_nr(VV_PROFILING, 1L);
|
||||
}
|
||||
else if (!do_profiling)
|
||||
EMSG(_("E750: First use :profile start <fname>"));
|
||||
else
|
||||
{
|
||||
/* The rest is similar to ":breakadd". */
|
||||
ex_breakadd(eap);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Dump the profiling info.
|
||||
*/
|
||||
void
|
||||
profile_dump()
|
||||
{
|
||||
FILE *fd;
|
||||
|
||||
if (profile_fname != NULL)
|
||||
{
|
||||
fd = fopen((char *)profile_fname, "w");
|
||||
if (fd == NULL)
|
||||
EMSG2(_(e_notopen), profile_fname);
|
||||
else
|
||||
{
|
||||
func_dump_profile(fd);
|
||||
script_dump_profile(fd);
|
||||
fclose(fd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Start profiling script "fp".
|
||||
*/
|
||||
static void
|
||||
script_do_profile(si)
|
||||
scriptitem_T *si;
|
||||
{
|
||||
si->sn_pr_count = 0;
|
||||
profile_zero(&si->sn_pr_total);
|
||||
profile_zero(&si->sn_pr_self);
|
||||
|
||||
ga_init2(&si->sn_prl_ga, sizeof(sn_prl_T), 100);
|
||||
si->sn_prl_idx = -1;
|
||||
si->sn_prof_on = TRUE;
|
||||
si->sn_pr_nest = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* save time when starting to invoke another script or function.
|
||||
*/
|
||||
void
|
||||
script_prof_save(tm)
|
||||
proftime_T *tm; /* place to store wait time */
|
||||
{
|
||||
scriptitem_T *si;
|
||||
|
||||
if (current_SID > 0 && current_SID <= script_items.ga_len)
|
||||
{
|
||||
si = &SCRIPT_ITEM(current_SID);
|
||||
if (si->sn_prof_on && si->sn_pr_nest++ == 0)
|
||||
profile_start(&si->sn_pr_child);
|
||||
}
|
||||
profile_get_wait(tm);
|
||||
}
|
||||
|
||||
/*
|
||||
* Count time spent in children after invoking another script or function.
|
||||
*/
|
||||
void
|
||||
script_prof_restore(tm)
|
||||
proftime_T *tm;
|
||||
{
|
||||
scriptitem_T *si;
|
||||
|
||||
if (current_SID > 0 && current_SID <= script_items.ga_len)
|
||||
{
|
||||
si = &SCRIPT_ITEM(current_SID);
|
||||
if (si->sn_prof_on && --si->sn_pr_nest == 0)
|
||||
{
|
||||
profile_end(&si->sn_pr_child);
|
||||
profile_sub_wait(tm, &si->sn_pr_child); /* don't count wait time */
|
||||
profile_add(&si->sn_pr_children, &si->sn_pr_child);
|
||||
profile_add(&si->sn_prl_children, &si->sn_pr_child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static proftime_T inchar_time;
|
||||
|
||||
/*
|
||||
* Called when starting to wait for the user to type a character.
|
||||
*/
|
||||
void
|
||||
prof_inchar_enter()
|
||||
{
|
||||
profile_start(&inchar_time);
|
||||
}
|
||||
|
||||
/*
|
||||
* Called when finished waiting for the user to type a character.
|
||||
*/
|
||||
void
|
||||
prof_inchar_exit()
|
||||
{
|
||||
profile_end(&inchar_time);
|
||||
profile_add(&prof_wait_time, &inchar_time);
|
||||
}
|
||||
|
||||
/*
|
||||
* Dump the profiling results for all scripts in file "fd".
|
||||
*/
|
||||
static void
|
||||
script_dump_profile(fd)
|
||||
FILE *fd;
|
||||
{
|
||||
int id;
|
||||
scriptitem_T *si;
|
||||
int i;
|
||||
FILE *sfd;
|
||||
sn_prl_T *pp;
|
||||
|
||||
for (id = 1; id <= script_items.ga_len; ++id)
|
||||
{
|
||||
si = &SCRIPT_ITEM(id);
|
||||
if (si->sn_prof_on)
|
||||
{
|
||||
fprintf(fd, "SCRIPT %s\n", si->sn_name);
|
||||
if (si->sn_pr_count == 1)
|
||||
fprintf(fd, "Sourced 1 time\n");
|
||||
else
|
||||
fprintf(fd, "Sourced %d times\n", si->sn_pr_count);
|
||||
fprintf(fd, "Total time: %s\n", profile_msg(&si->sn_pr_total));
|
||||
fprintf(fd, " Self time: %s\n", profile_msg(&si->sn_pr_self));
|
||||
fprintf(fd, "\n");
|
||||
fprintf(fd, "count total (s) self (s)\n");
|
||||
|
||||
sfd = fopen((char *)si->sn_name, "r");
|
||||
if (sfd == NULL)
|
||||
fprintf(fd, "Cannot open file!\n");
|
||||
else
|
||||
{
|
||||
for (i = 0; i < si->sn_prl_ga.ga_len; ++i)
|
||||
{
|
||||
if (vim_fgets(IObuff, IOSIZE, sfd))
|
||||
break;
|
||||
pp = &PRL_ITEM(si, i);
|
||||
if (pp->snp_count > 0)
|
||||
{
|
||||
fprintf(fd, "%5d ", pp->snp_count);
|
||||
if (profile_equal(&pp->sn_prl_total, &pp->sn_prl_self))
|
||||
fprintf(fd, " ");
|
||||
else
|
||||
fprintf(fd, "%s ", profile_msg(&pp->sn_prl_total));
|
||||
fprintf(fd, "%s ", profile_msg(&pp->sn_prl_self));
|
||||
}
|
||||
else
|
||||
fprintf(fd, " ");
|
||||
fprintf(fd, "%s", IObuff);
|
||||
}
|
||||
fclose(sfd);
|
||||
}
|
||||
fprintf(fd, "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Return TRUE when a function defined in the current script should be
|
||||
* profiled.
|
||||
*/
|
||||
int
|
||||
prof_def_func()
|
||||
{
|
||||
scriptitem_T *si = &SCRIPT_ITEM(current_SID);
|
||||
|
||||
return si->sn_pr_force;
|
||||
}
|
||||
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -2116,24 +2568,6 @@ source_level(cookie)
|
||||
|
||||
static char_u *get_one_sourceline __ARGS((struct source_cookie *sp));
|
||||
|
||||
#ifdef FEAT_EVAL
|
||||
/* Growarray to store the names of sourced scripts.
|
||||
* For Unix also store the dev/ino, so that we don't have to stat() each
|
||||
* script when going through the list. */
|
||||
struct scriptstuff
|
||||
{
|
||||
char_u *name;
|
||||
# ifdef UNIX
|
||||
int dev;
|
||||
ino_t ino;
|
||||
# endif
|
||||
};
|
||||
static garray_T script_names = {0, 0, sizeof(struct scriptstuff), 4, NULL};
|
||||
#define SCRIPT_NAME(id) (((struct scriptstuff *)script_names.ga_data)[(id) - 1].name)
|
||||
#define SCRIPT_DEV(id) (((struct scriptstuff *)script_names.ga_data)[(id) - 1].dev)
|
||||
#define SCRIPT_INO(id) (((struct scriptstuff *)script_names.ga_data)[(id) - 1].ino)
|
||||
#endif
|
||||
|
||||
#if defined(WIN32) && defined(FEAT_CSCOPE)
|
||||
static FILE *fopen_noinh_readbin __ARGS((char *filename));
|
||||
|
||||
@ -2177,6 +2611,7 @@ do_source(fname, check_other, is_vimrc)
|
||||
static scid_T last_current_SID = 0;
|
||||
void *save_funccalp;
|
||||
int save_debug_break_level = debug_break_level;
|
||||
scriptitem_T *si = NULL;
|
||||
# ifdef UNIX
|
||||
struct stat st;
|
||||
int stat_ok;
|
||||
@ -2186,6 +2621,9 @@ do_source(fname, check_other, is_vimrc)
|
||||
struct timeval tv_rel;
|
||||
struct timeval tv_start;
|
||||
#endif
|
||||
#ifdef FEAT_PROFILE
|
||||
proftime_T wait_start;
|
||||
#endif
|
||||
|
||||
#ifdef RISCOS
|
||||
p = mch_munge_fname(fname);
|
||||
@ -2327,6 +2765,15 @@ do_source(fname, check_other, is_vimrc)
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_EVAL
|
||||
# ifdef FEAT_PROFILE
|
||||
if (do_profiling)
|
||||
prof_child_enter(&wait_start); /* entering a child now */
|
||||
# endif
|
||||
|
||||
/* Don't use local function variables, if called from a function.
|
||||
* Also starts profiling timer for nested script. */
|
||||
save_funccalp = save_funccal();
|
||||
|
||||
/*
|
||||
* Check if this script was sourced before to finds its SID.
|
||||
* If it's new, generate a new SID.
|
||||
@ -2335,48 +2782,72 @@ do_source(fname, check_other, is_vimrc)
|
||||
# ifdef UNIX
|
||||
stat_ok = (mch_stat((char *)fname_exp, &st) >= 0);
|
||||
# endif
|
||||
for (current_SID = script_names.ga_len; current_SID > 0; --current_SID)
|
||||
if (SCRIPT_NAME(current_SID) != NULL
|
||||
for (current_SID = script_items.ga_len; current_SID > 0; --current_SID)
|
||||
{
|
||||
si = &SCRIPT_ITEM(current_SID);
|
||||
if (si->sn_name != NULL
|
||||
&& (
|
||||
# ifdef UNIX
|
||||
/* Compare dev/ino when possible, it catches symbolic
|
||||
* links. Also compare file names, the inode may change
|
||||
* when the file was edited. */
|
||||
((stat_ok && SCRIPT_DEV(current_SID) != -1)
|
||||
&& (SCRIPT_DEV(current_SID) == st.st_dev
|
||||
&& SCRIPT_INO(current_SID) == st.st_ino)) ||
|
||||
((stat_ok && si->sn_dev != -1)
|
||||
&& (si->sn_dev == st.st_dev
|
||||
&& si->sn_ino == st.st_ino)) ||
|
||||
# endif
|
||||
fnamecmp(SCRIPT_NAME(current_SID), fname_exp) == 0))
|
||||
fnamecmp(si->sn_name, fname_exp) == 0))
|
||||
break;
|
||||
}
|
||||
if (current_SID == 0)
|
||||
{
|
||||
current_SID = ++last_current_SID;
|
||||
if (ga_grow(&script_names, (int)(current_SID - script_names.ga_len))
|
||||
== OK)
|
||||
if (ga_grow(&script_items, (int)(current_SID - script_items.ga_len))
|
||||
== FAIL)
|
||||
goto almosttheend;
|
||||
while (script_items.ga_len < current_SID)
|
||||
{
|
||||
while (script_names.ga_len < current_SID)
|
||||
{
|
||||
SCRIPT_NAME(script_names.ga_len + 1) = NULL;
|
||||
++script_names.ga_len;
|
||||
}
|
||||
SCRIPT_NAME(current_SID) = fname_exp;
|
||||
# ifdef UNIX
|
||||
if (stat_ok)
|
||||
{
|
||||
SCRIPT_DEV(current_SID) = st.st_dev;
|
||||
SCRIPT_INO(current_SID) = st.st_ino;
|
||||
}
|
||||
else
|
||||
SCRIPT_DEV(current_SID) = -1;
|
||||
++script_items.ga_len;
|
||||
SCRIPT_ITEM(script_items.ga_len).sn_name = NULL;
|
||||
# ifdef FEAT_PROFILE
|
||||
SCRIPT_ITEM(script_items.ga_len).sn_prof_on = FALSE;
|
||||
# endif
|
||||
fname_exp = NULL;
|
||||
}
|
||||
si = &SCRIPT_ITEM(current_SID);
|
||||
si->sn_name = fname_exp;
|
||||
fname_exp = NULL;
|
||||
# ifdef UNIX
|
||||
if (stat_ok)
|
||||
{
|
||||
si->sn_dev = st.st_dev;
|
||||
si->sn_ino = st.st_ino;
|
||||
}
|
||||
else
|
||||
si->sn_dev = -1;
|
||||
# endif
|
||||
|
||||
/* Allocate the local script variables to use for this script. */
|
||||
new_script_vars(current_SID);
|
||||
}
|
||||
|
||||
/* Don't use local function variables, if called from a function */
|
||||
save_funccalp = save_funccal();
|
||||
# ifdef FEAT_PROFILE
|
||||
if (do_profiling)
|
||||
{
|
||||
int forceit;
|
||||
|
||||
/* Check if we do profiling for this script. */
|
||||
if (!si->sn_prof_on && has_profiling(TRUE, si->sn_name, &forceit))
|
||||
{
|
||||
script_do_profile(si);
|
||||
si->sn_pr_force = forceit;
|
||||
}
|
||||
if (si->sn_prof_on)
|
||||
{
|
||||
++si->sn_pr_count;
|
||||
profile_start(&si->sn_pr_start);
|
||||
profile_zero(&si->sn_pr_children);
|
||||
}
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -2386,20 +2857,27 @@ do_source(fname, check_other, is_vimrc)
|
||||
DOCMD_VERBOSE|DOCMD_NOWAIT|DOCMD_REPEAT);
|
||||
|
||||
retval = OK;
|
||||
fclose(cookie.fp);
|
||||
vim_free(cookie.nextline);
|
||||
#ifdef FEAT_MBYTE
|
||||
convert_setup(&cookie.conv, NULL, NULL);
|
||||
|
||||
#ifdef FEAT_PROFILE
|
||||
if (do_profiling)
|
||||
{
|
||||
/* Get "si" again, "script_items" may have been reallocated. */
|
||||
si = &SCRIPT_ITEM(current_SID);
|
||||
if (si->sn_prof_on)
|
||||
{
|
||||
profile_end(&si->sn_pr_start);
|
||||
profile_sub_wait(&wait_start, &si->sn_pr_start);
|
||||
profile_add(&si->sn_pr_total, &si->sn_pr_start);
|
||||
profile_add(&si->sn_pr_self, &si->sn_pr_start);
|
||||
profile_sub(&si->sn_pr_self, &si->sn_pr_children);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (got_int)
|
||||
EMSG(_(e_interr));
|
||||
sourcing_name = save_sourcing_name;
|
||||
sourcing_lnum = save_sourcing_lnum;
|
||||
#ifdef FEAT_EVAL
|
||||
current_SID = save_current_SID;
|
||||
restore_funccal(save_funccalp);
|
||||
#endif
|
||||
if (p_verbose > 1)
|
||||
{
|
||||
msg_str((char_u *)_("finished sourcing %s"), fname);
|
||||
@ -2426,6 +2904,21 @@ do_source(fname, check_other, is_vimrc)
|
||||
++debug_break_level;
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_EVAL
|
||||
almosttheend:
|
||||
current_SID = save_current_SID;
|
||||
restore_funccal(save_funccalp);
|
||||
# ifdef FEAT_PROFILE
|
||||
if (do_profiling)
|
||||
prof_child_exit(&wait_start); /* leaving a child now */
|
||||
# endif
|
||||
#endif
|
||||
fclose(cookie.fp);
|
||||
vim_free(cookie.nextline);
|
||||
#ifdef FEAT_MBYTE
|
||||
convert_setup(&cookie.conv, NULL, NULL);
|
||||
#endif
|
||||
|
||||
theend:
|
||||
vim_free(fname_exp);
|
||||
return retval;
|
||||
@ -2442,9 +2935,9 @@ ex_scriptnames(eap)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 1; i <= script_names.ga_len && !got_int; ++i)
|
||||
if (SCRIPT_NAME(i) != NULL)
|
||||
smsg((char_u *)"%3d: %s", i, SCRIPT_NAME(i));
|
||||
for (i = 1; i <= script_items.ga_len && !got_int; ++i)
|
||||
if (SCRIPT_ITEM(i).sn_name != NULL)
|
||||
smsg((char_u *)"%3d: %s", i, SCRIPT_ITEM(i).sn_name);
|
||||
}
|
||||
|
||||
# if defined(BACKSLASH_IN_FILENAME) || defined(PROTO)
|
||||
@ -2456,9 +2949,9 @@ scriptnames_slash_adjust()
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 1; i <= script_names.ga_len; ++i)
|
||||
if (SCRIPT_NAME(i) != NULL)
|
||||
slash_adjust(SCRIPT_NAME(i));
|
||||
for (i = 1; i <= script_items.ga_len; ++i)
|
||||
if (SCRIPT_ITEM(i).sn_name != NULL)
|
||||
slash_adjust(SCRIPT_ITEM(i).sn_name);
|
||||
}
|
||||
# endif
|
||||
|
||||
@ -2477,8 +2970,9 @@ get_scriptname(id)
|
||||
return (char_u *)"-c argument";
|
||||
if (id == SID_ENV)
|
||||
return (char_u *)"environment variable";
|
||||
return SCRIPT_NAME(id);
|
||||
return SCRIPT_ITEM(id).sn_name;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(USE_CR) || defined(PROTO)
|
||||
@ -2565,6 +3059,10 @@ getsourceline(c, cookie, indent)
|
||||
sp->breakpoint = dbg_find_breakpoint(TRUE, sp->fname, sourcing_lnum);
|
||||
sp->dbg_tick = debug_tick;
|
||||
}
|
||||
# ifdef FEAT_PROFILE
|
||||
if (do_profiling)
|
||||
script_line_end();
|
||||
# endif
|
||||
#endif
|
||||
/*
|
||||
* Get current line. If there is a read-ahead line, use it, otherwise get
|
||||
@ -2579,6 +3077,10 @@ getsourceline(c, cookie, indent)
|
||||
line = sp->nextline;
|
||||
sp->nextline = NULL;
|
||||
++sourcing_lnum;
|
||||
#ifdef FEAT_PROFILE
|
||||
if (do_profiling)
|
||||
script_line_start();
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Only concatenate lines starting with a \ when 'cpoptions' doesn't
|
||||
@ -2783,6 +3285,90 @@ get_one_sourceline(sp)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if defined(FEAT_PROFILE) || defined(PROTO)
|
||||
/*
|
||||
* Called when starting to read a script line.
|
||||
* "sourcing_lnum" must be correct!
|
||||
* When skipping lines it may not actually be executed, but we won't find out
|
||||
* until later and we need to store the time now.
|
||||
*/
|
||||
void
|
||||
script_line_start()
|
||||
{
|
||||
scriptitem_T *si;
|
||||
sn_prl_T *pp;
|
||||
|
||||
if (current_SID <= 0 || current_SID > script_items.ga_len)
|
||||
return;
|
||||
si = &SCRIPT_ITEM(current_SID);
|
||||
if (si->sn_prof_on && sourcing_lnum >= 1)
|
||||
{
|
||||
/* Grow the array before starting the timer, so that the time spend
|
||||
* here isn't counted. */
|
||||
ga_grow(&si->sn_prl_ga, (int)(sourcing_lnum - si->sn_prl_ga.ga_len));
|
||||
si->sn_prl_idx = sourcing_lnum - 1;
|
||||
while (si->sn_prl_ga.ga_len <= si->sn_prl_idx
|
||||
&& si->sn_prl_ga.ga_len < si->sn_prl_ga.ga_maxlen)
|
||||
{
|
||||
/* Zero counters for a line that was not used before. */
|
||||
pp = &PRL_ITEM(si, si->sn_prl_ga.ga_len);
|
||||
pp->snp_count = 0;
|
||||
profile_zero(&pp->sn_prl_total);
|
||||
profile_zero(&pp->sn_prl_self);
|
||||
++si->sn_prl_ga.ga_len;
|
||||
}
|
||||
si->sn_prl_execed = FALSE;
|
||||
profile_start(&si->sn_prl_start);
|
||||
profile_zero(&si->sn_prl_children);
|
||||
profile_get_wait(&si->sn_prl_wait);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Called when actually executing a function line.
|
||||
*/
|
||||
void
|
||||
script_line_exec()
|
||||
{
|
||||
scriptitem_T *si;
|
||||
|
||||
if (current_SID <= 0 || current_SID > script_items.ga_len)
|
||||
return;
|
||||
si = &SCRIPT_ITEM(current_SID);
|
||||
if (si->sn_prof_on && si->sn_prl_idx >= 0)
|
||||
si->sn_prl_execed = TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Called when done with a function line.
|
||||
*/
|
||||
void
|
||||
script_line_end()
|
||||
{
|
||||
scriptitem_T *si;
|
||||
sn_prl_T *pp;
|
||||
|
||||
if (current_SID <= 0 || current_SID > script_items.ga_len)
|
||||
return;
|
||||
si = &SCRIPT_ITEM(current_SID);
|
||||
if (si->sn_prof_on && si->sn_prl_idx >= 0
|
||||
&& si->sn_prl_idx < si->sn_prl_ga.ga_len)
|
||||
{
|
||||
if (si->sn_prl_execed)
|
||||
{
|
||||
pp = &PRL_ITEM(si, si->sn_prl_idx);
|
||||
++pp->snp_count;
|
||||
profile_end(&si->sn_prl_start);
|
||||
profile_sub_wait(&si->sn_prl_wait, &si->sn_prl_start);
|
||||
profile_add(&pp->sn_prl_self, &si->sn_prl_start);
|
||||
profile_add(&pp->sn_prl_total, &si->sn_prl_start);
|
||||
profile_sub(&pp->sn_prl_self, &si->sn_prl_children);
|
||||
}
|
||||
si->sn_prl_idx = -1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* ":scriptencoding": Set encoding conversion for a sourced script.
|
||||
* Without the multi-byte feature it's simply ignored.
|
||||
|
@ -434,6 +434,10 @@ static void ex_folddo __ARGS((exarg_T *eap));
|
||||
# define ex_changes ex_ni
|
||||
#endif
|
||||
|
||||
#ifndef FEAT_PROFILE
|
||||
# define ex_profile ex_ni
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Declare cmdnames[].
|
||||
*/
|
||||
@ -728,6 +732,7 @@ do_cmdline(cmdline, getline, cookie, flags)
|
||||
void *cmd_cookie;
|
||||
struct loop_cookie cmd_loop_cookie;
|
||||
void *real_cookie;
|
||||
int getline_is_func;
|
||||
#else
|
||||
# define cmd_getline getline
|
||||
# define cmd_cookie cookie
|
||||
@ -772,13 +777,13 @@ do_cmdline(cmdline, getline, cookie, flags)
|
||||
real_cookie = getline_cookie(getline, cookie);
|
||||
|
||||
/* Inside a function use a higher nesting level. */
|
||||
if (getline_equal(getline, cookie, get_func_line)
|
||||
&& ex_nesting_level == func_level(real_cookie))
|
||||
getline_is_func = getline_equal(getline, cookie, get_func_line);
|
||||
if (getline_is_func && ex_nesting_level == func_level(real_cookie))
|
||||
++ex_nesting_level;
|
||||
|
||||
/* Get the function or script name and the address where the next breakpoint
|
||||
* line and the debug tick for a function or script are stored. */
|
||||
if (getline_equal(getline, cookie, get_func_line))
|
||||
if (getline_is_func)
|
||||
{
|
||||
fname = func_name(real_cookie);
|
||||
breakpoint = func_breakpoint(real_cookie);
|
||||
@ -837,13 +842,16 @@ do_cmdline(cmdline, getline, cookie, flags)
|
||||
next_cmdline = cmdline;
|
||||
do
|
||||
{
|
||||
#ifdef FEAT_EVAL
|
||||
getline_is_func = getline_equal(getline, cookie, get_func_line);
|
||||
#endif
|
||||
|
||||
/* stop skipping cmds for an error msg after all endif/while/for */
|
||||
if (next_cmdline == NULL
|
||||
#ifdef FEAT_EVAL
|
||||
&& !force_abort
|
||||
&& cstack.cs_idx < 0
|
||||
&& !(getline_equal(getline, cookie, get_func_line)
|
||||
&& func_has_abort(real_cookie))
|
||||
&& !(getline_is_func && func_has_abort(real_cookie))
|
||||
#endif
|
||||
)
|
||||
did_emsg = FALSE;
|
||||
@ -865,12 +873,23 @@ do_cmdline(cmdline, getline, cookie, flags)
|
||||
|
||||
/* Check if a function has returned or, unless it has an unclosed
|
||||
* try conditional, aborted. */
|
||||
if (getline_equal(getline, cookie, get_func_line)
|
||||
&& func_has_ended(real_cookie))
|
||||
if (getline_is_func)
|
||||
{
|
||||
retval = FAIL;
|
||||
break;
|
||||
# ifdef FEAT_PROFILE
|
||||
if (do_profiling)
|
||||
func_line_end(real_cookie);
|
||||
# endif
|
||||
if (func_has_ended(real_cookie))
|
||||
{
|
||||
retval = FAIL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#ifdef FEAT_PROFILE
|
||||
else if (do_profiling
|
||||
&& getline_equal(getline, cookie, getsourceline))
|
||||
script_line_end();
|
||||
#endif
|
||||
|
||||
/* Check if a sourced file hit a ":finish" command. */
|
||||
if (source_finished(getline, cookie))
|
||||
@ -903,6 +922,15 @@ do_cmdline(cmdline, getline, cookie, flags)
|
||||
fname, sourcing_lnum);
|
||||
*dbg_tick = debug_tick;
|
||||
}
|
||||
# ifdef FEAT_PROFILE
|
||||
if (do_profiling)
|
||||
{
|
||||
if (getline_is_func)
|
||||
func_line_start(real_cookie);
|
||||
else if (getline_equal(getline, cookie, getsourceline))
|
||||
script_line_start();
|
||||
}
|
||||
# endif
|
||||
}
|
||||
|
||||
if (cstack.cs_looplevel > 0)
|
||||
@ -1839,6 +1867,17 @@ do_one_cmd(cmdlinep, sourcing,
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_EVAL
|
||||
# ifdef FEAT_PROFILE
|
||||
/* Count this line for profiling if ea.skip is FALSE. */
|
||||
if (do_profiling && !ea.skip)
|
||||
{
|
||||
if (getline_equal(getline, cookie, get_func_line))
|
||||
func_line_exec(getline_cookie(getline, cookie));
|
||||
else if (getline_equal(getline, cookie, getsourceline))
|
||||
script_line_exec();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* May go to debug mode. If this happens and the ">quit" debug command is
|
||||
* used, throw an interrupt exception and skip the next command. */
|
||||
dbg_check_breakpoint(&ea);
|
||||
@ -4006,11 +4045,9 @@ skip_grep_pat(eap)
|
||||
if (*p != NUL && (eap->cmdidx == CMD_vimgrep
|
||||
|| eap->cmdidx == CMD_vimgrepadd || grep_internal(eap->cmdidx)))
|
||||
{
|
||||
p = skip_vimgrep_pat(p, NULL);
|
||||
p = skip_vimgrep_pat(p, NULL, NULL);
|
||||
if (p == NULL)
|
||||
p = eap->arg;
|
||||
else if (*p != NUL && !vim_iswhite(*p))
|
||||
++p; /* step past ending separator of /pat/ */
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
@ -379,6 +379,13 @@
|
||||
# define FEAT_EVAL
|
||||
#endif
|
||||
|
||||
/*
|
||||
* +profile Profiling for functions and scripts.
|
||||
*/
|
||||
#ifdef FEAT_HUGE
|
||||
# define FEAT_PROFILE
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Insert mode completion with 'completefunc'.
|
||||
*/
|
||||
|
12
src/fileio.c
12
src/fileio.c
@ -7925,6 +7925,9 @@ apply_autocmds_group(event, fname, fname_io, force, group, buf, eap)
|
||||
long save_cmdbang;
|
||||
#endif
|
||||
static int filechangeshell_busy = FALSE;
|
||||
#ifdef FEAT_PROFILE
|
||||
proftime_T wait_time;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Quickly return if there are no autocommands for this event or
|
||||
@ -8097,6 +8100,11 @@ apply_autocmds_group(event, fname, fname_io, force, group, buf, eap)
|
||||
#ifdef FEAT_EVAL
|
||||
save_current_SID = current_SID;
|
||||
|
||||
# ifdef FEAT_PROFILE
|
||||
if (do_profiling)
|
||||
prof_child_enter(&wait_time); /* doesn't count for the caller itself */
|
||||
# endif
|
||||
|
||||
/* Don't use local function variables, if called from a function */
|
||||
save_funccalp = save_funccal();
|
||||
#endif
|
||||
@ -8188,6 +8196,10 @@ apply_autocmds_group(event, fname, fname_io, force, group, buf, eap)
|
||||
#ifdef FEAT_EVAL
|
||||
current_SID = save_current_SID;
|
||||
restore_funccal(save_funccalp);
|
||||
# ifdef FEAT_PROFILE
|
||||
if (do_profiling)
|
||||
prof_child_exit(&wait_time);
|
||||
# endif
|
||||
#endif
|
||||
vim_free(fname);
|
||||
vim_free(sfname);
|
||||
|
@ -204,6 +204,9 @@ EXTERN int ex_nesting_level INIT(= 0); /* nesting level */
|
||||
EXTERN int debug_break_level INIT(= -1); /* break below this level */
|
||||
EXTERN int debug_did_msg INIT(= FALSE); /* did "debug mode" message */
|
||||
EXTERN int debug_tick INIT(= 0); /* breakpoint change count */
|
||||
# ifdef FEAT_PROFILE
|
||||
EXTERN int do_profiling INIT(= 0); /* ":profile start" used */
|
||||
# endif
|
||||
|
||||
/*
|
||||
* The exception currently being thrown. Used to pass an exception to
|
||||
@ -1406,7 +1409,9 @@ EXTERN char_u e_invexprmsg[] INIT(=N_("E449: Invalid expression received"));
|
||||
EXTERN char_u e_guarded[] INIT(=N_("E463: Region is guarded, cannot modify"));
|
||||
EXTERN char_u e_nbreadonly[] INIT(=N_("E744: NetBeans does not allow changes in read-only files"));
|
||||
#endif
|
||||
#if defined(FEAT_EVAL) || defined(FEAT_SYN_HL) || defined(PROTO)
|
||||
EXTERN char_u e_intern2[] INIT(=N_("E685: Internal error: %s"));
|
||||
#endif
|
||||
#if defined(HAVE_SETJMP_H) || defined(HAVE_TRY_EXCEPT)
|
||||
EXTERN char_u e_complex[] INIT(=N_("E361: Crash intercepted; regexp too complex?"));
|
||||
#endif
|
||||
|
@ -555,7 +555,7 @@ gui_init()
|
||||
/* When 'cmdheight' was set during startup it may not have taken
|
||||
* effect yet. */
|
||||
if (p_ch != 1L)
|
||||
command_height(1L);
|
||||
command_height(-1L);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -3808,7 +3808,7 @@ gui_mch_init_font(font_name, fontset)
|
||||
{
|
||||
/* TODO: Add support for bold italic underline proportional etc... */
|
||||
Str255 suggestedFont = "\pMonaco";
|
||||
int suggestedSize = 9;
|
||||
int suggestedSize = 10;
|
||||
FontInfo font_info;
|
||||
short font_id;
|
||||
GuiFont font;
|
||||
|
@ -4051,7 +4051,8 @@ gui_mch_enable_beval_area(beval)
|
||||
if (beval == NULL)
|
||||
return;
|
||||
TRACE0("gui_mch_enable_beval_area {{{");
|
||||
BevalTimerId = SetTimer(s_textArea, 0, p_bdlay / 2, (TIMERPROC)BevalTimerProc);
|
||||
BevalTimerId = SetTimer(s_textArea, 0, p_bdlay / 2,
|
||||
(TIMERPROC)BevalTimerProc);
|
||||
TRACE0("gui_mch_enable_beval_area }}}");
|
||||
}
|
||||
|
||||
|
@ -2352,6 +2352,10 @@ getout(exitval)
|
||||
apply_autocmds(EVENT_VIMLEAVE, NULL, NULL, FALSE, curbuf);
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_PROFILE
|
||||
profile_dump();
|
||||
#endif
|
||||
|
||||
if (did_emsg
|
||||
#ifdef FEAT_GUI
|
||||
|| (gui.in_use && msg_didany && p_verbose > 0)
|
||||
|
59
src/misc1.c
59
src/misc1.c
@ -3209,6 +3209,10 @@ init_homedir()
|
||||
{
|
||||
char_u *var;
|
||||
|
||||
/* In case we are called a second time (when 'encoding' changes). */
|
||||
vim_free(homedir);
|
||||
homedir = NULL;
|
||||
|
||||
#ifdef VMS
|
||||
var = mch_getenv((char_u *)"SYS$LOGIN");
|
||||
#else
|
||||
@ -3270,6 +3274,23 @@ init_homedir()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# if defined(FEAT_MBYTE)
|
||||
if (enc_utf8 && var != NULL)
|
||||
{
|
||||
int len;
|
||||
char_u *pp;
|
||||
|
||||
/* Convert from active codepage to UTF-8. Other conversions are
|
||||
* not done, because they would fail for non-ASCII characters. */
|
||||
acp_to_enc(var, STRLEN(var), &pp, &len);
|
||||
if (pp != NULL)
|
||||
{
|
||||
homedir = pp;
|
||||
return;
|
||||
}
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(OS2) || defined(MSDOS) || defined(MSWIN)
|
||||
@ -3594,7 +3615,25 @@ vim_getenv(name, mustfree)
|
||||
p = NULL;
|
||||
|
||||
if (p != NULL)
|
||||
{
|
||||
#if defined(FEAT_MBYTE) && defined(WIN3264)
|
||||
if (enc_utf8)
|
||||
{
|
||||
int len;
|
||||
char_u *pp;
|
||||
|
||||
/* Convert from active codepage to UTF-8. Other conversions are
|
||||
* not done, because they would fail for non-ASCII characters. */
|
||||
acp_to_enc(p, STRLEN(p), &pp, &len);
|
||||
if (pp != NULL)
|
||||
{
|
||||
p = pp;
|
||||
*mustfree = TRUE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return p;
|
||||
}
|
||||
|
||||
vimruntime = (STRCMP(name, "VIMRUNTIME") == 0);
|
||||
if (!vimruntime && STRCMP(name, "VIM") != 0)
|
||||
@ -3620,6 +3659,26 @@ vim_getenv(name, mustfree)
|
||||
*mustfree = TRUE;
|
||||
else
|
||||
p = mch_getenv((char_u *)"VIM");
|
||||
|
||||
#if defined(FEAT_MBYTE) && defined(WIN3264)
|
||||
if (enc_utf8)
|
||||
{
|
||||
int len;
|
||||
char_u *pp;
|
||||
|
||||
/* Convert from active codepage to UTF-8. Other conversions
|
||||
* are not done, because they would fail for non-ASCII
|
||||
* characters. */
|
||||
acp_to_enc(p, STRLEN(p), &pp, &len);
|
||||
if (pp != NULL)
|
||||
{
|
||||
if (mustfree)
|
||||
vim_free(p);
|
||||
p = pp;
|
||||
*mustfree = TRUE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
48
src/misc2.c
48
src/misc2.c
@ -1374,8 +1374,8 @@ vim_stristr(s1, s2)
|
||||
|
||||
/*
|
||||
* Version of strchr() and strrchr() that handle unsigned char strings
|
||||
* with characters above 128 correctly. Also it doesn't return a pointer to
|
||||
* the NUL at the end of the string.
|
||||
* with characters from 128 to 255 correctly. It also doesn't return a
|
||||
* pointer to the NUL at the end of the string.
|
||||
*/
|
||||
char_u *
|
||||
vim_strchr(string, c)
|
||||
@ -1430,10 +1430,31 @@ vim_strchr(string, c)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Version of strchr() that only works for bytes and handles unsigned char
|
||||
* strings with characters above 128 correctly. It also doesn't return a
|
||||
* pointer to the NUL at the end of the string.
|
||||
*/
|
||||
char_u *
|
||||
vim_strbyte(string, c)
|
||||
char_u *string;
|
||||
int c;
|
||||
{
|
||||
char_u *p = string;
|
||||
|
||||
while (*p != NUL)
|
||||
{
|
||||
if (*p == c)
|
||||
return p;
|
||||
++p;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Search for last occurrence of "c" in "string".
|
||||
* return NULL if not found.
|
||||
* Does not handle multi-byte!
|
||||
* Does not handle multi-byte char for "c"!
|
||||
*/
|
||||
char_u *
|
||||
vim_strrchr(string, c)
|
||||
@ -1441,12 +1462,13 @@ vim_strrchr(string, c)
|
||||
int c;
|
||||
{
|
||||
char_u *retval = NULL;
|
||||
char_u *p = string;
|
||||
|
||||
while (*string)
|
||||
while (*p)
|
||||
{
|
||||
if (*string == c)
|
||||
retval = string;
|
||||
mb_ptr_adv(string);
|
||||
if (*p == c)
|
||||
retval = p;
|
||||
mb_ptr_adv(p);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
@ -2549,6 +2571,9 @@ call_shell(cmd, opt)
|
||||
{
|
||||
char_u *ncmd;
|
||||
int retval;
|
||||
#ifdef FEAT_PROFILE
|
||||
proftime_T wait_time;
|
||||
#endif
|
||||
|
||||
if (p_verbose > 3)
|
||||
{
|
||||
@ -2558,6 +2583,11 @@ call_shell(cmd, opt)
|
||||
cursor_on();
|
||||
}
|
||||
|
||||
#ifdef FEAT_PROFILE
|
||||
if (do_profiling)
|
||||
prof_child_enter(&wait_time);
|
||||
#endif
|
||||
|
||||
if (*p_sh == NUL)
|
||||
{
|
||||
EMSG(_(e_shellempty));
|
||||
@ -2603,6 +2633,10 @@ call_shell(cmd, opt)
|
||||
|
||||
#ifdef FEAT_EVAL
|
||||
set_vim_var_nr(VV_SHELL_ERROR, (long)retval);
|
||||
# ifdef FEAT_PROFILE
|
||||
if (do_profiling)
|
||||
prof_child_exit(&wait_time);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
return retval;
|
||||
|
@ -5472,14 +5472,14 @@ nv_down(cap)
|
||||
{
|
||||
#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
|
||||
/* In a quickfix window a <CR> jumps to the error under the cursor. */
|
||||
if (bt_quickfix(curbuf) && cap->cmdchar == '\r')
|
||||
if (bt_quickfix(curbuf) && cap->cmdchar == CAR)
|
||||
do_cmdline_cmd((char_u *)".cc");
|
||||
else
|
||||
#endif
|
||||
{
|
||||
#ifdef FEAT_CMDWIN
|
||||
/* In the cmdline window a <CR> executes the command. */
|
||||
if (cmdwin_type != 0 && cap->cmdchar == '\r')
|
||||
if (cmdwin_type != 0 && cap->cmdchar == CAR)
|
||||
cmdwin_result = CAR;
|
||||
else
|
||||
#endif
|
||||
|
25
src/option.c
25
src/option.c
@ -2629,18 +2629,20 @@ set_init_1()
|
||||
# else
|
||||
static char *(names[3]) = {"TMPDIR", "TEMP", "TMP"};
|
||||
# endif
|
||||
int len;
|
||||
garray_T ga;
|
||||
int len;
|
||||
garray_T ga;
|
||||
int mustfree;
|
||||
|
||||
ga_init2(&ga, 1, 100);
|
||||
for (n = 0; n < (long)(sizeof(names) / sizeof(char *)); ++n)
|
||||
{
|
||||
mustfree = FALSE;
|
||||
# ifdef UNIX
|
||||
if (*names[n] == NUL)
|
||||
p = (char_u *)"/tmp";
|
||||
else
|
||||
# endif
|
||||
p = mch_getenv((char_u *)names[n]);
|
||||
p = vim_getenv((char_u *)names[n], &mustfree);
|
||||
if (p != NULL && *p != NUL)
|
||||
{
|
||||
/* First time count the NUL, otherwise count the ','. */
|
||||
@ -2655,6 +2657,8 @@ set_init_1()
|
||||
ga.ga_len += len;
|
||||
}
|
||||
}
|
||||
if (mustfree)
|
||||
vim_free(p);
|
||||
}
|
||||
if (ga.ga_data != NULL)
|
||||
{
|
||||
@ -2705,9 +2709,10 @@ set_init_1()
|
||||
char_u *buf;
|
||||
int i;
|
||||
int j;
|
||||
int mustfree = FALSE;
|
||||
|
||||
/* Initialize the 'cdpath' option's default value. */
|
||||
cdpath = mch_getenv((char_u *)"CDPATH");
|
||||
cdpath = vim_getenv((char_u *)"CDPATH", &mustfree);
|
||||
if (cdpath != NULL)
|
||||
{
|
||||
buf = alloc((unsigned)((STRLEN(cdpath) << 1) + 2));
|
||||
@ -2731,6 +2736,8 @@ set_init_1()
|
||||
options[opt_idx].def_val[VI_DEFAULT] = buf;
|
||||
options[opt_idx].flags |= P_DEF_ALLOCED;
|
||||
}
|
||||
if (mustfree)
|
||||
vim_free(cdpath);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -2961,6 +2968,10 @@ set_init_1()
|
||||
else
|
||||
p_tenc = empty_option;
|
||||
}
|
||||
# endif
|
||||
# if defined(WIN3264) && defined(FEAT_MBYTE)
|
||||
/* $HOME may have characters in active code page. */
|
||||
init_homedir();
|
||||
# endif
|
||||
}
|
||||
else
|
||||
@ -5089,6 +5100,12 @@ did_set_string_option(opt_idx, varp, new_value_alloced, oldval, errbuf,
|
||||
convert_setup(&input_conv, p_tenc, p_enc);
|
||||
convert_setup(&output_conv, p_enc, p_tenc);
|
||||
}
|
||||
|
||||
# if defined(WIN3264) && defined(FEAT_MBYTE)
|
||||
/* $HOME may have characters in active code page. */
|
||||
if (varp == &p_enc)
|
||||
init_homedir();
|
||||
# endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -1346,22 +1346,16 @@ clip_mch_request_selection(VimClipboard *cbd)
|
||||
break;
|
||||
}
|
||||
|
||||
#if defined(FEAT_MBYTE) && defined(WIN3264)
|
||||
# if defined(FEAT_MBYTE) && defined(WIN3264)
|
||||
/* The text is in the active codepage. Convert to 'encoding',
|
||||
* going through UCS-2. */
|
||||
MultiByteToWideChar_alloc(GetACP(), 0, str, str_size,
|
||||
(LPWSTR *)&to_free, &maxlen);
|
||||
acp_to_enc(str, str_size, &to_free, &maxlen);
|
||||
if (to_free != NULL)
|
||||
{
|
||||
str_size = maxlen;
|
||||
str = ucs2_to_enc((short_u *)to_free, &str_size);
|
||||
if (str != NULL)
|
||||
{
|
||||
vim_free(to_free);
|
||||
to_free = str;
|
||||
}
|
||||
str = to_free;
|
||||
}
|
||||
#endif
|
||||
# endif
|
||||
}
|
||||
}
|
||||
#ifdef FEAT_MBYTE
|
||||
@ -1398,6 +1392,31 @@ clip_mch_request_selection(VimClipboard *cbd)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if (defined(FEAT_MBYTE) && defined(WIN3264)) || defined(PROTO)
|
||||
/*
|
||||
* Convert from the active codepage to 'encoding'.
|
||||
* Input is "str[str_size]".
|
||||
* The result is in allocated memory: "out[outlen]". With terminating NUL.
|
||||
*/
|
||||
void
|
||||
acp_to_enc(str, str_size, out, outlen)
|
||||
char_u *str;
|
||||
int str_size;
|
||||
char_u **out;
|
||||
int *outlen;
|
||||
|
||||
{
|
||||
LPWSTR widestr;
|
||||
|
||||
MultiByteToWideChar_alloc(GetACP(), 0, str, str_size, &widestr, outlen);
|
||||
if (widestr != NULL)
|
||||
{
|
||||
*out = ucs2_to_enc((short_u *)widestr, outlen);
|
||||
vim_free(widestr);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Send the current selection to the clipboard.
|
||||
*/
|
||||
|
@ -10,10 +10,10 @@
|
||||
# language (xx) and add it to the next three lines.
|
||||
#
|
||||
|
||||
LANGUAGES = af ca cs de en_GB es fr ga it ja ko no pl ru sk sv uk zh_TW \
|
||||
LANGUAGES = af ca cs de en_GB es fr ga it ja ko no pl ru sk sv uk vi zh_TW \
|
||||
zh_TW.UTF-8 zh_CN zh_CN.UTF-8
|
||||
MOFILES = af.mo ca.mo cs.mo de.mo en_GB.mo es.mo fr.mo ga.mo it.mo ja.mo \
|
||||
ko.mo no.mo pl.mo ru.mo sk.mo sv.mo uk.mo \
|
||||
ko.mo no.mo pl.mo ru.mo sk.mo sv.mo uk.mo vi.mo \
|
||||
zh_TW.mo zh_TW.UTF-8.mo zh_CN.mo zh_CN.UTF-8.mo
|
||||
|
||||
PACKAGE = vim
|
||||
|
@ -6,10 +6,10 @@
|
||||
# Please read README_mvc.txt before using this file.
|
||||
#
|
||||
|
||||
LANGUAGES = af ca cs de en_GB es fr ga it ja ko no pl ru sk sv uk zh_TW \
|
||||
LANGUAGES = af ca cs de en_GB es fr ga it ja ko no pl ru sk sv uk vi zh_TW \
|
||||
zh_TW.UTF-8 zh_CN zh_CN.UTF-8
|
||||
MOFILES = af.mo ca.mo cs.mo de.mo en_GB.mo es.mo fr.mo ga.mo it.mo ja.mo \
|
||||
ko.mo no.mo pl.mo ru.mo sk.mo sv.mo uk.mo \
|
||||
ko.mo no.mo pl.mo ru.mo sk.mo sv.mo uk.mo vi.mo \
|
||||
zh_TW.mo zh_TW.UTF-8.mo zh_CN.mo zh_CN.UTF-8.mo
|
||||
|
||||
PACKAGE = vim
|
||||
|
@ -4,10 +4,10 @@
|
||||
# Note: ja.sjis, *.cp1250 and zh_CN.cp936 are only for MS-Windows, they are
|
||||
# not installed on Unix
|
||||
|
||||
LANGUAGES = af ca cs de en_GB es fr ga it ja ko no pl ru sk sv uk zh_TW \
|
||||
LANGUAGES = af ca cs de en_GB es fr ga it ja ko no pl ru sk sv uk vi zh_TW \
|
||||
zh_TW.UTF-8 zh_CN zh_CN.UTF-8
|
||||
MOFILES = af.mo ca.mo cs.mo de.mo en_GB.mo es.mo fr.mo ga.mo it.mo ja.mo \
|
||||
ko.mo no.mo pl.mo ru.mo sk.mo sv.mo uk.mo \
|
||||
ko.mo no.mo pl.mo ru.mo sk.mo sv.mo uk.mo vi.mo \
|
||||
zh_TW.mo zh_TW.UTF-8.mo zh_CN.mo zh_CN.UTF-8.mo
|
||||
|
||||
PACKAGE = vim
|
||||
|
6625
src/po/vi.po
Normal file
6625
src/po/vi.po
Normal file
File diff suppressed because it is too large
Load Diff
@ -21,7 +21,9 @@ char_u *eval_to_string_safe __ARGS((char_u *arg, char_u **nextcmd));
|
||||
int eval_to_number __ARGS((char_u *expr));
|
||||
char_u *call_vim_function __ARGS((char_u *func, int argc, char_u **argv, int safe));
|
||||
void *save_funccal __ARGS((void));
|
||||
void restore_funccal __ARGS((void *fc));
|
||||
void restore_funccal __ARGS((void *vfc));
|
||||
void prof_child_enter __ARGS((proftime_T *tm));
|
||||
void prof_child_exit __ARGS((proftime_T *tm));
|
||||
int eval_foldexpr __ARGS((char_u *arg, int *cp));
|
||||
void ex_let __ARGS((exarg_T *eap));
|
||||
void *eval_for_line __ARGS((char_u *arg, int *errp, char_u **nextcmdp, int skip));
|
||||
@ -34,6 +36,9 @@ void ex_lockvar __ARGS((exarg_T *eap));
|
||||
int do_unlet __ARGS((char_u *name, int forceit));
|
||||
void del_menutrans_vars __ARGS((void));
|
||||
char_u *get_user_var_name __ARGS((expand_T *xp, int idx));
|
||||
int list_append_dict __ARGS((list_T *list, dict_T *dict));
|
||||
dict_T *dict_alloc __ARGS((void));
|
||||
int dict_add_nr_str __ARGS((dict_T *d, char *key, long nr, char_u *str));
|
||||
char_u *get_function_name __ARGS((expand_T *xp, int idx));
|
||||
char_u *get_expr_name __ARGS((expand_T *xp, int idx));
|
||||
void set_vim_var_nr __ARGS((int idx, long val));
|
||||
@ -52,6 +57,7 @@ void ex_echo __ARGS((exarg_T *eap));
|
||||
void ex_echohl __ARGS((exarg_T *eap));
|
||||
void ex_execute __ARGS((exarg_T *eap));
|
||||
void ex_function __ARGS((exarg_T *eap));
|
||||
void func_dump_profile __ARGS((FILE *fd));
|
||||
char_u *get_user_func_name __ARGS((expand_T *xp, int idx));
|
||||
void ex_delfunction __ARGS((exarg_T *eap));
|
||||
void ex_return __ARGS((exarg_T *eap));
|
||||
@ -59,6 +65,9 @@ int do_return __ARGS((exarg_T *eap, int reanimate, int is_cmd, void *rettv));
|
||||
void discard_pending_return __ARGS((void *rettv));
|
||||
char_u *get_return_cmd __ARGS((void *rettv));
|
||||
char_u *get_func_line __ARGS((int c, void *cookie, int indent));
|
||||
void func_line_start __ARGS((void *cookie));
|
||||
void func_line_exec __ARGS((void *cookie));
|
||||
void func_line_end __ARGS((void *cookie));
|
||||
int func_has_ended __ARGS((void *cookie));
|
||||
int func_has_abort __ARGS((void *cookie));
|
||||
int read_viminfo_varlist __ARGS((vir_T *virp, int writing));
|
||||
|
@ -8,7 +8,24 @@ void ex_debuggreedy __ARGS((exarg_T *eap));
|
||||
void ex_breakdel __ARGS((exarg_T *eap));
|
||||
void ex_breaklist __ARGS((exarg_T *eap));
|
||||
linenr_T dbg_find_breakpoint __ARGS((int file, char_u *fname, linenr_T after));
|
||||
int has_profiling __ARGS((int file, char_u *fname, int *fp));
|
||||
void dbg_breakpoint __ARGS((char_u *name, linenr_T lnum));
|
||||
void profile_zero __ARGS((proftime_T *tm));
|
||||
void profile_start __ARGS((proftime_T *tm));
|
||||
void profile_end __ARGS((proftime_T *tm));
|
||||
void profile_sub __ARGS((proftime_T *tm, proftime_T *tm2));
|
||||
void profile_add __ARGS((proftime_T *tm, proftime_T *tm2));
|
||||
void profile_get_wait __ARGS((proftime_T *tm));
|
||||
void profile_sub_wait __ARGS((proftime_T *tm, proftime_T *tma));
|
||||
int profile_equal __ARGS((proftime_T *tm1, proftime_T *tm2));
|
||||
char *profile_msg __ARGS((proftime_T *tm));
|
||||
void ex_profile __ARGS((exarg_T *eap));
|
||||
void profile_dump __ARGS((void));
|
||||
void script_prof_save __ARGS((proftime_T *tm));
|
||||
void script_prof_restore __ARGS((proftime_T *tm));
|
||||
void prof_inchar_enter __ARGS((void));
|
||||
void prof_inchar_exit __ARGS((void));
|
||||
int prof_def_func __ARGS((void));
|
||||
int autowrite __ARGS((buf_T *buf, int forceit));
|
||||
void autowrite_all __ARGS((void));
|
||||
int check_changed __ARGS((buf_T *buf, int checkaw, int mult_win, int forceit, int allbuf));
|
||||
@ -43,11 +60,13 @@ int *source_dbg_tick __ARGS((void *cookie));
|
||||
int source_level __ARGS((void *cookie));
|
||||
int do_source __ARGS((char_u *fname, int check_other, int is_vimrc));
|
||||
void ex_scriptnames __ARGS((exarg_T *eap));
|
||||
int has_scriptname __ARGS((char_u *name));
|
||||
void scriptnames_slash_adjust __ARGS((void));
|
||||
char_u *get_scriptname __ARGS((scid_T id));
|
||||
char *fgets_cr __ARGS((char *s, int n, FILE *stream));
|
||||
char_u *getsourceline __ARGS((int c, void *cookie, int indent));
|
||||
void script_line_start __ARGS((void));
|
||||
void script_line_exec __ARGS((void));
|
||||
void script_line_end __ARGS((void));
|
||||
void ex_scriptencoding __ARGS((exarg_T *eap));
|
||||
void ex_finish __ARGS((exarg_T *eap));
|
||||
void do_finish __ARGS((exarg_T *eap, int reanimate));
|
||||
|
@ -40,6 +40,7 @@ void vim_free __ARGS((void *x));
|
||||
int vim_stricmp __ARGS((char *s1, char *s2));
|
||||
int vim_strnicmp __ARGS((char *s1, char *s2, size_t len));
|
||||
char_u *vim_strchr __ARGS((char_u *string, int c));
|
||||
char_u *vim_strbyte __ARGS((char_u *string, int c));
|
||||
char_u *vim_strrchr __ARGS((char_u *string, int c));
|
||||
int vim_isspace __ARGS((int x));
|
||||
void ga_clear __ARGS((garray_T *gap));
|
||||
|
@ -31,6 +31,7 @@ void clip_mch_lose_selection __ARGS((VimClipboard *cbd));
|
||||
short_u *enc_to_ucs2 __ARGS((char_u *str, int *lenp));
|
||||
char_u *ucs2_to_enc __ARGS((short_u *str, int *lenp));
|
||||
void clip_mch_request_selection __ARGS((VimClipboard *cbd));
|
||||
void acp_to_enc __ARGS((char_u *str, int str_size, char_u **out, int *outlen));
|
||||
void clip_mch_set_selection __ARGS((VimClipboard *cbd));
|
||||
void DumpPutS __ARGS((const char *psz));
|
||||
int mch_get_winpos __ARGS((int *x, int *y));
|
||||
|
@ -19,7 +19,8 @@ void ex_cc __ARGS((exarg_T *eap));
|
||||
void ex_cnext __ARGS((exarg_T *eap));
|
||||
void ex_cfile __ARGS((exarg_T *eap));
|
||||
void ex_vimgrep __ARGS((exarg_T *eap));
|
||||
char_u *skip_vimgrep_pat __ARGS((char_u *p, char_u **s));
|
||||
char_u *skip_vimgrep_pat __ARGS((char_u *p, char_u **s, int *flags));
|
||||
int get_errorlist __ARGS((list_T *list));
|
||||
void ex_cbuffer __ARGS((exarg_T *eap));
|
||||
void ex_helpgrep __ARGS((exarg_T *eap));
|
||||
/* vim: set ft=c : */
|
||||
|
156
src/quickfix.c
156
src/quickfix.c
@ -35,7 +35,7 @@ struct qf_line
|
||||
int qf_col; /* column where the error occurred */
|
||||
int qf_nr; /* error number */
|
||||
char_u *qf_text; /* description of the error */
|
||||
char_u qf_virt_col; /* set to TRUE if qf_col is screen column */
|
||||
char_u qf_viscol; /* set to TRUE if qf_col is screen column */
|
||||
char_u qf_cleared;/* set to TRUE if line has been deleted */
|
||||
char_u qf_type; /* type of the error (mostly 'E'); 1 for
|
||||
:helpgrep */
|
||||
@ -88,7 +88,7 @@ struct eformat
|
||||
|
||||
static int qf_init_ext __ARGS((char_u *efile, buf_T *buf, char_u *errorformat, int newlist, linenr_T lnumfirst, linenr_T lnumlast));
|
||||
static void qf_new_list __ARGS((void));
|
||||
static int qf_add_entry __ARGS((struct qf_line **prevp, char_u *dir, char_u *fname, char_u *mesg, long lnum, int col, int virt_col, int nr, int type, int valid));
|
||||
static int qf_add_entry __ARGS((struct qf_line **prevp, char_u *dir, char_u *fname, char_u *mesg, long lnum, int col, int vis_col, int nr, int type, int valid));
|
||||
static void qf_msg __ARGS((void));
|
||||
static void qf_free __ARGS((int idx));
|
||||
static char_u *qf_types __ARGS((int, int));
|
||||
@ -147,7 +147,7 @@ qf_init_ext(efile, buf, errorformat, newlist, lnumfirst, lnumlast)
|
||||
char_u *errmsg;
|
||||
char_u *fmtstr = NULL;
|
||||
int col = 0;
|
||||
char_u use_virt_col = FALSE;
|
||||
char_u use_viscol = FALSE;
|
||||
int type = 0;
|
||||
int valid;
|
||||
linenr_T buflnum = lnumfirst;
|
||||
@ -467,7 +467,7 @@ restofline:
|
||||
errmsg[0] = NUL;
|
||||
lnum = 0;
|
||||
col = 0;
|
||||
use_virt_col = FALSE;
|
||||
use_viscol = FALSE;
|
||||
enr = -1;
|
||||
type = 0;
|
||||
tail = NULL;
|
||||
@ -515,12 +515,12 @@ restofline:
|
||||
{
|
||||
col = (int)(regmatch.endp[i] - regmatch.startp[i] + 1);
|
||||
if (*((char_u *)regmatch.startp[i]) != TAB)
|
||||
use_virt_col = TRUE;
|
||||
use_viscol = TRUE;
|
||||
}
|
||||
if ((i = (int)fmt_ptr->addr[8]) > 0) /* %v */
|
||||
{
|
||||
col = (int)atol((char *)regmatch.startp[i]);
|
||||
use_virt_col = TRUE;
|
||||
use_viscol = TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -578,7 +578,7 @@ restofline:
|
||||
qfprev->qf_lnum = lnum;
|
||||
if (!qfprev->qf_col)
|
||||
qfprev->qf_col = col;
|
||||
qfprev->qf_virt_col = use_virt_col;
|
||||
qfprev->qf_viscol = use_viscol;
|
||||
if (!qfprev->qf_fnum)
|
||||
qfprev->qf_fnum = qf_get_fnum(directory,
|
||||
*namebuf || directory ? namebuf
|
||||
@ -623,7 +623,7 @@ restofline:
|
||||
errmsg,
|
||||
lnum,
|
||||
col,
|
||||
use_virt_col,
|
||||
use_viscol,
|
||||
enr,
|
||||
type,
|
||||
valid) == FAIL)
|
||||
@ -714,14 +714,14 @@ qf_new_list()
|
||||
* Returns OK or FAIL.
|
||||
*/
|
||||
static int
|
||||
qf_add_entry(prevp, dir, fname, mesg, lnum, col, virt_col, nr, type, valid)
|
||||
qf_add_entry(prevp, dir, fname, mesg, lnum, col, vis_col, nr, type, valid)
|
||||
struct qf_line **prevp; /* pointer to previously added entry or NULL */
|
||||
char_u *dir; /* optional directory name */
|
||||
char_u *fname; /* file name or NULL */
|
||||
char_u *mesg; /* message */
|
||||
long lnum; /* line number */
|
||||
int col; /* column */
|
||||
int virt_col; /* using virtual column */
|
||||
int vis_col; /* using visual column */
|
||||
int nr; /* error number */
|
||||
int type; /* type character */
|
||||
int valid; /* valid entry */
|
||||
@ -739,7 +739,7 @@ qf_add_entry(prevp, dir, fname, mesg, lnum, col, virt_col, nr, type, valid)
|
||||
}
|
||||
qfp->qf_lnum = lnum;
|
||||
qfp->qf_col = col;
|
||||
qfp->qf_virt_col = virt_col;
|
||||
qfp->qf_viscol = vis_col;
|
||||
qfp->qf_nr = nr;
|
||||
if (type != 1 && !vim_isprintc(type)) /* only printable chars allowed */
|
||||
type = 0;
|
||||
@ -1285,7 +1285,7 @@ qf_jump(dir, errornr, forceit)
|
||||
if (qf_ptr->qf_col > 0)
|
||||
{
|
||||
curwin->w_cursor.col = qf_ptr->qf_col - 1;
|
||||
if (qf_ptr->qf_virt_col == TRUE)
|
||||
if (qf_ptr->qf_viscol == TRUE)
|
||||
{
|
||||
/*
|
||||
* Check each character from the beginning of the error
|
||||
@ -2300,6 +2300,8 @@ ex_vimgrep(eap)
|
||||
#endif
|
||||
#ifdef FEAT_AUTOCMD
|
||||
char_u *au_name = NULL;
|
||||
int flags = 0;
|
||||
colnr_T col;
|
||||
|
||||
switch (eap->cmdidx)
|
||||
{
|
||||
@ -2318,14 +2320,12 @@ ex_vimgrep(eap)
|
||||
|
||||
/* Get the search pattern: either white-separated or enclosed in // */
|
||||
regmatch.regprog = NULL;
|
||||
p = skip_vimgrep_pat(eap->arg, &s);
|
||||
p = skip_vimgrep_pat(eap->arg, &s, &flags);
|
||||
if (p == NULL)
|
||||
{
|
||||
EMSG(_("E682: Invalid search pattern or delimiter"));
|
||||
goto theend;
|
||||
}
|
||||
if (*p != NUL)
|
||||
*p++ = NUL;
|
||||
regmatch.regprog = vim_regcomp(s, RE_MAGIC);
|
||||
if (regmatch.regprog == NULL)
|
||||
goto theend;
|
||||
@ -2437,10 +2437,13 @@ ex_vimgrep(eap)
|
||||
goto jumpend;
|
||||
}
|
||||
#endif
|
||||
/* Try for a match in all lines of the buffer. */
|
||||
for (lnum = 1; lnum <= buf->b_ml.ml_line_count; ++lnum)
|
||||
{
|
||||
if (vim_regexec_multi(®match, curwin, buf, lnum,
|
||||
(colnr_T)0) > 0)
|
||||
/* For ":1vimgrep" look for multiple matches. */
|
||||
col = 0;
|
||||
while (vim_regexec_multi(®match, curwin, buf, lnum,
|
||||
col) > 0)
|
||||
{
|
||||
if (qf_add_entry(&prevp,
|
||||
NULL, /* dir */
|
||||
@ -2449,7 +2452,7 @@ ex_vimgrep(eap)
|
||||
regmatch.startpos[0].lnum + lnum, FALSE),
|
||||
regmatch.startpos[0].lnum + lnum,
|
||||
regmatch.startpos[0].col + 1,
|
||||
FALSE, /* virt_col */
|
||||
FALSE, /* vis_col */
|
||||
0, /* nr */
|
||||
0, /* type */
|
||||
TRUE /* valid */
|
||||
@ -2460,6 +2463,13 @@ ex_vimgrep(eap)
|
||||
}
|
||||
else
|
||||
found_match = TRUE;
|
||||
if ((flags & VGR_GLOBAL) == 0
|
||||
|| regmatch.endpos[0].lnum > 0)
|
||||
break;
|
||||
col = regmatch.endpos[0].col
|
||||
+ (col == regmatch.endpos[0].col);
|
||||
if (col > STRLEN(ml_get_buf(buf, lnum, FALSE)))
|
||||
break;
|
||||
}
|
||||
line_breakcheck();
|
||||
if (got_int)
|
||||
@ -2485,14 +2495,14 @@ jumpend:
|
||||
{
|
||||
/* When not hiding the buffer and no match was found we
|
||||
* don't need to remember the buffer, wipe it out. If
|
||||
* there was a match and it wasn't the first one: only
|
||||
* unload the buffer. */
|
||||
* there was a match and it wasn't the first one or we
|
||||
* won't jump there: only unload the buffer. */
|
||||
if (!found_match)
|
||||
{
|
||||
wipe_dummy_buffer(buf);
|
||||
buf = NULL;
|
||||
}
|
||||
else if (buf != first_match_buf)
|
||||
else if (buf != first_match_buf || (flags & VGR_NOJUMP))
|
||||
{
|
||||
unload_dummy_buffer(buf);
|
||||
buf = NULL;
|
||||
@ -2528,7 +2538,10 @@ jumpend:
|
||||
|
||||
/* Jump to first match. */
|
||||
if (qf_lists[qf_curlist].qf_count > 0)
|
||||
qf_jump(0, 0, FALSE);
|
||||
{
|
||||
if ((flags & VGR_NOJUMP) == 0)
|
||||
qf_jump(0, 0, eap->forceit);
|
||||
}
|
||||
else
|
||||
EMSG2(_(e_nomatch2), s);
|
||||
|
||||
@ -2543,29 +2556,57 @@ theend:
|
||||
}
|
||||
|
||||
/*
|
||||
* Skip over the pattern argument of ":vimgrep /pat/".
|
||||
* Skip over the pattern argument of ":vimgrep /pat/[g][j]".
|
||||
* Put the start of the pattern in "*s", unless "s" is NULL.
|
||||
* Return a pointer to the char just past the pattern.
|
||||
* If "flags" is not NULL put the flags in it: VGR_GLOBAL, VGR_NOJUMP.
|
||||
* If "s" is not NULL terminate the pattern with a NUL.
|
||||
* Return a pointer to the char just past the pattern plus flags.
|
||||
*/
|
||||
char_u *
|
||||
skip_vimgrep_pat(p, s)
|
||||
char_u *p;
|
||||
char_u **s;
|
||||
skip_vimgrep_pat(p, s, flags)
|
||||
char_u *p;
|
||||
char_u **s;
|
||||
int *flags;
|
||||
{
|
||||
int c;
|
||||
|
||||
if (vim_isIDc(*p))
|
||||
{
|
||||
/* ":vimgrep pattern fname" */
|
||||
if (s != NULL)
|
||||
*s = p;
|
||||
return skiptowhite(p);
|
||||
p = skiptowhite(p);
|
||||
if (s != NULL && *p != NUL)
|
||||
*p++ = NUL;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* ":vimgrep /pattern/[g][j] fname" */
|
||||
if (s != NULL)
|
||||
*s = p + 1;
|
||||
c = *p;
|
||||
p = skip_regexp(p + 1, c, TRUE, NULL);
|
||||
if (*p != c)
|
||||
return NULL;
|
||||
|
||||
/* Truncate the pattern. */
|
||||
if (s != NULL)
|
||||
*p = NUL;
|
||||
++p;
|
||||
|
||||
/* Find the flags */
|
||||
while (*p == 'g' || *p == 'j')
|
||||
{
|
||||
if (flags != NULL)
|
||||
{
|
||||
if (*p == 'g')
|
||||
*flags |= VGR_GLOBAL;
|
||||
else
|
||||
*flags |= VGR_NOJUMP;
|
||||
}
|
||||
++p;
|
||||
}
|
||||
}
|
||||
if (s != NULL)
|
||||
*s = p + 1;
|
||||
c = *p;
|
||||
p = skip_regexp(p + 1, c, TRUE, NULL);
|
||||
if (*p != c)
|
||||
return NULL;
|
||||
return p;
|
||||
}
|
||||
|
||||
@ -2667,6 +2708,51 @@ unload_dummy_buffer(buf)
|
||||
close_buffer(NULL, buf, DOBUF_UNLOAD);
|
||||
}
|
||||
|
||||
#if defined(FEAT_EVAL) || defined(PROTO)
|
||||
/*
|
||||
* Add each quickfix error to list "list" as a dictionary.
|
||||
*/
|
||||
int
|
||||
get_errorlist(list)
|
||||
list_T *list;
|
||||
{
|
||||
dict_T *dict;
|
||||
char_u buf[2];
|
||||
struct qf_line *qfp;
|
||||
int i;
|
||||
|
||||
if (qf_curlist >= qf_listcount || qf_lists[qf_curlist].qf_count == 0)
|
||||
{
|
||||
EMSG(_(e_quickfix));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
qfp = qf_lists[qf_curlist].qf_start;
|
||||
for (i = 1; !got_int && i <= qf_lists[qf_curlist].qf_count; ++i)
|
||||
{
|
||||
if ((dict = dict_alloc()) == NULL)
|
||||
return FAIL;
|
||||
if (list_append_dict(list, dict) == FAIL)
|
||||
return FAIL;
|
||||
|
||||
buf[0] = qfp->qf_type;
|
||||
buf[1] = NUL;
|
||||
if ( dict_add_nr_str(dict, "bufnr", (long)qfp->qf_fnum, NULL) == FAIL
|
||||
|| dict_add_nr_str(dict, "lnum", (long)qfp->qf_lnum, NULL) == FAIL
|
||||
|| dict_add_nr_str(dict, "col", (long)qfp->qf_col, NULL) == FAIL
|
||||
|| dict_add_nr_str(dict, "vcol", (long)qfp->qf_viscol, NULL) == FAIL
|
||||
|| dict_add_nr_str(dict, "nr", (long)qfp->qf_nr, NULL) == FAIL
|
||||
|| dict_add_nr_str(dict, "text", 0L, qfp->qf_text) == FAIL
|
||||
|| dict_add_nr_str(dict, "type", 0L, buf) == FAIL
|
||||
|| dict_add_nr_str(dict, "valid", (long)qfp->qf_valid, NULL) == FAIL)
|
||||
return FAIL;
|
||||
|
||||
qfp = qfp->qf_next;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* ":[range]cbuffer [bufnr]" command.
|
||||
*/
|
||||
@ -2781,7 +2867,7 @@ ex_helpgrep(eap)
|
||||
lnum,
|
||||
(int)(regmatch.startp[0] - IObuff)
|
||||
+ 1, /* col */
|
||||
FALSE, /* virt_col */
|
||||
FALSE, /* vis_col */
|
||||
0, /* nr */
|
||||
1, /* type */
|
||||
TRUE /* valid */
|
||||
|
57
src/regexp.c
57
src/regexp.c
@ -3265,12 +3265,38 @@ vim_regexec_both(line, col)
|
||||
#endif
|
||||
c = *prog->regmust;
|
||||
s = line + col;
|
||||
while ((s = cstrchr(s, c)) != NULL)
|
||||
{
|
||||
if (cstrncmp(s, prog->regmust, &prog->regmlen) == 0)
|
||||
break; /* Found it. */
|
||||
mb_ptr_adv(s);
|
||||
}
|
||||
|
||||
/*
|
||||
* This is used very often, esp. for ":global". Use three versions of
|
||||
* the loop to avoid overhead of conditions.
|
||||
*/
|
||||
if (!ireg_ic
|
||||
#ifdef FEAT_MBYTE
|
||||
&& !has_mbyte
|
||||
#endif
|
||||
)
|
||||
while ((s = vim_strbyte(s, c)) != NULL)
|
||||
{
|
||||
if (cstrncmp(s, prog->regmust, &prog->regmlen) == 0)
|
||||
break; /* Found it. */
|
||||
++s;
|
||||
}
|
||||
#ifdef FEAT_MBYTE
|
||||
else if (!ireg_ic || (!enc_utf8 && mb_char2len(c) > 1))
|
||||
while ((s = vim_strchr(s, c)) != NULL)
|
||||
{
|
||||
if (cstrncmp(s, prog->regmust, &prog->regmlen) == 0)
|
||||
break; /* Found it. */
|
||||
mb_ptr_adv(s);
|
||||
}
|
||||
#endif
|
||||
else
|
||||
while ((s = cstrchr(s, c)) != NULL)
|
||||
{
|
||||
if (cstrncmp(s, prog->regmust, &prog->regmlen) == 0)
|
||||
break; /* Found it. */
|
||||
mb_ptr_adv(s);
|
||||
}
|
||||
if (s == NULL) /* Not present. */
|
||||
goto theend;
|
||||
}
|
||||
@ -3339,8 +3365,16 @@ vim_regexec_both(line, col)
|
||||
{
|
||||
if (prog->regstart != NUL)
|
||||
{
|
||||
/* Skip until the char we know it must start with. */
|
||||
s = cstrchr(regline + col, prog->regstart);
|
||||
/* Skip until the char we know it must start with.
|
||||
* Used often, do some work to avoid call overhead. */
|
||||
if (!ireg_ic
|
||||
#ifdef FEAT_MBYTE
|
||||
&& !has_mbyte
|
||||
#endif
|
||||
)
|
||||
s = vim_strbyte(regline + col, prog->regstart);
|
||||
else
|
||||
s = cstrchr(regline + col, prog->regstart);
|
||||
if (s == NULL)
|
||||
{
|
||||
retval = 0;
|
||||
@ -3375,7 +3409,8 @@ vim_regexec_both(line, col)
|
||||
|
||||
#ifdef HAVE_SETJMP_H
|
||||
inner_end:
|
||||
;
|
||||
if (did_mch_startjmp)
|
||||
mch_endjmp();
|
||||
#endif
|
||||
#ifdef HAVE_TRY_EXCEPT
|
||||
}
|
||||
@ -3391,10 +3426,6 @@ inner_end:
|
||||
retval = 0L;
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_SETJMP_H
|
||||
if (did_mch_startjmp)
|
||||
mch_endjmp();
|
||||
#endif
|
||||
|
||||
theend:
|
||||
/* Didn't find a match. */
|
||||
|
17
src/ui.c
17
src/ui.c
@ -138,6 +138,11 @@ ui_inchar(buf, maxlen, wtime, tb_change_cnt)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_PROFILE
|
||||
if (do_profiling && wtime != 0)
|
||||
prof_inchar_enter();
|
||||
#endif
|
||||
|
||||
#ifdef NO_CONSOLE_INPUT
|
||||
/* Don't wait for character input when the window hasn't been opened yet.
|
||||
* Do try reading, this works when redirecting stdin from a file.
|
||||
@ -150,12 +155,13 @@ ui_inchar(buf, maxlen, wtime, tb_change_cnt)
|
||||
# ifndef NO_CONSOLE
|
||||
retval = mch_inchar(buf, maxlen, 10L, tb_change_cnt);
|
||||
if (retval > 0 || typebuf_changed(tb_change_cnt))
|
||||
return retval;
|
||||
goto theend;
|
||||
# endif
|
||||
if (wtime == -1 && ++count == 1000)
|
||||
read_error_exit();
|
||||
buf[0] = CAR;
|
||||
return 1;
|
||||
retval = 1;
|
||||
goto theend;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -186,6 +192,13 @@ ui_inchar(buf, maxlen, wtime, tb_change_cnt)
|
||||
|
||||
ctrl_c_interrupts = TRUE;
|
||||
|
||||
#ifdef NO_CONSOLE_INPUT
|
||||
theend:
|
||||
#endif
|
||||
#ifdef FEAT_PROFILE
|
||||
if (do_profiling && wtime != 0)
|
||||
prof_inchar_exit();
|
||||
#endif
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
@ -421,6 +421,11 @@ static char *(features[]) =
|
||||
#else
|
||||
"-printer",
|
||||
#endif
|
||||
#ifdef FEAT_PROFILE
|
||||
"+profile",
|
||||
#else
|
||||
"-profile",
|
||||
#endif
|
||||
#ifdef FEAT_PYTHON
|
||||
# ifdef DYNAMIC_PYTHON
|
||||
"+python/dyn",
|
||||
|
@ -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 (2005 Feb 21)"
|
||||
#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2005 Feb 21, compiled "
|
||||
#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2005 Feb 26)"
|
||||
#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2005 Feb 26, compiled "
|
||||
|
13
src/vim.h
13
src/vim.h
@ -1533,7 +1533,8 @@ int vim_memcmp __ARGS((void *, void *, size_t));
|
||||
#define VV_INSERTMODE 33
|
||||
#define VV_VAL 34
|
||||
#define VV_KEY 35
|
||||
#define VV_LEN 36 /* number of v: vars */
|
||||
#define VV_PROFILING 36
|
||||
#define VV_LEN 37 /* number of v: vars */
|
||||
|
||||
#ifdef FEAT_CLIPBOARD
|
||||
|
||||
@ -1620,6 +1621,12 @@ typedef int VimClipboard; /* This is required for the prototypes. */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_PROFILE
|
||||
typedef struct timeval proftime_T;
|
||||
#else
|
||||
typedef int proftime_T; /* dummy for function prototypes */
|
||||
#endif
|
||||
|
||||
#include "option.h" /* option variables and defines */
|
||||
#include "ex_cmds.h" /* Ex command defines */
|
||||
#include "proto.h" /* function prototypes */
|
||||
@ -1865,4 +1872,8 @@ typedef int VimClipboard; /* This is required for the prototypes. */
|
||||
# define handle_signal(x) 0
|
||||
#endif
|
||||
|
||||
/* flags for skip_vimgrep_pat() */
|
||||
#define VGR_GLOBAL 1
|
||||
#define VGR_NOJUMP 2
|
||||
|
||||
#endif /* VIM__H */
|
||||
|
36
src/window.c
36
src/window.c
@ -74,6 +74,11 @@ static void win_new_height __ARGS((win_T *, int));
|
||||
|
||||
#define NOWIN (win_T *)-1 /* non-exisiting window */
|
||||
|
||||
#ifdef FEAT_WINDOWS
|
||||
static long p_ch_used = 1L; /* value of 'cmdheight' when frame
|
||||
size was set */
|
||||
#endif
|
||||
|
||||
#if defined(FEAT_WINDOWS) || defined(PROTO)
|
||||
/*
|
||||
* all CTRL-W window commands are handled here, called from normal_cmd().
|
||||
@ -498,6 +503,23 @@ do_window(nchar, Prenum, xchar)
|
||||
break;
|
||||
#endif
|
||||
|
||||
case K_KENTER:
|
||||
case CAR:
|
||||
#if defined(FEAT_QUICKFIX)
|
||||
/*
|
||||
* In a quickfix window a <CR> jumps to the error under the
|
||||
* cursor in a new window.
|
||||
*/
|
||||
if (bt_quickfix(curbuf))
|
||||
{
|
||||
sprintf((char *)cbuf, "split +%ldcc",
|
||||
(long)curwin->w_cursor.lnum);
|
||||
do_cmdline_cmd(cbuf);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
|
||||
/* CTRL-W g extended commands */
|
||||
case 'g':
|
||||
case Ctrl_G:
|
||||
@ -2680,6 +2702,9 @@ win_alloc_first()
|
||||
topframe->fr_width = Columns;
|
||||
#endif
|
||||
topframe->fr_height = Rows - p_ch;
|
||||
#ifdef FEAT_WINDOWS
|
||||
p_ch_used = p_ch;
|
||||
#endif
|
||||
topframe->fr_win = curwin;
|
||||
curwin->w_frame = topframe;
|
||||
}
|
||||
@ -3308,6 +3333,10 @@ shell_new_rows()
|
||||
win_new_height(firstwin, h);
|
||||
#endif
|
||||
compute_cmdrow();
|
||||
#ifdef FEAT_WINDOWS
|
||||
p_ch_used = p_ch;
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
/* Disabled: don't want making the screen smaller make a window larger. */
|
||||
if (p_ea)
|
||||
@ -4315,6 +4344,13 @@ command_height(old_p_ch)
|
||||
int h;
|
||||
frame_T *frp;
|
||||
|
||||
/* When passed a negative value use the value of p_ch that we remembered.
|
||||
* This is needed for when the GUI starts up, we can't be sure in what
|
||||
* order things happen. */
|
||||
if (old_p_ch < 0)
|
||||
old_p_ch = p_ch_used;
|
||||
p_ch_used = p_ch;
|
||||
|
||||
/* Find bottom frame with width of screen. */
|
||||
frp = lastwin->w_frame;
|
||||
# ifdef FEAT_VERTSPLIT
|
||||
|
Loading…
x
Reference in New Issue
Block a user