aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2017-12-14 00:24:35 +0100
committerGitHub <noreply@github.com>2017-12-14 00:24:35 +0100
commit6ff13d78b7eb0a1fae2e2e8cdd054072e1467158 (patch)
treee52065c81ca5caec6370def83147094e6e93917d /src
parent7164f618504bb1b3374da1bcc26c6cf2ac8b3f86 (diff)
parented92ece815e1f32259b3f0397476ff6ac92726e3 (diff)
downloadrneovim-6ff13d78b7eb0a1fae2e2e8cdd054072e1467158.tar.gz
rneovim-6ff13d78b7eb0a1fae2e2e8cdd054072e1467158.tar.bz2
rneovim-6ff13d78b7eb0a1fae2e2e8cdd054072e1467158.zip
Merge #7720 'tui: rework deferred-termcodes implementation'
Diffstat (limited to 'src')
-rw-r--r--src/nvim/os/pty_process_unix.c8
-rw-r--r--src/nvim/os/signal.c3
-rw-r--r--src/nvim/tui/tui.c42
-rw-r--r--src/nvim/ui.h2
4 files changed, 27 insertions, 28 deletions
diff --git a/src/nvim/os/pty_process_unix.c b/src/nvim/os/pty_process_unix.c
index 53301e4b53..855ca2ae47 100644
--- a/src/nvim/os/pty_process_unix.c
+++ b/src/nvim/os/pty_process_unix.c
@@ -72,8 +72,7 @@ int pty_process_spawn(PtyProcess *ptyproc)
ELOG("forkpty failed: %s", strerror(errno));
return status;
} else if (pid == 0) {
- init_child(ptyproc);
- abort();
+ init_child(ptyproc); // never returns
}
// make sure the master file descriptor is non blocking
@@ -163,14 +162,15 @@ static void init_child(PtyProcess *ptyproc) FUNC_ATTR_NONNULL_ALL
Process *proc = (Process *)ptyproc;
if (proc->cwd && os_chdir(proc->cwd) != 0) {
- fprintf(stderr, "chdir failed: %s\n", strerror(errno));
+ ELOG("chdir failed: %s", strerror(errno));
return;
}
char *prog = ptyproc->process.argv[0];
setenv("TERM", ptyproc->term_name ? ptyproc->term_name : "ansi", 1);
execvp(prog, ptyproc->process.argv);
- fprintf(stderr, "execvp failed: %s: %s\n", strerror(errno), prog);
+ ELOG("execvp failed: %s: %s", strerror(errno), prog);
+ _exit(122); // 122 is EXEC_FAILED in the Vim source.
}
static void init_termios(struct termios *termios) FUNC_ATTR_NONNULL_ALL
diff --git a/src/nvim/os/signal.c b/src/nvim/os/signal.c
index fd6d3b32e4..732be072e1 100644
--- a/src/nvim/os/signal.c
+++ b/src/nvim/os/signal.c
@@ -10,6 +10,7 @@
#endif
#include "nvim/ascii.h"
+#include "nvim/log.h"
#include "nvim/vim.h"
#include "nvim/globals.h"
#include "nvim/memline.h"
@@ -162,7 +163,7 @@ static void on_signal(SignalWatcher *handle, int signum, void *data)
}
break;
default:
- fprintf(stderr, "Invalid signal %d", signum);
+ ELOG("invalid signal: %d", signum);
break;
}
}
diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c
index 49aa41b9b0..b8f43e9d13 100644
--- a/src/nvim/tui/tui.c
+++ b/src/nvim/tui/tui.c
@@ -70,6 +70,7 @@ typedef struct {
UIBridgeData *bridge;
Loop *loop;
bool stop;
+ uv_timer_t after_startup_timer;
unibi_var_t params[9];
char buf[OUTBUF_SIZE];
size_t bufpos;
@@ -169,24 +170,6 @@ static size_t unibi_pre_fmt_str(TUIData *data, unsigned int unibi_index,
return unibi_run(str, data->params, buf, len);
}
-/// Emits some termcodes after Nvim startup, which were observed to slowdown
-/// rendering during startup in tmux 2.3 (+focus-events). #7649
-static void terminfo_after_startup_event(void **argv)
-{
- UI *ui = argv[0];
- bool defer = argv[1] != NULL; // clever(?) boolean without malloc() dance.
- TUIData *data = ui->data;
- if (defer) { // We're on the main-loop. Now forward to the TUI loop.
- loop_schedule(data->loop,
- event_create(terminfo_after_startup_event, 2, ui, NULL));
- return;
- }
- // Enable bracketed paste
- unibi_out_ext(ui, data->unibi_ext.enable_bracketed_paste);
- // Enable focus reporting
- unibi_out_ext(ui, data->unibi_ext.enable_focus_reporting);
-}
-
static void termname_set_event(void **argv)
{
char *termname = argv[0];
@@ -266,6 +249,9 @@ static void terminfo_start(UI *ui)
unibi_out(ui, unibi_enter_ca_mode);
unibi_out(ui, unibi_keypad_xmit);
unibi_out(ui, unibi_clear_screen);
+ // Enable bracketed paste
+ unibi_out_ext(ui, data->unibi_ext.enable_bracketed_paste);
+
uv_loop_init(&data->write_loop);
if (data->out_isatty) {
uv_tty_init(&data->write_loop, &data->output_handle.tty, data->out_fd, 0);
@@ -278,9 +264,6 @@ static void terminfo_start(UI *ui)
uv_pipe_init(&data->write_loop, &data->output_handle.pipe, 0);
uv_pipe_open(&data->output_handle.pipe, data->out_fd);
}
-
- loop_schedule(&main_loop,
- event_create(terminfo_after_startup_event, 2, ui, ui));
}
static void terminfo_stop(UI *ui)
@@ -308,6 +291,18 @@ static void terminfo_stop(UI *ui)
unibi_destroy(data->ut);
}
+static void after_startup_timer_cb(uv_timer_t *handle)
+ FUNC_ATTR_NONNULL_ALL
+{
+ UI *ui = handle->data;
+ TUIData *data = ui->data;
+ uv_timer_stop(&data->after_startup_timer);
+
+ // Emit this after Nvim startup, not during. This works around a tmux
+ // 2.3 bug(?) which caused slow drawing during startup. #7649
+ unibi_out_ext(ui, data->unibi_ext.enable_focus_reporting);
+}
+
static void tui_terminal_start(UI *ui)
{
TUIData *data = ui->data;
@@ -317,6 +312,8 @@ static void tui_terminal_start(UI *ui)
update_size(ui);
signal_watcher_start(&data->winch_handle, sigwinch_cb, SIGWINCH);
term_input_start(&data->input);
+
+ uv_timer_start(&data->after_startup_timer, after_startup_timer_cb, 500, 0);
}
static void tui_terminal_stop(UI *ui)
@@ -350,6 +347,8 @@ static void tui_main(UIBridgeData *bridge, UI *ui)
#ifdef UNIX
signal_watcher_start(&data->cont_handle, sigcont_cb, SIGCONT);
#endif
+ uv_timer_init(&data->loop->uv, &data->after_startup_timer);
+ data->after_startup_timer.data = ui;
#if TERMKEY_VERSION_MAJOR > 0 || TERMKEY_VERSION_MINOR > 18
data->input.tk_ti_hook_fn = tui_tk_ti_getstr;
@@ -368,6 +367,7 @@ static void tui_main(UIBridgeData *bridge, UI *ui)
loop_poll_events(&tui_loop, -1); // tui_loop.events is never processed
}
+ uv_close((uv_handle_t *)&data->after_startup_timer, NULL);
ui_bridge_stopped(bridge);
term_input_destroy(&data->input);
signal_watcher_stop(&data->cont_handle);
diff --git a/src/nvim/ui.h b/src/nvim/ui.h
index f1ea0716e6..0e40a1a215 100644
--- a/src/nvim/ui.h
+++ b/src/nvim/ui.h
@@ -31,11 +31,9 @@ struct ui_t {
bool ui_ext[UI_WIDGETS]; ///< Externalized widgets
int width, height;
void *data;
-
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "ui_events.generated.h"
#endif
-
void (*event)(UI *ui, char *name, Array args, bool *args_consumed);
void (*stop)(UI *ui);
};