Use wnoutrefresh, pnoutrefresh and doupdate

Issue #298