aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/tabpage.c
diff options
context:
space:
mode:
authorJames McCoy <jamessan@jamessan.com>2016-10-03 23:36:47 -0400
committerJames McCoy <jamessan@jamessan.com>2016-10-04 14:34:35 -0400
commit1ebb75b1ec5b22d7c7dba1c7fdc9e7969b81ad4d (patch)
tree9b2202052b77173d73efcdd7b34a273f25ff5caa /src/nvim/api/tabpage.c
parentb1edc8abb7e0f11064fde9d4b208fb06f0c16a35 (diff)
downloadrneovim-1ebb75b1ec5b22d7c7dba1c7fdc9e7969b81ad4d.tar.gz
rneovim-1ebb75b1ec5b22d7c7dba1c7fdc9e7969b81ad4d.tar.bz2
rneovim-1ebb75b1ec5b22d7c7dba1c7fdc9e7969b81ad4d.zip
api: Support getting the number of a window/tabpage
In order to provide better compatibility with the classic bindings, the API needs to provide the ability to query the number (really index) of the window/tabpage. This is needed for neovim/python-client#87, as discussed in neovim/neovim#1898. Signed-off-by: James McCoy <jamessan@jamessan.com>
Diffstat (limited to 'src/nvim/api/tabpage.c')
-rw-r--r--src/nvim/api/tabpage.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/nvim/api/tabpage.c b/src/nvim/api/tabpage.c
index 8b1fb041e2..fa00988ae3 100644
--- a/src/nvim/api/tabpage.c
+++ b/src/nvim/api/tabpage.c
@@ -159,6 +159,23 @@ Window nvim_tabpage_get_win(Tabpage tabpage, Error *err)
}
}
+/// Gets the tab page number
+///
+/// @param tabpage The tabpage handle
+/// @param[out] err Details of an error that may have occurred
+/// @return The tabpage number
+Integer nvim_tabpage_get_number(Tabpage tabpage, Error *err)
+{
+ Integer rv = 0;
+ tabpage_T *tab = find_tab_by_handle(tabpage, err);
+
+ if (!tab) {
+ return rv;
+ }
+
+ return tabpage_index(tab);
+}
+
/// Checks if a tab page is valid
///
/// @param tabpage The tab page handle