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>
This commit is contained in:
James McCoy
2016-10-03 23:36:47 -04:00
parent b1edc8abb7
commit 1ebb75b1ec
5 changed files with 104 additions and 26 deletions

View File

@@ -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