mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
refactor(tui/input.c): remove unused multithreading code (#22342)
This commit is contained in:
parent
96b6b27f74
commit
286777c333
@ -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.
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user