Fix flickering of the UI
Draw everything into curses buffer and then draw it all at once on the screen via doupdate().
clear() is the problematic one, because it's actually a combination of erase() and refresh() and there is no need to refresh the screen between clearing and redrawing.
Ok I looked into this, clear does not call refresh internally.
It does however cause a complete repaint the next time refresh is called, instead of
just computing and applying the difference.
This behavior is actually needed occasionally, for example when resizing the terminal in your fork there is a good chance to get some scrambled output.
I'm not sure if this is the only case where a complete refresh is needed
Ok I looked into this,
cleardoes not call refresh internally. It does however cause a complete repaint the next timerefreshis called, instead of just computing and applying the difference.
You're right, clearing is delayed.
This behavior is actually needed occasionally, for example when resizing the terminal in your fork there is a good chance to get some scrambled output.
I don't think that erase() and doupdate() will leave something from previous state, but can add redrawwin() to tell curses to not assume any particular terminal state and get clear-like behaviour without that irritating flicker.