I don't understand what function(s) to use to repaint the screen when the user presses Ctrl-L or Ctrl-R. What's the difference between using clearok()
, redrawwin()
, or wrefresh()
with curscr
as argument? From the OpenBSD man pages:
If clearok is called with TRUE as argument, the next call to wrefresh with this window will clear the screen completely and redraw the entire screen from scratch. This is useful when the contents of the screen are uncertain, or in some cases for a more pleasing visual effect. If the win argument to clearok is the global variable curscr, the next call to wrefresh with any window causes the screen to be cleared and repainted from scratch.
...
If the win argument to wrefresh is the global variable curscr, the screen is immediately cleared and repainted from scratch.
...
The wredrawln routine indicates to curses that some screen lines are corrupted and should be thrown away before anything is written over them. It touches the indicated lines (marking them changed). The routine redrawwin() touches the entire window.
The "OpenBSD manpages" are ncurses. The key-bindings are irrelevant.
You've asked about three features:
But those are different:
clearok()
, you are not telling curses that you've lost track of what's on the screen, but saying that it's preferable to clear it (and curses will do that), butredrawwin()
isn't repainting the whole screen, but a window. Your application might do this if it is imitating the panel library, making some windows overlap and wanting to "raise" an obscured window above the others. Finally,curscr
explicitly is telling curses to bypass the normal sequence of printing onto a window, or onto stdscr
, then applying changes from stdscr
onto newscr
, and applying differences between newscr
and curscr
to curscr
. As far as curses is concerned, curscr
has whatever is put onto the physical screen. So when you modify curscr
, curses updates the physical screen as soon as it is asked to refresh.For what it's worth, the curscr
feature predates ncurses, though I'd have to point to source-code to show that. It's mentioned in this changelog entry from 1995 though:
src/curses/resizwin.c
: refresh curscr to force screen update in ncurses