Reputation: 509
I'm compiling some c code using the ncurses library, under gcc and Fedora. The code is copied exactly from http://techlister.com/linux/creating-menu-with-ncurses-in-c/1293/
It compiles fine but as I manipulate the code I wanted to understand some of ncurses' subtleties - specifically, its screen refresh scheme. I've read in multiple places (this site and elsewhere) statements such as:
The refresh and wrefresh routines (or wnoutrefresh and doupdate) must be called to get actual output to the terminal, as other routines merely manipulate data structures.
I interpret that as meaning if I call things like mvwprintw(), I am only manipulating what amounts to a virtual window, and to get my changes to actually appear, I need to call wrefresh(). However the code I copied only calls wrefresh() once near the top and seems to repaint the screen as needed.
QUESTION: Can some one clarify when one should need to call refresh() or wrefresh()?
Thanks.
Upvotes: 0
Views: 53
Reputation: 54515
The other wrefresh
is happening in this line
while(( ch = wgetch(w)) != 'q'){
because (as noted in the wgetch
manual page):
If the window is not a pad, and it has been moved or modified since the last call to
wrefresh
,wrefresh
will be called before another character is read.
Upvotes: 1