aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/os/input.c7
-rw-r--r--src/nvim/tui/input.c35
2 files changed, 24 insertions, 18 deletions
diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c
index 8070f4c420..5d43dff5c1 100644
--- a/src/nvim/os/input.c
+++ b/src/nvim/os/input.c
@@ -50,6 +50,11 @@ void input_init(void)
input_buffer = rbuffer_new(INPUT_BUFFER_SIZE + MAX_KEY_CODE_LEN);
}
+void input_global_fd_init(int fd)
+{
+ global_fd = fd;
+}
+
/// Global TTY (or pipe for "-es") input stream, before UI starts.
int input_global_fd(void)
{
@@ -62,7 +67,7 @@ void input_start(int fd)
return;
}
- global_fd = fd;
+ input_global_fd_init(fd);
rstream_init_fd(&main_loop, &read_stream, fd, READ_BUFFER_SIZE);
rstream_start(&read_stream, input_read_cb, NULL);
}
diff --git a/src/nvim/tui/input.c b/src/nvim/tui/input.c
index 7a725df0a1..b7072768ec 100644
--- a/src/nvim/tui/input.c
+++ b/src/nvim/tui/input.c
@@ -32,23 +32,6 @@ void tinput_init(TermInput *input, Loop *loop)
uv_mutex_init(&input->key_buffer_mutex);
uv_cond_init(&input->key_buffer_cond);
- const char *term = os_getenv("TERM");
- if (!term) {
- term = ""; // termkey_new_abstract assumes non-null (#2745)
- }
-
-#if TERMKEY_VERSION_MAJOR > 0 || TERMKEY_VERSION_MINOR > 18
- input->tk = termkey_new_abstract(term,
- TERMKEY_FLAG_UTF8 | TERMKEY_FLAG_NOSTART);
- termkey_hook_terminfo_getstr(input->tk, input->tk_ti_hook_fn, NULL);
- termkey_start(input->tk);
-#else
- input->tk = termkey_new_abstract(term, TERMKEY_FLAG_UTF8);
-#endif
-
- int curflags = termkey_get_canonflags(input->tk);
- termkey_set_canonflags(input->tk, curflags | TERMKEY_CANON_DELBS);
-
// If stdin is not a pty, switch to stderr. For cases like:
// echo q | nvim -es
// ls *.md | xargs nvim
@@ -67,6 +50,24 @@ void tinput_init(TermInput *input, Loop *loop)
input->in_fd = 2;
}
#endif
+ input_global_fd_init(input->in_fd);
+
+ const char *term = os_getenv("TERM");
+ if (!term) {
+ term = ""; // termkey_new_abstract assumes non-null (#2745)
+ }
+
+#if TERMKEY_VERSION_MAJOR > 0 || TERMKEY_VERSION_MINOR > 18
+ input->tk = termkey_new_abstract(term,
+ TERMKEY_FLAG_UTF8 | TERMKEY_FLAG_NOSTART);
+ termkey_hook_terminfo_getstr(input->tk, input->tk_ti_hook_fn, NULL);
+ termkey_start(input->tk);
+#else
+ input->tk = termkey_new_abstract(term, TERMKEY_FLAG_UTF8);
+#endif
+
+ int curflags = termkey_get_canonflags(input->tk);
+ termkey_set_canonflags(input->tk, curflags | TERMKEY_CANON_DELBS);
// setup input handle
rstream_init_fd(loop, &input->read_stream, input->in_fd, 0xfff);