[comp.unix.programmer] Life Under Curses

boutell@brahms.udel.edu (Thomas B Boutell) (02/18/91)

I'm the author of a moderately well- known Curses- based game (Broken
Throne), and I know my way around the library pretty well, but there's
one thing I *still* can't seem to do: force a total refresh of the
screen. Not just the parts curses "knows" it has changed, EVERYTHING.
I've run into the need for a redraw key.

mike (02/18/91)

In an article, brahms.udel.edu!boutell (Thomas B Boutell) writes:
>I'm the author of a moderately well- known Curses- based game (Broken
>Throne), and I know my way around the library pretty well, but there's
>one thing I *still* can't seem to do: force a total refresh of the
>screen. Not just the parts curses "knows" it has changed, EVERYTHING.
>I've run into the need for a redraw key.

Use touchwin(win) and then wrefresh(win); if for some reason your
curses library doesn't have 'em, then you can do something like this:

redrawsrc()
{
WINDOW	*w;

	w = newwin(24,80,0,0);	/* create a temporary window */
	overwrite(stdscr,w);	/* copy stdscr to temp window */
	wclear(stdscr);		/* clear stdscr */
	wrefresh(stdscr);	/* and refresh */
	overwrite(w,stdscr);	/* copy the original stdscr back */
	wrefresh(stdscr);	/* refresh again */
	delwin(w);		/* dump the temp window */
}

Hope that this helps.
Cheers,
-- 
Michael Stefanik, MGI Inc., Los Angeles| Opinions stated are not even my own.
Title of the week: Systems Engineer    | UUCP: ...!uunet!bria!mike
-------------------------------------------------------------------------------
Remember folks: If you can't flame MS-DOS, then what _can_ you flame?

john@jwt.UUCP (John Temples) (02/19/91)

In article <464@bria> uunet!bria!mike writes:
>Use touchwin(win) and then wrefresh(win); if for some reason your
>curses library doesn't have 'em, then you can do something like this:

touchwin() didn't seem to do anything at all on my SVR3.2 system when I was
trying to figure out how to do a complete screen redraw.  I ended up doing
{ endwin(); doupdate(); }  That got all windows redrawn.
-- 
John W. Temples -- john@jwt.UUCP (uunet!jwt!john)

jim@segue.segue.com (Jim Balter) (02/20/91)

In article <18812@brahms.udel.edu> boutell@brahms.udel.edu (Thomas B Boutell) writes:
>one thing I *still* can't seem to do: force a total refresh of the
>screen. Not just the parts curses "knows" it has changed, EVERYTHING.

	clearok(stdscr, TRUE);
	refresh();

staceyc@sco.COM (Stacey Campbell) (02/21/91)

In article <18812@brahms.udel.edu> boutell@brahms.udel.edu (Thomas B Boutell) writes:
>[how to] force a total refresh of the screen.

The following works on System V curses, your mileage may vary for BSD;

	wrefresh(curscr);

From the man page curses(3X);

Use of curscr
	The special window curscr can be used in only a few routines.
	If the window argument to clearok is curscr, the next call to
	wrefresh() with any window will cause the screen to be cleared
	and repainted from scratch.  If the window argument to wrefresh()
	is curscr, the screen is immediately cleared and repainted
	from scratch.  (This is how most programs would implement a
	"repaint-screen" routine.)
-- 
                             Stacey Campbell       
                        Internet: staceyc@sco.com
     UUCP: {uunet,ucscc,att,sq,altos,lotus,sun,microsoft}!sco!staceyc

allbery@NCoast.ORG (Brandon S. Allbery KB8JRR) (02/26/91)

As quoted from <1991Feb18.215907.18174@jwt.UUCP> by john@jwt.UUCP (John Temples):
+---------------
| In article <464@bria> uunet!bria!mike writes:
| >Use touchwin(win) and then wrefresh(win); if for some reason your
| >curses library doesn't have 'em, then you can do something like this:
| 
| touchwin() didn't seem to do anything at all on my SVR3.2 system when I was
| trying to figure out how to do a complete screen redraw.  I ended up doing
| { endwin(); doupdate(); }  That got all windows redrawn.
+---------------

All touchwin does is disable some optimization, so wnoutrefresh() has to do
more work to figure out what actually changed.  It doesn't actually force
curses to believe that things *did* change.  This is needed because some
things (subwindows?) can cause things to change without telling the right
parts of curses, so wnoutrefresh() doesn't notice.

++Brandon
-- 
Me: Brandon S. Allbery			    VHF/UHF: KB8JRR on 220, 2m, 440
Internet: allbery@NCoast.ORG		    Packet: KB8JRR @ WA8BXN
America OnLine: KB8JRR			    AMPR: KB8JRR.AmPR.ORG [44.70.4.88]
uunet!usenet.ins.cwru.edu!ncoast!allbery    Delphi: ALLBERY

allbery@NCoast.ORG (Brandon S. Allbery KB8JRR) (02/26/91)

As quoted from <6426@segue.segue.com> by jim@segue.segue.com (Jim Balter):
+---------------
| In article <18812@brahms.udel.edu> boutell@brahms.udel.edu (Thomas B Boutell) writes:
| >one thing I *still* can't seem to do: force a total refresh of the
| >screen. Not just the parts curses "knows" it has changed, EVERYTHING.
| 
| 	clearok(stdscr, TRUE);
| 	refresh();
+---------------

Great if all you're using is stdscr.  But what if you aren't?

	wrefresh(curscr);

works for me.  RTFM.

++Brandon.
-- 
Me: Brandon S. Allbery			    VHF/UHF: KB8JRR on 220, 2m, 440
Internet: allbery@NCoast.ORG		    Packet: KB8JRR @ WA8BXN
America OnLine: KB8JRR			    AMPR: KB8JRR.AmPR.ORG [44.70.4.88]
uunet!usenet.ins.cwru.edu!ncoast!allbery    Delphi: ALLBERY