This is not so much a fix, as a workaround for an incredibly busted
tty driver in macOS. I've tried nearly every other approach I can
think of, and this is the best of a bunch of really rotten options.
The draw back here is that reinitializing the screen may not work as well
as we'd like, and that there may be a leaked descriptor and goroutine
after you Fini() on macOS. Not many other approaches seem viable, and to
be honest, very few applications are likely to ever notice that.
If some Apple developer sees this, please talk to me about the fixes
needed in the tty driver -- this has been a known bug (to me at least)
for many years now.
fixes#164 KeyEscape does not work in Go 1.9 under Linux
This is a complete refactor of the input loop for UNIX systems.
We use a blocking reader on the TTY, and a separate select
loop for timers and other events. This means that our idle
use should be low now.