mirror of
https://github.com/vim/vim.git
synced 2025-09-29 04:34:16 -04:00
patch 8.1.0307: there is no good way to get the window layout
Problem: There is no good way to get the window layout. Solution: Add the winlayout() function. (Yegappan Lakshmanan)
This commit is contained in:
49
src/window.c
49
src/window.c
@@ -7236,4 +7236,53 @@ win_findbuf(typval_T *argvars, list_T *list)
|
||||
list_append_number(list, wp->w_id);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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
|
||||
|
Reference in New Issue
Block a user