Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!decwrl!labrea!polya!ali From: ali@polya.Stanford.EDU (Ali T. Ozer) Newsgroups: comp.sys.next Subject: Re: Postscript Previewing? Message-ID: <6778@polya.Stanford.EDU> Date: 10 Feb 89 15:09:24 GMT References: <16435@iuvax.cs.indiana.edu> <1485@mace.cc.purdue.edu> <3060@haven.umd.edu> Reply-To: aozer@NeXT.com (Ali Ozer) Distribution: usa Organization: . Lines: 49 In article rfr@cs.cmu.edu (Rick Rashid) writes: >There is a very simple fix to Yap which, although it is not a perfect >solution, allows you to preview multipage documents. > ... fix: > "/showpage {{buttondown {erasepage exit} if} loop} def\n" > ... >This will cause the previewer to pause waiting for a mouse click each time >it finishes a page. Each time you click it will clear the window and >then process the postscript description of the next page. This hack has >the problem that it erases the entire window (including the border) ... Thanks for the code! Here's a version of the fix that will only erase the internal area of the window. Remember that Yap defines two variables, yapwidth & yapheight, that describe the size of the internal area of the output window. The following code waits for a mouse down on a "showpage" and simply erases that rectangle. We need to save the graphics state at the beginning of the program, however, to assure that any changes made by the user program to the gstate do not screw up are rectfill. We temporarily bring the saved graphics state (yapgstate) to focus everytime we want to do the erase. The following code, like Rick's, has the *massive* problem that it busy waits. The "while not buttondown" loop in the server really brings the postscript performance down. I'll post a better version of the following, without this problem, soon... Diffs to original controller.pswm: 65,68d64 < defineps CreateGState () < /yapgstate gstate def < endps < 144d139 < CreateGState (); 263,267c258,259 < fprintf (fp, "yapgstate currentgstate pop " < "/yapwidth %f def /yapheight %f def\n" < "/showpage {{buttondown {gsave yapgstate setgstate 1 setgray " < "0 0 yapwidth yapheight rectfill grestore exit} if} " < "loop} def /yaptime usertime def\n", --- > fprintf (fp, "/yapwidth %f def /yapheight %f def\n" > "/showpage {} def /yaptime usertime def\n", Ali Ozer, aozer@NeXT.com NeXT Developer Support