mirror of
https://github.com/neovim/neovim.git
synced 2025-09-18 09:18:19 +00:00
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:
@@ -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
|
||||
|
Reference in New Issue
Block a user