copy of https://code.google.com/p/goncurses/ with my slight modifications