neovim/neovim — pull request #289 by tarruda (2014-03-04 23:32:32+00:00)
Title: Migrate input reading to a libuv event loop

This configures a libuv event loop running in a background thread, started with
the 'io_init' at the beginning of the program. For now it's only responsible for
reading from stdin(or stderr when vim is started on the right side of a pipe),
but this infrastructure can be reused for implementing other mch_* functions
that would require a libuv event loop.

Here's a list of changes performed:

- Move mch_exit, mch_inchar, mch_delay and mch_char_avail to the new 'io' module
- Remove unused functions in os_unix.c
- Remove hangul input support

The blocking aspect of 'mch_inchar', 'mch_delay' and 'mch_char_avail' is
emulated using a mutex combined with a condition variable, set by the thread
running the event loop.

This also removed all code that made use of the 'inbuf' static variable in ui.c
including the hangulin.c module. Hangul input is scheduled for removal from vim
(if vim is dropping support for a feature then I guess it's safe for us to
remove it too) and I had to tweak it to compile without GUI, but I should have
avoided the trouble and removed it from the beginning of the project. If hangul
input is needed we can try to integrate when we have a codebase that is easier
to maintain.

The code used in this PR will be used for job control(and consequently the new plugin architecture), so I want to get this merged as soon as possible(Right now it's using some module-globals but those will be refactored). After this PR I will implement job control on top of libuv and refactor mch_call_shell to use the new job control infrastructure it. After that I can start working on msgpack integration for the UI and plugins, which will let neovim grow more 'horizontally'

@ashleyh can you run this on TSAN before I merge? Next weekend I'm gonna setup a shiny new ubuntu 64 bit development virtual machine so this is will be the last time, I promise :)