aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api
diff options
context:
space:
mode:
authorThiago de Arruda <tpadilha84@gmail.com>2014-05-28 09:05:13 -0300
committerThiago de Arruda <tpadilha84@gmail.com>2014-05-28 09:05:13 -0300
commite4fe2dbd777a59a9a9b386d960eb9dddc459e84e (patch)
treeaa99bd39c8a87c95f93457dcf4456caab45f7310 /src/nvim/api
parent1faf546ea286ae324c79cfef3b5613a0004182bb (diff)
parentcd8421537034d0b5cc567d81afc4fa5316da171e (diff)
downloadrneovim-e4fe2dbd777a59a9a9b386d960eb9dddc459e84e.tar.gz
rneovim-e4fe2dbd777a59a9a9b386d960eb9dddc459e84e.tar.bz2
rneovim-e4fe2dbd777a59a9a9b386d960eb9dddc459e84e.zip
Merge 'Refactor WStream to enable writing the same buffer to multiple targets'
Diffstat (limited to 'src/nvim/api')
-rw-r--r--src/nvim/api/buffer.c1
-rw-r--r--src/nvim/api/vim.c19
-rw-r--r--src/nvim/api/vim.h12
3 files changed, 32 insertions, 0 deletions
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c
index 4721045048..d2b4cafaac 100644
--- a/src/nvim/api/buffer.c
+++ b/src/nvim/api/buffer.c
@@ -121,6 +121,7 @@ end:
}
free(rv.items);
+ rv.items = NULL;
}
return rv;
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index 694781e0a3..39e2c32d6d 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -7,6 +7,7 @@
#include "nvim/api/private/helpers.h"
#include "nvim/api/private/defs.h"
#include "nvim/api/buffer.h"
+#include "nvim/os/channel.h"
#include "nvim/vim.h"
#include "nvim/buffer.h"
#include "nvim/window.h"
@@ -327,6 +328,24 @@ void vim_set_current_tabpage(Tabpage tabpage, Error *err)
try_end(err);
}
+void vim_subscribe(uint64_t channel_id, String event)
+{
+ size_t length = (event.size < EVENT_MAXLEN ? event.size : EVENT_MAXLEN);
+ char e[EVENT_MAXLEN + 1];
+ memcpy(e, event.data, length);
+ e[length] = NUL;
+ channel_subscribe(channel_id, e);
+}
+
+void vim_unsubscribe(uint64_t channel_id, String event)
+{
+ size_t length = (event.size < EVENT_MAXLEN ? event.size : EVENT_MAXLEN);
+ char e[EVENT_MAXLEN + 1];
+ memcpy(e, event.data, length);
+ e[length] = NUL;
+ channel_unsubscribe(channel_id, e);
+}
+
static void write_msg(String message, bool to_err)
{
static int pos = 0;
diff --git a/src/nvim/api/vim.h b/src/nvim/api/vim.h
index acfab11cf7..4d1ac9023e 100644
--- a/src/nvim/api/vim.h
+++ b/src/nvim/api/vim.h
@@ -155,5 +155,17 @@ Tabpage vim_get_current_tabpage(void);
/// @param[out] err Details of an error that may have occurred
void vim_set_current_tabpage(Tabpage tabpage, Error *err);
+/// Subscribes to event broadcasts
+///
+/// @param channel_id The channel id(passed automatically by the dispatcher)
+/// @param event The event type string
+void vim_subscribe(uint64_t channel_id, String event);
+
+/// Unsubscribes to event broadcasts
+///
+/// @param channel_id The channel id(passed automatically by the dispatcher)
+/// @param event The event type string
+void vim_unsubscribe(uint64_t channel_id, String event);
+
#endif // NVIM_API_VIM_H