diff options
| author | Thiago de Arruda <tpadilha84@gmail.com> | 2015-02-18 13:31:39 -0300 |
|---|---|---|
| committer | Thiago de Arruda <tpadilha84@gmail.com> | 2015-02-18 13:31:39 -0300 |
| commit | 366662d932551e558d10f09887ddf144ed5db34b (patch) | |
| tree | 45e87e5fb1755ce2cdbc5a47e85c43fd40704395 /src/nvim/os | |
| parent | 66a03a7385dfd11503d22d8cc9dc6a972e27dcc2 (diff) | |
| parent | e7c945ab597aff7af2611ca9bffa4a11e18c0a87 (diff) | |
| download | rneovim-366662d932551e558d10f09887ddf144ed5db34b.tar.gz rneovim-366662d932551e558d10f09887ddf144ed5db34b.tar.bz2 rneovim-366662d932551e558d10f09887ddf144ed5db34b.zip | |
Merge PR #2007 'Fixes for the new TUI'
Diffstat (limited to 'src/nvim/os')
| -rw-r--r-- | src/nvim/os/input.c | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c index 2c2b0fc871..00efa28161 100644 --- a/src/nvim/os/input.c +++ b/src/nvim/os/input.c @@ -148,22 +148,34 @@ size_t input_enqueue(String keys) uint8_t buf[6] = {0}; unsigned int new_size = trans_special((uint8_t **)&ptr, buf, true); - if (!new_size) { - if (*ptr == '<') { - // Invalid key sequence, skip until the next '>' or until *end - do { - ptr++; - } while (ptr < end && *ptr != '>'); + if (new_size) { + new_size = handle_mouse_event(&ptr, buf, new_size); + rbuffer_write(input_buffer, (char *)buf, new_size); + continue; + } + + if (*ptr == '<') { + // Invalid key sequence, skip until the next '>' or until *end + do { ptr++; - continue; - } - // copy the character unmodified - *buf = (uint8_t)*ptr++; - new_size = 1; + } while (ptr < end && *ptr != '>'); + ptr++; + continue; } - new_size = handle_mouse_event(&ptr, buf, new_size); - rbuffer_write(input_buffer, (char *)buf, new_size); + // copy the character, escaping CSI and K_SPECIAL + if ((uint8_t)*ptr == CSI) { + rbuffer_write(input_buffer, (char *)&(uint8_t){K_SPECIAL}, 1); + rbuffer_write(input_buffer, (char *)&(uint8_t){KS_EXTRA}, 1); + rbuffer_write(input_buffer, (char *)&(uint8_t){KE_CSI}, 1); + } else if ((uint8_t)*ptr == K_SPECIAL) { + rbuffer_write(input_buffer, (char *)&(uint8_t){K_SPECIAL}, 1); + rbuffer_write(input_buffer, (char *)&(uint8_t){KS_SPECIAL}, 1); + rbuffer_write(input_buffer, (char *)&(uint8_t){KE_FILLER}, 1); + } else { + rbuffer_write(input_buffer, ptr, 1); + } + ptr++; } size_t rv = (size_t)(ptr - keys.data); |