Use FindCurses to find curses libraries

- Some systems have the FindCurses.cmake module to find
  the curses/ncurses libraries using find_package(). And
  in some CheckLibraries is not very reliable, so as
  fallback FindCurses is now used if no other option
  works.
Turn main_loop into uv_idle

- Disregard this commit as a rambling, I just wanted to implement
  something else, and I needed the uv loop so I implemented the
  the main_loop as an idle callback.