From 3e83e44792021fb9d18acbb664172ce9a06dc9be Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Sun, 14 Dec 2014 09:20:07 -0300 Subject: input: Ignore invalid "<" key sequences Ignoring invalid key sequences simplifies input handling in UIs. The only downside is having to use "" everytime a "<" is needed on functional tests. --- src/nvim/os/input.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/nvim/os/input.c') diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c index c0d588f4ef..130e239a34 100644 --- a/src/nvim/os/input.c +++ b/src/nvim/os/input.c @@ -187,14 +187,20 @@ size_t input_enqueue(String keys) 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, new_size); } -- cgit From 7b537ffda9751c1ec48fafae0f5b2a6bee29ad8b Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Wed, 14 Jan 2015 16:59:54 -0300 Subject: input: Read row/col position when processing mouse wheel --- src/nvim/os/input.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/nvim/os/input.c') diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c index 130e239a34..f04f0d8092 100644 --- a/src/nvim/os/input.c +++ b/src/nvim/os/input.c @@ -223,7 +223,8 @@ static unsigned int handle_mouse_event(char **ptr, uint8_t *buf, 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; } -- cgit From 361c2290b6d8280c61d3e8193fa08f638f790da1 Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Thu, 15 Jan 2015 08:58:14 -0300 Subject: input: Fix check for mouse coordinates Must check for EOF which will result in row/col being uninitialized. --- src/nvim/os/input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/os/input.c') diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c index f04f0d8092..2ae4558f3d 100644 --- a/src/nvim/os/input.c +++ b/src/nvim/os/input.c @@ -233,7 +233,7 @@ static unsigned int handle_mouse_event(char **ptr, uint8_t *buf, // 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; -- cgit