API: Implement tabpage_get_window

This commit is contained in:
Thiago de Arruda 2014-05-11 11:12:11 -03:00
parent e026be46af
commit 14f2a3d533
2 changed files with 26 additions and 3 deletions

View File

@ -3,6 +3,7 @@
#include <stdlib.h>
#include "api/tabpage.h"
#include "api/vim.h"
#include "api/defs.h"
#include "api/helpers.h"
@ -36,9 +37,31 @@ Object tabpage_set_var(Tabpage tabpage, String name, Object value, Error *err)
return dict_set_value(tab->tp_vars, name, value, err);
}
Window tabpage_get_buffer(Tabpage tabpage, Error *err)
Window tabpage_get_window(Tabpage tabpage, Error *err)
{
abort();
Window rv = 0;
tabpage_T *tab = find_tab(tabpage, err);
if (!tab) {
return rv;
}
if (tab == curtab) {
return vim_get_current_window();
} else {
tabpage_T *tp;
win_T *wp;
rv = 1;
FOR_ALL_TAB_WINDOWS(tp, wp) {
if (tp == tab && wp == tab->tp_curwin) {
return rv;
}
rv++;
}
// There should always be a current window for a tabpage
abort();
}
}
bool tabpage_is_valid(Tabpage tabpage)

View File

@ -35,7 +35,7 @@ Object tabpage_set_var(Tabpage tabpage, String name, Object value, Error *err);
/// @param tabpage The tab page handle
/// @param[out] err Details of an error that may have occurred
/// @return The Window handle
Window tabpage_get_buffer(Tabpage tabpage, Error *err);
Window tabpage_get_window(Tabpage tabpage, Error *err);
/// Checks if a tab page is valid
///