1
0
forked from aniani/vim

patch 7.4.2204

Problem:    It is not easy to get information about buffers, windows and
            tabpages.
Solution:   Add getbufinfo(), getwininfo() and gettabinfo(). (Yegappan
            Lakshmanan)
This commit is contained in:
Bram Moolenaar
2016-08-12 22:23:25 +02:00
parent ebcccad573
commit b5ae48e9ff
13 changed files with 528 additions and 1 deletions

View File

@@ -2081,6 +2081,7 @@ garbagecollect([{atexit}]) none free memory, breaking cyclic references
get({list}, {idx} [, {def}]) any get item {idx} from {list} or {def}
get({dict}, {key} [, {def}]) any get item {key} from {dict} or {def}
get({func}, {what}) any get property of funcref/partial {func}
getbufinfo( [{expr}]) List information about buffers
getbufline({expr}, {lnum} [, {end}])
List lines {lnum} to {end} of buffer {expr}
getbufvar({expr}, {varname} [, {def}])
@@ -2110,10 +2111,12 @@ getqflist([{what}]) List list of quickfix items
getreg([{regname} [, 1 [, {list}]]])
String or List contents of register
getregtype([{regname}]) String type of register
gettabinfo( [{expr}]) List list of tab pages
gettabvar({nr}, {varname} [, {def}])
any variable {varname} in tab {nr} or {def}
gettabwinvar({tabnr}, {winnr}, {name} [, {def}])
any {name} in {winnr} in tab page {tabnr}
getwininfo( [{winid}]) List list of windows
getwinposx() Number X coord in pixels of GUI Vim window
getwinposy() Number Y coord in pixels of GUI Vim window
getwinvar({nr}, {varname} [, {def}])
@@ -3976,6 +3979,55 @@ get({func}, {what})
'dict' The dictionary
'args' The list with arguments
*getbufinfo()*
getbufinfo([{expr}])
getbufinfo([{dict}])
Get information aobut buffers as a List of Dictionaries.
Without an argument information about all the buffers is
returned.
When the argument is a Dictionary only the buffers matching
the specified criteria are returned. The following keys can
be specified in {dict}:
buflisted include only listed buffers.
bufloaded include only loaded buffers.
Otherwise, {expr} specifies a particular buffer to return
information for. For the use of {expr}, see |bufname()|
above. If the buffer is found the returned List has one item.
Otherwise the result is an empty list.
Each returned List item is a dictionary with the following
entries:
changed TRUE if the buffer is modified.
changedtick number of changes made to the buffer.
hidden TRUE if the buffer is hidden.
listed TRUE if the buffer is listed.
lnum current line number in buffer.
loaded TRUE if the buffer is loaded.
name full path to the file in the buffer.
nr buffer number.
options dictionary of buffer local options.
signs list of signs placed in the buffer.
Each list item is a dictionary with
the following fields:
id sign identifier
lnum line number
name sign name
variables dictionary of buffer local variables.
windows list of window IDs with this buffer
Examples: >
for buf in getbufinfo()
echo buf.name
endfor
for buf in getbufinfo({'buflisted':1})
if buf.options.filetype == 'java'
....
endif
endfor
<
*getbufline()*
getbufline({expr}, {lnum} [, {end}])
Return a |List| with the lines starting from {lnum} to {end}
@@ -4461,6 +4513,18 @@ getregtype([{regname}]) *getregtype()*
<CTRL-V> is one character with value 0x16.
If {regname} is not specified, |v:register| is used.
gettabinfo([{arg}]) *gettabinfo()*
If {arg} is not specified, then information about all the tab
pages is returned as a List. Each List item is a Dictionary.
Otherwise, {arg} specifies the tab page number and information
about that one is returned. If the tab page does not exist an
empty List is returned.
Each List item is a Dictionary with the following entries:
nr tab page number.
windows List of window IDs in the tag page.
variables dictionary of tabpage local variables.
gettabvar({tabnr}, {varname} [, {def}]) *gettabvar()*
Get the value of a tab-local variable {varname} in tab page
{tabnr}. |t:var|
@@ -4502,6 +4566,26 @@ getwinposy() The result is a Number, which is the Y coordinate in pixels of
the top of the GUI Vim window. The result will be -1 if the
information is not available.
getwininfo([{winid}]) *getwininfo()*
Returns information about windows as a List with Dictionaries.
If {winid} is given Information about the window with that ID
is returned. If the window does not exist the result is an
empty list.
Without an information about all the windows in all the tab
pages is returned.
Each List item is a Dictionary with the following entries:
nr window number.
tpnr tab page number.
winid window ID.
height window height.
width window width.
bufnum number of buffer in the window.
options dictionary of window local options.
variables dictionary of window local variables.
getwinvar({winnr}, {varname} [, {def}]) *getwinvar()*
Like |gettabwinvar()| for the current tabpage.
Examples: >

View File

@@ -1,4 +1,4 @@
*usr_41.txt* For Vim version 7.4. Last change: 2016 Jul 24
*usr_41.txt* For Vim version 7.4. Last change: 2016 Aug 07
VIM USER MANUAL - by Bram Moolenaar
@@ -803,6 +803,9 @@ Buffers, windows and the argument list:
win_gotoid() go to window with ID
win_id2tabwin() get tab and window nr from window ID
win_id2win() get window nr from window ID
getbufinfo() get a list with buffer information
gettabinfo() get a list with tab page information
getwininfo() get a list with window information
Command line: *command-line-functions*
getcmdline() get the current command line
@@ -957,7 +960,10 @@ Jobs: *job-functions*
Timers: *timer-functions*
timer_start() create a timer
timer_pause() pause or unpause a timer
timer_stop() stop a timer
timer_stopall() stop all timers
timer_info() get information about timers
Various: *various-functions*
mode() get current editing mode