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

@@ -341,6 +341,26 @@ Tabpage nvim_win_get_tabpage(Window window, Error *err)
return rv;
}
/// Gets the window number
///
/// @param window The window handle
/// @param[out] err Details of an error that may have occurred
/// @return The window number
Integer nvim_win_get_number(Window window, Error *err)
{
Integer rv = 0;
win_T *win = find_window_by_handle(window, err);
if (!win) {
return rv;
}
int tabnr;
win_get_tabwin(window, &tabnr, (int *)&rv);
return rv;
}
/// Checks if a window is valid
///
/// @param window The window handle