aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/tui
diff options
context:
space:
mode:
authorThiago de Arruda <tpadilha84@gmail.com>2015-08-07 22:54:02 -0300
committerThiago de Arruda <tpadilha84@gmail.com>2015-08-13 08:49:38 -0300
commit502aee690c980fcb3cfcb3f211dcfad06103db46 (patch)
tree803dbcccaa874b78cbdfeacc74b7cc891e09f89a /src/nvim/tui
parenta6e0d35d2da3ee4270ddb712410ea0c8c55b0f0f (diff)
downloadrneovim-502aee690c980fcb3cfcb3f211dcfad06103db46.tar.gz
rneovim-502aee690c980fcb3cfcb3f211dcfad06103db46.tar.bz2
rneovim-502aee690c980fcb3cfcb3f211dcfad06103db46.zip
event: Refactor async event processing
- Improve the implementation of deferred/immediate events. - Use the new queue module to change how/when events are queued/processed by giving a private queue to each emitter. - Immediate events(which only exist to break uv_run recursion) are now represented in the `loop->fast_events` queue. - Events pushed to child queues are propagated to the event loop main queue and processed as K_EVENT keys.
Diffstat (limited to 'src/nvim/tui')
-rw-r--r--src/nvim/tui/term_input.inl9
-rw-r--r--src/nvim/tui/tui.c15
2 files changed, 6 insertions, 18 deletions
diff --git a/src/nvim/tui/term_input.inl b/src/nvim/tui/term_input.inl
index 0a84a3688b..1907d9895e 100644
--- a/src/nvim/tui/term_input.inl
+++ b/src/nvim/tui/term_input.inl
@@ -206,7 +206,7 @@ static bool handle_forced_escape(TermInput *input)
return false;
}
-static void restart_reading(Event event);
+static void restart_reading(void **argv);
static void read_cb(Stream *stream, RBuffer *buf, void *data, bool eof)
{
@@ -226,8 +226,7 @@ static void read_cb(Stream *stream, RBuffer *buf, void *data, bool eof)
// ls *.md | xargs nvim
input->in_fd = 2;
stream_close(&input->read_stream, NULL);
- loop_push_event(&loop,
- (Event) { .data = input, .handler = restart_reading }, false);
+ queue_put(loop.fast_events, restart_reading, 1, input);
} else {
input_done();
}
@@ -272,9 +271,9 @@ static void read_cb(Stream *stream, RBuffer *buf, void *data, bool eof)
rbuffer_reset(input->read_stream.buffer);
}
-static void restart_reading(Event event)
+static void restart_reading(void **argv)
{
- TermInput *input = event.data;
+ TermInput *input = argv[0];
rstream_init_fd(&loop, &input->read_stream, input->in_fd, 0xfff, input);
rstream_start(&input->read_stream, read_cb);
}
diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c
index 28870b5abb..460fdb81a8 100644
--- a/src/nvim/tui/tui.c
+++ b/src/nvim/tui/tui.c
@@ -205,24 +205,13 @@ static void tui_stop(UI *ui)
xfree(ui);
}
-static void try_resize(Event ev)
+static void sigwinch_cb(SignalWatcher *watcher, int signum, void *data)
{
- UI *ui = ev.data;
+ UI *ui = data;
update_size(ui);
ui_refresh();
}
-static void sigwinch_cb(SignalWatcher *watcher, int signum, void *data)
-{
- got_winch = true;
- // Queue the event because resizing can result in recursive event_poll calls
- // FIXME(blueyed): TUI does not resize properly when not deferred. Why? #2322
- loop_push_event(&loop, (Event) {
- .data = data,
- .handler = try_resize
- }, true);
-}
-
static bool attrs_differ(HlAttrs a1, HlAttrs a2)
{
return a1.foreground != a2.foreground || a1.background != a2.background