mirror of
https://github.com/neovim/neovim.git
synced 2025-10-08 10:56:31 +00:00
TUI: set os/input.c:global_fd to input->in_fd #10174
Problem: When we changed startup to wait for the TUI (like a remote UI), we forgot to set os/input.c:global_fd. That used to be done by input_start(). Solution: Initialize os/input.c:global_fd before initializing libtermkey (termkey_new_abstract) so that tui_get_stty_erase() and friends can inspect the correct fd. fixes #10134 close #10174
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user