Compare commits

...

13 Commits

Author SHA1 Message Date
7ee80f7661 patch 8.1.2012: more functions can be used as methods
Problem:    More functions can be used as methods.
Solution:   Make terminal functions usable as a method.  Fix term_getattr().
2019-09-08 20:55:06 +02:00
ce90e36f59 patch 8.1.2011: more functions can be used as methods
Problem:    More functions can be used as methods.
Solution:   Make various functions usable as a method.  Make the window
            command test faster.
2019-09-08 18:58:44 +02:00
9490b9a61c patch 8.1.2010: new file uses old style comments
Problem:    New file uses old style comments.
Solution:   Change to new style comments. (Yegappan Lakshmanan, closes #4910)
2019-09-08 17:20:12 +02:00
3d2a3cbce8 patch 8.1.2009: cursorline highlighting not updated in popup window
Problem:    Cursorline highlighting not updated in popup window. (Marko
            Mahnič)
Solution:   Check if the cursor position changed. (closes #4912)
2019-09-08 17:12:01 +02:00
4544bd2f24 patch 8.1.2008: error for invalid range when using listener and undo
Problem:    Error for invalid range when using listener and undo. (Paul Jolly)
Solution:   Do not change the cursor before the lines are restored.
            (closes #4908)
2019-09-08 15:27:21 +02:00
fca068b977 patch 8.1.2007: no test for what 8.1.1926 fixes
Problem:    No test for what 8.1.1926 fixes.
Solution:   Add a test case.
2019-09-08 14:07:47 +02:00
6cdce2a003 patch 8.1.2006: build failure with huge features but without channel feature
Problem:    Build failure with huge features but without channel feature.
Solution:   Add #ifdef. (Dominique Pelle, closes #4906)
2019-09-07 23:25:09 +02:00
6d7d7cf750 patch 8.1.2005: the regexp.c file is too big
Problem:    The regexp.c file is too big.
Solution:   Move the backtracking engine to a separate file. (Yegappan
            Lakshmanan, closes #4905)
2019-09-07 23:16:33 +02:00
f6ed61e148 patch 8.1.2004: more functions can be used as methods
Problem:    More functions can be used as methods.
Solution:   Make various functions usable as a method.
2019-09-07 19:05:09 +02:00
30e9b3c425 Update runtime files 2019-09-07 16:24:12 +02:00
fa90d70884 patch 8.1.2003: MS-Windows: code page 65001 is not recognized
Problem:    MS-Windows: code page 65001 is not recognized.
Solution:   Use utf-8 for code page 65001. (Dan Thompson, closes #4902)
2019-09-07 16:07:47 +02:00
9b1cd65d8b patch 8.1.2002: version number 2000 missing
Problem:    Version number 2000 missing.
Solution:   Add the number in the list of patches.
2019-09-07 15:51:28 +02:00
261f346f81 patch 8.1.2001: some source files are too big
Problem:    Some source files are too big.
Solution:   Move buffer and window related functions to evalbuffer.c and
            evalwindow.c. (Yegappan Lakshmanan, closes #4898)
2019-09-07 15:45:32 +02:00
69 changed files with 7999 additions and 7680 deletions

View File

@ -34,8 +34,10 @@ SRC_ALL = \
src/digraph.c \
src/edit.c \
src/eval.c \
src/evalbuffer.c \
src/evalfunc.c \
src/evalvars.c \
src/evalwindow.c \
src/ex_cmdidxs.h \
src/ex_cmds.c \
src/ex_cmds.h \
@ -90,6 +92,7 @@ SRC_ALL = \
src/profiler.c \
src/quickfix.c \
src/regexp.c \
src/regexp_bt.c \
src/regexp_nfa.c \
src/regexp.h \
src/scriptfile.c \
@ -189,8 +192,10 @@ SRC_ALL = \
src/proto/digraph.pro \
src/proto/edit.pro \
src/proto/eval.pro \
src/proto/evalbuffer.pro \
src/proto/evalfunc.pro \
src/proto/evalvars.pro \
src/proto/evalwindow.pro \
src/proto/ex_cmds.pro \
src/proto/ex_cmds2.pro \
src/proto/ex_docmd.pro \

View File

@ -1,4 +1,4 @@
*cmdline.txt* For Vim version 8.1. Last change: 2019 Aug 18
*cmdline.txt* For Vim version 8.1. Last change: 2019 Sep 04
VIM REFERENCE MANUAL by Bram Moolenaar
@ -909,8 +909,7 @@ Note: these are typed literally, they are not special keys!
*%:8* *%:p* *%:.* *%:~* *%:h* *%:t* *%:r* *%:e* *%:s* *%:gs* *%:S*
The file name modifiers can be used after "%", "#", "#n", "<cfile>", "<sfile>",
"<afile>" or "<abuf>". They are also used with the |fnamemodify()| function.
These are not available when Vim has been compiled without the |+modify_fname|
feature.
These modifiers can be given, in this order:
:p Make file name a full path. Must be the first modifier. Also
changes "~/" (and "~user/" for Unix and VMS) to the path for

View File

@ -100,7 +100,7 @@ g CTRL-G Prints the current position of the cursor in five
:buffers
:files
:ls List all the currently known file names. See
'windows.txt' |:files| |:buffers| |:ls|.
|windows.txt| |:files| |:buffers| |:ls|.
Vim will remember the full path name of a file name that you enter. In most
cases when the file name is displayed only the name you typed is shown, but
@ -1233,7 +1233,7 @@ The syntax is best shown via some examples: >
< Open the browser in the C:/bar directory, with the current
buffer filename as default, and save the buffer under the
filename chosen.
Also see the |'browsedir'| option.
Also see the 'browsedir' option.
For versions of Vim where browsing is not supported, the command is executed
unmodified.

View File

@ -8895,7 +8895,11 @@ sound_playevent({name} [, {callback}])
Returns the sound ID, which can be passed to `sound_stop()`.
Returns zero if the sound could not be played.
{only available when compiled with the |+sound| feature}
Can also be used as a |method|: >
GetSoundName()->sound_playevent()
< {only available when compiled with the |+sound| feature}
*sound_playfile()*
sound_playfile({path} [, {callback}])
@ -8903,6 +8907,10 @@ sound_playfile({path} [, {callback}])
must be a full path. On Ubuntu you may find files to play
with this command: >
:!find /usr/share/sounds -type f | grep -v index.theme
< Can also be used as a |method|: >
GetSoundPath()->sound_playfile()
< {only available when compiled with the |+sound| feature}
@ -8913,7 +8921,10 @@ sound_stop({id}) *sound_stop()*
On MS-Windows, this does not work for event sound started by
`sound_playevent()`. To stop event sounds, use `sound_clear()`.
{only available when compiled with the |+sound| feature}
Can also be used as a |method|: >
soundid->sound_stop()
< {only available when compiled with the |+sound| feature}
*soundfold()*
soundfold({word})
@ -8924,6 +8935,9 @@ soundfold({word})
This can be used for making spelling suggestions. Note that
the method can be quite slow.
Can also be used as a |method|: >
GetWord()->soundfold()
<
*spellbadword()*
spellbadword([{sentence}])
Without argument: The result is the badly spelled word under
@ -8950,6 +8964,9 @@ spellbadword([{sentence}])
'spell' option must be set and the value of 'spelllang' is
used.
Can also be used as a |method|: >
GetText()->spellbadword()
<
*spellsuggest()*
spellsuggest({word} [, {max} [, {capital}]])
Return a |List| with spelling suggestions to replace {word}.
@ -8973,6 +8990,8 @@ spellsuggest({word} [, {max} [, {capital}]])
'spell' option must be set and the values of 'spelllang' and
'spellsuggest' are used.
Can also be used as a |method|: >
GetWord()->spellsuggest()
split({expr} [, {pattern} [, {keepempty}]]) *split()*
Make a |List| out of {expr}. When {pattern} is omitted or
@ -9069,6 +9088,19 @@ str2nr({expr} [, {base}]) *str2nr()*
leading "0b" or "0B" is ignored.
Text after the number is silently ignored.
Can also be used as a |method|: >
GetText()->str2nr()
strcharpart({src}, {start} [, {len}]) *strcharpart()*
Like |strpart()| but using character index and length instead
of byte index and length.
When a character index is used where a character does not
exist it is assumed to be one character. For example: >
strcharpart('abc', -1, 2)
< results in 'a'.
Can also be used as a |method|: >
GetText()->strcharpart(5)
strchars({expr} [, {skipcc}]) *strchars()*
The result is a Number, which is the number of characters
@ -9094,13 +9126,8 @@ strchars({expr} [, {skipcc}]) *strchars()*
endfunction
endif
<
strcharpart({src}, {start} [, {len}]) *strcharpart()*
Like |strpart()| but using character index and length instead
of byte index and length.
When a character index is used where a character does not
exist it is assumed to be one character. For example: >
strcharpart('abc', -1, 2)
< results in 'a'.
Can also be used as a |method|: >
GetText()->strchars()
strdisplaywidth({expr} [, {col}]) *strdisplaywidth()*
The result is a Number, which is the number of display cells
@ -9115,6 +9142,9 @@ strdisplaywidth({expr} [, {col}]) *strdisplaywidth()*
Ambiguous, this function's return value depends on 'ambiwidth'.
Also see |strlen()|, |strwidth()| and |strchars()|.
Can also be used as a |method|: >
GetText()->strdisplaywidth()
strftime({format} [, {time}]) *strftime()*
The result is a String, which is a formatted date and time, as
specified by the {format} string. The given {time} is used,
@ -9134,12 +9164,18 @@ strftime({format} [, {time}]) *strftime()*
< Not available on all systems. To check use: >
:if exists("*strftime")
< Can also be used as a |method|: >
GetFormat()->strftime()
strgetchar({str}, {index}) *strgetchar()*
Get character {index} from {str}. This uses a character
index, not a byte index. Composing characters are considered
separate characters here.
Also see |strcharpart()| and |strchars()|.
Can also be used as a |method|: >
GetText()->strgetchar(5)
stridx({haystack}, {needle} [, {start}]) *stridx()*
The result is a Number, which gives the byte index in
{haystack} of the first occurrence of the String {needle}.
@ -9159,6 +9195,8 @@ stridx({haystack}, {needle} [, {start}]) *stridx()*
stridx() works similar to the C function strstr(). When used
with a single character it works similar to strchr().
Can also be used as a |method|: >
GetHaystack()->stridx(needle)
*string()*
string({expr}) Return {expr} converted to a String. If {expr} is a Number,
Float, String, Blob or a composition of them, then the result
@ -9211,6 +9249,9 @@ strpart({src}, {start} [, {len}]) *strpart()*
example, to get three bytes under and after the cursor: >
strpart(getline("."), col(".") - 1, 3)
<
Can also be used as a |method|: >
GetText()->strpart(5)
strridx({haystack}, {needle} [, {start}]) *strridx()*
The result is a Number, which gives the byte index in
{haystack} of the last occurrence of the String {needle}.
@ -9229,6 +9270,9 @@ strridx({haystack}, {needle} [, {start}]) *strridx()*
When used with a single character it works similar to the C
function strrchr().
Can also be used as a |method|: >
GetHaystack()->strridx(needle)
strtrans({expr}) *strtrans()*
The result is a String, which is {expr} with all unprintable
characters translated into printable characters |'isprint'|.
@ -9277,6 +9321,9 @@ submatch({nr} [, {list}]) *submatch()* *E935*
< This finds the first number in the line and adds one to it.
A line break is included as a newline character.
Can also be used as a |method|: >
GetNr()->submatch()
substitute({expr}, {pat}, {sub}, {flags}) *substitute()*
The result is a String, which is a copy of {expr}, in which
the first match of {pat} is replaced with {sub}.
@ -9340,6 +9387,9 @@ swapinfo({fname}) *swapinfo()*
Not a swap file: does not contain correct block ID
Magic number mismatch: Info in first block is invalid
Can also be used as a |method|: >
GetFilename()->swapinfo()
swapname({expr}) *swapname()*
The result is the swap file path of the buffer {expr}.
For the use of {expr}, see |bufname()| above.
@ -9347,6 +9397,9 @@ swapname({expr}) *swapname()*
|:swapname| (unless no swap file).
If buffer {expr} has no swap file, returns an empty string.
Can also be used as a |method|: >
GetBufname()->swapname()
synID({lnum}, {col}, {trans}) *synID()*
The result is a Number, which is the syntax ID at the position
{lnum} and {col} in the current window.
@ -9553,6 +9606,8 @@ tabpagebuflist([{arg}]) *tabpagebuflist()*
endfor
< Note that a buffer may appear in more than one window.
Can also be used as a |method|: >
GetTabpage()->tabpagebuflist()
tabpagenr([{arg}]) *tabpagenr()*
The result is a Number, which is the number of the current
@ -9575,6 +9630,9 @@ tabpagewinnr({tabarg} [, {arg}]) *tabpagewinnr()*
tabpagewinnr(4, '$') " number of windows in tab page 4
< When {tabarg} is invalid zero is returned.
Can also be used as a |method|: >
GetTabpage()->tabpagewinnr()
<
*tagfiles()*
tagfiles() Returns a |List| with the file names used to search for tags
for the current buffer. This is the 'tags' option expanded.
@ -9623,6 +9681,9 @@ taglist({expr} [, {filename}]) *taglist()*
located by Vim. Refer to |tags-file-format| for the format of
the tags file generated by the different ctags tools.
Can also be used as a |method|: >
GetTagpattern()->taglist()
tan({expr}) *tan()*
Return the tangent of {expr}, measured in radians, as a |Float|
in the range [-inf, inf].

View File

@ -1,4 +1,4 @@
*index.txt* For Vim version 8.1. Last change: 2019 Aug 21
*index.txt* For Vim version 8.1. Last change: 2019 Sep 02
VIM REFERENCE MANUAL by Bram Moolenaar
@ -23,7 +23,7 @@ to look for deleting something, use: "/delete".
5. Terminal-Job mode |terminal-job-index|
6. EX commands |ex-cmd-index|
For an overview of options see help.txt |option-list|.
For an overview of options see |option-list|.
For an overview of built-in functions see |functions|.
For a list of Vim variables see |vim-variable|.
For a complete listing of all help items see |help-tags|.
@ -1128,6 +1128,8 @@ The commands are sorted on the non-optional part of their name.
tag command action ~
------------------------------------------------------------------------------
|:| : nothing
|:range| :{range} go to last line in {range}
|:!| :! filter lines or execute an external command
|:!!| :!! repeat last ":!" command
|:#| :# same as ":number"

View File

@ -1,4 +1,4 @@
*popup.txt* For Vim version 8.1. Last change: 2019 Sep 03
*popup.txt* For Vim version 8.1. Last change: 2019 Sep 04
VIM REFERENCE MANUAL by Bram Moolenaar

View File

@ -1,4 +1,4 @@
*sign.txt* For Vim version 8.1. Last change: 2019 Jul 21
*sign.txt* For Vim version 8.1. Last change: 2019 Sep 06
VIM REFERENCE MANUAL by Gordon Prieur

View File

@ -152,8 +152,8 @@ a slash. Thus "-R" means recovery and "-/R" readonly.
This can be used to find out where time is spent while loading
your .vimrc, plugins and opening the first file.
When {fname} already exists new messages are appended.
(Only available when compiled with the |+startuptime|
feature).
{only available when compiled with the |+startuptime|
feature}
*--literal*
--literal Take file names literally, don't expand wildcards. Not needed
@ -311,10 +311,10 @@ a slash. Thus "-R" means recovery and "-/R" readonly.
-l Lisp mode. Sets the 'lisp' and 'showmatch' options on.
*-A*
-A Arabic mode. Sets the 'arabic' option on. (Only when
-A Arabic mode. Sets the 'arabic' option on. {only when
compiled with the |+arabic| features (which include
|+rightleft|), otherwise Vim gives an error message
and exits.)
and exits}
*-F*
-F This was used for Farsi mode, which has been removed.
@ -322,8 +322,8 @@ a slash. Thus "-R" means recovery and "-/R" readonly.
*-H*
-H Hebrew mode. Sets the 'hkmap' and 'rightleft' options on.
(Only when compiled with the |+rightleft| feature, otherwise
Vim gives an error message and exits.)
{only when compiled with the |+rightleft| feature, otherwise
Vim gives an error message and exits}
*-V* *verbose*
-V[N] Verbose. Sets the 'verbose' option to [N] (default: 10).

View File

@ -1746,7 +1746,7 @@ There are several html preprocessor languages out there. html.vim has been
written such that it should be trivial to include it. To do so add the
following two lines to the syntax coloring file for that language
(the example comes from the asp.vim file):
>
runtime! syntax/html.vim
syn cluster htmlPreproc add=asp

View File

@ -6846,6 +6846,7 @@ getfperm() eval.txt /*getfperm()*
getfsize() eval.txt /*getfsize()*
getftime() eval.txt /*getftime()*
getftype() eval.txt /*getftype()*
getimstatus() eval.txt /*getimstatus()*
getjumplist() eval.txt /*getjumplist()*
getlatestvimscripts-install pi_getscript.txt /*getlatestvimscripts-install*
getline() eval.txt /*getline()*
@ -8256,6 +8257,7 @@ popup-callback popup.txt /*popup-callback*
popup-close popup.txt /*popup-close*
popup-examples popup.txt /*popup-examples*
popup-filter popup.txt /*popup-filter*
popup-filter-mode popup.txt /*popup-filter-mode*
popup-function-details popup.txt /*popup-function-details*
popup-functions popup.txt /*popup-functions*
popup-intro popup.txt /*popup-intro*

View File

@ -479,6 +479,9 @@ term_dumpdiff({filename}, {filename} [, {options}])
Using the "s" key the top and bottom parts are swapped. This
makes it easy to spot a difference.
Can also be used as a |method|: >
GetFilename()->term_dumpdiff(otherfile)
<
*term_dumpload()*
term_dumpload({filename} [, {options}])
Open a new window displaying the contents of {filename}
@ -488,6 +491,9 @@ term_dumpload({filename} [, {options}])
For {options} see |term_dumpdiff()|.
Can also be used as a |method|: >
GetFilename()-> term_dumpload()
<
*term_dumpwrite()*
term_dumpwrite({buf}, {filename} [, {options}])
Dump the contents of the terminal screen of {buf} in the file
@ -502,11 +508,18 @@ term_dumpwrite({buf}, {filename} [, {options}])
"rows" maximum number of rows to dump
"columns" maximum number of columns to dump
Can also be used as a |method|, the base is used for the file
name: >
GetFilename()-> term_dumpwrite(bufnr)
term_getaltscreen({buf}) *term_getaltscreen()*
Returns 1 if the terminal of {buf} is using the alternate
screen.
{buf} is used as with |term_getsize()|.
{only available when compiled with the |+terminal| feature}
Can also be used as a |method|: >
GetBufnr()->term_getaltscreen()
term_getansicolors({buf}) *term_getansicolors()*
Get the ANSI color palette in use by terminal {buf}.
@ -517,8 +530,12 @@ term_getansicolors({buf}) *term_getansicolors()*
{buf} is used as with |term_getsize()|. If the buffer does not
exist or is not a terminal window, an empty list is returned.
{only available when compiled with the |+terminal| feature and
with GUI enabled and/or the |+termguicolors| feature}
Can also be used as a |method|: >
GetBufnr()->term_getansicolors()
< {only available when compiled with GUI enabled and/or the
|+termguicolors| feature}
term_getattr({attr}, {what}) *term_getattr()*
Given {attr}, a value returned by term_scrape() in the "attr"
@ -528,7 +545,10 @@ term_getattr({attr}, {what}) *term_getattr()*
underline
strike
reverse
{only available when compiled with the |+terminal| feature}
Can also be used as a |method|: >
GetAttr()->term_getattr()
term_getcursor({buf}) *term_getcursor()*
Get the cursor position of terminal {buf}. Returns a list with
@ -550,13 +570,18 @@ term_getcursor({buf}) *term_getcursor()*
{buf} must be the buffer number of a terminal window. If the
buffer does not exist or is not a terminal window, an empty
list is returned.
{only available when compiled with the |+terminal| feature}
Can also be used as a |method|: >
GetBufnr()->term_getcursor()
term_getjob({buf}) *term_getjob()*
Get the Job associated with terminal window {buf}.
{buf} is used as with |term_getsize()|.
Returns |v:null| when there is no job.
{only available when compiled with the |+terminal| feature}
Can also be used as a |method|: >
GetBufnr()->term_getjob()
term_getline({buf}, {row}) *term_getline()*
Get a line of text from the terminal window of {buf}.
@ -567,7 +592,10 @@ term_getline({buf}, {row}) *term_getline()*
returned.
To get attributes of each character use |term_scrape()|.
{only available when compiled with the |+terminal| feature}
Can also be used as a |method|: >
GetBufnr()->term_getline(row)
term_getscrolled({buf}) *term_getscrolled()*
Return the number of lines that scrolled to above the top of
@ -579,7 +607,10 @@ term_getscrolled({buf}) *term_getscrolled()*
< (if that line exists).
{buf} is used as with |term_getsize()|.
{only available when compiled with the |+terminal| feature}
Can also be used as a |method|: >
GetBufnr()->term_getscrolled()
term_getsize({buf}) *term_getsize()*
Get the size of terminal {buf}. Returns a list with two
@ -589,7 +620,10 @@ term_getsize({buf}) *term_getsize()*
{buf} must be the buffer number of a terminal window. Use an
empty string for the current buffer. If the buffer does not
exist or is not a terminal window, an empty list is returned.
{only available when compiled with the |+terminal| feature}
Can also be used as a |method|: >
GetBufnr()->term_getsize()
term_getstatus({buf}) *term_getstatus()*
Get the status of terminal {buf}. This returns a comma
@ -602,7 +636,10 @@ term_getstatus({buf}) *term_getstatus()*
{buf} must be the buffer number of a terminal window. If the
buffer does not exist or is not a terminal window, an empty
string is returned.
{only available when compiled with the |+terminal| feature}
Can also be used as a |method|: >
GetBufnr()->term_getstatus()
term_gettitle({buf}) *term_gettitle()*
Get the title of terminal {buf}. This is the title that the
@ -611,7 +648,10 @@ term_gettitle({buf}) *term_gettitle()*
{buf} must be the buffer number of a terminal window. If the
buffer does not exist or is not a terminal window, an empty
string is returned.
{only available when compiled with the |+terminal| feature}
Can also be used as a |method|: >
GetBufnr()->term_gettitle()
term_gettty({buf} [, {input}]) *term_gettty()*
Get the name of the controlling terminal associated with
@ -620,12 +660,15 @@ term_gettty({buf} [, {input}]) *term_gettty()*
When {input} is omitted or 0, return the name for writing
(stdout). When {input} is 1 return the name for reading
(stdin). On UNIX, both return same name.
{only available when compiled with the |+terminal| feature}
Can also be used as a |method|: >
GetBufnr()->term_gettty()
term_list() *term_list()*
Return a list with the buffer numbers of all buffers for
terminal windows.
{only available when compiled with the |+terminal| feature}
term_scrape({buf}, {row}) *term_scrape()*
Get the contents of {row} of terminal screen of {buf}.
@ -642,7 +685,10 @@ term_scrape({buf}, {row}) *term_scrape()*
"attr" attributes of the cell, use |term_getattr()|
to get the individual flags
"width" cell width: 1 or 2
{only available when compiled with the |+terminal| feature}
Can also be used as a |method|: >
GetBufnr()->term_scrape(row)
term_sendkeys({buf}, {keys}) *term_sendkeys()*
Send keystrokes {keys} to terminal {buf}.
@ -650,7 +696,10 @@ term_sendkeys({buf}, {keys}) *term_sendkeys()*
{keys} are translated as key sequences. For example, "\<c-x>"
means the character CTRL-X.
{only available when compiled with the |+terminal| feature}
Can also be used as a |method|: >
GetBufnr()->term_sendkeys(keys)
term_setansicolors({buf}, {colors}) *term_setansicolors()*
Set the ANSI color palette used by terminal {buf}.
@ -680,8 +729,12 @@ term_setansicolors({buf}, {colors}) *term_setansicolors()*
'termguicolors' is set. When not using GUI colors (GUI mode
or 'termguicolors'), the terminal window always uses the 16
ANSI colors of the underlying terminal.
{only available when compiled with the |+terminal| feature and
with GUI enabled and/or the |+termguicolors| feature}
Can also be used as a |method|: >
GetBufnr()->term_setansicolors(colors)
< {only available with GUI enabled and/or the |+termguicolors|
feature}
term_setkill({buf}, {how}) *term_setkill()*
When exiting Vim or trying to close the terminal window in
@ -695,6 +748,10 @@ term_setkill({buf}, {how}) *term_setkill()*
After sending the signal Vim will wait for up to a second to
check that the job actually stopped.
Can also be used as a |method|: >
GetBufnr()->term_setkill(how)
term_setrestore({buf}, {command}) *term_setrestore()*
Set the command to write in a session file to restore the job
in this terminal. The line written in the session file is: >
@ -703,7 +760,10 @@ term_setrestore({buf}, {command}) *term_setrestore()*
Use an empty {command} to run 'shell'.
Use "NONE" to not restore this window.
{only available when compiled with the |+terminal| feature}
Can also be used as a |method|: >
GetBufnr()->term_setrestore(command)
term_setsize({buf}, {rows}, {cols}) *term_setsize()* *E955*
Set the size of terminal {buf}. The size of the window
@ -714,7 +774,10 @@ term_setsize({buf}, {rows}, {cols}) *term_setsize()* *E955*
{buf} must be the buffer number of a terminal window. Use an
empty string for the current buffer. If the buffer does not
exist or is not a terminal window, an error is given.
{only available when compiled with the |+terminal| feature}
Can also be used as a |method|: >
GetBufnr()->term_setsize(rows, cols)
term_start({cmd} [, {options}]) *term_start()*
Open a terminal window and run {cmd} in it.
@ -781,14 +844,20 @@ term_start({cmd} [, {options}]) *term_start()*
"tty_type" (MS-Windows only): Specify which pty to
use. See 'termwintype' for the values.
{only available when compiled with the |+terminal| feature}
Can also be used as a |method|: >
GetCommand()->term_start()
< {only available when compiled with the |+terminal| feature}
term_wait({buf} [, {time}]) *term_wait()*
Wait for pending updates of {buf} to be handled.
{buf} is used as with |term_getsize()|.
{time} is how long to wait for updates to arrive in msec. If
not set then 10 msec will be used.
{only available when compiled with the |+terminal| feature}
Can also be used as a |method|: >
GetBufnr()->term_wait()
==============================================================================
3. Terminal communication *terminal-communication*

View File

@ -44,6 +44,8 @@ test_alloc_fail({id}, {countdown}, {repeat}) *test_alloc_fail()*
let memory allocation fail {repeat} times. When {repeat} is
smaller than one it fails one time.
Can also be used as a |method|: >
GetAllocId()->test_alloc_fail()
test_autochdir() *test_autochdir()*
Set a flag to enable the effect of 'autochdir' before Vim
@ -55,6 +57,8 @@ test_feedinput({string}) *test_feedinput()*
were typed by the user. This uses a low level input buffer.
This function works only when with |+unix| or GUI is running.
Can also be used as a |method|: >
GetText()->test_feedinput()
test_garbagecollect_now() *test_garbagecollect_now()*
Like garbagecollect(), but executed right away. This must
@ -73,6 +77,8 @@ test_getvalue({name}) *test_getvalue()*
{name} are supported:
need_fileinfo
Can also be used as a |method|: >
GetName()->test_getvalue()
test_ignore_error({expr}) *test_ignore_error()*
Ignore any error containing {expr}. A normal message is given
@ -84,6 +90,8 @@ test_ignore_error({expr}) *test_ignore_error()*
When the {expr} is the string "RESET" then the list of ignored
errors is made empty.
Can also be used as a |method|: >
GetErrorText()->test_ignore_error()
test_null_blob() *test_null_blob()*
Return a |Blob| that is null. Only useful for testing.
@ -124,6 +132,9 @@ test_option_not_set({name}) *test_option_not_set()*
even though the value is "double".
Only to be used for testing!
Can also be used as a |method|: >
GetOptionName()->test_option_not_set()
test_override({name}, {val}) *test_override()*
Overrides certain parts of Vim's internal processing to be able
@ -155,12 +166,17 @@ test_override({name}, {val}) *test_override()*
< The value of "starting" is saved. It is restored by: >
call test_override('starting', 0)
< Can also be used as a |method|: >
GetOverrideVal()-> test_override('starting')
test_refcount({expr}) *test_refcount()*
Return the reference count of {expr}. When {expr} is of a
type that does not have a reference count, returns -1. Only
to be used for testing.
Can also be used as a |method|: >
GetVarname()->test_refcount()
test_scrollbar({which}, {value}, {dragging}) *test_scrollbar()*
Pretend using scrollbar {which} to move it to position
@ -179,6 +195,8 @@ test_scrollbar({which}, {value}, {dragging}) *test_scrollbar()*
Only works when the {which} scrollbar actually exists,
obviously only when using the GUI.
Can also be used as a |method|: >
GetValue()->test_scrollbar('right', 0)
test_setmouse({row}, {col}) *test_setmouse()*
Set the mouse position to be used for the next mouse action.
@ -197,6 +215,9 @@ test_settime({expr}) *test_settime()*
{expr} must evaluate to a number. When the value is zero the
normal behavior is restored.
Can also be used as a |method|: >
GetTime()->test_settime()
==============================================================================
3. Assert functions *assert-functions-details*

View File

@ -341,7 +341,7 @@ will move accordingly.
When text is deleted and a text property no longer includes any text, it is
deleted. However, a text property that was defined as zero-width will remain,
unless the whole line is deleted.
` *E275*
*E275*
When a buffer is unloaded, all the text properties are gone. There is no way
to store the properties in a file. You can only re-create them. When a
buffer is hidden the text is preserved and so are the text properties. It is

View File

@ -1,4 +1,4 @@
*todo.txt* For Vim version 8.1. Last change: 2019 Aug 30
*todo.txt* For Vim version 8.1. Last change: 2019 Sep 07
VIM REFERENCE MANUAL by Bram Moolenaar
@ -138,6 +138,8 @@ Patch to add win_splitmove() function. (Andy Massimino, #4561)
Patch for #4733: #4734. Test needs improvements.
Add CmdwinLeavePost (#4762). Also add WinLeavePost then?
Patch to fix session file when using multiple tabs. (Jason Franklin, 2019 May
20)
Also put :argadd commands at the start for all buffers, so that their order
@ -278,8 +280,6 @@ Many users don't like 'thesaurus' to match so many words. (#4667, #1611)
Some composing characters actually add a cell width to the character they are
on top off, making the whole thing two characters wide. (#4526)
Add CmdwinLeavePost (#4762). Also add WinLeavePost then?
Should we include some part of pull request #4505, not increment changedtick
in some cases? E.g. for ":write" when the changed flag was already off, the
buffer didn't change at all.

View File

@ -1,4 +1,4 @@
*various.txt* For Vim version 8.1. Last change: 2019 Aug 21
*various.txt* For Vim version 8.1. Last change: 2019 Sep 04
VIM REFERENCE MANUAL by Bram Moolenaar
@ -388,7 +388,7 @@ m *+lua* |Lua| interface
m *+lua/dyn* |Lua| interface |/dyn|
N *+menu* |:menu|
N *+mksession* |:mksession|
N *+modify_fname* |filename-modifiers|
T *+modify_fname* |filename-modifiers|
N *+mouse* Mouse handling |mouse-using|
N *+mouseshape* |'mouseshape'|
B *+mouse_dec* Unix only: Dec terminal mouse handling |dec-mouse|

View File

@ -1,8 +1,8 @@
" Vim indent file
" Language: Tcl
" Previous Maintainer: Nikolai Weibull <now@bitwi.se>
" Latest Update: Chris Heithoff <chrisheithoff@gmail.com>
" Latest Revision: 2018-12-05
" Previous Maintainer: Nikolai Weibull <now@bitwi.se>
" Latest Revision: 2018-12-05
if exists("b:did_indent")
finish

View File

@ -359,8 +359,8 @@ func! s:SetupColorSchemes() abort
let s:did_setup_color_schemes = 1
let n = globpath(&runtimepath, "colors/*.vim", 1, 1)
let n += globpath(&runtimepath, "pack/*/start/*/colors/*.vim", 1, 1)
let n += globpath(&runtimepath, "pack/*/opt/*/colors/*.vim", 1, 1)
let n += globpath(&packpath, "pack/*/start/*/colors/*.vim", 1, 1)
let n += globpath(&packpath, "pack/*/opt/*/colors/*.vim", 1, 1)
" Ignore case for VMS and windows, sort on name
let names = sort(map(n, 'substitute(v:val, "\\c.*[/\\\\:\\]]\\([^/\\\\:]*\\)\\.vim", "\\1", "")'), 1)

View File

@ -721,8 +721,10 @@ OBJ = \
$(OUTDIR)/digraph.o \
$(OUTDIR)/edit.o \
$(OUTDIR)/eval.o \
$(OUTDIR)/evalbuffer.o \
$(OUTDIR)/evalfunc.o \
$(OUTDIR)/evalvars.o \
$(OUTDIR)/evalwindow.o \
$(OUTDIR)/ex_cmds.o \
$(OUTDIR)/ex_cmds2.o \
$(OUTDIR)/ex_docmd.o \
@ -1177,7 +1179,7 @@ $(OUTDIR)/os_w32exeg.o: os_w32exe.c $(INCL)
$(OUTDIR)/os_win32.o: os_win32.c $(INCL) $(MZSCHEME_INCL)
$(CC) -c $(CFLAGS) os_win32.c -o $@
$(OUTDIR)/regexp.o: regexp.c regexp_nfa.c $(INCL)
$(OUTDIR)/regexp.o: regexp.c regexp_bt.c regexp_nfa.c $(INCL)
$(CC) -c $(CFLAGS) regexp.c -o $@
$(OUTDIR)/terminal.o: terminal.c $(INCL) $(TERM_DEPS)

View File

@ -41,8 +41,10 @@ SRC = arabic.c \
digraph.c \
edit.c \
eval.c \
evalbuffer.c \
evalfunc.c \
evalvars.c \
evalwindow.c \
ex_cmds.c \
ex_cmds2.c \
ex_docmd.c \

View File

@ -728,8 +728,10 @@ OBJ = \
$(OUTDIR)\digraph.obj \
$(OUTDIR)\edit.obj \
$(OUTDIR)\eval.obj \
$(OUTDIR)\evalbuffer.obj \
$(OUTDIR)\evalfunc.obj \
$(OUTDIR)\evalvars.obj \
$(OUTDIR)\evalwindow.obj \
$(OUTDIR)\ex_cmds.obj \
$(OUTDIR)\ex_cmds2.obj \
$(OUTDIR)\ex_docmd.obj \
@ -1485,10 +1487,14 @@ $(OUTDIR)/edit.obj: $(OUTDIR) edit.c $(INCL)
$(OUTDIR)/eval.obj: $(OUTDIR) eval.c $(INCL)
$(OUTDIR)/evalbuffer.obj: $(OUTDIR) evalbuffer.c $(INCL)
$(OUTDIR)/evalfunc.obj: $(OUTDIR) evalfunc.c $(INCL)
$(OUTDIR)/evalvars.obj: $(OUTDIR) evalvars.c $(INCL)
$(OUTDIR)/evalwindow.obj: $(OUTDIR) evalwindow.c $(INCL)
$(OUTDIR)/ex_cmds.obj: $(OUTDIR) ex_cmds.c $(INCL)
$(OUTDIR)/ex_cmds2.obj: $(OUTDIR) ex_cmds2.c $(INCL)
@ -1631,7 +1637,7 @@ $(OUTDIR)/profiler.obj: $(OUTDIR) profiler.c $(INCL)
$(OUTDIR)/quickfix.obj: $(OUTDIR) quickfix.c $(INCL)
$(OUTDIR)/regexp.obj: $(OUTDIR) regexp.c regexp_nfa.c $(INCL)
$(OUTDIR)/regexp.obj: $(OUTDIR) regexp.c regexp_bt.c regexp_nfa.c $(INCL)
$(OUTDIR)/scriptfile.obj: $(OUTDIR) scriptfile.c $(INCL)
@ -1775,8 +1781,10 @@ proto.h: \
proto/digraph.pro \
proto/edit.pro \
proto/eval.pro \
proto/evalbuffer.pro \
proto/evalfunc.pro \
proto/evalvars.pro \
proto/evalwindow.pro \
proto/ex_cmds.pro \
proto/ex_cmds2.pro \
proto/ex_docmd.pro \

View File

@ -309,8 +309,10 @@ ALL_LIBS = $(LIBS) $(GUI_LIB_DIR) $(GUI_LIB) \
SRC = arabic.c arglist.c autocmd.c beval.c blob.c blowfish.c buffer.c \
change.c charset.c cmdexpand.c cmdhist.c crypt.c crypt_zip.c \
debugger.c dict.c diff.c digraph.c edit.c eval.c evalfunc.c \
evalvars.c ex_cmds.c ex_cmds2.c ex_docmd.c ex_eval.c ex_getln.c \
debugger.c dict.c diff.c digraph.c edit.c eval.c evalbuffer.c \
evalfunc.c \
evalvars.c evalwindow.c ex_cmds.c ex_cmds2.c ex_docmd.c ex_eval.c \
ex_getln.c \
if_cscope.c if_xcmdsrv.c fileio.c filepath.c, findfile.c fold.c \
getchar.c hardcopy.c hashtab.c highlight.c \
indent.c insexpand.c json.c list.c main.c map.c mark.c menu.c mbyte.c \
@ -327,7 +329,8 @@ SRC = arabic.c arglist.c autocmd.c beval.c blob.c blowfish.c buffer.c \
OBJ = arabic.obj arglist.obj autocmd.obj beval.obj blob.obj blowfish.obj \
buffer.obj change.obj charset.obj cmdexpand.obj cmdhist.obj \
crypt.obj crypt_zip.obj debugger.obj dict.obj diff.obj digraph.obj \
edit.obj eval.obj evalfunc.obj evalvars.obj ex_cmds.obj ex_cmds2.obj \
edit.obj eval.obj evalbuffer.obj evalfunc.obj evalvars.obj \
evalwindow.obj ex_cmds.obj ex_cmds2.obj \
ex_docmd.obj ex_eval.obj ex_getln.obj if_cscope.obj if_xcmdsrv.obj \
fileio.obj filepath.obj \
findfile.obj fold.obj getchar.obj hardcopy.obj hashtab.obj \
@ -567,6 +570,10 @@ eval.obj : eval.c vim.h [.auto]config.h feature.h os_unix.h \
ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h beval.h \
[.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h \
version.h
evalbuffer.obj : evalbuffer.c vim.h [.auto]config.h feature.h os_unix.h \
ascii.h keymap.h term.h macros.h option.h structs.h \
regexp.h gui.h beval.h [.proto]gui_beval.pro alloc.h ex_cmds.h spell.h \
proto.h globals.h version.h
evalfunc.obj : evalfunc.c vim.h [.auto]config.h feature.h os_unix.h \
ascii.h keymap.h term.h macros.h option.h structs.h \
regexp.h gui.h beval.h [.proto]gui_beval.pro alloc.h ex_cmds.h spell.h \
@ -575,6 +582,10 @@ evalvars.obj : evalvars.c vim.h [.auto]config.h feature.h os_unix.h \
ascii.h keymap.h term.h macros.h option.h structs.h \
regexp.h gui.h beval.h [.proto]gui_beval.pro alloc.h ex_cmds.h spell.h \
proto.h globals.h version.h
evalwindow.obj : evalwindow.c vim.h [.auto]config.h feature.h os_unix.h \
ascii.h keymap.h term.h macros.h option.h structs.h \
regexp.h gui.h beval.h [.proto]gui_beval.pro alloc.h ex_cmds.h spell.h \
proto.h globals.h version.h
ex_cmds.obj : ex_cmds.c vim.h [.auto]config.h feature.h os_unix.h \
ascii.h keymap.h term.h macros.h structs.h regexp.h \
gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \

View File

@ -1595,8 +1595,10 @@ BASIC_SRC = \
digraph.c \
edit.c \
eval.c \
evalbuffer.c \
evalfunc.c \
evalvars.c \
evalwindow.c \
ex_cmds.c \
ex_cmds2.c \
ex_docmd.c \
@ -1726,8 +1728,10 @@ OBJ_COMMON = \
objects/digraph.o \
objects/edit.o \
objects/eval.o \
objects/evalbuffer.o \
objects/evalfunc.o \
objects/evalvars.o \
objects/evalwindow.o \
objects/ex_cmds.o \
objects/ex_cmds2.o \
objects/ex_docmd.o \
@ -1870,8 +1874,10 @@ PRO_AUTO = \
digraph.pro \
edit.pro \
eval.pro \
evalbuffer.pro \
evalfunc.pro \
evalvars.pro \
evalwindow.pro \
ex_cmds.pro \
ex_cmds2.pro \
ex_docmd.pro \
@ -3080,12 +3086,18 @@ objects/edit.o: edit.c
objects/eval.o: eval.c
$(CCC) -o $@ eval.c
objects/evalbuffer.o: evalbuffer.c
$(CCC) -o $@ evalbuffer.c
objects/evalfunc.o: evalfunc.c
$(CCC) -o $@ evalfunc.c
objects/evalvars.o: evalvars.c
$(CCC) -o $@ evalvars.c
objects/evalwindow.o: evalwindow.c
$(CCC) -o $@ evalwindow.c
objects/ex_cmds.o: ex_cmds.c
$(CCC) -o $@ ex_cmds.c
@ -3314,7 +3326,7 @@ objects/pty.o: pty.c
objects/quickfix.o: quickfix.c
$(CCC) -o $@ quickfix.c
objects/regexp.o: regexp.c regexp_nfa.c
objects/regexp.o: regexp.c regexp_bt.c regexp_nfa.c
$(CCC) -o $@ regexp.c
objects/scriptfile.o: scriptfile.c
@ -3603,6 +3615,10 @@ objects/eval.o: eval.c vim.h protodef.h auto/config.h feature.h os_unix.h \
auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
proto.h globals.h version.h
objects/evalbuffer.o: evalbuffer.c vim.h protodef.h auto/config.h feature.h os_unix.h \
auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
proto.h globals.h version.h
objects/evalfunc.o: evalfunc.c vim.h protodef.h auto/config.h feature.h os_unix.h \
auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
@ -3611,6 +3627,10 @@ objects/evalvars.o: evalvars.c vim.h protodef.h auto/config.h feature.h \
os_unix.h auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
proto.h globals.h
objects/evalwindow.o: evalwindow.c vim.h protodef.h auto/config.h feature.h \
os_unix.h auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
proto.h globals.h
objects/ex_cmds.o: ex_cmds.c vim.h protodef.h auto/config.h feature.h os_unix.h \
auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
@ -3774,7 +3794,7 @@ objects/quickfix.o: quickfix.c vim.h protodef.h auto/config.h feature.h os_unix.
objects/regexp.o: regexp.c vim.h protodef.h auto/config.h feature.h os_unix.h \
auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
proto.h globals.h regexp_nfa.c
proto.h globals.h regexp_bt.c regexp_nfa.c
objects/scriptfile.o: scriptfile.c vim.h protodef.h auto/config.h feature.h os_unix.h \
auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \

View File

@ -33,8 +33,10 @@ cmdhist.c | command-line history
debugger.c | vim script debugger
diff.c | diff mode (vimdiff)
eval.c | expression evaluation
evalbuffer.c | buffer related built-in functions
evalfunc.c | built-in functions
evalvars.c | vim variables
evalwindow.c | window related built-in functions
fileio.c | reading and writing files
filepath.c | dealing with file names and paths
findfile.c | search for files in 'path'

View File

@ -5450,66 +5450,6 @@ buf_spname(buf_T *buf)
return NULL;
}
#if defined(FEAT_JOB_CHANNEL) \
|| defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) \
|| defined(PROTO)
/*
* Find a window for buffer "buf".
* If found OK is returned and "wp" and "tp" are set to the window and tabpage.
* If not found FAIL is returned.
*/
static int
find_win_for_buf(
buf_T *buf,
win_T **wp,
tabpage_T **tp)
{
FOR_ALL_TAB_WINDOWS(*tp, *wp)
if ((*wp)->w_buffer == buf)
goto win_found;
return FAIL;
win_found:
return OK;
}
/*
* Find a window that contains "buf" and switch to it.
* If there is no such window, use the current window and change "curbuf".
* Caller must initialize save_curbuf to NULL.
* restore_win_for_buf() MUST be called later!
*/
void
switch_to_win_for_buf(
buf_T *buf,
win_T **save_curwinp,
tabpage_T **save_curtabp,
bufref_T *save_curbuf)
{
win_T *wp;
tabpage_T *tp;
if (find_win_for_buf(buf, &wp, &tp) == FAIL)
switch_buffer(save_curbuf, buf);
else if (switch_win(save_curwinp, save_curtabp, wp, tp, TRUE) == FAIL)
{
restore_win(*save_curwinp, *save_curtabp, TRUE);
switch_buffer(save_curbuf, buf);
}
}
void
restore_win_for_buf(
win_T *save_curwin,
tabpage_T *save_curtab,
bufref_T *save_curbuf)
{
if (save_curbuf->br_buf == NULL)
restore_win(save_curwin, save_curtab, TRUE);
else
restore_buffer(save_curbuf);
}
#endif
/*
* Set 'buflisted' for curbuf to "on" and trigger autocommands if it changed.
*/
@ -5603,48 +5543,3 @@ wipe_buffer(
if (!aucmd)
unblock_autocmds();
}
#if defined(FEAT_EVAL) || defined(PROTO)
/*
* Mark references in functions of buffers.
*/
int
set_ref_in_buffers(int copyID)
{
int abort = FALSE;
buf_T *bp;
FOR_ALL_BUFFERS(bp)
{
listener_T *lnr;
typval_T tv;
for (lnr = bp->b_listener; !abort && lnr != NULL; lnr = lnr->lr_next)
{
if (lnr->lr_callback.cb_partial != NULL)
{
tv.v_type = VAR_PARTIAL;
tv.vval.v_partial = lnr->lr_callback.cb_partial;
abort = abort || set_ref_in_item(&tv, copyID, NULL, NULL);
}
}
# ifdef FEAT_JOB_CHANNEL
if (!abort && bp->b_prompt_callback.cb_partial != NULL)
{
tv.v_type = VAR_PARTIAL;
tv.vval.v_partial = bp->b_prompt_callback.cb_partial;
abort = abort || set_ref_in_item(&tv, copyID, NULL, NULL);
}
if (!abort && bp->b_prompt_interrupt.cb_partial != NULL)
{
tv.v_type = VAR_PARTIAL;
tv.vval.v_partial = bp->b_prompt_interrupt.cb_partial;
abort = abort || set_ref_in_item(&tv, copyID, NULL, NULL);
}
# endif
if (abort)
break;
}
return abort;
}
#endif

View File

@ -1036,7 +1036,7 @@ prepare_buffer(buf_T *buf)
* Returns NULL if there is something very wrong (error already reported).
*/
static buf_T *
find_buffer(char_u *name, int err, int msg)
channel_find_buffer(char_u *name, int err, int msg)
{
buf_T *buf = NULL;
buf_T *save_curbuf = curbuf;
@ -1126,7 +1126,7 @@ channel_set_options(channel_T *channel, jobopt_T *opt)
if (opt->jo_set2 & JO2_OUT_MSG)
msg = opt->jo_message[PART_OUT];
buf = find_buffer(opt->jo_io_name[PART_OUT], FALSE, msg);
buf = channel_find_buffer(opt->jo_io_name[PART_OUT], FALSE, msg);
}
if (buf != NULL)
{
@ -1173,7 +1173,7 @@ channel_set_options(channel_T *channel, jobopt_T *opt)
if (opt->jo_set2 & JO2_ERR_MSG)
msg = opt->jo_message[PART_ERR];
buf = find_buffer(opt->jo_io_name[PART_ERR], TRUE, msg);
buf = channel_find_buffer(opt->jo_io_name[PART_ERR], TRUE, msg);
}
if (buf != NULL)
{

887
src/evalbuffer.c Normal file
View File

@ -0,0 +1,887 @@
/* vi:set ts=8 sts=4 sw=4 noet:
*
* VIM - Vi IMproved by Bram Moolenaar
*
* Do ":help uganda" in Vim to read copying and usage conditions.
* Do ":help credits" in Vim to see a list of people who contributed.
* See README.txt for an overview of the Vim source code.
*/
/*
* evalbuffer.c: Buffer related builtin functions
*/
#include "vim.h"
#if defined(FEAT_EVAL) || defined(PROTO)
/*
* Mark references in functions of buffers.
*/
int
set_ref_in_buffers(int copyID)
{
int abort = FALSE;
buf_T *bp;
FOR_ALL_BUFFERS(bp)
{
listener_T *lnr;
typval_T tv;
for (lnr = bp->b_listener; !abort && lnr != NULL; lnr = lnr->lr_next)
{
if (lnr->lr_callback.cb_partial != NULL)
{
tv.v_type = VAR_PARTIAL;
tv.vval.v_partial = lnr->lr_callback.cb_partial;
abort = abort || set_ref_in_item(&tv, copyID, NULL, NULL);
}
}
# ifdef FEAT_JOB_CHANNEL
if (!abort && bp->b_prompt_callback.cb_partial != NULL)
{
tv.v_type = VAR_PARTIAL;
tv.vval.v_partial = bp->b_prompt_callback.cb_partial;
abort = abort || set_ref_in_item(&tv, copyID, NULL, NULL);
}
if (!abort && bp->b_prompt_interrupt.cb_partial != NULL)
{
tv.v_type = VAR_PARTIAL;
tv.vval.v_partial = bp->b_prompt_interrupt.cb_partial;
abort = abort || set_ref_in_item(&tv, copyID, NULL, NULL);
}
# endif
if (abort)
break;
}
return abort;
}
buf_T *
buflist_find_by_name(char_u *name, int curtab_only)
{
int save_magic;
char_u *save_cpo;
buf_T *buf;
// Ignore 'magic' and 'cpoptions' here to make scripts portable
save_magic = p_magic;
p_magic = TRUE;
save_cpo = p_cpo;
p_cpo = (char_u *)"";
buf = buflist_findnr(buflist_findpat(name, name + STRLEN(name),
TRUE, FALSE, curtab_only));
p_magic = save_magic;
p_cpo = save_cpo;
return buf;
}
/*
* Find a buffer by number or exact name.
*/
buf_T *
find_buffer(typval_T *avar)
{
buf_T *buf = NULL;
if (avar->v_type == VAR_NUMBER)
buf = buflist_findnr((int)avar->vval.v_number);
else if (avar->v_type == VAR_STRING && avar->vval.v_string != NULL)
{
buf = buflist_findname_exp(avar->vval.v_string);
if (buf == NULL)
{
// No full path name match, try a match with a URL or a "nofile"
// buffer, these don't use the full path.
FOR_ALL_BUFFERS(buf)
if (buf->b_fname != NULL
&& (path_with_url(buf->b_fname)
#ifdef FEAT_QUICKFIX
|| bt_nofilename(buf)
#endif
)
&& STRCMP(buf->b_fname, avar->vval.v_string) == 0)
break;
}
}
return buf;
}
/*
* If there is a window for "curbuf", make it the current window.
*/
static void
find_win_for_curbuf(void)
{
wininfo_T *wip;
for (wip = curbuf->b_wininfo; wip != NULL; wip = wip->wi_next)
{
if (wip->wi_win != NULL)
{
curwin = wip->wi_win;
break;
}
}
}
/*
* Set line or list of lines in buffer "buf".
*/
static void
set_buffer_lines(
buf_T *buf,
linenr_T lnum_arg,
int append,
typval_T *lines,
typval_T *rettv)
{
linenr_T lnum = lnum_arg + (append ? 1 : 0);
char_u *line = NULL;
list_T *l = NULL;
listitem_T *li = NULL;
long added = 0;
linenr_T append_lnum;
buf_T *curbuf_save = NULL;
win_T *curwin_save = NULL;
int is_curbuf = buf == curbuf;
// When using the current buffer ml_mfp will be set if needed. Useful when
// setline() is used on startup. For other buffers the buffer must be
// loaded.
if (buf == NULL || (!is_curbuf && buf->b_ml.ml_mfp == NULL) || lnum < 1)
{
rettv->vval.v_number = 1; // FAIL
return;
}
if (!is_curbuf)
{
curbuf_save = curbuf;
curwin_save = curwin;
curbuf = buf;
find_win_for_curbuf();
}
if (append)
// appendbufline() uses the line number below which we insert
append_lnum = lnum - 1;
else
// setbufline() uses the line number above which we insert, we only
// append if it's below the last line
append_lnum = curbuf->b_ml.ml_line_count;
if (lines->v_type == VAR_LIST)
{
l = lines->vval.v_list;
li = l->lv_first;
}
else
line = tv_get_string_chk(lines);
// default result is zero == OK
for (;;)
{
if (l != NULL)
{
// list argument, get next string
if (li == NULL)
break;
line = tv_get_string_chk(&li->li_tv);
li = li->li_next;
}
rettv->vval.v_number = 1; // FAIL
if (line == NULL || lnum > curbuf->b_ml.ml_line_count + 1)
break;
// When coming here from Insert mode, sync undo, so that this can be
// undone separately from what was previously inserted.
if (u_sync_once == 2)
{
u_sync_once = 1; // notify that u_sync() was called
u_sync(TRUE);
}
if (!append && lnum <= curbuf->b_ml.ml_line_count)
{
// Existing line, replace it.
// Removes any existing text properties.
if (u_savesub(lnum) == OK && ml_replace_len(
lnum, line, (colnr_T)STRLEN(line) + 1, TRUE, TRUE) == OK)
{
changed_bytes(lnum, 0);
if (is_curbuf && lnum == curwin->w_cursor.lnum)
check_cursor_col();
rettv->vval.v_number = 0; // OK
}
}
else if (added > 0 || u_save(lnum - 1, lnum) == OK)
{
// append the line
++added;
if (ml_append(lnum - 1, line, (colnr_T)0, FALSE) == OK)
rettv->vval.v_number = 0; // OK
}
if (l == NULL) // only one string argument
break;
++lnum;
}
if (added > 0)
{
win_T *wp;
tabpage_T *tp;
appended_lines_mark(append_lnum, added);
// Only adjust the cursor for buffers other than the current, unless it
// is the current window. For curbuf and other windows it has been
// done in mark_adjust_internal().
FOR_ALL_TAB_WINDOWS(tp, wp)
if (wp->w_buffer == buf
&& (wp->w_buffer != curbuf || wp == curwin)
&& wp->w_cursor.lnum > append_lnum)
wp->w_cursor.lnum += added;
check_cursor_col();
update_topline();
}
if (!is_curbuf)
{
curbuf = curbuf_save;
curwin = curwin_save;
}
}
/*
* "append(lnum, string/list)" function
*/
void
f_append(typval_T *argvars, typval_T *rettv)
{
linenr_T lnum = tv_get_lnum(&argvars[0]);
set_buffer_lines(curbuf, lnum, TRUE, &argvars[1], rettv);
}
/*
* "appendbufline(buf, lnum, string/list)" function
*/
void
f_appendbufline(typval_T *argvars, typval_T *rettv)
{
linenr_T lnum;
buf_T *buf;
buf = tv_get_buf(&argvars[0], FALSE);
if (buf == NULL)
rettv->vval.v_number = 1; // FAIL
else
{
lnum = tv_get_lnum_buf(&argvars[1], buf);
set_buffer_lines(buf, lnum, TRUE, &argvars[2], rettv);
}
}
/*
* "bufadd(expr)" function
*/
void
f_bufadd(typval_T *argvars, typval_T *rettv)
{
char_u *name = tv_get_string(&argvars[0]);
rettv->vval.v_number = buflist_add(*name == NUL ? NULL : name, 0);
}
/*
* "bufexists(expr)" function
*/
void
f_bufexists(typval_T *argvars, typval_T *rettv)
{
rettv->vval.v_number = (find_buffer(&argvars[0]) != NULL);
}
/*
* "buflisted(expr)" function
*/
void
f_buflisted(typval_T *argvars, typval_T *rettv)
{
buf_T *buf;
buf = find_buffer(&argvars[0]);
rettv->vval.v_number = (buf != NULL && buf->b_p_bl);
}
/*
* "bufload(expr)" function
*/
void
f_bufload(typval_T *argvars, typval_T *rettv UNUSED)
{
buf_T *buf = get_buf_arg(&argvars[0]);
if (buf != NULL)
buffer_ensure_loaded(buf);
}
/*
* "bufloaded(expr)" function
*/
void
f_bufloaded(typval_T *argvars, typval_T *rettv)
{
buf_T *buf;
buf = find_buffer(&argvars[0]);
rettv->vval.v_number = (buf != NULL && buf->b_ml.ml_mfp != NULL);
}
/*
* "bufname(expr)" function
*/
void
f_bufname(typval_T *argvars, typval_T *rettv)
{
buf_T *buf;
if (argvars[0].v_type == VAR_UNKNOWN)
buf = curbuf;
else
{
(void)tv_get_number(&argvars[0]); // issue errmsg if type error
++emsg_off;
buf = tv_get_buf(&argvars[0], FALSE);
--emsg_off;
}
rettv->v_type = VAR_STRING;
if (buf != NULL && buf->b_fname != NULL)
rettv->vval.v_string = vim_strsave(buf->b_fname);
else
rettv->vval.v_string = NULL;
}
/*
* "bufnr(expr)" function
*/
void
f_bufnr(typval_T *argvars, typval_T *rettv)
{
buf_T *buf;
int error = FALSE;
char_u *name;
if (argvars[0].v_type == VAR_UNKNOWN)
buf = curbuf;
else
{
(void)tv_get_number(&argvars[0]); // issue errmsg if type error
++emsg_off;
buf = tv_get_buf(&argvars[0], FALSE);
--emsg_off;
}
// If the buffer isn't found and the second argument is not zero create a
// new buffer.
if (buf == NULL
&& argvars[1].v_type != VAR_UNKNOWN
&& tv_get_number_chk(&argvars[1], &error) != 0
&& !error
&& (name = tv_get_string_chk(&argvars[0])) != NULL
&& !error)
buf = buflist_new(name, NULL, (linenr_T)1, 0);
if (buf != NULL)
rettv->vval.v_number = buf->b_fnum;
else
rettv->vval.v_number = -1;
}
static void
buf_win_common(typval_T *argvars, typval_T *rettv, int get_nr)
{
win_T *wp;
int winnr = 0;
buf_T *buf;
(void)tv_get_number(&argvars[0]); // issue errmsg if type error
++emsg_off;
buf = tv_get_buf(&argvars[0], TRUE);
FOR_ALL_WINDOWS(wp)
{
++winnr;
if (wp->w_buffer == buf)
break;
}
rettv->vval.v_number = (wp != NULL ? (get_nr ? winnr : wp->w_id) : -1);
--emsg_off;
}
/*
* "bufwinid(nr)" function
*/
void
f_bufwinid(typval_T *argvars, typval_T *rettv)
{
buf_win_common(argvars, rettv, FALSE);
}
/*
* "bufwinnr(nr)" function
*/
void
f_bufwinnr(typval_T *argvars, typval_T *rettv)
{
buf_win_common(argvars, rettv, TRUE);
}
/*
* "deletebufline()" function
*/
void
f_deletebufline(typval_T *argvars, typval_T *rettv)
{
buf_T *buf;
linenr_T first, last;
linenr_T lnum;
long count;
int is_curbuf;
buf_T *curbuf_save = NULL;
win_T *curwin_save = NULL;
tabpage_T *tp;
win_T *wp;
buf = tv_get_buf(&argvars[0], FALSE);
if (buf == NULL)
{
rettv->vval.v_number = 1; // FAIL
return;
}
is_curbuf = buf == curbuf;
first = tv_get_lnum_buf(&argvars[1], buf);
if (argvars[2].v_type != VAR_UNKNOWN)
last = tv_get_lnum_buf(&argvars[2], buf);
else
last = first;
if (buf->b_ml.ml_mfp == NULL || first < 1
|| first > buf->b_ml.ml_line_count || last < first)
{
rettv->vval.v_number = 1; // FAIL
return;
}
if (!is_curbuf)
{
curbuf_save = curbuf;
curwin_save = curwin;
curbuf = buf;
find_win_for_curbuf();
}
if (last > curbuf->b_ml.ml_line_count)
last = curbuf->b_ml.ml_line_count;
count = last - first + 1;
// When coming here from Insert mode, sync undo, so that this can be
// undone separately from what was previously inserted.
if (u_sync_once == 2)
{
u_sync_once = 1; // notify that u_sync() was called
u_sync(TRUE);
}
if (u_save(first - 1, last + 1) == FAIL)
{
rettv->vval.v_number = 1; // FAIL
return;
}
for (lnum = first; lnum <= last; ++lnum)
ml_delete(first, TRUE);
FOR_ALL_TAB_WINDOWS(tp, wp)
if (wp->w_buffer == buf)
{
if (wp->w_cursor.lnum > last)
wp->w_cursor.lnum -= count;
else if (wp->w_cursor.lnum> first)
wp->w_cursor.lnum = first;
if (wp->w_cursor.lnum > wp->w_buffer->b_ml.ml_line_count)
wp->w_cursor.lnum = wp->w_buffer->b_ml.ml_line_count;
}
check_cursor_col();
deleted_lines_mark(first, count);
if (!is_curbuf)
{
curbuf = curbuf_save;
curwin = curwin_save;
}
}
/*
* Returns buffer options, variables and other attributes in a dictionary.
*/
static dict_T *
get_buffer_info(buf_T *buf)
{
dict_T *dict;
tabpage_T *tp;
win_T *wp;
list_T *windows;
dict = dict_alloc();
if (dict == NULL)
return NULL;
dict_add_number(dict, "bufnr", buf->b_fnum);
dict_add_string(dict, "name", buf->b_ffname);
dict_add_number(dict, "lnum", buf == curbuf ? curwin->w_cursor.lnum
: buflist_findlnum(buf));
dict_add_number(dict, "loaded", buf->b_ml.ml_mfp != NULL);
dict_add_number(dict, "listed", buf->b_p_bl);
dict_add_number(dict, "changed", bufIsChanged(buf));
dict_add_number(dict, "changedtick", CHANGEDTICK(buf));
dict_add_number(dict, "hidden",
buf->b_ml.ml_mfp != NULL && buf->b_nwindows == 0);
// Get a reference to buffer variables
dict_add_dict(dict, "variables", buf->b_vars);
// List of windows displaying this buffer
windows = list_alloc();
if (windows != NULL)
{
FOR_ALL_TAB_WINDOWS(tp, wp)
if (wp->w_buffer == buf)
list_append_number(windows, (varnumber_T)wp->w_id);
dict_add_list(dict, "windows", windows);
}
#ifdef FEAT_TEXT_PROP
// List of popup windows displaying this buffer
windows = list_alloc();
if (windows != NULL)
{
for (wp = first_popupwin; wp != NULL; wp = wp->w_next)
if (wp->w_buffer == buf)
list_append_number(windows, (varnumber_T)wp->w_id);
FOR_ALL_TABPAGES(tp)
for (wp = tp->tp_first_popupwin; wp != NULL; wp = wp->w_next)
if (wp->w_buffer == buf)
list_append_number(windows, (varnumber_T)wp->w_id);
dict_add_list(dict, "popups", windows);
}
#endif
#ifdef FEAT_SIGNS
if (buf->b_signlist != NULL)
{
// List of signs placed in this buffer
list_T *signs = list_alloc();
if (signs != NULL)
{
get_buffer_signs(buf, signs);
dict_add_list(dict, "signs", signs);
}
}
#endif
return dict;
}
/*
* "getbufinfo()" function
*/
void
f_getbufinfo(typval_T *argvars, typval_T *rettv)
{
buf_T *buf = NULL;
buf_T *argbuf = NULL;
dict_T *d;
int filtered = FALSE;
int sel_buflisted = FALSE;
int sel_bufloaded = FALSE;
int sel_bufmodified = FALSE;
if (rettv_list_alloc(rettv) != OK)
return;
// List of all the buffers or selected buffers
if (argvars[0].v_type == VAR_DICT)
{
dict_T *sel_d = argvars[0].vval.v_dict;
if (sel_d != NULL)
{
dictitem_T *di;
filtered = TRUE;
di = dict_find(sel_d, (char_u *)"buflisted", -1);
if (di != NULL && tv_get_number(&di->di_tv))
sel_buflisted = TRUE;
di = dict_find(sel_d, (char_u *)"bufloaded", -1);
if (di != NULL && tv_get_number(&di->di_tv))
sel_bufloaded = TRUE;
di = dict_find(sel_d, (char_u *)"bufmodified", -1);
if (di != NULL && tv_get_number(&di->di_tv))
sel_bufmodified = TRUE;
}
}
else if (argvars[0].v_type != VAR_UNKNOWN)
{
// Information about one buffer. Argument specifies the buffer
(void)tv_get_number(&argvars[0]); // issue errmsg if type error
++emsg_off;
argbuf = tv_get_buf(&argvars[0], FALSE);
--emsg_off;
if (argbuf == NULL)
return;
}
// Return information about all the buffers or a specified buffer
FOR_ALL_BUFFERS(buf)
{
if (argbuf != NULL && argbuf != buf)
continue;
if (filtered && ((sel_bufloaded && buf->b_ml.ml_mfp == NULL)
|| (sel_buflisted && !buf->b_p_bl)
|| (sel_bufmodified && !buf->b_changed)))
continue;
d = get_buffer_info(buf);
if (d != NULL)
list_append_dict(rettv->vval.v_list, d);
if (argbuf != NULL)
return;
}
}
/*
* Get line or list of lines from buffer "buf" into "rettv".
* Return a range (from start to end) of lines in rettv from the specified
* buffer.
* If 'retlist' is TRUE, then the lines are returned as a Vim List.
*/
static void
get_buffer_lines(
buf_T *buf,
linenr_T start,
linenr_T end,
int retlist,
typval_T *rettv)
{
char_u *p;
rettv->v_type = VAR_STRING;
rettv->vval.v_string = NULL;
if (retlist && rettv_list_alloc(rettv) == FAIL)
return;
if (buf == NULL || buf->b_ml.ml_mfp == NULL || start < 0)
return;
if (!retlist)
{
if (start >= 1 && start <= buf->b_ml.ml_line_count)
p = ml_get_buf(buf, start, FALSE);
else
p = (char_u *)"";
rettv->vval.v_string = vim_strsave(p);
}
else
{
if (end < start)
return;
if (start < 1)
start = 1;
if (end > buf->b_ml.ml_line_count)
end = buf->b_ml.ml_line_count;
while (start <= end)
if (list_append_string(rettv->vval.v_list,
ml_get_buf(buf, start++, FALSE), -1) == FAIL)
break;
}
}
/*
* "getbufline()" function
*/
void
f_getbufline(typval_T *argvars, typval_T *rettv)
{
linenr_T lnum;
linenr_T end;
buf_T *buf;
(void)tv_get_number(&argvars[0]); // issue errmsg if type error
++emsg_off;
buf = tv_get_buf(&argvars[0], FALSE);
--emsg_off;
lnum = tv_get_lnum_buf(&argvars[1], buf);
if (argvars[2].v_type == VAR_UNKNOWN)
end = lnum;
else
end = tv_get_lnum_buf(&argvars[2], buf);
get_buffer_lines(buf, lnum, end, TRUE, rettv);
}
/*
* "getline(lnum, [end])" function
*/
void
f_getline(typval_T *argvars, typval_T *rettv)
{
linenr_T lnum;
linenr_T end;
int retlist;
lnum = tv_get_lnum(argvars);
if (argvars[1].v_type == VAR_UNKNOWN)
{
end = 0;
retlist = FALSE;
}
else
{
end = tv_get_lnum(&argvars[1]);
retlist = TRUE;
}
get_buffer_lines(curbuf, lnum, end, retlist, rettv);
}
/*
* "setbufline()" function
*/
void
f_setbufline(typval_T *argvars, typval_T *rettv)
{
linenr_T lnum;
buf_T *buf;
buf = tv_get_buf(&argvars[0], FALSE);
if (buf == NULL)
rettv->vval.v_number = 1; // FAIL
else
{
lnum = tv_get_lnum_buf(&argvars[1], buf);
set_buffer_lines(buf, lnum, FALSE, &argvars[2], rettv);
}
}
/*
* "setline()" function
*/
void
f_setline(typval_T *argvars, typval_T *rettv)
{
linenr_T lnum = tv_get_lnum(&argvars[0]);
set_buffer_lines(curbuf, lnum, FALSE, &argvars[1], rettv);
}
#endif // FEAT_EVAL
#if defined(FEAT_JOB_CHANNEL) \
|| defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) \
|| defined(PROTO)
/*
* Make "buf" the current buffer. restore_buffer() MUST be called to undo.
* No autocommands will be executed. Use aucmd_prepbuf() if there are any.
*/
void
switch_buffer(bufref_T *save_curbuf, buf_T *buf)
{
block_autocmds();
set_bufref(save_curbuf, curbuf);
--curbuf->b_nwindows;
curbuf = buf;
curwin->w_buffer = buf;
++curbuf->b_nwindows;
}
/*
* Restore the current buffer after using switch_buffer().
*/
void
restore_buffer(bufref_T *save_curbuf)
{
unblock_autocmds();
/* Check for valid buffer, just in case. */
if (bufref_valid(save_curbuf))
{
--curbuf->b_nwindows;
curwin->w_buffer = save_curbuf->br_buf;
curbuf = save_curbuf->br_buf;
++curbuf->b_nwindows;
}
}
/*
* Find a window for buffer "buf".
* If found OK is returned and "wp" and "tp" are set to the window and tabpage.
* If not found FAIL is returned.
*/
static int
find_win_for_buf(
buf_T *buf,
win_T **wp,
tabpage_T **tp)
{
FOR_ALL_TAB_WINDOWS(*tp, *wp)
if ((*wp)->w_buffer == buf)
return OK;
return FAIL;
}
/*
* Find a window that contains "buf" and switch to it.
* If there is no such window, use the current window and change "curbuf".
* Caller must initialize save_curbuf to NULL.
* restore_win_for_buf() MUST be called later!
*/
void
switch_to_win_for_buf(
buf_T *buf,
win_T **save_curwinp,
tabpage_T **save_curtabp,
bufref_T *save_curbuf)
{
win_T *wp;
tabpage_T *tp;
if (find_win_for_buf(buf, &wp, &tp) == FAIL)
switch_buffer(save_curbuf, buf);
else if (switch_win(save_curwinp, save_curtabp, wp, tp, TRUE) == FAIL)
{
restore_win(*save_curwinp, *save_curtabp, TRUE);
switch_buffer(save_curbuf, buf);
}
}
void
restore_win_for_buf(
win_T *save_curwin,
tabpage_T *save_curtab,
bufref_T *save_curbuf)
{
if (save_curbuf->br_buf == NULL)
restore_win(save_curwin, save_curtab, TRUE);
else
restore_buffer(save_curbuf);
}
#endif

File diff suppressed because it is too large Load Diff

1054
src/evalwindow.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -4468,8 +4468,10 @@ enc_locale(void)
if (acp == 1200)
STRCPY(buf, "ucs-2le");
else if (acp == 1252) /* cp1252 is used as latin1 */
else if (acp == 1252) // cp1252 is used as latin1
STRCPY(buf, "latin1");
else if (acp == 65001)
STRCPY(buf, "utf-8");
else
sprintf(buf, "cp%ld", acp);

View File

@ -542,8 +542,15 @@ popup_show_curline(win_T *wp)
{
if (wp->w_cursor.lnum < wp->w_topline)
wp->w_topline = wp->w_cursor.lnum;
else if (wp->w_cursor.lnum >= wp->w_botline)
else if (wp->w_cursor.lnum >= wp->w_botline
&& (curwin->w_valid & VALID_BOTLINE))
{
wp->w_topline = wp->w_cursor.lnum - wp->w_height + 1;
if (wp->w_topline < 1)
wp->w_topline = 1;
else if (wp->w_topline > wp->w_buffer->b_ml.ml_line_count)
wp->w_topline = wp->w_buffer->b_ml.ml_line_count;
}
// Don't use "firstline" now.
wp->w_firstline = 0;
@ -593,6 +600,7 @@ popup_highlight_curline(win_T *wp)
}
else
sign_undefine_by_name(sign_name, FALSE);
wp->w_popup_last_curline = wp->w_cursor.lnum;
}
/*
@ -1059,6 +1067,11 @@ popup_adjust_position(win_T *wp)
wp->w_popup_leftoff = 0;
wp->w_popup_rightoff = 0;
// May need to update the "cursorline" highlighting, which may also change
// "topline"
if (wp->w_popup_last_curline != wp->w_cursor.lnum)
popup_highlight_curline(wp);
// If no line was specified default to vertical centering.
if (wantline == 0)
center_vert = TRUE;
@ -1159,7 +1172,9 @@ popup_adjust_position(win_T *wp)
// start at the desired first line
if (wp->w_firstline > 0)
wp->w_topline = wp->w_firstline;
if (wp->w_topline > wp->w_buffer->b_ml.ml_line_count)
if (wp->w_topline < 1)
wp->w_topline = 1;
else if (wp->w_topline > wp->w_buffer->b_ml.ml_line_count)
wp->w_topline = wp->w_buffer->b_ml.ml_line_count;
// Compute width based on longest text line and the 'wrap' option.
@ -2998,6 +3013,7 @@ check_popup_unhidden(win_T *wp)
* Return TRUE if popup_adjust_position() needs to be called for "wp".
* That is when the buffer in the popup was changed, or the popup is following
* a textprop and the referenced buffer was changed.
* Or when the cursor line changed and "cursorline" is set.
*/
static int
popup_need_position_adjust(win_T *wp)
@ -3007,7 +3023,9 @@ popup_need_position_adjust(win_T *wp)
if (win_valid(wp->w_popup_prop_win))
return wp->w_popup_prop_changedtick
!= CHANGEDTICK(wp->w_popup_prop_win->w_buffer)
|| wp->w_popup_prop_topline != wp->w_popup_prop_win->w_topline;
|| wp->w_popup_prop_topline != wp->w_popup_prop_win->w_topline
|| ((wp->w_popup_flags & POPF_CURSORLINE)
&& wp->w_cursor.lnum != wp->w_popup_last_curline);
return FALSE;
}

View File

@ -75,7 +75,10 @@ extern int _stricoll(char *a, char *b);
# include "digraph.pro"
# include "edit.pro"
# include "eval.pro"
# include "evalbuffer.pro"
# include "evalfunc.pro"
# include "evalvars.pro"
# include "evalwindow.pro"
# include "ex_cmds.pro"
# include "ex_cmds2.pro"
# include "ex_docmd.pro"
@ -111,7 +114,6 @@ extern int _stricoll(char *a, char *b);
# ifdef FEAT_VIMINFO
# include "viminfo.pro"
# endif
# include "evalvars.pro"
/* These prototypes cannot be produced automatically. */
int smsg(const char *, ...)

View File

@ -65,10 +65,7 @@ int bt_dontwrite(buf_T *buf);
int bt_dontwrite_msg(buf_T *buf);
int buf_hide(buf_T *buf);
char_u *buf_spname(buf_T *buf);
void switch_to_win_for_buf(buf_T *buf, win_T **save_curwinp, tabpage_T **save_curtabp, bufref_T *save_curbuf);
void restore_win_for_buf(win_T *save_curwin, tabpage_T *save_curtab, bufref_T *save_curbuf);
void set_buflisted(int on);
int buf_contents_changed(buf_T *buf);
void wipe_buffer(buf_T *buf, int aucmd);
int set_ref_in_buffers(int copyID);
/* vim: set ft=c : */

26
src/proto/evalbuffer.pro Normal file
View File

@ -0,0 +1,26 @@
/* evalbuffer.c */
int set_ref_in_buffers(int copyID);
buf_T *buflist_find_by_name(char_u *name, int curtab_only);
buf_T *find_buffer(typval_T *avar);
void f_append(typval_T *argvars, typval_T *rettv);
void f_appendbufline(typval_T *argvars, typval_T *rettv);
void f_bufadd(typval_T *argvars, typval_T *rettv);
void f_bufexists(typval_T *argvars, typval_T *rettv);
void f_buflisted(typval_T *argvars, typval_T *rettv);
void f_bufload(typval_T *argvars, typval_T *rettv);
void f_bufloaded(typval_T *argvars, typval_T *rettv);
void f_bufname(typval_T *argvars, typval_T *rettv);
void f_bufnr(typval_T *argvars, typval_T *rettv);
void f_bufwinid(typval_T *argvars, typval_T *rettv);
void f_bufwinnr(typval_T *argvars, typval_T *rettv);
void f_deletebufline(typval_T *argvars, typval_T *rettv);
void f_getbufinfo(typval_T *argvars, typval_T *rettv);
void f_getbufline(typval_T *argvars, typval_T *rettv);
void f_getline(typval_T *argvars, typval_T *rettv);
void f_setbufline(typval_T *argvars, typval_T *rettv);
void f_setline(typval_T *argvars, typval_T *rettv);
void switch_buffer(bufref_T *save_curbuf, buf_T *buf);
void restore_buffer(bufref_T *save_curbuf);
void switch_to_win_for_buf(buf_T *buf, win_T **save_curwinp, tabpage_T **save_curtabp, bufref_T *save_curbuf);
void restore_win_for_buf(win_T *save_curwin, tabpage_T *save_curtab, bufref_T *save_curbuf);
/* vim: set ft=c : */

View File

@ -5,11 +5,13 @@ int has_internal_func(char_u *name);
int call_internal_func(char_u *name, int argcount, typval_T *argvars, typval_T *rettv);
int call_internal_method(char_u *name, int argcount, typval_T *argvars, typval_T *rettv, typval_T *basetv);
linenr_T tv_get_lnum(typval_T *argvars);
linenr_T tv_get_lnum_buf(typval_T *argvars, buf_T *buf);
buf_T *buflist_find_by_name(char_u *name, int curtab_only);
buf_T *tv_get_buf(typval_T *tv, int curtab_only);
buf_T *get_buf_arg(typval_T *arg);
win_T *get_optional_window(typval_T *argvars, int idx);
void execute_redir_str(char_u *value, int value_len);
void execute_common(typval_T *argvars, typval_T *rettv, int arg_off);
void mzscheme_call_vim(char_u *name, typval_T *args, typval_T *rettv);
float_T vim_round(float_T f);
long do_searchpair(char_u *spat, char_u *mpat, char_u *epat, int dir, typval_T *skip, int flags, pos_T *match_pos, linenr_T lnum_stop, long time_limit);

36
src/proto/evalwindow.pro Normal file
View File

@ -0,0 +1,36 @@
/* evalwindow.c */
win_T *win_id2wp(int id);
win_T *win_id2wp_tp(int id, tabpage_T **tpp);
void win_findbuf(typval_T *argvars, list_T *list);
win_T *find_win_by_nr(typval_T *vp, tabpage_T *tp);
win_T *find_win_by_nr_or_id(typval_T *vp);
win_T *find_tabwin(typval_T *wvp, typval_T *tvp, tabpage_T **ptp);
void f_gettabinfo(typval_T *argvars, typval_T *rettv);
void f_getwininfo(typval_T *argvars, typval_T *rettv);
void f_getwinpos(typval_T *argvars, typval_T *rettv);
void f_getwinposx(typval_T *argvars, typval_T *rettv);
void f_getwinposy(typval_T *argvars, typval_T *rettv);
void f_tabpagenr(typval_T *argvars, typval_T *rettv);
void f_tabpagewinnr(typval_T *argvars, typval_T *rettv);
void f_win_execute(typval_T *argvars, typval_T *rettv);
void f_win_findbuf(typval_T *argvars, typval_T *rettv);
void f_win_getid(typval_T *argvars, typval_T *rettv);
void f_win_gotoid(typval_T *argvars, typval_T *rettv);
void f_win_id2tabwin(typval_T *argvars, typval_T *rettv);
void f_win_id2win(typval_T *argvars, typval_T *rettv);
void f_win_screenpos(typval_T *argvars, typval_T *rettv);
void f_winbufnr(typval_T *argvars, typval_T *rettv);
void f_wincol(typval_T *argvars, typval_T *rettv);
void f_winheight(typval_T *argvars, typval_T *rettv);
void f_winlayout(typval_T *argvars, typval_T *rettv);
void f_winline(typval_T *argvars, typval_T *rettv);
void f_winnr(typval_T *argvars, typval_T *rettv);
void f_winrestcmd(typval_T *argvars, typval_T *rettv);
void f_winrestview(typval_T *argvars, typval_T *rettv);
void f_winsaveview(typval_T *argvars, typval_T *rettv);
void f_winwidth(typval_T *argvars, typval_T *rettv);
int switch_win(win_T **save_curwin, tabpage_T **save_curtab, win_T *win, tabpage_T *tp, int no_display);
int switch_win_noblock(win_T **save_curwin, tabpage_T **save_curtab, win_T *win, tabpage_T *tp, int no_display);
void restore_win(win_T *save_curwin, tabpage_T *save_curtab, int no_display);
void restore_win_noblock(win_T *save_curwin, tabpage_T *save_curtab, int no_display);
/* vim: set ft=c : */

View File

@ -73,25 +73,8 @@ void check_lnums(int do_curwin);
void reset_lnums(void);
void make_snapshot(int idx);
void restore_snapshot(int idx, int close_curwin);
int switch_win(win_T **save_curwin, tabpage_T **save_curtab, win_T *win, tabpage_T *tp, int no_display);
int switch_win_noblock(win_T **save_curwin, tabpage_T **save_curtab, win_T *win, tabpage_T *tp, int no_display);
void restore_win(win_T *save_curwin, tabpage_T *save_curtab, int no_display);
void restore_win_noblock(win_T *save_curwin, tabpage_T *save_curtab, int no_display);
void switch_buffer(bufref_T *save_curbuf, buf_T *buf);
void restore_buffer(bufref_T *save_curbuf);
int win_hasvertsplit(void);
int get_win_number(win_T *wp, win_T *first_win);
int get_tab_number(tabpage_T *tp);
char *check_colorcolumn(win_T *wp);
int win_getid(typval_T *argvars);
int win_gotoid(typval_T *argvars);
void win_id2tabwin(typval_T *argvars, list_T *list);
win_T *win_id2wp(int id);
win_T *win_id2wp_tp(int id, tabpage_T **tpp);
int win_id2win(typval_T *argvars);
void win_findbuf(typval_T *argvars, list_T *list);
win_T *find_win_by_nr(typval_T *vp, tabpage_T *tp);
win_T *find_win_by_nr_or_id(typval_T *vp);
win_T *find_tabwin(typval_T *wvp, typval_T *tvp, tabpage_T **ptp);
void get_framelayout(frame_T *fr, list_T *l, int outer);
/* vim: set ft=c : */

File diff suppressed because it is too large Load Diff

5351
src/regexp_bt.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -3050,6 +3050,8 @@ struct window_S
int w_popup_prop_topline; // w_topline of window with
// w_popup_prop_type when position was
// computed
linenr_T w_popup_last_curline; // last known w_cursor.lnum of window
// with "cursorline" set
callback_T w_close_cb; // popup close callback
callback_T w_filter_cb; // popup filter callback
int w_filter_mode; // mode when filter callback is used

View File

@ -5055,6 +5055,8 @@ f_term_getattr(typval_T *argvars, typval_T *rettv)
if (name == NULL)
return;
if (attr > HL_ALL)
attr = syn_attr2attr(attr);
for (i = 0; i < sizeof(attrs)/sizeof(attrs[0]); ++i)
if (STRCMP(name, attrs[i].name) == 0)
{

View File

@ -0,0 +1,10 @@
> +0&#ffffff0@74
|~+0#4040ff13&| @73
|~| @73
|~| @34|1+0#0000001#ffd7ff255@2| +0#4040ff13#ffffff0@35
|~| @34|2+0#0000001#e0e0e08@2| +0#4040ff13#ffffff0@35
|~| @34|3+0#0000001#ffd7ff255@2| +0#4040ff13#ffffff0@35
|~| @73
|~| @73
|~| @73
| +0#0000000&@56|0|,|0|-|1| @8|A|l@1|

View File

@ -259,7 +259,7 @@ endfunc
func Test_override()
call test_override('char_avail', 1)
call test_override('redraw', 1)
eval 1->test_override('redraw')
call test_override('ALL', 0)
call assert_fails("call test_override('xxx', 1)", 'E475')
call assert_fails("call test_override('redraw', 'yes')", 'E474')

View File

@ -424,7 +424,7 @@ func Test_breakindent11_vartabs()
call s:test_windows('setl cpo-=n sbr=>> nu nuw=4 nolist briopt= ts=4 vts=4')
let text = getline(2)
let width = strlen(text[1:]) + 2->indent() + strlen(&sbr) * 3 " text wraps 3 times
call assert_equal(width, strdisplaywidth(text))
call assert_equal(width, text->strdisplaywidth())
call s:close_windows('set sbr= vts&')
endfunc

View File

@ -53,7 +53,7 @@ endfunc
func Test_strgetchar()
call assert_equal(char2nr('a'), strgetchar('axb', 0))
call assert_equal(char2nr('x'), strgetchar('axb', 1))
call assert_equal(char2nr('x'), 'axb'->strgetchar(1))
call assert_equal(char2nr('b'), strgetchar('axb', 2))
call assert_equal(-1, strgetchar('axb', -1))
@ -63,7 +63,7 @@ endfunc
func Test_strcharpart()
call assert_equal('a', strcharpart('axb', 0, 1))
call assert_equal('x', strcharpart('axb', 1, 1))
call assert_equal('x', 'axb'->strcharpart(1, 1))
call assert_equal('b', strcharpart('axb', 2, 1))
call assert_equal('xb', strcharpart('axb', 1))

View File

@ -138,7 +138,7 @@ func Test_str2nr()
call assert_equal(-123456789, str2nr('-123456789'))
call assert_equal(5, str2nr('101', 2))
call assert_equal(5, str2nr('0b101', 2))
call assert_equal(5, '0b101'->str2nr(2))
call assert_equal(5, str2nr('0B101', 2))
call assert_equal(-5, str2nr('-101', 2))
call assert_equal(-5, str2nr('-0b101', 2))
@ -184,7 +184,7 @@ func Test_strftime()
" of strftime() can be 17 or 18, depending on timezone.
call assert_match('^2017-01-1[78]$', strftime('%Y-%m-%d', 1484695512))
"
call assert_match('^\d\d\d\d-\(0\d\|1[012]\)-\([012]\d\|3[01]\) \([01]\d\|2[0-3]\):[0-5]\d:\([0-5]\d\|60\)$', strftime('%Y-%m-%d %H:%M:%S'))
call assert_match('^\d\d\d\d-\(0\d\|1[012]\)-\([012]\d\|3[01]\) \([01]\d\|2[0-3]\):[0-5]\d:\([0-5]\d\|60\)$', '%Y-%m-%d %H:%M:%S'->strftime())
call assert_fails('call strftime([])', 'E730:')
call assert_fails('call strftime("%Y", [])', 'E745:')
@ -415,7 +415,7 @@ endfunc
func Test_strpart()
call assert_equal('de', strpart('abcdefg', 3, 2))
call assert_equal('ab', strpart('abcdefg', -2, 4))
call assert_equal('abcdefg', strpart('abcdefg', -2))
call assert_equal('abcdefg', 'abcdefg'->strpart(-2))
call assert_equal('fg', strpart('abcdefg', 5, 4))
call assert_equal('defg', strpart('abcdefg', 3))
@ -763,11 +763,11 @@ endfunc
func Test_stridx()
call assert_equal(-1, stridx('', 'l'))
call assert_equal(0, stridx('', ''))
call assert_equal(0, stridx('hello', ''))
call assert_equal(0, 'hello'->stridx(''))
call assert_equal(-1, stridx('hello', 'L'))
call assert_equal(2, stridx('hello', 'l', -1))
call assert_equal(2, stridx('hello', 'l', 0))
call assert_equal(2, stridx('hello', 'l', 1))
call assert_equal(2, 'hello'->stridx('l', 1))
call assert_equal(3, stridx('hello', 'l', 3))
call assert_equal(-1, stridx('hello', 'l', 4))
call assert_equal(-1, stridx('hello', 'l', 10))
@ -780,7 +780,7 @@ func Test_strridx()
call assert_equal(0, strridx('', ''))
call assert_equal(5, strridx('hello', ''))
call assert_equal(-1, strridx('hello', 'L'))
call assert_equal(3, strridx('hello', 'l'))
call assert_equal(3, 'hello'->strridx('l'))
call assert_equal(3, strridx('hello', 'l', 10))
call assert_equal(3, strridx('hello', 'l', 3))
call assert_equal(2, strridx('hello', 'l', 2))

View File

@ -398,72 +398,69 @@ func Test_set_guifont()
endfunc
func Test_set_guifontset()
CheckFeature xfontset
let skipped = ''
if !has('xfontset')
let skipped = g:not_supported . 'xfontset'
else
let ctype_saved = v:ctype
let ctype_saved = v:ctype
" First, since XCreateFontSet(3) is very sensitive to locale, fonts must
" be chosen meticulously.
let font_head = '-misc-fixed-medium-r-normal--14'
" First, since XCreateFontSet(3) is very sensitive to locale, fonts must
" be chosen meticulously.
let font_head = '-misc-fixed-medium-r-normal--14'
let font_aw70 = font_head . '-130-75-75-c-70'
let font_aw140 = font_head . '-130-75-75-c-140'
let font_aw70 = font_head . '-130-75-75-c-70'
let font_aw140 = font_head . '-130-75-75-c-140'
let font_jisx0201 = font_aw70 . '-jisx0201.1976-0'
let font_jisx0208 = font_aw140 . '-jisx0208.1983-0'
let font_jisx0201 = font_aw70 . '-jisx0201.1976-0'
let font_jisx0208 = font_aw140 . '-jisx0208.1983-0'
let full_XLFDs = join([ font_jisx0208, font_jisx0201 ], ',')
let short_XLFDs = join([ font_aw140, font_aw70 ], ',')
let singleton = font_head . '-*'
let aliases = 'k14,r14'
let full_XLFDs = join([ font_jisx0208, font_jisx0201 ], ',')
let short_XLFDs = join([ font_aw140, font_aw70 ], ',')
let singleton = font_head . '-*'
let aliases = 'k14,r14'
" Second, among 'locales', look up such a locale that gets 'set
" guifontset=' to work successfully with every fontset specified with
" 'fontsets'.
let locales = [ 'ja_JP.UTF-8', 'ja_JP.eucJP', 'ja_JP.SJIS' ]
let fontsets = [ full_XLFDs, short_XLFDs, singleton, aliases ]
" Second, among 'locales', look up such a locale that gets 'set
" guifontset=' to work successfully with every fontset specified with
" 'fontsets'.
let locales = [ 'ja_JP.UTF-8', 'ja_JP.eucJP', 'ja_JP.SJIS' ]
let fontsets = [ full_XLFDs, short_XLFDs, singleton, aliases ]
let feasible = 0
for locale in locales
let feasible = 0
for locale in locales
try
exec 'language ctype' locale
catch /^Vim\%((\a\+)\)\=:E197/
continue
endtry
let done = 0
for fontset in fontsets
try
exec 'language ctype' locale
catch /^Vim\%((\a\+)\)\=:E197/
continue
exec 'set guifontset=' . fontset
catch /^Vim\%((\a\+)\)\=:E\%(250\|252\|234\|597\|598\)/
break
endtry
let done = 0
for fontset in fontsets
try
exec 'set guifontset=' . fontset
catch /^Vim\%((\a\+)\)\=:E\%(250\|252\|234\|597\|598\)/
break
endtry
let done += 1
endfor
if done == len(fontsets)
let feasible = 1
break
endif
let done += 1
endfor
" Third, give a set of tests if it is found feasible.
if !feasible
let skipped = g:not_hosted
else
" N.B. 'v:ctype' has already been set to an appropriate value in the
" previous loop.
for fontset in fontsets
exec 'set guifontset=' . fontset
call assert_equal(fontset, &guifontset)
endfor
if done == len(fontsets)
let feasible = 1
break
endif
endfor
" Finally, restore ctype.
exec 'language ctype' ctype_saved
" Third, give a set of tests if it is found feasible.
if !feasible
let skipped = g:not_hosted
else
" N.B. 'v:ctype' has already been set to an appropriate value in the
" previous loop.
for fontset in fontsets
exec 'set guifontset=' . fontset
call assert_equal(fontset, &guifontset)
endfor
endif
" Finally, restore ctype.
exec 'language ctype' ctype_saved
if !empty(skipped)
throw skipped
endif
@ -677,7 +674,7 @@ func Test_scrollbars()
set guioptions+=rlb
" scroll to move line 11 at top, moves the cursor there
call test_scrollbar('left', 10, 0)
eval 10->test_scrollbar('left', 0)
redraw
call assert_equal(1, winline())
call assert_equal(11, line('.'))

View File

@ -552,6 +552,26 @@ func Test_cursorline_after_yank()
call delete('Xtest_cursorline_yank')
endfunc
" test for issue #4862
func Test_put_before_cursorline()
new
only!
call setline(1, 'A')
redraw
let std_attr = screenattr(1, 1)
set cursorline
redraw
let cul_attr = screenattr(1, 1)
normal yyP
redraw
" Line 1 has cursor so it should be highlighted with CursorLine.
call assert_equal(cul_attr, screenattr(1, 1))
" And CursorLine highlighting from the second line should be gone.
call assert_equal(std_attr, screenattr(2, 1))
set nocursorline
bwipe!
endfunc
func Test_cursorline_with_visualmode()
CheckScreendump

View File

@ -234,7 +234,7 @@ func Test_listener_garbage_collect()
new
let id = listener_add(function('MyListener', [{}]), bufnr(''))
call test_garbagecollect_now()
" must not crach caused by invalid memory access
" must not crash caused by invalid memory access
normal ia
call assert_true(v:true)
@ -268,3 +268,25 @@ func Test_listener_caches_buffer_line()
iunmap <CR>
set nocindent
endfunc
" Verify the fix for issue #4908
func Test_listener_undo_line_number()
function DoIt()
" NOP
endfunction
function EchoChanges(bufnr, start, end, added, changes)
call DoIt()
endfunction
new
let lid = listener_add("EchoChanges")
call setline(1, ['a', 'b', 'c'])
set undolevels& " start new undo block
call feedkeys("ggcG\<Esc>", 'xt')
undo
bwipe!
delfunc DoIt
delfunc EchoChanges
call listener_remove(lid)
endfunc

View File

@ -90,7 +90,7 @@ func Test_echoerr()
if has('float')
call assert_equal("\n1.23 IgNoRe", execute(':echoerr 1.23 "IgNoRe"'))
endif
call test_ignore_error('<lambda>')
eval '<lambda>'->test_ignore_error()
call assert_match("function('<lambda>\\d*')", execute(':echoerr {-> 1234}'))
call test_ignore_error('RESET')
endfunc

View File

@ -408,7 +408,7 @@ endfunc
func Test_mksession_terminal_restore_other()
terminal
call term_setrestore(bufnr('%'), 'other')
eval bufnr('%')->term_setrestore('other')
mksession! Xtest_mks.out
let lines = readfile('Xtest_mks.out')
let term_cmd = ''

View File

@ -510,7 +510,7 @@ func Test_shortmess_F2()
call assert_true(empty(execute('bn', '')))
call assert_false(test_getvalue('need_fileinfo'))
call assert_true(empty(execute('bn', '')))
call assert_false(test_getvalue('need_fileinfo'))
call assert_false('need_fileinfo'->test_getvalue())
set hidden
call assert_true(empty(execute('bn', '')))
call assert_false(test_getvalue('need_fileinfo'))

View File

@ -2306,6 +2306,20 @@ func Test_popup_cursorline()
call term_sendkeys(buf, "x")
call StopVimInTerminal(buf)
" ---------
" Cursor in second line when creating the popup
" ---------
let lines =<< trim END
let winid = popup_create(['111', '222', '333'], #{
\ cursorline : 1,
\ })
call win_execute(winid, "2")
END
call writefile(lines, 'XtestPopupCursorLine')
let buf = RunVimInTerminal('-S XtestPopupCursorLine', #{rows: 10})
call VerifyScreenDump(buf, 'Test_popupwin_cursorline_7', {})
call StopVimInTerminal(buf)
call delete('XtestPopupCursorLine')
endfunc

View File

@ -517,7 +517,7 @@ func Test_nomem()
call test_alloc_fail(GetAllocId('qf_dirname_start'), 0, 0)
call assert_fails('vimgrep vim runtest.vim', 'E342:')
call test_alloc_fail(GetAllocId('qf_dirname_now'), 0, 0)
call GetAllocId('qf_dirname_now')->test_alloc_fail(0, 0)
call assert_fails('vimgrep vim runtest.vim', 'E342:')
call test_alloc_fail(GetAllocId('qf_namebuf'), 0, 0)

View File

@ -13,13 +13,13 @@ func Test_play_event()
if has('win32')
throw 'Skipped: Playing event with callback is not supported on Windows'
endif
let id = sound_playevent('bell', 'PlayCallback')
let id = 'bell'->sound_playevent('PlayCallback')
if id == 0
throw 'Skipped: bell event not available'
endif
" Stop it quickly, avoid annoying the user.
sleep 20m
call sound_stop(id)
eval id->sound_stop()
sleep 30m
call assert_equal(id, g:id)
call assert_equal(1, g:result) " sound was aborted
@ -35,7 +35,7 @@ func Test_play_silent()
endif
" play until the end
let id2 = sound_playfile(fname, 'PlayCallback')
let id2 = fname->sound_playfile('PlayCallback')
call assert_true(id2 > 0)
sleep 500m
call assert_equal(id2, g:id)

View File

@ -73,7 +73,7 @@ func Test_spellbadword()
set spell
call assert_equal(['bycycle', 'bad'], spellbadword('My bycycle.'))
call assert_equal(['another', 'caps'], spellbadword('A sentence. another sentence'))
call assert_equal(['another', 'caps'], 'A sentence. another sentence'->spellbadword())
set spelllang=en
call assert_equal(['', ''], spellbadword('centre'))
@ -179,7 +179,7 @@ func Test_zz_basic()
\ )
call assert_equal("gebletegek", soundfold('goobledygoook'))
call assert_equal("kepereneven", soundfold('k<>op<6F>r<EFBFBD>n<EFBFBD>ven'))
call assert_equal("kepereneven", 'k<>op<6F>r<EFBFBD>n<EFBFBD>ven'->soundfold())
call assert_equal("everles gesvets etele", soundfold('oeverloos gezwets edale'))
endfunc
@ -440,7 +440,7 @@ func TestGoodBadBase()
break
endif
let prevbad = bad
let lst = spellsuggest(bad, 3)
let lst = bad->spellsuggest(3)
normal mm
call add(result, [bad, lst])

View File

@ -337,7 +337,7 @@ func Test_sub_replace_5()
\ substitute('A123456789',
\ 'A\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)',
\ '\=string([submatch(0, 1), submatch(9, 1), ' .
\ 'submatch(8, 1), submatch(7, 1), submatch(6, 1), ' .
\ 'submatch(8, 1), 7->submatch(1), submatch(6, 1), ' .
\ 'submatch(5, 1), submatch(4, 1), submatch(3, 1), ' .
\ 'submatch(2, 1), submatch(1, 1)])',
\ ''))

View File

@ -111,7 +111,7 @@ func Test_swapinfo()
w
let fname = s:swapname()
call assert_match('Xswapinfo', fname)
let info = swapinfo(fname)
let info = fname->swapinfo()
let ver = printf('VIM %d.%d', v:version / 100, v:version % 100)
call assert_equal(ver, info.version)
@ -153,7 +153,7 @@ func Test_swapname()
let buf = bufnr('%')
let expected = s:swapname()
wincmd p
call assert_equal(expected, swapname(buf))
call assert_equal(expected, buf->swapname())
new Xtest3
setlocal noswapfile

View File

@ -13,7 +13,7 @@ func Test_taglist()
split Xtext
call assert_equal(['FFoo', 'BFoo'], map(taglist("Foo"), {i, v -> v.name}))
call assert_equal(['FFoo', 'BFoo'], map(taglist("Foo", "Xtext"), {i, v -> v.name}))
call assert_equal(['FFoo', 'BFoo'], map("Foo"->taglist("Xtext"), {i, v -> v.name}))
call assert_equal(['FFoo', 'BFoo'], map(taglist("Foo", "Xfoo"), {i, v -> v.name}))
call assert_equal(['BFoo', 'FFoo'], map(taglist("Foo", "Xbar"), {i, v -> v.name}))

View File

@ -646,7 +646,7 @@ func Test_term_rgb_response()
" response to t_RB, 4 digits, dark
set background=light
call test_option_not_set('background')
eval 'background'->test_option_not_set()
let red = 0x29
let green = 0x4a
let blue = 0x6b

View File

@ -25,7 +25,7 @@ func Run_shell_in_terminal(options)
let g:job = term_getjob(buf)
call assert_equal(v:t_job, type(g:job))
let string = string({'job': term_getjob(buf)})
let string = string({'job': buf->term_getjob()})
call assert_match("{'job': 'process \\d\\+ run'}", string)
return buf
@ -42,7 +42,7 @@ func Test_terminal_basic()
" ConPTY works on anonymous pipe.
if !has('conpty')
call assert_match('^\\\\.\\pipe\\', job_info(g:job).tty_out)
call assert_match('^\\\\.\\pipe\\', term_gettty(''))
call assert_match('^\\\\.\\pipe\\', ''->term_gettty())
endif
endif
call assert_equal('t', mode())
@ -91,7 +91,7 @@ func Test_terminal_paste_register()
call feedkeys("echo \<C-W>\"\" \<C-W>\"=37 + 5\<CR>\<CR>", 'xt')
call WaitForAssert({-> assert_match("echo text to paste 42$", getline(1))})
call WaitForAssert({-> assert_equal('text to paste 42', getline(2))})
call WaitForAssert({-> assert_equal('text to paste 42', 2->getline())})
exe buf . 'bwipe!'
unlet g:job
@ -176,12 +176,14 @@ func Check_123(buf)
call assert_true(len(l) == 0)
let l = term_scrape(a:buf, 999)
call assert_true(len(l) == 0)
let l = term_scrape(a:buf, 1)
let l = a:buf->term_scrape(1)
call assert_true(len(l) > 0)
call assert_equal('1', l[0].chars)
call assert_equal('2', l[1].chars)
call assert_equal('3', l[2].chars)
call assert_equal('#00e000', l[0].fg)
call assert_equal(0, term_getattr(l[0].attr, 'bold'))
call assert_equal(0, l[0].attr->term_getattr('italic'))
if has('win32')
" On Windows 'background' always defaults to dark, even though the terminal
" may use a light background. Therefore accept both white and black.
@ -238,7 +240,7 @@ func Test_terminal_scrape_multibyte()
" multibyte characters.
let buf = term_start("cmd /K chcp 65001")
call term_sendkeys(buf, "type Xtext\<CR>")
call term_sendkeys(buf, "exit\<CR>")
eval buf->term_sendkeys("exit\<CR>")
let line = 4
else
let buf = term_start("cat Xtext")
@ -283,7 +285,8 @@ func Test_terminal_scroll()
sleep 100m
endif
let scrolled = term_getscrolled(buf)
let scrolled = buf->term_getscrolled()
call assert_equal(scrolled, term_getscrolled(buf))
call assert_equal('1', getline(1))
call assert_equal('1', term_getline(buf, 1 - scrolled))
call assert_equal('49', getline(49))
@ -383,12 +386,12 @@ func Test_terminal_size()
vsplit
exe 'terminal ++rows=5 ++cols=33 ' . cmd
call assert_equal([5, 33], term_getsize(''))
call assert_equal([5, 33], ''->term_getsize())
call term_setsize('', 6, 0)
call assert_equal([6, 33], term_getsize(''))
call term_setsize('', 0, 35)
eval ''->term_setsize(0, 35)
call assert_equal([6, 35], term_getsize(''))
call term_setsize('', 7, 30)
@ -407,7 +410,7 @@ func Test_terminal_size()
bwipe!
call assert_equal(20, size[1])
call term_start(cmd, {'vertical': 1, 'term_cols': 26})
eval cmd->term_start({'vertical': 1, 'term_cols': 26})
let size = term_getsize('')
bwipe!
call assert_equal(26, size[1])
@ -618,7 +621,7 @@ func Test_terminal_env()
else
call term_sendkeys(buf, "echo $TESTENV\r")
endif
call term_wait(buf)
eval buf->term_wait()
call StopShellInTerminal(buf)
call WaitForAssert({-> assert_equal('correct', getline(2))})
@ -1006,7 +1009,7 @@ endfunc
" Run Vim, start a terminal in that Vim, set the kill argument with
" term_setkill(), check that :qall works.
func Test_terminal_qall_kill_func()
call Run_terminal_qall_kill('term', 'call term_setkill(buf, "kill")')
call Run_terminal_qall_kill('term', 'eval buf->term_setkill("kill")')
endfunc
" Run Vim, start a terminal in that Vim without the kill argument,
@ -1107,7 +1110,7 @@ func Test_terminal_dumpwrite_composing()
call writefile([text], 'Xcomposing')
let buf = RunVimInTerminal('--cmd "set encoding=utf-8" Xcomposing', {})
call WaitForAssert({-> assert_match(text, term_getline(buf, 1))})
call term_dumpwrite(buf, 'Xdump')
eval 'Xdump'->term_dumpwrite(buf)
let dumpline = readfile('Xdump')[0]
call assert_match('|à| |ê| |ö', dumpline)
@ -1127,7 +1130,7 @@ func Test_terminal_dumpload()
call Check_dump01(0)
" Load another dump in the same window
let buf2 = term_dumpload('dumps/Test_diff_01.dump', {'bufnr': buf})
let buf2 = 'dumps/Test_diff_01.dump'->term_dumpload({'bufnr': buf})
call assert_equal(buf, buf2)
call assert_notequal('one two three four five', trim(getline(1)))
@ -1148,7 +1151,7 @@ endfunc
func Test_terminal_dumpdiff()
call assert_equal(1, winnr('$'))
call term_dumpdiff('dumps/Test_popup_command_01.dump', 'dumps/Test_popup_command_02.dump')
eval 'dumps/Test_popup_command_01.dump'->term_dumpdiff('dumps/Test_popup_command_02.dump')
call assert_equal(2, winnr('$'))
call assert_equal(62, line('$'))
call Check_dump01(0)
@ -1490,7 +1493,7 @@ func Test_terminal_ansicolors_func()
call assert_equal(s:test_colors, term_getansicolors(buf))
call term_setansicolors(buf, g:terminal_ansi_colors)
call assert_equal(g:terminal_ansi_colors, term_getansicolors(buf))
call assert_equal(g:terminal_ansi_colors, buf->term_getansicolors())
let colors = [
\ 'ivory', 'AliceBlue',
@ -1502,7 +1505,7 @@ func Test_terminal_ansicolors_func()
\ 'grey47', 'gray97',
\ 'MistyRose2', 'DodgerBlue4',
\]
call term_setansicolors(buf, colors)
eval buf->term_setansicolors(colors)
let colors[4] = 'Invalid'
call assert_fails('call term_setansicolors(buf, colors)', 'E474:')
@ -1856,7 +1859,7 @@ func Test_terminal_hidden()
call term_sendkeys(bnr, "asdf\<CR>")
call WaitForAssert({-> assert_match('asdf', term_getline(bnr, 2))})
call term_sendkeys(bnr, "\<C-D>")
call WaitForAssert({-> assert_equal('finished', term_getstatus(bnr))})
call WaitForAssert({-> assert_equal('finished', bnr->term_getstatus())})
bwipe!
endfunc
@ -1944,7 +1947,7 @@ func Test_term_getcursor()
" Show the cursor.
call term_sendkeys(buf, "echo -e '\\033[?25h'\r")
call WaitForAssert({-> assert_equal(1, term_getcursor(buf)[2].visible)})
call WaitForAssert({-> assert_equal(1, buf->term_getcursor()[2].visible)})
" Change color of cursor.
call WaitForAssert({-> assert_equal('', term_getcursor(buf)[2].color)})
@ -1989,7 +1992,7 @@ endfunc
func Test_term_gettitle()
" term_gettitle() returns an empty string for a non-terminal buffer
" and for a non-existing buffer.
call assert_equal('', term_gettitle(bufnr('%')))
call assert_equal('', bufnr('%')->term_gettitle())
call assert_equal('', term_gettitle(bufnr('$') + 1))
if !has('title') || &title == 0 || empty(&t_ts)
@ -2083,3 +2086,19 @@ func Test_terminal_getwinpos()
set splitright&
only!
endfunc
func Test_terminal_altscreen()
CheckUnix
let buf = term_start(&shell, {})
call term_sendkeys(buf, 'echo "\e[?1047h"' .. "\r")
call term_wait(buf)
call assert_equal(1, term_getaltscreen(buf))
call term_sendkeys(buf, 'echo "\e[?1047l"' .. "\r")
call term_wait(buf)
call assert_equal(0, buf->term_getaltscreen())
call term_sendkeys(buf, "exit\r")
exe buf . "bwipe!"
endfunc

View File

@ -251,7 +251,7 @@ func FeedAndPeek(timer)
endfunc
func Interrupt(timer)
call test_feedinput("\<C-C>")
eval "\<C-C>"->test_feedinput()
endfunc
func Test_timer_peek_and_get_char()

View File

@ -17,7 +17,7 @@ func Test_strchars()
let exp = [[1, 1, 1], [3, 3, 3], [2, 2, 1], [3, 3, 1], [1, 1, 1]]
for i in range(len(inp))
call assert_equal(exp[i][0], strchars(inp[i]))
call assert_equal(exp[i][1], strchars(inp[i], 0))
call assert_equal(exp[i][1], inp[i]->strchars(0))
call assert_equal(exp[i][2], strchars(inp[i], 1))
endfor
endfunc

View File

@ -171,7 +171,7 @@ func Test_cmdline_history_order()
call histdel(':')
" items go before and after
call test_settime(8)
eval 8->test_settime()
call histadd(':', "echo '8'")
call test_settime(39)
call histadd(':', "echo '39'")

View File

@ -1596,7 +1596,7 @@ func Test_refcount()
call assert_equal(1, test_refcount(x))
let x = {}
call assert_equal(1, test_refcount(x))
call assert_equal(1, x->test_refcount())
let x = 0zff
call assert_equal(1, test_refcount(x))

View File

@ -485,7 +485,7 @@ func Test_window_newtab()
wincmd T
call assert_equal(2, tabpagenr('$'))
call assert_equal(['Xb', 'Xa'], map(tabpagebuflist(1), 'bufname(v:val)'))
call assert_equal(['Xc' ], map(tabpagebuflist(2), 'bufname(v:val)'))
call assert_equal(['Xc' ], map(2->tabpagebuflist(), 'bufname(v:val)'))
%bw!
endfunc
@ -598,8 +598,11 @@ endfunc
func Fun_RenewFile()
" Need to wait a bit for the timestamp to be older.
sleep 2
silent execute '!echo "1" > tmp.txt'
let old_ftime = getftime("tmp.txt")
while getftime("tmp.txt") == old_ftime
sleep 100m
silent execute '!echo "1" > tmp.txt'
endwhile
sp
wincmd p
edit! tmp.txt
@ -835,7 +838,7 @@ func Test_winnr()
tabnew
call assert_equal(8, tabpagewinnr(1, 'j'))
call assert_equal(2, tabpagewinnr(1, 'k'))
call assert_equal(2, 1->tabpagewinnr('k'))
call assert_equal(4, tabpagewinnr(1, 'h'))
call assert_equal(6, tabpagewinnr(1, 'l'))

View File

@ -479,7 +479,9 @@ ui_wait_for_chars_or_timer(
// There is a pending job or channel, should return soon in order
// to handle them ASAP. Do check for input briefly.
due_time = 10L;
# ifdef FEAT_JOB_CHANNEL
brief_wait = TRUE;
# endif
}
# endif
if (wait_func(due_time, interrupted, ignore_input))

View File

@ -2624,6 +2624,7 @@ u_undoredo(int undo)
linenr_T top, bot;
linenr_T lnum;
linenr_T newlnum = MAXLNUM;
pos_T new_curpos = curwin->w_cursor;
long i;
u_entry_T *uep, *nuep;
u_entry_T *newlist = NULL;
@ -2667,29 +2668,31 @@ u_undoredo(int undo)
{
unblock_autocmds();
iemsg(_("E438: u_undo: line numbers wrong"));
changed(); /* don't want UNCHANGED now */
changed(); // don't want UNCHANGED now
return;
}
oldsize = bot - top - 1; /* number of lines before undo */
newsize = uep->ue_size; /* number of lines after undo */
oldsize = bot - top - 1; // number of lines before undo
newsize = uep->ue_size; // number of lines after undo
// Decide about the cursor position, depending on what text changed.
// Don't set it yet, it may be invalid if lines are going to be added.
if (top < newlnum)
{
/* If the saved cursor is somewhere in this undo block, move it to
* the remembered position. Makes "gwap" put the cursor back
* where it was. */
// If the saved cursor is somewhere in this undo block, move it to
// the remembered position. Makes "gwap" put the cursor back
// where it was.
lnum = curhead->uh_cursor.lnum;
if (lnum >= top && lnum <= top + newsize + 1)
{
curwin->w_cursor = curhead->uh_cursor;
newlnum = curwin->w_cursor.lnum - 1;
new_curpos = curhead->uh_cursor;
newlnum = new_curpos.lnum - 1;
}
else
{
/* Use the first line that actually changed. Avoids that
* undoing auto-formatting puts the cursor in the previous
* line. */
// Use the first line that actually changed. Avoids that
// undoing auto-formatting puts the cursor in the previous
// line.
for (i = 0; i < newsize && i < oldsize; ++i)
{
char_u *p = ml_get(top + 1 + i);
@ -2702,28 +2705,29 @@ u_undoredo(int undo)
if (i == newsize && newlnum == MAXLNUM && uep->ue_next == NULL)
{
newlnum = top;
curwin->w_cursor.lnum = newlnum + 1;
new_curpos.lnum = newlnum + 1;
}
else if (i < newsize)
{
newlnum = top + i;
curwin->w_cursor.lnum = newlnum + 1;
new_curpos.lnum = newlnum + 1;
}
}
}
empty_buffer = FALSE;
/* delete the lines between top and bot and save them in newarray */
/*
* Delete the lines between top and bot and save them in newarray.
*/
if (oldsize > 0)
{
if ((newarray = U_ALLOC_LINE(sizeof(undoline_T) * oldsize)) == NULL)
{
do_outofmem_msg((long_u)(sizeof(undoline_T) * oldsize));
/*
* We have messed up the entry list, repair is impossible.
* we have to free the rest of the list.
*/
// We have messed up the entry list, repair is impossible.
// we have to free the rest of the list.
while (uep != NULL)
{
nuep = uep->ue_next;
@ -2732,14 +2736,14 @@ u_undoredo(int undo)
}
break;
}
/* delete backwards, it goes faster in most cases */
// delete backwards, it goes faster in most cases
for (lnum = bot - 1, i = oldsize; --i >= 0; --lnum)
{
/* what can we do when we run out of memory? */
// what can we do when we run out of memory?
if (u_save_line(&newarray[i], lnum) == FAIL)
do_outofmem_msg((long_u)0);
/* remember we deleted the last line in the buffer, and a
* dummy empty line will be inserted */
// remember we deleted the last line in the buffer, and a
// dummy empty line will be inserted
if (curbuf->b_ml.ml_line_count == 1)
empty_buffer = TRUE;
ml_delete(lnum, FALSE);
@ -2748,7 +2752,12 @@ u_undoredo(int undo)
else
newarray = NULL;
/* insert the lines in u_array between top and bot */
// make sure the cursor is on a valid line after the deletions
check_cursor_lnum();
/*
* Insert the lines in u_array between top and bot.
*/
if (newsize)
{
for (lnum = top, i = 0; i < newsize; ++i, ++lnum)
@ -2766,7 +2775,7 @@ u_undoredo(int undo)
vim_free((char_u *)uep->ue_array);
}
/* adjust marks */
// adjust marks
if (oldsize != newsize)
{
mark_adjust(top + 1, top + oldsize, (long)MAXLNUM,
@ -2779,7 +2788,7 @@ u_undoredo(int undo)
changed_lines(top + 1, 0, bot, newsize - oldsize);
/* set '[ and '] mark */
// set '[ and '] mark
if (top + 1 < curbuf->b_op_start.lnum)
curbuf->b_op_start.lnum = top + 1;
if (newsize == 0 && top + 1 > curbuf->b_op_end.lnum)
@ -2801,6 +2810,10 @@ u_undoredo(int undo)
newlist = uep;
}
// Set the cursor to the desired position. Check that the line is valid.
curwin->w_cursor = new_curpos;
check_cursor_lnum();
curhead->uh_entry = newlist;
curhead->uh_flags = new_flags;
if ((old_flags & UH_EMPTYBUF) && BUFEMPTY())

View File

@ -757,6 +757,32 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
2012,
/**/
2011,
/**/
2010,
/**/
2009,
/**/
2008,
/**/
2007,
/**/
2006,
/**/
2005,
/**/
2004,
/**/
2003,
/**/
2002,
/**/
2001,
/**/
2000,
/**/
1999,
/**/

View File

@ -6587,144 +6587,6 @@ restore_snapshot_rec(frame_T *sn, frame_T *fr)
return wp;
}
#if defined(FEAT_EVAL) || defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) \
|| defined(PROTO)
/*
* Set "win" to be the curwin and "tp" to be the current tab page.
* restore_win() MUST be called to undo, also when FAIL is returned.
* No autocommands will be executed until restore_win() is called.
* When "no_display" is TRUE the display won't be affected, no redraw is
* triggered, another tabpage access is limited.
* Returns FAIL if switching to "win" failed.
*/
int
switch_win(
win_T **save_curwin,
tabpage_T **save_curtab,
win_T *win,
tabpage_T *tp,
int no_display)
{
block_autocmds();
return switch_win_noblock(save_curwin, save_curtab, win, tp, no_display);
}
/*
* As switch_win() but without blocking autocommands.
*/
int
switch_win_noblock(
win_T **save_curwin,
tabpage_T **save_curtab,
win_T *win,
tabpage_T *tp,
int no_display)
{
*save_curwin = curwin;
if (tp != NULL)
{
*save_curtab = curtab;
if (no_display)
{
curtab->tp_firstwin = firstwin;
curtab->tp_lastwin = lastwin;
curtab = tp;
firstwin = curtab->tp_firstwin;
lastwin = curtab->tp_lastwin;
}
else
goto_tabpage_tp(tp, FALSE, FALSE);
}
if (!win_valid(win))
return FAIL;
curwin = win;
curbuf = curwin->w_buffer;
return OK;
}
/*
* Restore current tabpage and window saved by switch_win(), if still valid.
* When "no_display" is TRUE the display won't be affected, no redraw is
* triggered.
*/
void
restore_win(
win_T *save_curwin,
tabpage_T *save_curtab,
int no_display)
{
restore_win_noblock(save_curwin, save_curtab, no_display);
unblock_autocmds();
}
/*
* As restore_win() but without unblocking autocommands.
*/
void
restore_win_noblock(
win_T *save_curwin,
tabpage_T *save_curtab,
int no_display)
{
if (save_curtab != NULL && valid_tabpage(save_curtab))
{
if (no_display)
{
curtab->tp_firstwin = firstwin;
curtab->tp_lastwin = lastwin;
curtab = save_curtab;
firstwin = curtab->tp_firstwin;
lastwin = curtab->tp_lastwin;
}
else
goto_tabpage_tp(save_curtab, FALSE, FALSE);
}
if (win_valid(save_curwin))
{
curwin = save_curwin;
curbuf = curwin->w_buffer;
}
#ifdef FEAT_TEXT_PROP
else if (WIN_IS_POPUP(curwin))
// original window was closed and now we're in a popup window: Go
// to the first valid window.
win_goto(firstwin);
#endif
}
/*
* Make "buf" the current buffer. restore_buffer() MUST be called to undo.
* No autocommands will be executed. Use aucmd_prepbuf() if there are any.
*/
void
switch_buffer(bufref_T *save_curbuf, buf_T *buf)
{
block_autocmds();
set_bufref(save_curbuf, curbuf);
--curbuf->b_nwindows;
curbuf = buf;
curwin->w_buffer = buf;
++curbuf->b_nwindows;
}
/*
* Restore the current buffer after using switch_buffer().
*/
void
restore_buffer(bufref_T *save_curbuf)
{
unblock_autocmds();
/* Check for valid buffer, just in case. */
if (bufref_valid(save_curbuf))
{
--curbuf->b_nwindows;
curwin->w_buffer = save_curbuf->br_buf;
curbuf = save_curbuf->br_buf;
++curbuf->b_nwindows;
}
}
#endif
#if defined(FEAT_GUI) || defined(PROTO)
/*
* Return TRUE if there is any vertically split window.
@ -6896,312 +6758,3 @@ skip:
return NULL; // no error
}
#endif
#if defined(FEAT_EVAL) || defined(PROTO)
int
win_getid(typval_T *argvars)
{
int winnr;
win_T *wp;
if (argvars[0].v_type == VAR_UNKNOWN)
return curwin->w_id;
winnr = tv_get_number(&argvars[0]);
if (winnr > 0)
{
if (argvars[1].v_type == VAR_UNKNOWN)
wp = firstwin;
else
{
tabpage_T *tp;
int tabnr = tv_get_number(&argvars[1]);
FOR_ALL_TABPAGES(tp)
if (--tabnr == 0)
break;
if (tp == NULL)
return -1;
if (tp == curtab)
wp = firstwin;
else
wp = tp->tp_firstwin;
}
for ( ; wp != NULL; wp = wp->w_next)
if (--winnr == 0)
return wp->w_id;
}
return 0;
}
int
win_gotoid(typval_T *argvars)
{
win_T *wp;
tabpage_T *tp;
int id = tv_get_number(&argvars[0]);
FOR_ALL_TAB_WINDOWS(tp, wp)
if (wp->w_id == id)
{
goto_tabpage_win(tp, wp);
return 1;
}
return 0;
}
void
win_id2tabwin(typval_T *argvars, list_T *list)
{
win_T *wp;
tabpage_T *tp;
int winnr = 1;
int tabnr = 1;
int id = tv_get_number(&argvars[0]);
FOR_ALL_TABPAGES(tp)
{
FOR_ALL_WINDOWS_IN_TAB(tp, wp)
{
if (wp->w_id == id)
{
list_append_number(list, tabnr);
list_append_number(list, winnr);
return;
}
++winnr;
}
++tabnr;
winnr = 1;
}
list_append_number(list, 0);
list_append_number(list, 0);
}
/*
* Return the window pointer of window "id".
*/
win_T *
win_id2wp(int id)
{
return win_id2wp_tp(id, NULL);
}
/*
* Return the window and tab pointer of window "id".
*/
win_T *
win_id2wp_tp(int id, tabpage_T **tpp)
{
win_T *wp;
tabpage_T *tp;
FOR_ALL_TAB_WINDOWS(tp, wp)
if (wp->w_id == id)
{
if (tpp != NULL)
*tpp = tp;
return wp;
}
#ifdef FEAT_TEXT_PROP
// popup windows are in separate lists
FOR_ALL_TABPAGES(tp)
for (wp = tp->tp_first_popupwin; wp != NULL; wp = wp->w_next)
if (wp->w_id == id)
{
if (tpp != NULL)
*tpp = tp;
return wp;
}
for (wp = first_popupwin; wp != NULL; wp = wp->w_next)
if (wp->w_id == id)
{
if (tpp != NULL)
*tpp = tp;
return wp;
}
#endif
return NULL;
}
int
win_id2win(typval_T *argvars)
{
win_T *wp;
int nr = 1;
int id = tv_get_number(&argvars[0]);
FOR_ALL_WINDOWS(wp)
{
if (wp->w_id == id)
return nr;
++nr;
}
return 0;
}
void
win_findbuf(typval_T *argvars, list_T *list)
{
win_T *wp;
tabpage_T *tp;
int bufnr = tv_get_number(&argvars[0]);
FOR_ALL_TAB_WINDOWS(tp, wp)
if (wp->w_buffer->b_fnum == bufnr)
list_append_number(list, wp->w_id);
}
/*
* Find window specified by "vp" in tabpage "tp".
*/
win_T *
find_win_by_nr(
typval_T *vp,
tabpage_T *tp) // NULL for current tab page
{
win_T *wp;
int nr = (int)tv_get_number_chk(vp, NULL);
if (nr < 0)
return NULL;
if (nr == 0)
return curwin;
FOR_ALL_WINDOWS_IN_TAB(tp, wp)
{
if (nr >= LOWEST_WIN_ID)
{
if (wp->w_id == nr)
return wp;
}
else if (--nr <= 0)
break;
}
if (nr >= LOWEST_WIN_ID)
{
#ifdef FEAT_TEXT_PROP
// check tab-local popup windows
for (wp = tp->tp_first_popupwin; wp != NULL; wp = wp->w_next)
if (wp->w_id == nr)
return wp;
// check global popup windows
for (wp = first_popupwin; wp != NULL; wp = wp->w_next)
if (wp->w_id == nr)
return wp;
#endif
return NULL;
}
return wp;
}
/*
* Find a window: When using a Window ID in any tab page, when using a number
* in the current tab page.
*/
win_T *
find_win_by_nr_or_id(typval_T *vp)
{
int nr = (int)tv_get_number_chk(vp, NULL);
if (nr >= LOWEST_WIN_ID)
return win_id2wp(tv_get_number(vp));
return find_win_by_nr(vp, NULL);
}
/*
* Find window specified by "wvp" in tabpage "tvp".
* Returns the tab page in 'ptp'
*/
win_T *
find_tabwin(
typval_T *wvp, // VAR_UNKNOWN for current window
typval_T *tvp, // VAR_UNKNOWN for current tab page
tabpage_T **ptp)
{
win_T *wp = NULL;
tabpage_T *tp = NULL;
long n;
if (wvp->v_type != VAR_UNKNOWN)
{
if (tvp->v_type != VAR_UNKNOWN)
{
n = (long)tv_get_number(tvp);
if (n >= 0)
tp = find_tabpage(n);
}
else
tp = curtab;
if (tp != NULL)
{
wp = find_win_by_nr(wvp, tp);
if (wp == NULL && wvp->v_type == VAR_NUMBER
&& wvp->vval.v_number != -1)
// A window with the specified number is not found
tp = NULL;
}
}
else
{
wp = curwin;
tp = curtab;
}
if (ptp != NULL)
*ptp = tp;
return wp;
}
/*
* Get the layout of the given tab page for winlayout().
*/
void
get_framelayout(frame_T *fr, list_T *l, int outer)
{
frame_T *child;
list_T *fr_list;
list_T *win_list;
if (fr == NULL)
return;
if (outer)
// outermost call from f_winlayout()
fr_list = l;
else
{
fr_list = list_alloc();
if (fr_list == NULL)
return;
list_append_list(l, fr_list);
}
if (fr->fr_layout == FR_LEAF)
{
if (fr->fr_win != NULL)
{
list_append_string(fr_list, (char_u *)"leaf", -1);
list_append_number(fr_list, fr->fr_win->w_id);
}
}
else
{
list_append_string(fr_list,
fr->fr_layout == FR_ROW ? (char_u *)"row" : (char_u *)"col", -1);
win_list = list_alloc();
if (win_list == NULL)
return;
list_append_list(fr_list, win_list);
child = fr->fr_child;
while (child != NULL)
{
get_framelayout(child, win_list, FALSE);
child = child->fr_next;
}
}
}
#endif