diff options
author | Thiago de Arruda <tpadilha84@gmail.com> | 2015-10-29 10:06:05 -0300 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2015-10-29 10:06:05 -0300 |
commit | 58962d89c8db631c04c35f84ca19eaf2c82b0059 (patch) | |
tree | bac981b93194b61b149e2e5a15baa5f95f5c852c /src | |
parent | 98b5ec565b955687ad7e2914378d999975b841df (diff) | |
parent | c2185833e83f05f7e252b40e56fbd5417e30cfd4 (diff) | |
download | rneovim-58962d89c8db631c04c35f84ca19eaf2c82b0059.tar.gz rneovim-58962d89c8db631c04c35f84ca19eaf2c82b0059.tar.bz2 rneovim-58962d89c8db631c04c35f84ca19eaf2c82b0059.zip |
Merge PR #3546 'Fix some regressions'
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/os/input.c | 8 | ||||
-rw-r--r-- | src/nvim/tui/tui.c | 22 |
2 files changed, 21 insertions, 9 deletions
diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c index df803609ae..ef6b5ff6f5 100644 --- a/src/nvim/os/input.c +++ b/src/nvim/os/input.c @@ -82,9 +82,11 @@ static void cursorhold_event(void **argv) static void create_cursorhold_event(void) { - // If the queue had any items, this function should not have been - // called(inbuf_poll would return kInputAvail) - assert(queue_empty(loop.events)); + // If events are enabled and the queue has any items, this function should not + // have been called(inbuf_poll would return kInputAvail) + // TODO(tarruda): Cursorhold should be implemented as a timer set during the + // `state_check` callback for the states where it can be triggered. + assert(!events_enabled || queue_empty(loop.events)); queue_put(loop.events, cursorhold_event, 0); } diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index c87f6d331b..c5f2950e62 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -43,7 +43,11 @@ typedef struct { TermInput input; uv_loop_t write_loop; unibi_term *ut; - uv_tty_t output_handle; + union { + uv_tty_t tty; + uv_pipe_t pipe; + } output_handle; + bool out_isatty; SignalWatcher winch_handle, cont_handle; bool cont_received; // Event scheduled by the ui bridge. Since the main thread suspends until @@ -116,8 +120,8 @@ static void terminfo_start(UI *ui) data->unibi_ext.enter_insert_mode = -1; data->unibi_ext.enter_replace_mode = -1; data->unibi_ext.exit_insert_mode = -1; - // write output to stderr if stdout is not a tty - data->out_fd = os_isatty(1) ? 1 : (os_isatty(2) ? 2 : 1); + data->out_fd = 1; + data->out_isatty = os_isatty(data->out_fd); // setup unibilium data->ut = unibi_from_env(); if (!data->ut) { @@ -132,8 +136,13 @@ static void terminfo_start(UI *ui) // Enable bracketed paste unibi_out(ui, data->unibi_ext.enable_bracketed_paste); uv_loop_init(&data->write_loop); - uv_tty_init(&data->write_loop, &data->output_handle, data->out_fd, 0); - uv_tty_set_mode(&data->output_handle, UV_TTY_MODE_RAW); + if (data->out_isatty) { + uv_tty_init(&data->write_loop, &data->output_handle.tty, data->out_fd, 0); + uv_tty_set_mode(&data->output_handle.tty, UV_TTY_MODE_RAW); + } else { + uv_pipe_init(&data->write_loop, &data->output_handle.pipe, 0); + uv_pipe_open(&data->output_handle.pipe, data->out_fd); + } } static void terminfo_stop(UI *ui) @@ -677,7 +686,8 @@ static void update_size(UI *ui) } // 2 - try from a system call(ioctl/TIOCGWINSZ on unix) - if (!uv_tty_get_winsize(&data->output_handle, &width, &height)) { + if (data->out_isatty && + !uv_tty_get_winsize(&data->output_handle.tty, &width, &height)) { goto end; } |