aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/os
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2017-04-28 20:37:52 +0200
committerGitHub <noreply@github.com>2017-04-28 20:37:52 +0200
commit129f107c0c26fbf371bcf165ec20eb13356bfb8e (patch)
tree864bf25c65c6cfcd4e17c0ebd04afdad1342c268 /src/nvim/os
parent7044aa6e8256844bc1bd23eb61d4a41ca6d418d0 (diff)
parent8f59d1483934f91011b755406251136c406e77f6 (diff)
downloadrneovim-129f107c0c26fbf371bcf165ec20eb13356bfb8e.tar.gz
rneovim-129f107c0c26fbf371bcf165ec20eb13356bfb8e.tar.bz2
rneovim-129f107c0c26fbf371bcf165ec20eb13356bfb8e.zip
Merge #6247 'api: nvim_get_mode()'
Diffstat (limited to 'src/nvim/os')
-rw-r--r--src/nvim/os/input.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c
index 7b5e14dd19..31e06ce404 100644
--- a/src/nvim/os/input.c
+++ b/src/nvim/os/input.c
@@ -23,6 +23,7 @@
#include "nvim/main.h"
#include "nvim/misc1.h"
#include "nvim/state.h"
+#include "nvim/msgpack_rpc/channel.h"
#define READ_BUFFER_SIZE 0xfff
#define INPUT_BUFFER_SIZE (READ_BUFFER_SIZE * 4)
@@ -38,6 +39,7 @@ static RBuffer *input_buffer = NULL;
static bool input_eof = false;
static int global_fd = 0;
static int events_enabled = 0;
+static bool blocking = false;
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "os/input.c.generated.h"
@@ -327,13 +329,25 @@ static unsigned int handle_mouse_event(char **ptr, uint8_t *buf,
return bufsize;
}
+/// @return true if the main loop is blocked and waiting for input.
+bool input_blocking(void)
+{
+ return blocking;
+}
+
static bool input_poll(int ms)
{
if (do_profiling == PROF_YES && ms) {
prof_inchar_enter();
}
+ if ((ms == - 1 || ms > 0) && !events_enabled && !input_eof) {
+ // The pending input provoked a blocking wait. Do special events now. #6247
+ blocking = true;
+ multiqueue_process_events(ch_before_blocking_events);
+ }
LOOP_PROCESS_EVENTS_UNTIL(&main_loop, NULL, ms, input_ready() || input_eof);
+ blocking = false;
if (do_profiling == PROF_YES && ms) {
prof_inchar_exit();