diff options
author | Thiago de Arruda <tpadilha84@gmail.com> | 2014-05-23 15:49:44 -0300 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-05-23 16:06:58 -0300 |
commit | a842fe4dc1e0624a6332ee0fef40517e7925dfb4 (patch) | |
tree | a7a870dcff8ddbaaf00d7a4eb78b209dfc0b1ad5 /src/nvim/api/tabpage.c | |
parent | f70f9bfac1ae62828d222bc6ccb528e6e93be523 (diff) | |
download | rneovim-a842fe4dc1e0624a6332ee0fef40517e7925dfb4.tar.gz rneovim-a842fe4dc1e0624a6332ee0fef40517e7925dfb4.tar.bz2 rneovim-a842fe4dc1e0624a6332ee0fef40517e7925dfb4.zip |
API: Refactor: Return handles instead of indexes
- Define specialized arrays for each remote object type
- Implement msgpack_rpc functions for dealing with the new types
- Refactor all functions dealing with buffers, windows and tabpages to
return/accept handles instead of list indexes.
Diffstat (limited to 'src/nvim/api/tabpage.c')
-rw-r--r-- | src/nvim/api/tabpage.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/nvim/api/tabpage.c b/src/nvim/api/tabpage.c index f4e5f2857a..58efc6a514 100644 --- a/src/nvim/api/tabpage.c +++ b/src/nvim/api/tabpage.c @@ -6,10 +6,11 @@ #include "nvim/api/vim.h" #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" +#include "nvim/memory.h" -Integer tabpage_get_window_count(Tabpage tabpage, Error *err) +WindowArray tabpage_get_windows(Tabpage tabpage, Error *err) { - Integer rv = 0; + WindowArray rv = {.size = 0}; tabpage_T *tab = find_tab(tabpage, err); if (!tab) { @@ -23,7 +24,17 @@ Integer tabpage_get_window_count(Tabpage tabpage, Error *err) if (tp != tab) { break; } - rv++; + rv.size++; + } + + rv.items = xmalloc(sizeof(Window) * rv.size); + size_t i = 0; + + FOR_ALL_TAB_WINDOWS(tp, wp) { + if (tp != tab) { + break; + } + rv.items[i++] = wp->handle; } return rv; @@ -67,13 +78,11 @@ Window tabpage_get_window(Tabpage tabpage, Error *err) } else { tabpage_T *tp; win_T *wp; - rv = 1; FOR_ALL_TAB_WINDOWS(tp, wp) { if (tp == tab && wp == tab->tp_curwin) { - return rv; + return wp->handle; } - rv++; } // There should always be a current window for a tabpage abort(); |