diff options
author | erw7 <erw7.github@gmail.com> | 2019-04-28 18:46:48 +0900 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2019-04-28 11:46:48 +0200 |
commit | 8072f085d2edc254334af52261c6ff68d9143834 (patch) | |
tree | c40d4363047951fc97215a0e5ead755ce1a4edfd | |
parent | cf80fd9e02422f90ecb967aacf7a5549246b4689 (diff) | |
download | rneovim-8072f085d2edc254334af52261c6ff68d9143834.tar.gz rneovim-8072f085d2edc254334af52261c6ff68d9143834.tar.bz2 rneovim-8072f085d2edc254334af52261c6ff68d9143834.zip |
win: stream_init() issue with tty on Windows #9884
ref #9825
-rw-r--r-- | src/nvim/event/rstream.c | 10 | ||||
-rw-r--r-- | src/nvim/event/stream.c | 10 | ||||
-rw-r--r-- | src/nvim/event/stream.h | 3 | ||||
-rw-r--r-- | src/nvim/tui/input.c | 8 | ||||
-rw-r--r-- | src/nvim/tui/input.h | 3 |
5 files changed, 19 insertions, 15 deletions
diff --git a/src/nvim/event/rstream.c b/src/nvim/event/rstream.c index 6812b342bf..19907d2e45 100644 --- a/src/nvim/event/rstream.c +++ b/src/nvim/event/rstream.c @@ -21,16 +21,14 @@ #endif void rstream_init_fd(Loop *loop, Stream *stream, int fd, size_t bufsize) - FUNC_ATTR_NONNULL_ARG(1) - FUNC_ATTR_NONNULL_ARG(2) + FUNC_ATTR_NONNULL_ARG(1, 2) { stream_init(loop, stream, fd, NULL); rstream_init(stream, bufsize); } void rstream_init_stream(Stream *stream, uv_stream_t *uvstream, size_t bufsize) - FUNC_ATTR_NONNULL_ARG(1) - FUNC_ATTR_NONNULL_ARG(2) + FUNC_ATTR_NONNULL_ARG(1, 2) { stream_init(NULL, stream, -1, uvstream); rstream_init(stream, bufsize); @@ -138,6 +136,10 @@ static void read_cb(uv_stream_t *uvstream, ssize_t cnt, const uv_buf_t *buf) } // Called by the by the 'idle' handle to emulate a reading event +// +// Idle callbacks are invoked once per event loop: +// - to perform some very low priority activity. +// - to keep the loop "alive" (so there is always an event to process) static void fread_idle_cb(uv_idle_t *handle) { uv_fs_t req; diff --git a/src/nvim/event/stream.c b/src/nvim/event/stream.c index ba25b76ec7..70b1d890d6 100644 --- a/src/nvim/event/stream.c +++ b/src/nvim/event/stream.c @@ -53,9 +53,19 @@ void stream_init(Loop *loop, Stream *stream, int fd, uv_stream_t *uvstream) stream->uv.idle.data = stream; } else { assert(type == UV_NAMED_PIPE || type == UV_TTY); +#ifdef WIN32 + if (type == UV_TTY) { + uv_tty_init(&loop->uv, &stream->uv.tty, fd, 0); + uv_tty_set_mode(&stream->uv.tty, UV_TTY_MODE_RAW); + stream->uvstream = STRUCT_CAST(uv_stream_t, &stream->uv.tty); + } else { +#endif uv_pipe_init(&loop->uv, &stream->uv.pipe, 0); uv_pipe_open(&stream->uv.pipe, fd); stream->uvstream = STRUCT_CAST(uv_stream_t, &stream->uv.pipe); +#ifdef WIN32 + } +#endif } } diff --git a/src/nvim/event/stream.h b/src/nvim/event/stream.h index 694dab6568..a5c33a66a2 100644 --- a/src/nvim/event/stream.h +++ b/src/nvim/event/stream.h @@ -36,6 +36,9 @@ struct stream { uv_pipe_t pipe; uv_tcp_t tcp; uv_idle_t idle; +#ifdef WIN32 + uv_tty_t tty; +#endif } uv; uv_stream_t *uvstream; uv_buf_t uvbuf; diff --git a/src/nvim/tui/input.c b/src/nvim/tui/input.c index 04decb1a8c..6d9023bd79 100644 --- a/src/nvim/tui/input.c +++ b/src/nvim/tui/input.c @@ -49,15 +49,7 @@ void tinput_init(TermInput *input, Loop *loop) int curflags = termkey_get_canonflags(input->tk); termkey_set_canonflags(input->tk, curflags | TERMKEY_CANON_DELBS); // setup input handle -#ifdef WIN32 - uv_tty_init(&loop->uv, &input->tty_in, 0, 1); - uv_tty_set_mode(&input->tty_in, UV_TTY_MODE_RAW); - rstream_init_stream(&input->read_stream, - (uv_stream_t *)&input->tty_in, - 0xfff); -#else rstream_init_fd(loop, &input->read_stream, input->in_fd, 0xfff); -#endif // initialize a timer handle for handling ESC with libtermkey time_watcher_init(loop, &input->timer_handle, input); } diff --git a/src/nvim/tui/input.h b/src/nvim/tui/input.h index 573cc9d683..7d59cf5c6a 100644 --- a/src/nvim/tui/input.h +++ b/src/nvim/tui/input.h @@ -17,9 +17,6 @@ typedef struct term_input { #endif TimeWatcher timer_handle; Loop *loop; -#ifdef WIN32 - uv_tty_t tty_in; -#endif Stream read_stream; RBuffer *key_buffer; uv_mutex_t key_buffer_mutex; |