diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2019-05-25 21:59:33 -0400 |
---|---|---|
committer | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2019-05-26 07:27:50 -0400 |
commit | f60af8694b5fd7339e3b9883f6bc5be34852fd14 (patch) | |
tree | 4cab97c1a3ffc974d79afc01f4e7b6bb60dbc846 /src/nvim/window.c | |
parent | 08aa9b00237ab45dadeffdf381e0e3c228337e53 (diff) | |
download | rneovim-f60af8694b5fd7339e3b9883f6bc5be34852fd14.tar.gz rneovim-f60af8694b5fd7339e3b9883f6bc5be34852fd14.tar.bz2 rneovim-f60af8694b5fd7339e3b9883f6bc5be34852fd14.zip |
vim-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)
https://github.com/vim/vim/commit/0f6b4f06dece71487a6d8546c50de775d9c8c287
Diffstat (limited to 'src/nvim/window.c')
-rw-r--r-- | src/nvim/window.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/nvim/window.c b/src/nvim/window.c index 2ce3b7067b..e6b19cf88d 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -6658,6 +6658,41 @@ void win_findbuf(typval_T *argvars, list_T *list) } } +// Get the layout of the given tab page for winlayout(). +void get_framelayout(const frame_T *fr, list_T *l, bool outer) +{ + list_T *fr_list; + + if (fr == NULL) { + return; + } + + if (outer) { + // outermost call from f_winlayout() + fr_list = l; + } else { + fr_list = tv_list_alloc(2); + tv_list_append_list(l, fr_list); + } + + if (fr->fr_layout == FR_LEAF) { + if (fr->fr_win != NULL) { + tv_list_append_string(fr_list, "leaf", -1); + tv_list_append_number(fr_list, fr->fr_win->handle); + } + } else { + tv_list_append_string(fr_list, fr->fr_layout == FR_ROW ? "row" : "col", -1); + + list_T *const win_list = tv_list_alloc(kListLenUnknown); + tv_list_append_list(fr_list, win_list); + const frame_T *child = fr->fr_child; + while (child != NULL) { + get_framelayout(child, win_list, false); + child = child->fr_next; + } + } +} + void win_ui_flush_positions(void) { FOR_ALL_TAB_WINDOWS(tp, wp) { |