Rewrite input reading code, so that it behaves well on more platforms.
Rewrite input reading code, so that it behaves well on more platforms.

Fixes #46.

Tested it on xterm linux, urxvt linux and mintty cygwin.

termbox/termbox,termbox/termbox,nsf/termbox,jaytaph/termbox-1,tempbottle/termbox,jaytaph/termbox-1,mohsenil85/termbox,nsf/termbox,tempbottle/termbox,termbox/termbox,nsf/termbox,jaytaph/termbox-1,mohsenil85/termbox,tempbottle/termbox,mohsenil85/termbox