mirror of
https://github.com/vim/vim.git
synced 2025-09-28 04:24:06 -04:00
patch 8.1.1952: more functions can be used as a method
Problem: More functions can be used as a method. Solution: Allow more functions to be used as a method.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
*eval.txt* For Vim version 8.1. Last change: 2019 Aug 28
|
*eval.txt* For Vim version 8.1. Last change: 2019 Aug 31
|
||||||
|
|
||||||
|
|
||||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||||
@@ -5517,7 +5517,7 @@ gettabwinvar({tabnr}, {winnr}, {varname} [, {def}]) *gettabwinvar()*
|
|||||||
gettabwinvar({tabnr}, {winnr}, '&')
|
gettabwinvar({tabnr}, {winnr}, '&')
|
||||||
|
|
||||||
< Can also be used as a |method|: >
|
< Can also be used as a |method|: >
|
||||||
GetTabnr()->gettabvar(winnr, varname)
|
GetTabnr()->gettabwinvar(winnr, varname)
|
||||||
|
|
||||||
gettagstack([{nr}]) *gettagstack()*
|
gettagstack([{nr}]) *gettagstack()*
|
||||||
The result is a Dict, which is the tag stack of window {nr}.
|
The result is a Dict, which is the tag stack of window {nr}.
|
||||||
@@ -5547,6 +5547,9 @@ gettagstack([{nr}]) *gettagstack()*
|
|||||||
|
|
||||||
See |tagstack| for more information about the tag stack.
|
See |tagstack| for more information about the tag stack.
|
||||||
|
|
||||||
|
Can also be used as a |method|: >
|
||||||
|
GetWinnr()->gettagstack()
|
||||||
|
|
||||||
getwininfo([{winid}]) *getwininfo()*
|
getwininfo([{winid}]) *getwininfo()*
|
||||||
Returns information about windows as a List with Dictionaries.
|
Returns information about windows as a List with Dictionaries.
|
||||||
|
|
||||||
@@ -5581,6 +5584,9 @@ getwininfo([{winid}]) *getwininfo()*
|
|||||||
winrow topmost screen column of the window,
|
winrow topmost screen column of the window,
|
||||||
row from |win_screenpos()|
|
row from |win_screenpos()|
|
||||||
|
|
||||||
|
Can also be used as a |method|: >
|
||||||
|
GetWinnr()->getwininfo()
|
||||||
|
|
||||||
getwinpos([{timeout}]) *getwinpos()*
|
getwinpos([{timeout}]) *getwinpos()*
|
||||||
The result is a list with two numbers, the result of
|
The result is a list with two numbers, the result of
|
||||||
getwinposx() and getwinposy() combined:
|
getwinposx() and getwinposy() combined:
|
||||||
@@ -5600,6 +5606,10 @@ getwinpos([{timeout}]) *getwinpos()*
|
|||||||
" Do some work here
|
" Do some work here
|
||||||
endwhile
|
endwhile
|
||||||
<
|
<
|
||||||
|
|
||||||
|
Can also be used as a |method|: >
|
||||||
|
GetTimeout()->getwinpos()
|
||||||
|
<
|
||||||
*getwinposx()*
|
*getwinposx()*
|
||||||
getwinposx() The result is a Number, which is the X coordinate in pixels of
|
getwinposx() The result is a Number, which is the X coordinate in pixels of
|
||||||
the left hand side of the GUI Vim window. Also works for an
|
the left hand side of the GUI Vim window. Also works for an
|
||||||
@@ -5619,6 +5629,9 @@ getwinvar({winnr}, {varname} [, {def}]) *getwinvar()*
|
|||||||
Examples: >
|
Examples: >
|
||||||
:let list_is_on = getwinvar(2, '&list')
|
:let list_is_on = getwinvar(2, '&list')
|
||||||
:echo "myvar = " . getwinvar(1, 'myvar')
|
:echo "myvar = " . getwinvar(1, 'myvar')
|
||||||
|
|
||||||
|
< Can also be used as a |method|: >
|
||||||
|
GetWinnr()->getwinvar(varname)
|
||||||
<
|
<
|
||||||
glob({expr} [, {nosuf} [, {list} [, {alllinks}]]]) *glob()*
|
glob({expr} [, {nosuf} [, {list} [, {alllinks}]]]) *glob()*
|
||||||
Expand the file wildcards in {expr}. See |wildcards| for the
|
Expand the file wildcards in {expr}. See |wildcards| for the
|
||||||
@@ -5656,6 +5669,9 @@ glob({expr} [, {nosuf} [, {list} [, {alllinks}]]]) *glob()*
|
|||||||
See |expand()| for expanding special Vim variables. See
|
See |expand()| for expanding special Vim variables. See
|
||||||
|system()| for getting the raw output of an external command.
|
|system()| for getting the raw output of an external command.
|
||||||
|
|
||||||
|
Can also be used as a |method|: >
|
||||||
|
GetExpr()->glob()
|
||||||
|
|
||||||
glob2regpat({expr}) *glob2regpat()*
|
glob2regpat({expr}) *glob2regpat()*
|
||||||
Convert a file pattern, as used by glob(), into a search
|
Convert a file pattern, as used by glob(), into a search
|
||||||
pattern. The result can be used to match with a string that
|
pattern. The result can be used to match with a string that
|
||||||
@@ -5668,7 +5684,9 @@ glob2regpat({expr}) *glob2regpat()*
|
|||||||
Note that the result depends on the system. On MS-Windows
|
Note that the result depends on the system. On MS-Windows
|
||||||
a backslash usually means a path separator.
|
a backslash usually means a path separator.
|
||||||
|
|
||||||
*globpath()*
|
Can also be used as a |method|: >
|
||||||
|
GetExpr()->glob2regpat()
|
||||||
|
< *globpath()*
|
||||||
globpath({path}, {expr} [, {nosuf} [, {list} [, {alllinks}]]])
|
globpath({path}, {expr} [, {nosuf} [, {list} [, {alllinks}]]])
|
||||||
Perform glob() on all directories in {path} and concatenate
|
Perform glob() on all directories in {path} and concatenate
|
||||||
the results. Example: >
|
the results. Example: >
|
||||||
@@ -5704,6 +5722,10 @@ globpath({path}, {expr} [, {nosuf} [, {list} [, {alllinks}]]])
|
|||||||
< Upwards search and limiting the depth of "**" is not
|
< Upwards search and limiting the depth of "**" is not
|
||||||
supported, thus using 'path' will not always work properly.
|
supported, thus using 'path' will not always work properly.
|
||||||
|
|
||||||
|
Can also be used as a |method|, the base is passed as the
|
||||||
|
second argument: >
|
||||||
|
GetExpr()->globpath(&rtp)
|
||||||
|
<
|
||||||
*has()*
|
*has()*
|
||||||
has({feature}) The result is a Number, which is 1 if the feature {feature} is
|
has({feature}) The result is a Number, which is 1 if the feature {feature} is
|
||||||
supported, zero otherwise. The {feature} argument is a
|
supported, zero otherwise. The {feature} argument is a
|
||||||
|
@@ -584,15 +584,15 @@ static funcentry_T global_functions[] =
|
|||||||
{"gettabinfo", 0, 1, FEARG_1, f_gettabinfo},
|
{"gettabinfo", 0, 1, FEARG_1, f_gettabinfo},
|
||||||
{"gettabvar", 2, 3, FEARG_1, f_gettabvar},
|
{"gettabvar", 2, 3, FEARG_1, f_gettabvar},
|
||||||
{"gettabwinvar", 3, 4, FEARG_1, f_gettabwinvar},
|
{"gettabwinvar", 3, 4, FEARG_1, f_gettabwinvar},
|
||||||
{"gettagstack", 0, 1, 0, f_gettagstack},
|
{"gettagstack", 0, 1, FEARG_1, f_gettagstack},
|
||||||
{"getwininfo", 0, 1, 0, f_getwininfo},
|
{"getwininfo", 0, 1, FEARG_1, f_getwininfo},
|
||||||
{"getwinpos", 0, 1, 0, f_getwinpos},
|
{"getwinpos", 0, 1, FEARG_1, f_getwinpos},
|
||||||
{"getwinposx", 0, 0, 0, f_getwinposx},
|
{"getwinposx", 0, 0, 0, f_getwinposx},
|
||||||
{"getwinposy", 0, 0, 0, f_getwinposy},
|
{"getwinposy", 0, 0, 0, f_getwinposy},
|
||||||
{"getwinvar", 2, 3, 0, f_getwinvar},
|
{"getwinvar", 2, 3, FEARG_1, f_getwinvar},
|
||||||
{"glob", 1, 4, 0, f_glob},
|
{"glob", 1, 4, FEARG_1, f_glob},
|
||||||
{"glob2regpat", 1, 1, 0, f_glob2regpat},
|
{"glob2regpat", 1, 1, FEARG_1, f_glob2regpat},
|
||||||
{"globpath", 2, 5, 0, f_globpath},
|
{"globpath", 2, 5, FEARG_2, f_globpath},
|
||||||
{"has", 1, 1, 0, f_has},
|
{"has", 1, 1, 0, f_has},
|
||||||
{"has_key", 2, 2, FEARG_1, f_has_key},
|
{"has_key", 2, 2, FEARG_1, f_has_key},
|
||||||
{"haslocaldir", 0, 2, 0, f_haslocaldir},
|
{"haslocaldir", 0, 2, 0, f_haslocaldir},
|
||||||
|
@@ -77,7 +77,7 @@ function Test_getbufwintabinfo()
|
|||||||
|
|
||||||
call assert_equal('green', winlist[2].variables.signal)
|
call assert_equal('green', winlist[2].variables.signal)
|
||||||
call assert_equal(w4_id, winlist[3].winid)
|
call assert_equal(w4_id, winlist[3].winid)
|
||||||
let winfo = getwininfo(w5_id)[0]
|
let winfo = w5_id->getwininfo()[0]
|
||||||
call assert_equal(2, winfo.tabnr)
|
call assert_equal(2, winfo.tabnr)
|
||||||
call assert_equal([], getwininfo(3))
|
call assert_equal([], getwininfo(3))
|
||||||
|
|
||||||
|
@@ -16,7 +16,7 @@ function Test_glob()
|
|||||||
" Execute these commands in the sandbox, so that using the shell fails.
|
" Execute these commands in the sandbox, so that using the shell fails.
|
||||||
" Setting 'shell' to an invalid name causes a memory leak.
|
" Setting 'shell' to an invalid name causes a memory leak.
|
||||||
sandbox call assert_equal("", glob('Xxx\{'))
|
sandbox call assert_equal("", glob('Xxx\{'))
|
||||||
sandbox call assert_equal("", glob('Xxx\$'))
|
sandbox call assert_equal("", 'Xxx\$'->glob())
|
||||||
w! Xxx\{
|
w! Xxx\{
|
||||||
w! Xxx\$
|
w! Xxx\$
|
||||||
sandbox call assert_equal("Xxx{", glob('Xxx\{'))
|
sandbox call assert_equal("Xxx{", glob('Xxx\{'))
|
||||||
@@ -29,5 +29,5 @@ function Test_globpath()
|
|||||||
sandbox call assert_equal("sautest/autoload/globone.vim\nsautest/autoload/globtwo.vim",
|
sandbox call assert_equal("sautest/autoload/globone.vim\nsautest/autoload/globtwo.vim",
|
||||||
\ globpath('sautest/autoload', 'glob*.vim'))
|
\ globpath('sautest/autoload', 'glob*.vim'))
|
||||||
sandbox call assert_equal(['sautest/autoload/globone.vim', 'sautest/autoload/globtwo.vim'],
|
sandbox call assert_equal(['sautest/autoload/globone.vim', 'sautest/autoload/globtwo.vim'],
|
||||||
\ globpath('sautest/autoload', 'glob*.vim', 0, 1))
|
\ 'glob*.vim'->globpath('sautest/autoload', 0, 1))
|
||||||
endfunction
|
endfunction
|
||||||
|
@@ -12,8 +12,8 @@ func Test_var()
|
|||||||
let def_str = "Chance"
|
let def_str = "Chance"
|
||||||
call assert_equal('Dance', getwinvar(1, 'var_str'))
|
call assert_equal('Dance', getwinvar(1, 'var_str'))
|
||||||
call assert_equal('Dance', getwinvar(1, 'var_str', def_str))
|
call assert_equal('Dance', getwinvar(1, 'var_str', def_str))
|
||||||
call assert_equal({'var_str': 'Dance'}, getwinvar(1, ''))
|
call assert_equal({'var_str': 'Dance'}, 1->getwinvar(''))
|
||||||
call assert_equal({'var_str': 'Dance'}, getwinvar(1, '', def_str))
|
call assert_equal({'var_str': 'Dance'}, 1->getwinvar('', def_str))
|
||||||
unlet w:var_str
|
unlet w:var_str
|
||||||
call assert_equal('Chance', getwinvar(1, 'var_str', def_str))
|
call assert_equal('Chance', getwinvar(1, 'var_str', def_str))
|
||||||
call assert_equal({}, getwinvar(1, ''))
|
call assert_equal({}, getwinvar(1, ''))
|
||||||
|
@@ -8,7 +8,7 @@ endfunc
|
|||||||
|
|
||||||
func Test_glob2regpat_valid()
|
func Test_glob2regpat_valid()
|
||||||
call assert_equal('^foo\.', glob2regpat('foo.*'))
|
call assert_equal('^foo\.', glob2regpat('foo.*'))
|
||||||
call assert_equal('^foo.$', glob2regpat('foo?'))
|
call assert_equal('^foo.$', 'foo?'->glob2regpat())
|
||||||
call assert_equal('\.vim$', glob2regpat('*.vim'))
|
call assert_equal('\.vim$', glob2regpat('*.vim'))
|
||||||
call assert_equal('^[abc]$', glob2regpat('[abc]'))
|
call assert_equal('^[abc]$', glob2regpat('[abc]'))
|
||||||
call assert_equal('^foo bar$', glob2regpat('foo\ bar'))
|
call assert_equal('^foo bar$', glob2regpat('foo\ bar'))
|
||||||
|
@@ -268,7 +268,7 @@ func Test_getsettagstack()
|
|||||||
enew | only
|
enew | only
|
||||||
call settagstack(1, {'items' : []})
|
call settagstack(1, {'items' : []})
|
||||||
call assert_equal(0, gettagstack(1).length)
|
call assert_equal(0, gettagstack(1).length)
|
||||||
call assert_equal([], gettagstack(1).items)
|
call assert_equal([], 1->gettagstack().items)
|
||||||
" Error cases
|
" Error cases
|
||||||
call assert_equal({}, gettagstack(100))
|
call assert_equal({}, gettagstack(100))
|
||||||
call assert_equal(-1, settagstack(100, {'items' : []}))
|
call assert_equal(-1, settagstack(100, {'items' : []}))
|
||||||
|
@@ -2066,6 +2066,9 @@ func Test_terminal_getwinpos()
|
|||||||
" In the GUI it can be more, let's assume a 20 x 14 cell.
|
" In the GUI it can be more, let's assume a 20 x 14 cell.
|
||||||
" And then add 100 / 200 tolerance.
|
" And then add 100 / 200 tolerance.
|
||||||
let [xroot, yroot] = getwinpos()
|
let [xroot, yroot] = getwinpos()
|
||||||
|
let winpos = 50->getwinpos()
|
||||||
|
call assert_equal(xroot, winpos[0])
|
||||||
|
call assert_equal(yroot, winpos[1])
|
||||||
let [winrow, wincol] = win_screenpos('.')
|
let [winrow, wincol] = win_screenpos('.')
|
||||||
let xoff = wincol * (has('gui_running') ? 14 : 7) + 100
|
let xoff = wincol * (has('gui_running') ? 14 : 7) + 100
|
||||||
let yoff = winrow * (has('gui_running') ? 20 : 10) + 200
|
let yoff = winrow * (has('gui_running') ? 20 : 10) + 200
|
||||||
|
@@ -761,6 +761,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1952,
|
||||||
/**/
|
/**/
|
||||||
1951,
|
1951,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user