From d00ef758c3a644759064565cdc7fc219ece0df3a Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Thu, 24 May 2018 11:51:35 +0200 Subject: lint --- src/nvim/os/input.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/nvim/os') diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c index 405500767d..69caa6aaf3 100644 --- a/src/nvim/os/input.c +++ b/src/nvim/os/input.c @@ -50,7 +50,7 @@ void input_init(void) input_buffer = rbuffer_new(INPUT_BUFFER_SIZE + MAX_KEY_CODE_LEN); } -/// Gets the file from which input was gathered at startup. +/// File (set at startup) used to read user-input (or commands for -e/-es). int input_global_fd(void) { return global_fd; @@ -438,8 +438,9 @@ static bool input_ready(void) // Exit because of an input read error. static void read_error_exit(void) { - if (silent_mode) /* Normal way to exit for "ex -s" */ + if (silent_mode) { // Normal way to exit for "nvim -es". getout(0); + } STRCPY(IObuff, _("Vim: Error reading input, exiting...\n")); preserve_exit(); } -- cgit From 63058fb5b05a1293dd50851af46f33fc15110829 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 27 May 2018 03:41:02 +0200 Subject: startup: fix -es/-Es so they are actually silent silent-mode (-es/-Es) has been broken for years. The workaround up to now was to include --headless. But --headless is not equivalent because it prints all messages, not the limited subset defined by silent-mode. --- src/nvim/os/input.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/nvim/os') diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c index 69caa6aaf3..a2d1a7bace 100644 --- a/src/nvim/os/input.c +++ b/src/nvim/os/input.c @@ -64,7 +64,7 @@ void input_start(int fd) global_fd = fd; rstream_init_fd(&main_loop, &read_stream, fd, READ_BUFFER_SIZE); - rstream_start(&read_stream, read_cb, NULL); + rstream_start(&read_stream, input_read_cb, NULL); } void input_stop(void) @@ -108,6 +108,11 @@ int os_inchar(uint8_t *buf, int maxlen, int ms, int tb_change_cnt) } } else { if ((result = inbuf_poll((int)p_ut)) == kInputNone) { + if (read_stream.closed && silent_mode) { + // Input drained and eventloop drained: exit silent/batch-mode (-es). + read_error_exit(); + } + if (trigger_cursorhold() && !typebuf_changed(tb_change_cnt)) { create_cursorhold_event(); } else { @@ -376,11 +381,11 @@ static InbufPollResult inbuf_poll(int ms) return input_eof ? kInputEof : kInputNone; } -static void read_cb(Stream *stream, RBuffer *buf, size_t c, void *data, - bool at_eof) +static void input_read_cb(Stream *stream, RBuffer *buf, size_t c, void *data, + bool at_eof) { if (at_eof) { - input_eof = true; + input_done(); } assert(rbuffer_space(input_buffer) >= rbuffer_size(buf)); -- cgit From 4211255c755513aa91d4a9277b69b557fc6658ee Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 28 May 2018 07:09:55 +0200 Subject: startup: allow explicit "-" file arg with --headless --- src/nvim/os/input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/os') diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c index a2d1a7bace..c999396a6a 100644 --- a/src/nvim/os/input.c +++ b/src/nvim/os/input.c @@ -109,7 +109,7 @@ int os_inchar(uint8_t *buf, int maxlen, int ms, int tb_change_cnt) } else { if ((result = inbuf_poll((int)p_ut)) == kInputNone) { if (read_stream.closed && silent_mode) { - // Input drained and eventloop drained: exit silent/batch-mode (-es). + // Drained input and eventloop: exit silent/batch-mode (-es/-Es). read_error_exit(); } -- cgit From 1f300e08b8c0c35b2f3d79506ae9817cd8591624 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 29 May 2018 07:22:15 +0200 Subject: win/startup: remove --literal Fixes 2 failing tests in startup_spec.lua. The Windows-only `--literal` option complicates support of "stdin-as-text + file-args" (#7679). Could work around it, but it's not worth the trouble: - users have a reasonable (and englightening) alternative: nvim +"n *" - "always literal" is more consistent/predictable - avoids platform-specific special-case Unrelated changes: - Replace fileno(stdxx) with STDXX_FILENO for consistency (not motivated by any observed technical reason). --- src/nvim/os/input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/os') diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c index c999396a6a..dd44df2c3c 100644 --- a/src/nvim/os/input.c +++ b/src/nvim/os/input.c @@ -50,7 +50,7 @@ void input_init(void) input_buffer = rbuffer_new(INPUT_BUFFER_SIZE + MAX_KEY_CODE_LEN); } -/// File (set at startup) used to read user-input (or commands for -e/-es). +/// This is the global stream of user-input (or Ex-commands for "-es"). int input_global_fd(void) { return global_fd; -- cgit From d8c7ff13352d7182826b5716ff3b6a66df241231 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 30 May 2018 07:21:45 +0200 Subject: cleanup, test interactive -E --- src/nvim/os/input.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/nvim/os') diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c index dd44df2c3c..599487c345 100644 --- a/src/nvim/os/input.c +++ b/src/nvim/os/input.c @@ -34,7 +34,7 @@ typedef enum { kInputEof } InbufPollResult; -static Stream read_stream = {.closed = true}; +static Stream read_stream = { .closed = true }; // Input before UI starts. static RBuffer *input_buffer = NULL; static bool input_eof = false; static int global_fd = -1; @@ -50,7 +50,7 @@ void input_init(void) input_buffer = rbuffer_new(INPUT_BUFFER_SIZE + MAX_KEY_CODE_LEN); } -/// This is the global stream of user-input (or Ex-commands for "-es"). +/// Global TTY (or pipe for "-es") input stream, before UI starts. int input_global_fd(void) { return global_fd; @@ -109,7 +109,7 @@ int os_inchar(uint8_t *buf, int maxlen, int ms, int tb_change_cnt) } else { if ((result = inbuf_poll((int)p_ut)) == kInputNone) { if (read_stream.closed && silent_mode) { - // Drained input and eventloop: exit silent/batch-mode (-es/-Es). + // Drained eventloop & initial input; exit silent/batch-mode (-es/-Es). read_error_exit(); } -- cgit