From c2f3e361c52ec4e7149ea1d8c6a1202e0873da8e Mon Sep 17 00:00:00 2001 From: ZyX Date: Wed, 19 Apr 2017 19:11:50 +0300 Subject: *: Add comment to all C files --- src/nvim/tui/input.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/nvim/tui/input.c') diff --git a/src/nvim/tui/input.c b/src/nvim/tui/input.c index 8e5adb14f9..3f2ccd4746 100644 --- a/src/nvim/tui/input.c +++ b/src/nvim/tui/input.c @@ -1,3 +1,6 @@ +// This is an open source non-commercial project. Dear PVS-Studio, please check +// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com + #include "nvim/tui/input.h" #include "nvim/vim.h" -- cgit From 5c9860a0a2bf27d409c986673f0a74542561c4c3 Mon Sep 17 00:00:00 2001 From: Sander Bosma Date: Wed, 1 Mar 2017 10:43:47 +0100 Subject: api: Do not truncate errors <1 MB. #6237 Closes #5984 --- src/nvim/tui/input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/tui/input.c') diff --git a/src/nvim/tui/input.c b/src/nvim/tui/input.c index 3f2ccd4746..921f67fb7d 100644 --- a/src/nvim/tui/input.c +++ b/src/nvim/tui/input.c @@ -228,7 +228,7 @@ static int get_key_code_timeout(void) if (nvim_get_option(cstr_as_string("ttimeout"), &err).data.boolean) { ms = nvim_get_option(cstr_as_string("ttimeoutlen"), &err).data.integer; } - + xfree(err.msg); return (int)ms; } -- cgit From 2a49163103827465f25810f5f4e3d4305159f209 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 23 Apr 2017 15:59:59 +0200 Subject: api_clear_error() --- src/nvim/tui/input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/tui/input.c') diff --git a/src/nvim/tui/input.c b/src/nvim/tui/input.c index 921f67fb7d..be016668fc 100644 --- a/src/nvim/tui/input.c +++ b/src/nvim/tui/input.c @@ -228,7 +228,7 @@ static int get_key_code_timeout(void) if (nvim_get_option(cstr_as_string("ttimeout"), &err).data.boolean) { ms = nvim_get_option(cstr_as_string("ttimeoutlen"), &err).data.integer; } - xfree(err.msg); + api_clear_error(&err); return (int)ms; } -- cgit From e2936ed39768c07e810cd3c3e6255cf48fba494f Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 23 Apr 2017 22:06:02 +0200 Subject: tui/input.c: Use default 'ttimeoutlen' if option get fails. Should never happen, but better to be explicit. Helped-by: oni-link --- src/nvim/tui/input.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/nvim/tui/input.c') diff --git a/src/nvim/tui/input.c b/src/nvim/tui/input.c index be016668fc..b86ab8cf2f 100644 --- a/src/nvim/tui/input.c +++ b/src/nvim/tui/input.c @@ -223,10 +223,12 @@ static int get_key_code_timeout(void) { Integer ms = -1; // Check 'ttimeout' to determine if we should send ESC after 'ttimeoutlen'. - // See :help 'ttimeout' for more information Error err = ERROR_INIT; if (nvim_get_option(cstr_as_string("ttimeout"), &err).data.boolean) { - ms = nvim_get_option(cstr_as_string("ttimeoutlen"), &err).data.integer; + Object rv = nvim_get_option(cstr_as_string("ttimeoutlen"), &err); + if (!ERROR_SET(&err)) { + ms = rv.data.integer; + } } api_clear_error(&err); return (int)ms; -- cgit From 8f59d1483934f91011b755406251136c406e77f6 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Thu, 27 Apr 2017 14:38:41 +0200 Subject: event: Remove "priority" concept. It was replaced by the "child queue" concept (MultiQueue). --- src/nvim/tui/input.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/tui/input.c') diff --git a/src/nvim/tui/input.c b/src/nvim/tui/input.c index b86ab8cf2f..3d37fabeee 100644 --- a/src/nvim/tui/input.c +++ b/src/nvim/tui/input.c @@ -102,7 +102,7 @@ static void flush_input(TermInput *input, bool wait_until_empty) size_t drain_boundary = wait_until_empty ? 0 : 0xff; do { uv_mutex_lock(&input->key_buffer_mutex); - loop_schedule(&main_loop, event_create(1, wait_input_enqueue, 1, input)); + loop_schedule(&main_loop, event_create(wait_input_enqueue, 1, input)); input->waiting = true; while (input->waiting) { uv_cond_wait(&input->key_buffer_cond, &input->key_buffer_mutex); @@ -352,7 +352,7 @@ static void read_cb(Stream *stream, RBuffer *buf, size_t c, void *data, stream_close(&input->read_stream, NULL, NULL); multiqueue_put(input->loop->fast_events, restart_reading, 1, input); } else { - loop_schedule(&main_loop, event_create(1, input_done_event, 0)); + loop_schedule(&main_loop, event_create(input_done_event, 0)); } return; } -- cgit From 685ca180f7c96f77a79c78d3b26bd003f8cd834c Mon Sep 17 00:00:00 2001 From: Rui Abreu Ferreira Date: Sat, 18 Mar 2017 00:06:47 +0000 Subject: win: Terminal UI #6315 For CI builds unibilium is provided through msys2 packages, and libtermkey is built from source in third-party from equalsraf/libtermkey. In Windows we cannot read terminal input from the stdin file descriptor, instead use libuv's uv_tty API. It should handle key input and encoding. The UI suspend is not implemented for Windows, because the SIGSTP/SIGCONT do not exist in windows. Currently this is a NOOP. Closes #3902 Closes #6640 --- src/nvim/tui/input.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/nvim/tui/input.c') diff --git a/src/nvim/tui/input.c b/src/nvim/tui/input.c index 3d37fabeee..03587d68f0 100644 --- a/src/nvim/tui/input.c +++ b/src/nvim/tui/input.c @@ -47,7 +47,13 @@ void term_input_init(TermInput *input, Loop *loop) int curflags = termkey_get_canonflags(input->tk); termkey_set_canonflags(input->tk, curflags | TERMKEY_CANON_DELBS); // setup input handle +#ifdef WIN32 + uv_tty_init(loop, &input->tty_in, 0, 1); + uv_tty_set_mode(&input->tty_in, UV_TTY_MODE_RAW); + rstream_init_stream(&input->read_stream, &input->tty_in, 0xfff); +#else rstream_init_fd(loop, &input->read_stream, input->in_fd, 0xfff); +#endif // initialize a timer handle for handling ESC with libtermkey time_watcher_init(loop, &input->timer_handle, input); } -- cgit From b6b6e4a96f37ba6a54d194ecbc042d5ef7d595e6 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 28 Aug 2017 01:27:57 +0200 Subject: eventloop: FocusGained: schedule event instead of pseudokey closes #4840 closes #6164 --- src/nvim/tui/input.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/nvim/tui/input.c') diff --git a/src/nvim/tui/input.c b/src/nvim/tui/input.c index 03587d68f0..8bb5971bd4 100644 --- a/src/nvim/tui/input.c +++ b/src/nvim/tui/input.c @@ -8,6 +8,7 @@ #include "nvim/api/private/helpers.h" #include "nvim/ascii.h" #include "nvim/main.h" +#include "nvim/aucmd.h" #include "nvim/os/os.h" #include "nvim/os/input.h" #include "nvim/event/rstream.h" @@ -280,9 +281,9 @@ static void timer_cb(TimeWatcher *watcher, void *data) /// Handle focus events. /// -/// If the upcoming sequence of bytes in the input stream matches either the -/// escape code for focus gained `[I` or focus lost `[O` then consume -/// that sequence and push the appropriate event into the input queue +/// If the upcoming sequence of bytes in the input stream matches the termcode +/// for "focus gained" or "focus lost", consume that sequence and schedule an +/// event on the main loop. /// /// @param input the input stream /// @return true iff handle_focus_event consumed some input @@ -294,11 +295,7 @@ static bool handle_focus_event(TermInput *input) // Advance past the sequence bool focus_gained = *rbuffer_get(input->read_stream.buffer, 2) == 'I'; rbuffer_consumed(input->read_stream.buffer, 3); - if (focus_gained) { - enqueue_input(input, FOCUSGAINED_KEY, sizeof(FOCUSGAINED_KEY) - 1); - } else { - enqueue_input(input, FOCUSLOST_KEY, sizeof(FOCUSLOST_KEY) - 1); - } + aucmd_schedule_focusgained(focus_gained); return true; } return false; -- cgit From 07931ed1c8cc749222a513cba5bdf300067646bc Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Fri, 17 Nov 2017 22:24:01 +0100 Subject: tui: 'guicursor': use DECSCUSR for xterm-likes (#7576) Anything claiming to be an xterm gets DECSCUSR. This is the only reasonable choice unless/until we get more reliable detection (#7490). ref #6997 closes #7550 --- src/nvim/tui/input.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/nvim/tui/input.c') diff --git a/src/nvim/tui/input.c b/src/nvim/tui/input.c index 8bb5971bd4..8e08b77b00 100644 --- a/src/nvim/tui/input.c +++ b/src/nvim/tui/input.c @@ -14,8 +14,6 @@ #include "nvim/event/rstream.h" #define PASTETOGGLE_KEY "" -#define FOCUSGAINED_KEY "" -#define FOCUSLOST_KEY "" #define KEY_BUFFER_SIZE 0xfff #ifdef INCLUDE_GENERATED_DECLARATIONS -- cgit From fdcde7dba34b193e8fdafdf3b5b9c3ce4d430505 Mon Sep 17 00:00:00 2001 From: Peter Kalauskas Date: Sun, 19 Nov 2017 21:25:02 -0800 Subject: input.c: replace if/else with switch --- src/nvim/tui/input.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'src/nvim/tui/input.c') diff --git a/src/nvim/tui/input.c b/src/nvim/tui/input.c index 8e08b77b00..b76a11cc71 100644 --- a/src/nvim/tui/input.c +++ b/src/nvim/tui/input.c @@ -199,18 +199,24 @@ static void forward_mouse_event(TermInput *input, TermKeyKey *key) len += (size_t)snprintf(buf + len, sizeof(buf) - len, "Right"); } - if (ev == TERMKEY_MOUSE_PRESS) { - if (button == 4) { - len += (size_t)snprintf(buf + len, sizeof(buf) - len, "ScrollWheelUp"); - } else if (button == 5) { - len += (size_t)snprintf(buf + len, sizeof(buf) - len, "ScrollWheelDown"); - } else { - len += (size_t)snprintf(buf + len, sizeof(buf) - len, "Mouse"); - } - } else if (ev == TERMKEY_MOUSE_DRAG) { - len += (size_t)snprintf(buf + len, sizeof(buf) - len, "Drag"); - } else if (ev == TERMKEY_MOUSE_RELEASE) { - len += (size_t)snprintf(buf + len, sizeof(buf) - len, "Release"); + switch (ev) { + case TERMKEY_MOUSE_PRESS: + if (button == 4) { + len += (size_t)snprintf(buf + len, sizeof(buf) - len, "ScrollWheelUp"); + } else if (button == 5) { + len += (size_t)snprintf(buf + len, sizeof(buf) - len, "ScrollWheelDown"); + } else { + len += (size_t)snprintf(buf + len, sizeof(buf) - len, "Mouse"); + } + break; + case TERMKEY_MOUSE_DRAG: + len += (size_t)snprintf(buf + len, sizeof(buf) - len, "Drag"); + break; + case TERMKEY_MOUSE_RELEASE: + len += (size_t)snprintf(buf + len, sizeof(buf) - len, "Release"); + break; + case TERMKEY_MOUSE_UNKNOWN: + assert(false); } len += (size_t)snprintf(buf + len, sizeof(buf) - len, "><%d,%d>", col, row); -- cgit