aboutsummaryrefslogtreecommitdiff
path: root/src/api/helpers.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/helpers.c')
-rw-r--r--src/api/helpers.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/api/helpers.c b/src/api/helpers.c
index 40888f351d..9b7ff5fc7c 100644
--- a/src/api/helpers.c
+++ b/src/api/helpers.c
@@ -5,6 +5,7 @@
#include "api/helpers.h"
#include "api/defs.h"
#include "../vim.h"
+#include "../buffer.h"
#include "../window.h"
#include "memory.h"
#include "eval.h"
@@ -266,6 +267,32 @@ Object vim_to_object(typval_T *obj)
return rv;
}
+buf_T *find_buffer(Buffer buffer, Error *err)
+{
+ buf_T *buf = buflist_findnr(buffer);
+
+ if (buf == NULL) {
+ set_api_error("Invalid buffer id", err);
+ }
+
+ return buf;
+}
+
+win_T * find_window(Window window, Error *err)
+{
+ tabpage_T *tp;
+ win_T *wp;
+
+ FOR_ALL_TAB_WINDOWS(tp, wp) {
+ if (!--window) {
+ return wp;
+ }
+ }
+
+ set_api_error("Invalid window id", err);
+ return NULL;
+}
+
static bool object_to_vim(Object obj, typval_T *tv, Error *err)
{
tv->v_type = VAR_UNKNOWN;