diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-02-21 08:01:16 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-21 08:01:16 +0800 |
commit | 286777c3335d9a4d2c30bfda23ba507fead02aee (patch) | |
tree | bce1185278f28a9ae3620800e1f33782c66fd761 | |
parent | 96b6b27f74f8c5c2b798130b1ef9e1f61722b085 (diff) | |
download | rneovim-286777c3335d9a4d2c30bfda23ba507fead02aee.tar.gz rneovim-286777c3335d9a4d2c30bfda23ba507fead02aee.tar.bz2 rneovim-286777c3335d9a4d2c30bfda23ba507fead02aee.zip |
refactor(tui/input.c): remove unused multithreading code (#22342)
-rw-r--r-- | src/nvim/tui/input.c | 26 | ||||
-rw-r--r-- | src/nvim/tui/input.h | 3 |
2 files changed, 7 insertions, 22 deletions
diff --git a/src/nvim/tui/input.c b/src/nvim/tui/input.c index cb687d4f65..730dc9c27b 100644 --- a/src/nvim/tui/input.c +++ b/src/nvim/tui/input.c @@ -133,8 +133,6 @@ void tinput_init(TermInput *input, Loop *loop) input->ttimeout = (bool)p_ttimeout; input->ttimeoutlen = p_ttm; input->key_buffer = rbuffer_new(KEY_BUFFER_SIZE); - uv_mutex_init(&input->key_buffer_mutex); - uv_cond_init(&input->key_buffer_cond); for (size_t i = 0; i < ARRAY_SIZE(kitty_key_map_entry); i++) { map_put(KittyKey, cstr_t)(&kitty_key_map, kitty_key_map_entry[i].key, @@ -166,8 +164,6 @@ void tinput_destroy(TermInput *input) { map_destroy(KittyKey, cstr_t)(&kitty_key_map); rbuffer_free(input->key_buffer); - uv_mutex_destroy(&input->key_buffer_mutex); - uv_cond_destroy(&input->key_buffer_cond); time_watcher_close(&input->timer_handle, NULL); stream_close(&input->read_stream, NULL, NULL); termkey_destroy(input->tk); @@ -190,9 +186,9 @@ static void tinput_done_event(void **argv) os_exit(1); } -static void tinput_wait_enqueue(void **argv) +/// Send all pending input to Nvim server. +static void tinput_flush(TermInput *input) { - TermInput *input = argv[0]; if (input->paste) { // produce exactly one paste event const size_t len = rbuffer_size(input->key_buffer); String keys = { .data = xmallocz(len), .size = len }; @@ -222,21 +218,13 @@ static void tinput_wait_enqueue(void **argv) } } -static void tinput_flush(TermInput *input, bool wait_until_empty) -{ - size_t drain_boundary = wait_until_empty ? 0 : 0xff; - do { - tinput_wait_enqueue((void **)&input); - } while (rbuffer_size(input->key_buffer) > drain_boundary); -} - static void tinput_enqueue(TermInput *input, char *buf, size_t size) { if (rbuffer_size(input->key_buffer) > rbuffer_capacity(input->key_buffer) - 0xff) { // don't ever let the buffer get too full or we risk putting incomplete keys // into it - tinput_flush(input, false); + tinput_flush(input); } rbuffer_write(input->key_buffer, buf, size); } @@ -487,7 +475,7 @@ static void tinput_timer_cb(TimeWatcher *watcher, void *data) handle_raw_buffer(input, true); } tk_getkeys(input, true); - tinput_flush(input, true); + tinput_flush(input); } /// Handle focus events. @@ -535,13 +523,13 @@ static HandleState handle_bracketed_paste(TermInput *input) if (enable) { // Flush before starting paste. - tinput_flush(input, true); + tinput_flush(input); // Paste phase: "first-chunk". input->paste = 1; } else if (input->paste) { // Paste phase: "last-chunk". input->paste = input->paste == 2 ? 3 : -1; - tinput_flush(input, true); + tinput_flush(input); // Paste phase: "disabled". input->paste = 0; } @@ -735,7 +723,7 @@ static void tinput_read_cb(Stream *stream, RBuffer *buf, size_t count_, void *da } handle_raw_buffer(input, false); - tinput_flush(input, true); + tinput_flush(input); // An incomplete sequence was found. Leave it in the raw buffer and wait for // the next input. diff --git a/src/nvim/tui/input.h b/src/nvim/tui/input.h index d33cea6383..da565fbb6f 100644 --- a/src/nvim/tui/input.h +++ b/src/nvim/tui/input.h @@ -23,7 +23,6 @@ typedef struct term_input { int in_fd; // Phases: -1=all 0=disabled 1=first-chunk 2=continue 3=last-chunk int8_t paste; - bool waiting; bool ttimeout; int8_t waiting_for_bg_response; int8_t waiting_for_csiu_response; @@ -35,8 +34,6 @@ typedef struct term_input { Loop *loop; Stream read_stream; RBuffer *key_buffer; - uv_mutex_t key_buffer_mutex; - uv_cond_t key_buffer_cond; TUIData *tui_data; } TermInput; |