Hi all,
On Mon, Aug 8, 2016 at 4:37 PM, Yegappan Lakshmanan <[email protected]> wrote:
>
>>
>> By the way, I remember some patches that add functions returning
>> information about buffer/window/tabpage. It would be logical if
>> information regarding whether given buffer contains
>> quickfix/location/no list was included there.
>>
>
> I agree. The patch to get information about a buffer/window/tab page
> is at:
>
> https://github.com/vim/vim/pull/833
>
> The information about the quickfix/location list window/buffer can be
> added to this patch.
>
I am attaching a patch to add two new fields to the dict returned
by the getwininfo() function. The 'qfwin' field is set to true for the
quickfix window and the 'llwin' field is set to true for the location
list window.
In this patch I also made some other minor changes. Updated the
help text for getwinfo() and gettabinfo() to alphabetically sort the
field names. Used the FOR_ALL_BUFFERS() and FOR_ALL_TABPAGES()
macros for walking all the buffers and tab pages in the f_getbufinfo(),
f_gettabinfo() and f_getwininfo() functions.
- Yegappan
> Another alternative is the patch I sent two weeks ago to extend the
> getqflist() and getloclist() functions. The returned dictionary contains
> the 'winid' key which has the window ID of the quickfix or location
> list window.
>
> - Yegappan
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 6c81575..828ac49 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -4527,8 +4527,8 @@ gettabinfo([{arg}])
*gettabinfo()*
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.
+ windows List of window IDs in the tag page.
gettabvar({tabnr}, {varname} [, {def}])
*gettabvar()*
Get the value of a tab-local variable {varname} in tab page
@@ -4582,14 +4582,16 @@ getwininfo([{winid}])
*getwininfo()*
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.
+ height window height.
+ llwin set to true for location list window
+ nr window number.
options dictionary of window local options.
+ qfwin set to true for quickfix window
+ tpnr tab page number.
variables dictionary of window local variables.
+ width window width.
+ winid window ID.
getwinvar({winnr}, {varname} [, {def}])
*getwinvar()*
Like |gettabwinvar()| for the current tabpage.
diff --git a/src/evalfunc.c b/src/evalfunc.c
index ba6f0f5..13a856c 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -4027,7 +4027,7 @@ f_getbufinfo(typval_T *argvars, typval_T *rettv)
}
/* Return information about all the buffers or a specified buffer */
- for (buf = firstbuf; buf != NULL; buf = buf->b_next)
+ FOR_ALL_BUFFERS(buf)
{
if (argbuf != NULL && argbuf != buf)
continue;
@@ -5030,7 +5030,7 @@ f_gettabinfo(typval_T *argvars, typval_T *rettv)
#ifdef FEAT_WINDOWS
tabpage_T *tp, *tparg = NULL;
dict_T *d;
- int tpnr = 1;
+ int tpnr = 0;
if (rettv_list_alloc(rettv) != OK)
return;
@@ -5044,8 +5044,9 @@ f_gettabinfo(typval_T *argvars, typval_T *rettv)
}
/* Get information about a specific tab page or all tab pages */
- for (tp = first_tabpage; tp != NULL; tp = tp->tp_next, tpnr++)
+ FOR_ALL_TABPAGES(tp)
{
+ tpnr++;
if (tparg != NULL && tp != tparg)
continue;
d = get_tabpage_info(tp, tpnr);
@@ -5131,6 +5132,13 @@ get_win_info(win_T *wp, short tpnr, short winnr)
dict_add_nr_str(dict, "width", wp->w_width, NULL);
dict_add_nr_str(dict, "bufnum", wp->w_buffer->b_fnum, NULL);
+#ifdef FEAT_QUICKFIX
+ dict_add_nr_str(dict, "qfwin",
+ (bt_quickfix(wp->w_buffer) && wp->w_llist_ref == NULL), NULL);
+ dict_add_nr_str(dict, "llwin",
+ (bt_quickfix(wp->w_buffer) && wp->w_llist_ref != NULL), NULL);
+#endif
+
/* Copy window variables */
vars = dict_copy(wp->w_vars, TRUE, 0);
if (vars != NULL)
@@ -5155,7 +5163,7 @@ f_getwininfo(typval_T *argvars, typval_T *rettv)
tabpage_T *tp;
win_T *wp = NULL, *wparg = NULL;
dict_T *d;
- short tabnr, winnr;
+ short tabnr = 0, winnr;
#endif
if (rettv_list_alloc(rettv) != OK)
@@ -5172,13 +5180,13 @@ f_getwininfo(typval_T *argvars, typval_T *rettv)
/* Collect information about either all the windows across all the tab
* pages or one particular window.
*/
- tabnr = 1;
- for (tp = first_tabpage; tp != NULL; tp = tp->tp_next, tabnr++)
+ FOR_ALL_TABPAGES(tp)
{
- wp = (tp == curtab) ? firstwin : tp->tp_firstwin;
- winnr = 1;
- for (; wp; wp = wp->w_next, winnr++)
+ tabnr++;
+ winnr = 0;
+ FOR_ALL_WINDOWS_IN_TAB(tp, wp)
{
+ winnr++;
if (wparg != NULL && wp != wparg)
continue;
d = get_win_info(wp, tabnr, winnr);