diff options
Diffstat (limited to 'src/nvim/os')
-rw-r--r-- | src/nvim/os/input.c | 22 | ||||
-rw-r--r-- | src/nvim/os/job.c | 9 | ||||
-rw-r--r-- | src/nvim/os/shell.c | 12 | ||||
-rw-r--r-- | src/nvim/os/time.c | 4 |
4 files changed, 30 insertions, 17 deletions
diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c index cddc28fac9..2ae4558f3d 100644 --- a/src/nvim/os/input.c +++ b/src/nvim/os/input.c @@ -184,18 +184,24 @@ size_t input_enqueue(String keys) while (rbuffer_available(input_buffer) >= 6 && ptr < end) { uint8_t buf[6] = {0}; - int new_size = trans_special((uint8_t **)&ptr, buf, false); + unsigned int new_size = trans_special((uint8_t **)&ptr, buf, false); if (!new_size) { + if (*ptr == '<') { + // Invalid key sequence, skip until the next '>' or until *end + do { + ptr++; + } while (ptr < end && *ptr != '>'); + ptr++; + continue; + } // copy the character unmodified *buf = (uint8_t)*ptr++; new_size = 1; } new_size = handle_mouse_event(&ptr, buf, new_size); - // TODO(tarruda): Don't produce past unclosed '<' characters, except if - // there's a lot of characters after the '<' - rbuffer_write(input_buffer, (char *)buf, (size_t)new_size); + rbuffer_write(input_buffer, (char *)buf, new_size); } size_t rv = (size_t)(ptr - keys.data); @@ -205,7 +211,8 @@ size_t input_enqueue(String keys) // Mouse event handling code(Extract row/col if available and detect multiple // clicks) -static int handle_mouse_event(char **ptr, uint8_t *buf, int bufsize) +static unsigned int handle_mouse_event(char **ptr, uint8_t *buf, + unsigned int bufsize) { int mouse_code = 0; @@ -216,7 +223,8 @@ static int handle_mouse_event(char **ptr, uint8_t *buf, int bufsize) mouse_code = buf[5]; } - if (mouse_code < KE_LEFTMOUSE || mouse_code > KE_RIGHTRELEASE) { + if (!((mouse_code >= KE_LEFTMOUSE && mouse_code <= KE_RIGHTRELEASE) + || (mouse_code >= KE_MOUSEDOWN && mouse_code <= KE_MOUSERIGHT))) { return bufsize; } @@ -225,7 +233,7 @@ static int handle_mouse_event(char **ptr, uint8_t *buf, int bufsize) // find mouse coordinates, and it would be too expensive to refactor this // now. int col, row, advance; - if (sscanf(*ptr, "<%d,%d>%n", &col, &row, &advance)) { + if (sscanf(*ptr, "<%d,%d>%n", &col, &row, &advance) != EOF && advance) { if (col >= 0 && row >= 0) { mouse_row = row; mouse_col = col; diff --git a/src/nvim/os/job.c b/src/nvim/os/job.c index 17872ab9c9..8db5e3cc39 100644 --- a/src/nvim/os/job.c +++ b/src/nvim/os/job.c @@ -310,8 +310,15 @@ int job_wait(Job *job, int ms) FUNC_ATTR_NONNULL_ALL // we'll assume that a user frantically hitting interrupt doesn't like // the current job. Signal that it has to be killed. if (got_int) { + got_int = false; job_stop(job); - event_poll(0); + if (ms == -1) { + // We can only return, if all streams/handles are closed and the job + // exited. + event_poll_until(-1, job->refcount == 1); + } else { + event_poll(0); + } } if (job->refcount == 1) { diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c index d0f8442768..d481d6af56 100644 --- a/src/nvim/os/shell.c +++ b/src/nvim/os/shell.c @@ -24,7 +24,6 @@ #include "nvim/option_defs.h" #include "nvim/charset.h" #include "nvim/strings.h" -#include "nvim/ui.h" #define DYNAMIC_BUFFER_INIT {NULL, 0, 0} @@ -414,6 +413,7 @@ static size_t write_output(char *output, size_t remaining, bool to_buffer, char *start = output; size_t off = 0; + int lastrow = (int)Rows - 1; while (off < remaining) { if (output[off] == NL) { // Insert the line @@ -421,10 +421,8 @@ static size_t write_output(char *output, size_t remaining, bool to_buffer, if (to_buffer) { ml_append(curwin->w_cursor.lnum++, (char_u *)output, 0, false); } else { - // pending data from the output buffer has been flushed to the screen, - // safe to call ui_write directly - ui_write((char_u *)output, (int)off); - ui_write((char_u *)"\r\n", 2); + screen_del_lines(0, 0, 1, (int)Rows, true, NULL); + screen_puts_len((char_u *)output, (int)off, lastrow, 0, 0); } size_t skip = off + 1; output += skip; @@ -448,8 +446,8 @@ static size_t write_output(char *output, size_t remaining, bool to_buffer, // remember that the NL was missing curbuf->b_no_eol_lnum = curwin->w_cursor.lnum; } else { - ui_write((char_u *)output, (int)remaining); - ui_write((char_u *)"\r\n", 2); + screen_del_lines(0, 0, 1, (int)Rows, true, NULL); + screen_puts_len((char_u *)output, (int)remaining, lastrow, 0, 0); } output += remaining; } else if (to_buffer) { diff --git a/src/nvim/os/time.c b/src/nvim/os/time.c index 810ddea82b..b69be88fc7 100644 --- a/src/nvim/os/time.c +++ b/src/nvim/os/time.c @@ -80,11 +80,11 @@ struct tm *os_localtime_r(const time_t *restrict clock, { #ifdef UNIX // POSIX provides localtime_r() as a thread-safe version of localtime(). - return localtime_r(clock, result); + return localtime_r(clock, result); // NOLINT(runtime/threadsafe_fn) #else // Windows version of localtime() is thread-safe. // See http://msdn.microsoft.com/en-us/library/bf12f0hc%28VS.80%29.aspx - struct tm *local_time = localtime(clock); // NOLINT + struct tm *local_time = localtime(clock); // NOLINT(runtime/threadsafe_fn) if (!local_time) { return NULL; } |