summaryrefslogtreecommitdiff
path: root/src/window.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-08-21 16:56:34 +0200
committerBram Moolenaar <Bram@vim.org>2018-08-21 16:56:34 +0200
commit0f6b4f06dece71487a6d8546c50de775d9c8c287 (patch)
tree4801fcd4f84a5de0bcf7ba0d0dff832a8a192746 /src/window.c
parentda6e8919e75fa8f961d1b805e877c8a92e76dafb (diff)
downloadvim-git-0f6b4f06dece71487a6d8546c50de775d9c8c287.tar.gz
patch 8.1.0307: there is no good way to get the window layoutv8.1.0307
Problem: There is no good way to get the window layout. Solution: Add the winlayout() function. (Yegappan Lakshmanan)
Diffstat (limited to 'src/window.c')
-rw-r--r--src/window.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/window.c b/src/window.c
index e1781d3f4..5671cf900 100644
--- a/src/window.c
+++ b/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