diff options
Diffstat (limited to 'src/nvim/os')
-rw-r--r-- | src/nvim/os/channel.c | 4 | ||||
-rw-r--r-- | src/nvim/os/input.c | 22 | ||||
-rw-r--r-- | src/nvim/os/signal.c | 5 |
3 files changed, 30 insertions, 1 deletions
diff --git a/src/nvim/os/channel.c b/src/nvim/os/channel.c index 22d31608a5..2c1928f3b3 100644 --- a/src/nvim/os/channel.c +++ b/src/nvim/os/channel.c @@ -67,6 +67,10 @@ void channel_init(void) channels = pmap_new(uint64_t)(); event_strings = pmap_new(cstr_t)(); msgpack_sbuffer_init(&out_buffer); + + if (embedded_mode) { + channel_from_stdio(); + } } /// Teardown the module diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c index 15aebdbf3d..53024d1389 100644 --- a/src/nvim/os/input.c +++ b/src/nvim/os/input.c @@ -6,6 +6,7 @@ #include "nvim/os/input.h" #include "nvim/os/event.h" +#include "nvim/os/signal.h" #include "nvim/os/rstream_defs.h" #include "nvim/os/rstream.h" #include "nvim/ascii.h" @@ -34,6 +35,10 @@ static bool eof = false, started_reading = false; void input_init(void) { + if (embedded_mode) { + return; + } + read_stream = rstream_new(read_cb, READ_BUFFER_SIZE, NULL, NULL); rstream_set_file(read_stream, read_cmd_fd); } @@ -41,18 +46,30 @@ void input_init(void) // Listen for input void input_start(void) { + if (embedded_mode) { + return; + } + rstream_start(read_stream); } // Stop listening for input void input_stop(void) { + if (embedded_mode) { + return; + } + rstream_stop(read_stream); } // Copies (at most `count`) of was read from `read_cmd_fd` into `buf` uint32_t input_read(char *buf, uint32_t count) { + if (embedded_mode) { + return 0; + } + return rstream_read(read_stream, buf, count); } @@ -129,6 +146,11 @@ bool os_isatty(int fd) static bool input_poll(int32_t ms) { + if (embedded_mode) { + EventSource input_sources[] = { signal_event_source(), NULL }; + return event_poll(ms, input_sources); + } + EventSource input_sources[] = { rstream_event_source(read_stream), NULL diff --git a/src/nvim/os/signal.c b/src/nvim/os/signal.c index 17f270a5cc..2f93cfb08a 100644 --- a/src/nvim/os/signal.c +++ b/src/nvim/os/signal.c @@ -39,7 +39,10 @@ void signal_init(void) uv_signal_start(&shup, signal_cb, SIGHUP); uv_signal_start(&squit, signal_cb, SIGQUIT); uv_signal_start(&sterm, signal_cb, SIGTERM); - uv_signal_start(&swinch, signal_cb, SIGWINCH); + if (!embedded_mode) { + // TODO(tarruda): There must be an API function for resizing window + uv_signal_start(&swinch, signal_cb, SIGWINCH); + } #ifdef SIGPWR uv_signal_init(uv_default_loop(), &spwr); uv_signal_start(&spwr, signal_cb, SIGPWR); |