aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/window.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/window.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/window.c')
-rw-r--r--src/nvim/api/window.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/nvim/api/window.c b/src/nvim/api/window.c
index 166e43f698..382f65e7d9 100644
--- a/src/nvim/api/window.c
+++ b/src/nvim/api/window.c
@@ -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