From 3800b24c5abecfb9d1ed1d5d36ddcd5a31a45609 Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Wed, 29 Oct 2014 23:06:18 -0300 Subject: api: Add vim_input function and mark vim_feedkeys as deferred The `vim_feedkeys` must be deferred because it can potentially free the buffer passed to `os_inchar`(which in turns calls `vim_feedkeys` indirectly). The new `vim_input` function can be used to emulate user input(Since it does not mess with the typeahead, it is safe to execute without deferring). --- src/nvim/os/input.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/nvim/os/input.c') diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c index 1b1a681a8b..d948a48b64 100644 --- a/src/nvim/os/input.c +++ b/src/nvim/os/input.c @@ -165,6 +165,13 @@ void input_buffer_restore(String str) free(str.data); } +size_t input_enqueue(String keys) +{ + size_t rv = rbuffer_write(input_buffer, keys.data, keys.size); + process_interrupts(); + return rv; +} + static bool input_poll(int ms) { event_poll_until(ms, input_ready()); -- cgit