[comp.windows.news] Enhanced psview and DVI previewing

ajcd@lfcs.ed.ac.uk (Angus Duggan) (09/21/89)

I've decided to post my psview enhancements (enlargement/reduction,
scrollbars, European paper sizes, box mode), and my DVILASER/PS previewing
code. If you only want the psview enhancements, you only need the Part 1.

	Have fun,
		Angus
--
Angus Duggan, Department of Computer Science,	| <This space for hire>
University of Edinburgh, JCMB,			| USENET: ajcd@lfcs.ed.ac.uk
The King's Buildings, Mayfield Road,		| JANET:  ajcd@uk.ac.ed.lfcs
Edinburgh, EH9 3JZ, Scotland.	| OR:  ajcd%lfcs.ed.ac.uk@nsfnet-relay.ac.uk

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then feed it
# into a shell via "sh file" or similar.  To overwrite existing files,
# type "sh file -c".
# The tool that generated this appeared in the comp.sources.unix newsgroup;
# send mail to comp-sources-unix@uunet.uu.net if you want that tool.
# If this archive is complete, you will see the following message at the end:
#		"End of archive 1 (of 2)."
# Contents:  README MANIFEST psview.c.diff psview.cps.diff
# Wrapped by ajcd@cheops on Thu Sep 21 15:04:03 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'README' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'README'\"
else
echo shar: Extracting \"'README'\" \(9798 characters\)
sed "s/^X//" >'README' <<'END_OF_FILE'
X
X	Here are my diffs to psview, which add scrollbars, enlargement and
Xreduction, and a "size box". There are a few other minor differences, none of
Xwhich should cause problems.
X	This shar file also contains the necessary files to use psview for
Xpreviewing the output of Arbortext's DVILASER/PS driver.
X
XWARNING:
X	NO WARRANTY OF ANY KIND IS PROVIDED WITH THIS SOFTWARE. USE AT YOUR OWN
XRISK. NO LIABILITY FOR LOSS OF DATA OR DAMAGE IS ACCEPTED BY THE AUTHOR.
X
XN.B.
X	This was also my first attempt at using LiteItems and overlay canvases,
Xperhaps some experienced NeWS programmer would care to look over this code and
Xtell me what (if anything) is wrong with it.
X	You may do whatever you want to with this stuff, but I would like some
Xacknowledgement if you use them in a product. (Please?)
X
X-------------------------------------------------------------------------------
X
XInstallation:
X	To make the new psview, do
X	
X	cd /usr/NeWS/clientsrc/client
X	patch psview.c <psview.c.diff
X	patch psview.cps <psview.cps.diff
X
X	and then "make" it. psview should be installed in /usr/NeWS/bin. For
XDVILASER previewing, psmung should be compiled by
X
X	cc -O -o psmung psmung.c
X
X	then psmung and dviview should be installed in /usr/NeWS/bin, and
Xdvips.opt and dvips.pro should be installed in /usr/NeWS/lib. Your local
Xdvips.fnt should also be copied or linked into /usr/NeWS/lib.
X
X-------------------------------------------------------------------------------
X
XPS previewing:
X	The files psview.c.diff and psview.cps.diff contain diffs for the new
Xversion of psview. The differences from the original version are --
X
Xo	Scrollbars are placed by the viewing area. At normal or reduced sizes,
X	These scrollbars have no effect, but at enlarged sizes they allow
X	panning around the page.
X
Xo	Enlarge, Reduce, and Normal Size entries are available on the client
X	menu, and the e, r, and n keys can be used as accelerators. Enlargement
X	and reduction is by a factor of 1.41 (approx. sqrt(2)). Normal Size
X	rescales the page to fit in the current window size.
X
Xo	A "Box mode" cycler is in the bottom right corner. This can be cycled
X	between off, in, pt, and cm. When box mode is on, the left mouse button
X	can be used to point and size a box around part of the view, and the
X	dimensions and offset of the box (from the lower left corner of the
X	page) will be displayed continuously underneath the view window. The
X	dimensions of the box are displayed in inches, PostScript points
X	(1/72in), or centimetres. The middle button can be used to move the
X	box without altering its' size. The box is only shown on the page on
X	which it was drawn, i.e. if you move to another page while the box is
X	visible it will disappear, and re-appear if you move back to its' page.
X	I find this useful for getting offsets and sizes of PostScript pictures
X	for inclusion in TeX documents.
X
Xo	European paper sizes can be specified by "-A#" on the command line,
X	where # is in the range 0 to 5. The paper is normally in portrait
X	orientation, but landscape can be selected by appending "L" to the
X	option.
X
Xo	%%Page is accepted as a page separator, instead of %%Page:, but
X	%%Pages is rejected. This change was done because the version of
X	DVILASER/PS we are using produces %%Page as a page separator. This
X	change was done before I wrote "psmung", which should probably alter
X	%%Page to %%Page:. Also, it will wrongly accept %%PagePrologue as a
X	separator at the moment.
X
Xo	A test is made to see if a DVILASER output file is being viewed. These
X	files require the prologue download after the page has been resized.
X	Unfortunately, some other files require the prologue download before
X	page sizing, so both possibilities must be available.
X
Xo	psview now accepts input on the stdin stream. This was coded in
X	the original source code, but had been disabled for some inexplicable
X	reason.
X
Xo	The message "Please Wait" is now displayed while loading the prologue.
X	The munged DVILASER prologue is quite slow to load, because it
X	includes all of the font definitions used in the file.
X
Xo	The complete list of possible options to psview is given here:
X	Option		Function				Example
X	-#,#-#,#	page offset and size (in)		-1,1-8,11
X	-b#,#,#		background colour (hsb)			-b0,.99,.9
X	-bh#s#b#						-bh0s0.9b0.87
X	-br#g#b#	background colour (rgb)			-br0g0.9b0.87
X	-B		turn off page outline			-B
X	-c		default background colour		-c
X	-f#,#,#		foreground colour (hsb)			-f0,.99,.9
X	-fh#s#b#						-fh0s0.9b0.87
X	-fr#g#b#	foreground colour (rgb)			-fr0g0.9b0.87
X	-l		landscape slide size 7x11		-l
X	-s		slide height 6.8			-s
X	-S		slide height 5.7			-S
X	-v		verbose					-v
X	-a#		European page sizes a0-a5		-a4
X	-a#l		European page sizes a0-a5, landscape	-a3l
X
X-------------------------------------------------------------------------------
X
XDVI previewing:
X	The other files (psmung.c, dviview, dvips.opt, dvips.fnt, and
Xdvips.pro) are used to preview PostScript output from Arbortext's DVILASER/PS
Xdriver. This previewing option is slow to start up, but fast enough when it's
Xgoing. The big advantage is that PostScript pictures or overlays included in
Xthe TeX document can be previewed.
X	To preview, DVILASER/PS must be run with special option, prologue, and
Xfont files, and the output must be run through the "psmung" filter before
Xviewing. The shell script "dviview" will execute this process. Some points to
Xnote --
X
Xo	Check your version of DVILASER/PS. I have been told that the latest
X	version produces conforming PostScript, and so the psmung filter will
X	be unnecessary with this version. psmung takes the font and character
X	definitions and puts them at the end of the prologue. See the comments
X	in psmung for the format of the sections which are moved.
X
Xo	You should alter the dvips.opt file to reflect your local setup. The
X	important points to note are the printer definition line and the
X	download and reverse option lines. Make the printer parameter
X	"memoryavailable" large enough so that DVILASER/PS won't purge fonts;
X	this saves time and space. The "resolution" parameter should NOT be
X	scaled; NeWS runs into conversion errors if you use Arbortext's
X	suggested scalings.
X
Xo	When imaging 300 dpi fonts onto a Sun screen, a lot of detail is lost.
X	It would be better to build low-resolution versions of the TeX fonts
X	for previewing, at (say) 118 dpi. The resolution option should be
X	changed to reflect this, as should the font file. I just haven't got
X	around to doing this yet. Alternatively, if anyone knows how to alter
X	the scaling procedures to increase the density of the reduced image, I
X	would like to hear about it (but I suspect that this is impossible).
X
Xo	Occasionally characters get dropped, and don't appear properly until
X	the NeWS server is exited and restarted. This seems to happen only
X	when the server has been running for some time, and many documents
X	have been previewed. I have no idea what causes this.
X
Xo	On a different tack, I have a perl script (for v2p18) which will build
X	a new font file, given an option file, and the old font file. It
X	searches for all accessible fonts, sorts the sizes found, inserts the
X	design sizes from the tfm files, cross-references the pk/gf/pxl files
X	with tfm files, while preserving the order, downloading options and
X	PostScript fonts given in the original font file. Mail me if
X	interested.
X
X(And thanks to David Rodgers of Arbortext for allowing me to redistribute the
Xaltered DVILASER/PS prologue.)
X
X-------------------------------------------------------------------------------
X
XProblems encountered:
X	Here is a list of some of the problems encountered, and the solutions
Xadopted (if any).
X
Xo	Error messages. If an error occurs during page display, the message
X	"Page Display Error" is printed at the centre of the current page. I
X	had tried to use a popup error message, but this caused problems when
X	using a non-retained (e.g. colour) display; the popup caused damage to
X	the page, which redisplayed, causing an error which popped up a
X	message, which damaged the page... ad infinitum. I haven't cleaned up
X	the message display yet; if the page routine rotates and scales the
X	page, the message comes out rotated and scaled, and on top of whatever
X	is already on the page.
X
Xo	Reshaping items and overlays. I had problems with sending /reshape
X	message to items. For some types of item (e.g. scrollbars) it worked
X	as expected, but for others (e.g. cycleitems, messageitems), the text
X	within the item boundary was moved relative to the item frame by the x
X	and y amounts, rather than moving the whole item relative to its'
X	parent canvas. I used a /reshape with 0, 0, width, height arguments and
X	then a /move to get this to work. I couldn't get overlay canvases to
X	reshape at all, and had to resort to creating a new overlay each time
X	the parent was reshaped.
X 
Xo	NeWS font machinery. The NeWS setfont operator requires an object of
X	type 'fonttype', and will not accept even well-formed font
X	dictionaries. There were also problems with the matrix supplied to the
X	imagemask operator.
X
Xo	Entries in FontDirectory. Entries for previewing fonts are created in
X	FontDirectory, and are not removed (because of the lack of a complete
X	save/restore implementation in NeWS). Programs which look through
X	FontDirectory may get clogged up with previewer fonts. Only the
X	characters which are used by a document will be defined in these
X	fonts, so trying to select them for other use will cause problems.
X
X-------------------------------------------------------------------------------
X
X	Have fun,
X		Angus
X--
XAngus Duggan, Department of Computer Science,	| <This space for hire>
XUniversity of Edinburgh, JCMB,			| USENET: ajcd@lfcs.ed.ac.uk
XThe King's Buildings, Mayfield Road,		| JANET:  ajcd@uk.ac.ed.lfcs
XEdinburgh, EH9 3JZ, Scotland.	| OR:  ajcd%lfcs.ed.ac.uk@nsfnet-relay.ac.uk

END_OF_FILE
echo shar: NEWLINE appended to \"'README'\"
if test 9799 -ne `wc -c <'README'`; then
    echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'MANIFEST'\"
else
echo shar: Extracting \"'MANIFEST'\" \(620 characters\)
sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
X   File Name		Archive #	Description
X----------------------------------------------------------
X README                     1	Description of this shar file
X MANIFEST                   1	The file you are reading
X psview.c.diff              1	Diffs to psview for enhancements
X psview.cps.diff            1	Diffs to psview for enhancements
X dvips.opt                  2	DVILASER/PS option file for NeWS previewing
X dvips.pro                  2	DVILASER/PS prologue file for NeWS previewing
X dviview                    2	/bin/sh script to preview dvi file
X psmung.c                   2	Filter to rearrange DVILASER/PS output

END_OF_FILE
echo shar: NEWLINE appended to \"'MANIFEST'\"
if test 621 -ne `wc -c <'MANIFEST'`; then
    echo shar: \"'MANIFEST'\" unpacked with wrong size!
fi
# end of 'MANIFEST'
fi
if test -f 'psview.c.diff' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'psview.c.diff'\"
else
echo shar: Extracting \"'psview.c.diff'\" \(5286 characters\)
sed "s/^X//" >'psview.c.diff' <<'END_OF_FILE'
X*** /home/newswin/NeWS1.1/clientsrc/client/psview.c	Mon Feb 22 19:00:44 1988
X--- psview.c	Thu Sep 21 10:03:48 1989
X***************
X*** 61,66 ****
X--- 61,67 ----
X  static	int         box = 1;
X  static	int         recolor;
X  static	int         ditroff = 0;
X+ static	int         dvips = 0;
X  static	int         direction;
X  
X  struct point {
X***************
X*** 213,218 ****
X--- 214,220 ----
X          } 
X      while (fgets(line, sizeof line, f))
X  	if (line[0] == '%')
X+ 	  {
X  	    if (line[1] == '%')
X  		switch (line[2]) {
X  /*-		case 'E':
X***************
X*** 220,226 ****
X  			EndProlog = ftell(f);
X  		    break; */
X  		case 'P':
X! 		    if (strncmp(line + 3, "age:", 4) == 0) {
X  			if (npages >= psize) {
X  			    if (psize)
X  				pagestart = (int *) realloc(pagestart, (psize = npages * 3 / 2) * sizeof(int));
X--- 222,229 ----
X  			EndProlog = ftell(f);
X  		    break; */
X  		case 'P':
X! 		    if ((strncmp(line + 3, "age", 3) == 0) &&
X! 			(line[6] != 's')) {
X  			if (npages >= psize) {
X  			    if (psize)
X  				pagestart = (int *) realloc(pagestart, (psize = npages * 3 / 2) * sizeof(int));
X***************
X*** 236,242 ****
X  		    break;
X  		}
X  	    else if (line[1] == ' ' && line[2] == 'l' && strncmp(line, "% lib/psdit.pro", 15) == 0)
X! 		ditroff = 1;
X      if (npages > 0) {
X  	if (EndProlog < 0 || pagestart[0] < EndProlog)
X  	    EndProlog = pagestart[0];
X--- 239,248 ----
X  		    break;
X  		}
X  	    else if (line[1] == ' ' && line[2] == 'l' && strncmp(line, "% lib/psdit.pro", 15) == 0)
X! 	        ditroff = 1;
X!             else if (line[1] == ' ' && line[3] == 'D' && strncmp(line, "%  Dvips.pro", 12) == 0)
X! 	        dvips = 1;
X! 	  }
X      if (npages > 0) {
X  	if (EndProlog < 0 || pagestart[0] < EndProlog)
X  	    EndProlog = pagestart[0];
X***************
X*** 287,293 ****
X      ps_startpage();
X      PumpBytes(f, pagestart[n], pagestart[n + 1]); 
X      ps_endpage();
X!     if (notfirst)
X          ps_damageall();
X      notfirst = 1;
X  
X--- 293,299 ----
X      ps_startpage();
X      PumpBytes(f, pagestart[n], pagestart[n + 1]); 
X      ps_endpage();
X! /*    if (notfirst)*/
X          ps_damageall();
X      notfirst = 1;
X  
X***************
X*** 325,343 ****
X  		    ps_defBG();
X  	    }
X      }
X-     if (EndProlog > 0) {
X- 	ps_startprolog();
X- 	PumpBytes(f, 0, EndProlog);
X- 	ps_endprolog();
X-     }
X-     if (ditroff)
X- 	ps_ditroff_fix(); 
X      if (npages < 2) 
X          make_MIN_MAX();
X      if (npages >= 2) 
X          make_MAX();
X  
X!     GotoPage(f, 0);
X      {
X  	char        buf[100];
X  #ifndef SYSVREF
X--- 331,346 ----
X  		    ps_defBG();
X  	    }
X      }
X      if (npages < 2) 
X          make_MIN_MAX();
X      if (npages >= 2) 
X          make_MAX();
X  
X!     if (EndProlog > 0 && !dvips) {
X!         ps_startprolog();
X!         PumpBytes(f, 0, EndProlog);
X!         ps_endprolog();
X!     }
X      {
X  	char        buf[100];
X  #ifndef SYSVREF
X***************
X*** 354,359 ****
X--- 357,372 ----
X  	*dest++ = 0;
X  	ps_setupwindow(buf[0] ? buf : "Preview");
X      }
X+     if (EndProlog > 0 && dvips) {
X+         ps_dvips_fix();
X+         ps_startprolog();
X+         PumpBytes(f, 0, EndProlog);
X+         ps_endprolog();
X+     }
X+     if (ditroff)
X+ 	ps_ditroff_fix(); 
X+     ps_prolog_done();
X+     GotoPage(f, 0);
X      while (!psio_error(PostScriptInput) && !psio_eof(PostScriptInput))
X  	if (get_page_selection(&page_selection)) 
X  		GotoPage(f, page_selection - 1); 		
X***************
X*** 367,377 ****
X      char       *filename = 0;	/* The file to be previewed */
X      char       *tempname = 0;	/* The name of a temporary file, if we created
X  				 * one */
X      ProgramName = argv[0];
X!     if (argv[1] == NULL) { 
X  	   printf("%s: Requires PostScript filename.\n",ProgramName );
X             exit(0); 
X!     }
X      while (--argc > 0)
X  	if ((++argv)[0][0] == '-')
X  	    switch (argv[0][1]) {
X--- 380,393 ----
X      char       *filename = 0;	/* The file to be previewed */
X      char       *tempname = 0;	/* The name of a temporary file, if we created
X  				 * one */
X+     char       asize;           /* the size of A? paper */
X+     short      temp;            /* for swapping sizes */
X+ 
X      ProgramName = argv[0];
X! /*-    if (argv[1] == NULL) { 
X  	   printf("%s: Requires PostScript filename.\n",ProgramName );
X             exit(0); 
X!     } */
X      while (--argc > 0)
X  	if ((++argv)[0][0] == '-')
X  	    switch (argv[0][1]) {
X***************
X*** 390,395 ****
X--- 406,442 ----
X  			    ProgramName, argv[0]);
X  		    exit(-1);
X  		}
X+ 		break;
X+ 	    case 'a':
X+ 	    case 'A':
X+ 		asize = argv[0][2];
X+ 		if (asize < '0' || asize > '5') {
X+ 		    fprintf(stderr, "%s: Bad page size `%s'\n", ProgramName, argv[0]);
X+ 		    exit(-1);
X+ 		}
X+ 		size.x = 2381;
X+ 		size.y = 3368;
X+ 		while (asize-- > '0') {
X+ 		    short temp;
X+ 		    temp = size.y;
X+ 		    size.y = size.x;
X+ 		    size.x = temp / 2;
X+ 		}
X+ 		switch (argv[0][3]) {
X+ 		case 'L':
X+ 		case 'l':
X+ 		    temp = size.x; size.x = size.y; size.y = temp;
X+ 		    break;
X+ 		case 'P':
X+ 		case 'p':
X+ 		case '\0':
X+ 		    break;
X+ 		default:
X+ 		    fprintf(stderr, "%s: Bad page orientation `%s'\n", ProgramName, argv[0]);
X+ 		    exit(-1);
X+ 		}
X+ 		center.x = size.x / 2;
X+ 		center.y = size.y / 2;
X  		break;
X  	    case 'b':
X  		if (!parse_color(&argv[0][2], &FGBG[1])) {

END_OF_FILE
echo shar: NEWLINE appended to \"'psview.c.diff'\"
if test 5287 -ne `wc -c <'psview.c.diff'`; then
    echo shar: \"'psview.c.diff'\" unpacked with wrong size!
fi
# end of 'psview.c.diff'
fi
if test -f 'psview.cps.diff' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'psview.cps.diff'\"
else
echo shar: Extracting \"'psview.cps.diff'\" \(12841 characters\)
sed "s/^X//" >'psview.cps.diff' <<'END_OF_FILE'
X*** /home/newswin/NeWS1.1/clientsrc/client/psview.cps	Mon Feb 22 19:00:45 1988
X--- psview.cps	Thu Sep 21 10:03:49 1989
X***************
X*** 33,64 ****
X  	/BG 1 1 1 rgbcolor def
X  	/errordict 10 dict def
X  	errordict /rangecheck { stop } put
X! 	systemdict /settransfer /pop load def
X  	/settransfer {pop} def 
X  	/currenttransfer { { } } def
X  	/currentscreen { 0 0 { } } def
X  	/setscreen { pop pop pop } def
X  	/definefont { exch dup type /keywordtype ne { (                                    ) cvs cvn } if
X! 			exch definefont } def
X  	/StandardEncoding magic:AdobeSequence def
X  	magic:fontdict /Encoding StandardEncoding put
X!     /PGC { } def
X      /DoBox true def
X      /privudict 200 dict def
X      /@Dicts 0 array def
X!     /ps_paint {
X! 	PSCanvas setcanvas
X! 	initmatrix
X! 	clippath pathbbox
X  	h div exch w div min dup scale pop pop
X  	pathbbox 2 div exch 2 div exch translate pop pop
X  	cx neg cy neg translate
X  	FG setcolor
X! 	DoBox { cx w 2 div sub cy h 2 div sub moveto w h rect stroke } if
X! 	/paint PSItem send
X          FrameBorderColor strokecanvas 
X! 	startmatrix concat
X! 	PGC
X      } def
X      [1 0 0 1 0 0] setmatrix
X  cdef ps_ditroff_fix()
X--- 33,83 ----
X  	/BG 1 1 1 rgbcolor def
X  	/errordict 10 dict def
X  	errordict /rangecheck { stop } put
X! %	systemdict /settransfer /pop load put
X  	/settransfer {pop} def
X  	/currenttransfer { { } } def
X  	/currentscreen { 0 0 { } } def
X  	/setscreen { pop pop pop } def
X  	/definefont { exch dup type /keywordtype ne { (                                    ) cvs cvn } if
X! 			exch //definefont } def
X  	/StandardEncoding magic:AdobeSequence def
X  	magic:fontdict /Encoding StandardEncoding put
X!     /PGC {
X! 	cx cy moveto
X! 	/Times-Roman findfont 20 scalefont setfont
X! 	(Please Wait) cshow
X!     } def
X      /DoBox true def
X+     /PrologDone false def
X+     /PSPageW w def
X+     /PSPageH h def
X      /privudict 200 dict def
X      /@Dicts 0 array def
X!     /ps_scale { % canvas => -  scale and translate canvas
X! 	setcanvas initmatrix clippath pathbbox
X  	h div exch w div min dup scale pop pop
X  	pathbbox 2 div exch 2 div exch translate pop pop
X  	cx neg cy neg translate
X+ 	PSScale PSPageX PSPageY translate dup scale
X+ 	startmatrix concat
X+     } def
X+     /ps_paint {
X+ 	PSCanvas ps_scale
X  	FG setcolor
X! 	PrologDone {
X! 		DoBox { cx w 2 div sub cy h 2 div sub moveto
X! 			w h rect stroke } if
X! 		/paint PSSlider send
X! 		/paint PSHbar send /paint PSVbar send
X! 		/paint PScycle send
X  	        FrameBorderColor strokecanvas
X! 	} if
X! %	startmatrix concat
X! 	{PGC} stopped {
X! 		cx cy moveto
X! 		/Times-Roman findfont 20 scalefont setfont
X! 		(Page Display Error) cshow
X! 	} if
X      } def
X      [1 0 0 1 0 0] setmatrix
X  cdef ps_ditroff_fix()
X***************
X*** 82,89 ****
X  	/new_page { % new page number => -
X  		    dup /PageCount exch store
X  		    PAGE_TAG tagprint typedprint
X! 		    PSItem /ItemValue PageCount put
X! 		    /paint PSItem send
X  		  } def 
X  	/NEXT	  { PageCount 1 add dup MAX gt {pop}
X  		    { new_page } ifelse } def
X--- 101,108 ----
X  	/new_page { % new page number => -
X  		    dup /PageCount exch store
X  		    PAGE_TAG tagprint typedprint
X! 		    PSSlider /ItemValue PageCount put
X! 		    /paint PSSlider send
X  		  } def
X  	/NEXT	   { PageCount 1 add dup MAX gt {pop}
X  		     { new_page } ifelse } def
X***************
X*** 92,98 ****
X--- 111,163 ----
X  	/REDIS     { PageCount new_page } def
X   	/FIRST     { MIN new_page } def
X   	/LAST      { MAX new_page } def
X+ 	/new_scale { /PSPageX PSHbar /ItemValue get
X+ 		     PSScale 1 sub 0 max PSPageW mul mul neg def
X+ 		     /PSPageY PSVbar /ItemValue get
X+ 		     PSScale 1 sub 0 max PSPageH mul mul neg def
X+ 		   } def
X+ 	/ENLARGE   { {PSScale 1.41 mul /PSScale exch def
X+ 		      new_scale paint} win send
X+ 		   } def
X+ 	/REDUCE	   { {PSScale 1.41 div /PSScale exch def
X+ 		      new_scale paint} win send
X+ 		   } def
X+ 	/NORMAL	   { {/PSScale 1 def /PSPageX 0 def /PSPageY 0 def
X+ 		      paint} win send
X+ 		   } def
X+ 	/LEFT	   { {PScycle /ItemValue get 0 ne
X+ 		     {gsave
X+ 			PSOverlay ps_scale currentcursorlocation 2 copy
X+ 			{y0 sub exch x0 sub exch rect
X+ 			 x0 y0 x y points2rect /PSdisplay win send} getanimated
X+ 			waitprocess aload pop points2rect
X+ 			/PSBoxH exch def /PSBoxW exch def
X+ 			/PSBoxY exch def /PSBoxX exch def
X+ 			/PSBoxP PageCount def paintov
X+ 		       grestore} {NEXT} ifelse} win send
X+ 		   } def
X+ 	/MIDDLE	   { {PScycle /ItemValue get 0 ne PSBoxP PageCount eq and
X+ 		     {gsave
X+ 			PSOverlay ps_scale currentcursorlocation 2 copy
X+ 			{y0 sub PSBoxY add exch x0 sub PSBoxX add exch
X+ 			 2 copy moveto PSBoxW PSBoxH rect
X+ 			 PSBoxW PSBoxH /PSdisplay win send} getanimated
X+ 			waitprocess aload pop
X+ 			PSBoxY add exch PSBoxX add
X+ 			4 -1 roll sub /PSBoxX exch def
X+ 			exch sub /PSBoxY exch def paintov
X+ 		      grestore} if} win send
X+ 		   } def
X  	/EXIT      { EXIT_TAG tagprint } def
X+ 	/clearov { PSOverlay ps_scale erasepage } def
X+ 	/paintov { clearov
X+ 		PScycle /ItemValue get 0 ne PSBoxP PageCount eq and {
X+ 			PSBoxX PSBoxY PSBoxW PSBoxH rectpath stroke
X+ 			PSBoxX PSBoxY PSBoxW PSBoxH PSdisplay
X+ 		} {
X+ 			() /printstring PSmessage send
X+ 		} ifelse
X+ 	} def
X  	/paintfr {
X  	  win /FrameLabel fr_label put
X  	  /paint win send
X***************
X*** 101,116 ****
X  	/fr_data name def 
X  %
X  	/PSWindow DefaultWindow      
X!         /PSCanvas	null def	% the 2 sub windows
X!         /PSItem		null def	%
X    	/PageCount	1  def		% current page number, initially = 1 
X  	/MIN		1  def 	        % MIN always = 1, MAX sent by client
X  %
X     dictbegin 	        
X  	/FrameLabel fr_label def
X! 	/PaintClient { ps_paint } def
X  	/FrameFillColor BG def
X  	/IconHeight 15 def
X  %
X  %	gsave
X  %	    IconFont setfont
X--- 166,196 ----
X  	/fr_data name def
X  %
X  	/PSWindow DefaultWindow
X!         /PSCanvas	null def	% the image sub window
X! 	/PSScale	1 def		% image scale
X! 	/PSPageX	0 def		% image translation (in)
X! 	/PSPageY	0 def
X!         /PSOverlay	null def	% box overlay
X! 	/PSBoxX		0 def
X! 	/PSBoxY		0 def
X! 	/PSBoxW		0 def
X! 	/PSBoxH		0 def
X! 	/PSBoxP		-1 def
X!         /PSSlider	null def	% page slider
X! 	/PSHbar		null def	% scroll bars
X! 	/PSVbar		null def	% scroll bars
X! 	/PScycle	null def	% box cycle
X! 	/PSmessage	null def	% box message
X    	/PageCount	1  def		% current page number, initially = 1
X  	/MIN		1  def 	        % MIN always = 1, MAX sent by client
X  %
X     dictbegin
X  	/FrameLabel fr_label def
X! 	/PaintClient { clearov ps_paint paintov } def
X  	/FrameFillColor BG def
X  	/IconHeight 15 def
X+ 	/HbarLen 0 def
X+ 	/VbarLen 0 def
X  %
X  %	gsave
X  %	    IconFont setfont
X***************
X*** 131,136 ****
X--- 211,219 ----
X  %	    (Redisplay)         { REDIS }
X  	    (First Page)	{ FIRST }
X  	    (Last Page)  	{ LAST  }
X+ 	    (Enlarge)		{ ENLARGE }
X+ 	    (Reduce)		{ REDUCE }
X+ 	    (Normal Size)	{ NORMAL }
X  	    (Quit)         	{ EXIT  }
X  	] /new DefaultMenu send def
X     dictend
X***************
X*** 147,176 ****
X  	    { page new_page } ifelse
X  	    dictend
X          } def
X  	% Override two methods: the Client create & shape methods
X      	/CreateClientCanvas {
X      	    % create the ClientCanvas:
X      	    /CreateClientCanvas super send   	    
X      	    % Create the slider item:
X! 		/Item_len 200 def 
X! 	        /PSItem (Page Number: ) [ MIN MAX PageCount ]
X  		/Right {ItemValue /PSset win send}
X! 		ClientCanvas Item_len 0 /new SliderItem send
X  		dup /ItemFrame 1 put
X! 		20 5 /move 3 index send store 
X  
X! 	    % Activate the slider:
X! 	    [PSItem] forkitems pop	    
X  	    % Create the PostScript subwindow:
X  	    /PSCanvas ClientCanvas newcanvas store
X  	    PSCanvas /Mapped true put
X      	} def
X      	/ShapeClientCanvas {	   
X      	    % [Re] Shape the ClientCanvas:
X  	    /ShapeClientCanvas super send
X  	    ClientCanvas setcanvas 	    
X! 	    % Move the slider:
X! 	    20 5 /move PSItem send	    
X  	    % [Re] Shape the PostScript subwindow:
X  	    gsave
X  	       ClientCanvas setcanvas clippath pathbbox
X--- 230,324 ----
X  	    { page new_page } ifelse
X  	    dictend
X          } def
X+         /PSHscroll { % frac => -
X+ 	    PSScale 1 sub 0 max PSPageW mul mul neg
X+ 	    dup PSPageX eq
X+ 	    {pop} {/PSPageX exch def paint} ifelse
X+         } def
X+         /PSVscroll { % frac => -
X+ 	    PSScale 1 sub 0 max PSPageH mul mul neg
X+ 	    dup PSPageY eq
X+ 	    {pop} {/PSPageY exch def paint} ifelse
X+         } def
X+ 	/PSdisplay { % x0 y0 x y => -
X+ 	    PScycle /ItemValue get { % scale values
X+ 	      1 {4 {1.389 mul cvi 100 div 4 1 roll} repeat}	%inches
X+ 	      2 {4 {cvi 4 1 roll} repeat} 			%points
X+ 	      3 {4 {3.527 mul cvi 100 div 4 1 roll} repeat}	%centimetres
X+ 	    } case
X+             (X=% Y=% W=% H=%) [6 2 roll] /printf PSmessage send
X+ 	} def
X  	% Override two methods: the Client create & shape methods
X      	/CreateClientCanvas {
X      	    % create the ClientCanvas:
X      	    /CreateClientCanvas super send
X+ %	    ClientCanvas /Transparent false put
X+ %	    ClientCanvas /Mapped true put
X+ 	    % set up width factors:
X+ 		/SliderLen 150 def
X+ 		/HbarLen 200 def
X+ 		/VbarLen 200 def
X+ 		/CycleLen 60 def
X+ 		/MessageLen 225 def
X+ 
X      	    % Create the slider item:
X! 	        /PSSlider (Page: ) [ MIN MAX PageCount ]
X  		/Right {ItemValue /PSset win send}
X! 		ClientCanvas SliderLen 0 /new SliderItem send
X  		dup /ItemFrame 1 put
X! %		PSInset 5 /move 3 index send
X! 		store
X  
X! 	    % create scrollbars
X! 		/PSHbar [0 1 .01 .1 null] 0 {ItemValue /PSHscroll win send}
X! 		ClientCanvas 0 HbarLen /new SimpleScrollbar send
X! 		dup /BarVertical? false put
X! %		PSInset VbarLen PSInset add /move 3 index send
X! 		store
X! 
X! 		/PSVbar [0 1 .01 .1 null] 1 {ItemValue /PSVscroll win send}
X! 		ClientCanvas 0 VbarLen /new SimpleScrollbar send
X! %		HbarLen PSInset add PSItemHeight /move 3 index send
X! 		store
X! 
X! 	    % create box cycle
X! 		/PScycle (Box: ) [(off) (in) (pt) (cm)]
X! 		/Right {/paintov win send}
X! 		ClientCanvas CycleLen 0 /new CycleItem send
X! 		dup /ItemFrame 1 put
X! %		PSInset HbarLen add CycleLen 2 div sub 5 /move 3 index send
X! 		store
X! 
X! 	    % create message box
X! 		/PSmessage () () /Right {}
X! 		ClientCanvas MessageLen 0 /new MessageItem send
X! %		HbarLen 2 div PSInset add MessageLen 2 div sub 5 /move 3 index send
X! 		store
X! 
X! 	    % Activate the controls
X! 	    [PSSlider PSHbar PSVbar PScycle PSmessage] forkitems pop
X  	    % Create the PostScript subwindow:
X  	    /PSCanvas ClientCanvas newcanvas store
X  	    PSCanvas /Mapped true put
X+ 	    /PSOverlay PSCanvas createoverlay store
X      	} def
X      	/ShapeClientCanvas {
X      	    % [Re] Shape the ClientCanvas:
X  	    /ShapeClientCanvas super send
X  	    ClientCanvas setcanvas
X! 	    % Move the controls
X! 	    gsave
X! 		ClientCanvas setcanvas clippath pathbbox points2rect
X! 		PSInset sub PSItemHeight sub /VbarLen exch def
X! 		PSInset 2 mul sub /HbarLen exch def
X! 		pop pop
X! 	    grestore
X! 	    PSInset 5 /move PSSlider send
X! 	    PSInset VbarLen PSItemHeight add HbarLen 16 /reshape PSHbar send
X! 	    HbarLen PSInset add PSItemHeight 16 VbarLen /reshape PSVbar send
X! 	    PSInset HbarLen add CycleLen sub 5 /move PScycle send
X! 	    PSInset HbarLen add CycleLen sub MessageLen sub PSInset sub 5
X! 		/move PSmessage send
X  	    % [Re] Shape the PostScript subwindow:
X  	    gsave
X  		ClientCanvas setcanvas clippath pathbbox
X***************
X*** 177,182 ****
X--- 325,332 ----
X  		PSInset PSItemHeight translate
X  		PSItemHeight sub PSInset sub exch PSInset 2 mul sub exch
X  		rectpath PSCanvas reshapecanvas
X+ %		PSCanvas setcanvas clippath PSOverlay reshapecanvas
X+ 		/PSOverlay PSCanvas createoverlay store
X  	    grestore
X      	} def
X      classend def
X***************
X*** 197,205 ****
X  	62 { LAST } def	% '>'
X  	46 { LAST } def	% ','
X  	36 { LAST } def	% '$'
X  	3  { EXIT } def	% ^C
X  	113 {EXIT } def	% 'q'
X! 	/LeftMouseButton {NEXT} def
X      end
X  
X  { 		% done as a separate process so the file reading
X--- 347,359 ----
X  	62 { LAST } def	% '>'
X  	46 { LAST } def	% ','
X  	36 { LAST } def	% '$'
X+ 	101 { ENLARGE } def % 'e'
X+ 	114 { REDUCE } def % 'r'
X+ 	110 { NORMAL } def % 'n'
X  	3  { EXIT } def	% ^C
X  	113 {EXIT } def	% 'q'
X! 	/LeftMouseButton {LEFT} def
X! 	/MiddleMouseButton {MIDDLE} def
X      end
X  
X  { 		% done as a separate process so the file reading
X***************
X*** 214,219 ****
X--- 368,374 ----
X          /Name 200 dict dup begin
X  	    0 1 127 { dup def } for
X  	    /LeftMouseButton dup def
X+ 	    /MiddleMouseButton dup def
X  	end def
X  	/Action /DownTransition def
X  	/Canvas currentcanvas def
X***************
X*** 242,247 ****
X--- 397,406 ----
X      { countdictstack @DictHeight le { exit } if
X        end } loop
X      def
X+ cdef ps_dvips_fix()
X+ 	{PSCanvas ps_scale} win send
X+ cdef ps_prolog_done()
X+ 	/PrologDone true def
X  cdef ps_startprolog()
X  	/@DictHeight countdictstack def
X  	privudict begin

END_OF_FILE
echo shar: NEWLINE appended to \"'psview.cps.diff'\"
if test 12842 -ne `wc -c <'psview.cps.diff'`; then
    echo shar: \"'psview.cps.diff'\" unpacked with wrong size!
fi
# end of 'psview.cps.diff'
fi
echo shar: End of archive 1 \(of 2\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 2 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked both archives.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
Angus Duggan, Department of Computer Science,	| <This space for hire>
University of Edinburgh, JCMB,			| USENET: ajcd@lfcs.ed.ac.uk
The King's Buildings, Mayfield Road,		| JANET:  ajcd@uk.ac.ed.lfcs
Edinburgh, EH9 3JZ, Scotland.	| OR:  ajcd%lfcs.ed.ac.uk@nsfnet-relay.ac.uk

ajcd@lfcs.ed.ac.uk (Angus Duggan) (09/21/89)

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then feed it
# into a shell via "sh file" or similar.  To overwrite existing files,
# type "sh file -c".
# The tool that generated this appeared in the comp.sources.unix newsgroup;
# send mail to comp-sources-unix@uunet.uu.net if you want that tool.
# If this archive is complete, you will see the following message at the end:
#		"End of archive 2 (of 2)."
# Contents:  dvips.opt dvips.pro dviview psmung.c
# Wrapped by ajcd@cheops on Thu Sep 21 15:04:05 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'dvips.opt' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'dvips.opt'\"
else
echo shar: Extracting \"'dvips.opt'\" \(875 characters\)
sed "s/^X//" >'dvips.opt' <<'END_OF_FILE'
X%
X% This is the version of DVIPS.OPT distributed with
X% the Sun Workstation version of DVILASER/PS.
X% The Apollo and VAX/VMS versions differ slightly.
X%
X% Establish local defaults for DVILASER/PS. 
X%
X% Any DVILASER/PS commands can be placed in this file.  For 
X% example, commands to declare the paper width and height
X% as well as which PostScript printer is being used.
X%
X% tfmpath is set up to use the same tfm files as TeX.
X% new paths for pixels and tfms  AJCD 23/11/88
X% AJS Changed downloaded fonts => memoryavailable has changed
Xprinter LaserWriter memoryavailable 1000000 resolution 300 300
Xpixelpath /usr/local/share/tex/fonts/pk/canon /usr/local/share/tex/fonts/pk/arbor /usr/local/share/tex/fonts/pk/dist /usr/local/share/tex/fonts/pk/agfa
Xtfmpath /usr/local/share/tex/fonts/tfm
Xheight 11.65in
Xwidth 8.22in
Xreverse off
Xxy 1.3in 1.6in
Xdownload all prolog
X%verbose

END_OF_FILE
echo shar: NEWLINE appended to \"'dvips.opt'\"
if test 876 -ne `wc -c <'dvips.opt'`; then
    echo shar: \"'dvips.opt'\" unpacked with wrong size!
fi
# end of 'dvips.opt'
fi
if test -f 'dvips.pro' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'dvips.pro'\"
else
echo shar: Extracting \"'dvips.pro'\" \(17432 characters\)
sed "s/^X//" >'dvips.pro' <<'END_OF_FILE'
X% 
X%  Dvips.pro - included prolog for DviLaser-generated PostScript files.
X%
X%  This version hacked for NeWS previewing - AJCD 22/3/89
X% 
X%  Copyright (c) 1986-88, ArborText, Inc.  All Rights Reserved.
X%
X%  This PostScript prolog code is part of the proprietary DVILASER/PS
X%  program package and may not be copied or re-distributed without
X%  the permission of ArborText, Inc. 
X%
X
X/DeFiNeFoNt /definefont load def
X
X/definefont {
X  exch {findfont} stopped
X  {exch DeFiNeFoNt}
X  {exch pop}
X  ifelse
X} bind def
X
Xsystemdict /setpacking known  % use array packing mode if its available
X  {/savepackingmode currentpacking def 
X   true setpacking}
X  if
X 
X/$DviLaser where
X  {pop}
X  {/$DviLaser 200 dict def}
X  ifelse 
X 
X% Begin document
X/BeginDviLaserDoc {
X  vmstatus pop pop 0 eq 
X    { $DviLaser begin 
X      InitializeState }
X    { /DviLaserJob save def
X      $DviLaser begin
X      InitializeState
X      /DviLaserFonts save def }
X    ifelse
X} bind def
X 
X% End document
X/EndDviLaserDoc {
X  vmstatus pop pop 0 eq 
X    { end }
X    { DviLaserFonts restore
X      end
X      DviLaserJob restore }
X    ifelse
X} bind def
X 
X$DviLaser begin
X
X/tempstr 64 string def
X/tempint 0 def
X/tempmatrix matrix def
X 
X%
X%  Debugging routines
X%
X/DebugMode false def
X
X/PrintInt {
X  tempstr cvs print
X} bind def
X
X/PrintLn {
X  (\n) print flush
X} bind def
X 
X/PrintVMStats {
X  (VM status - ) print
X  vmstatus
X  3 copy
X  PrintInt (\(total\), ) print
X  PrintInt (\(used\), ) print
X  pop
X  exch sub 
X  PrintInt (\(remaining\), ) print
X  PrintInt (\(level\)) print
X  PrintLn
X} bind def
X 
X/VMS /PrintVMStats load def 
X 
X/VMSDebug {
X  DebugMode
X    {PrintVMStats}
X    {pop}
X    ifelse
X} bind def
X 
X(beginning of common prolog) VMSDebug 
X
X% Make it easy to bind definitions.
X/bdef /def load def %{ bind def } bind def
X/xdef { exch def } bdef
X
X% Begin page
X/BP {
X  /Magnification xdef
X  /DviLaserPage save def
X  (beginning of page) VMSDebug 
X} bdef
X 
X% End page
X/EP {
X  DviLaserPage restore
X} bdef
X 
X% Exit page (temporarily) to add fonts/characters.
X/XP {
X  % Save current point information so it can be reset later. 
X  /Xpos where {pop Xpos} {0} ifelse
X  /Ypos where {pop Ypos} {0} ifelse
X  {currentpoint} stopped {0 0 moveto currentpoint} if 
X  /DviLaserPage where {pop DviLaserPage restore} if
X  moveto
X  /Ypos xdef
X  /Xpos xdef
X} bdef
X 
X% Resume page
X/RP {
X  /DviLaserPage save def
X} bdef
X 
X% Purge all fonts to reclaim memory space. 
X/PF {
X  GlobalMode
X  LocalMode
X} bdef
X 
X% Switch to base save/restore level, saving state information. 
X/GlobalMode {
X  /UserSave where {pop UserSave} if  % invoke "UserSave" if available
X  PortraitMode 
X  PaperWidth 
X  PaperHeight 
X  PxlResolution 
X  Resolution 
X  Magnification
X  Ymax
X  RasterScaleFactor
X  % Save current point information so it can be reset later. 
X  /currentpoint cvx stopped {0 0 moveto currentpoint} if 
X  /DviLaserPage where {pop DviLaserPage restore} if
X  DviLaserFonts restore
X  RecoverState
X} bdef
X 
X% Preserve state at the base level.
X/RecoverState {
X  10 copy
X  /Ypos xdef
X  /Xpos xdef
X  /RasterScaleFactor xdef
X  /Ymax xdef
X  /Magnification xdef
X  /Resolution xdef
X  /PxlResolution xdef
X  /PaperHeight xdef
X  /PaperWidth xdef
X  /PortraitMode xdef
X  DoInitialScaling
X  PortraitMode not {PaperWidth 0 SetupLandscape} if
X  Xpos Ypos moveto
X} bdef
X
X% Initialize state variables to default values.
X/InitializeState {
X  /Resolution 3600.0 def
X  /PxlResolution 300.0 def
X  /RasterScaleFactor PxlResolution Resolution div def
X  /PortraitMode true def
X  GetPageDimensions
X  72.0 div Resolution mul /PaperHeight xdef
X  72.0 div Resolution mul /PaperWidth xdef
X  /Ymax PaperHeight def
X  /Magnification 1000.0 def
X  /Xpos 0.0 def
X  /Ypos 0.0 def
X  /InitialMatrix {{PSCanvas ps_scale matrix currentmatrix} win send} def
X} bdef
X 
X%
X%  Procedure to figure out the current page dimensions.  There unfortunately
X%  is no direct way to obtain this information.  This approach works for 
X%  letter, note, and legal page sizes.
X%
X%      GetPageDimensions <height> <width>
X%
X/GetPageDimensions {
X  /PSPageW win send 72.0 mul /PSPageH win send 72.0 mul
X} bdef
X
X% Switch from base save/restore level, restoring state information. 
X/LocalMode {
X  /Ypos xdef
X  /Xpos xdef
X  /RasterScaleFactor xdef
X  /Ymax xdef
X  /Magnification xdef
X  /Resolution xdef
X  /PxlResolution xdef
X  /PaperHeight xdef
X  /PaperWidth xdef
X  /PortraitMode xdef
X  DoInitialScaling
X  PortraitMode not {PaperWidth 0 SetupLandscape} if
X  Xpos Ypos moveto
X  /UserRestore where {pop UserRestore} if  % invoke "UserRestore" if available
X  /DviLaserFonts save def
X  /DviLaserPage save def
X} bdef
X 
X% Abbreviations 
X/S /show load def
X/SV /save load def
X/RST /restore load def
X 
X/Yadjust {Ymax exch sub} bdef
X 
X% (x,y) position absolute, just set Xpos & Ypos, don't move.
X/SXY {
X  Yadjust 
X  /Ypos xdef /Xpos xdef
X} bdef
X 
X% (x,y) position absolute
X/XY {
X  Yadjust 
X  2 copy /Ypos xdef /Xpos xdef
X  moveto
X} bdef
X 
X% (x,0) position absolute
X/X {
X  currentpoint exch pop 
X  2 copy /Ypos xdef /Xpos xdef
X  moveto
X} bdef
X 
X% (0,y) position absolute
X/Y {
X  currentpoint pop exch Yadjust 
X  2 copy /Ypos xdef /Xpos xdef
X  moveto
X} bdef
X 
X% (x,y) position relative
X/xy {
X  neg rmoveto
X  currentpoint /Ypos xdef /Xpos xdef
X} bdef
X 
X% (x,0) position relative
X/x {
X  0.0 rmoveto
X  currentpoint /Ypos xdef /Xpos xdef
X} bdef
X 
X% (0,y) position relative
X/y {
X  0.0 exch neg rmoveto
X  currentpoint /Ypos xdef /Xpos xdef
X  } bdef
X 
X% Print a rule
X/R {
X  /ht xdef
X  /wd xdef 
X  gsave
X    0 setgray
X    currentpoint
X    newpath
X      moveto
X      0.0 ht rlineto
X      wd 0.0 rlineto
X      0.0 ht neg rlineto
X      wd neg 0.0 rlineto
X    closepath fill
X  grestore
X  wd 0.0 rmoveto
X  currentpoint /Ypos xdef /Xpos xdef
X} bdef
X
X%
X%  <PXL-file resolution(pix/inch)> <resolution(pix/inch)> RES
X%
X/RES {
X  /Resolution xdef
X  /PxlResolution xdef
X  /RasterScaleFactor PxlResolution Resolution div def
X  DoInitialScaling
X} bdef
X
X%
X% Do initial scaling.
X%
X/DoInitialScaling {
X  InitialMatrix setmatrix
X  72.0 Resolution div dup scale   
X} bdef
X 
X%
X%  <paper-height(pix)> <paper-width(pix)> PM 
X%
X/PM { 
X  XP
X  /PaperWidth xdef 
X  /PaperHeight xdef
X  /Ymax PaperHeight def
X  /PortraitMode true def
X  DoInitialScaling
X  RP
X} bdef  
X 
X%
X%  <paper-height(pix)> <paper-width(pix)> LM 
X%
X/LM {
X  XP
X  /PaperWidth xdef 
X  /PaperHeight xdef
X  /Ymax PaperWidth def
X  /PortraitMode false def
X  DoInitialScaling
X  PaperWidth 0 SetupLandscape
X  RP
X} bdef  
X  
X% Change magnification setting
X/MAG {
X  XP
X  /Magnification xdef
X  RP
X} bdef
X 
X%
X%  Switch to landscape mode
X%
X/SetupLandscape {
X  translate
X  90.0 rotate
X} bdef
X 
X%
X%  <mode> SPB - begin "\special" mode
X%
X%  This is the PostScript procedure used to transfer from the internal
X%  environment used for the DVI translation code emitted by DVIPS to
X%  a standard PostScript environment.
X%
X%  Parameters: 0 - Local
X%              1 - Global
X%              2 - Inline
X%
X/SPB {
X  /spc_mode xdef
X  spc_mode 0 eq spc_mode 2 eq or
X    {XP}
X    {spc_mode 1 eq {GlobalMode} if} 
X    ifelse
X  Resolution 72.0 div dup scale        % Restore default scaling...
X  Magnification 1000.0 div dup scale   % Adjust for any magnification...
X  /Xpos Xpos 72.0 Resolution div mul 1000.0 Magnification div mul def
X  /Ypos Ypos 72.0 Resolution div mul 1000.0 Magnification div mul def
X} bdef
X 
X%
X%  <mode> SPE - end "\special" mode
X%
X%  This is the PostScript procedure used to reenter the internal
X%  environment used for the DVI translation code emitted by DVIPS from 
X%  the standard PostScript environment provided for processing user-supplied
X%  PostScript code.
X%
X%  Parameters: 0 - Local
X%              1 - Global
X%              2 - Inline
X%
X/SPE {
X  /spc_mode xdef
X  1000.0 Magnification div dup scale   % Un-adjust for any magnification...
X  72.0 Resolution div dup scale        % Restore default internal scaling...
X  spc_mode 0 eq spc_mode 2 eq or
X    {RP}
X    {spc_mode 1 eq {LocalMode} if} 
X    ifelse
X} bdef
X 
X%
X%  <num-copies> PP
X%
X/PP {
X  /#copies xdef
X  showpage
X  /#copies 1 def
X} bdef
X 
X%
X%  CLRP
X%
X/CLRP {
X%  erasepage
X} bdef
X 
X%
X%  /font-name <point-size(pix)> DMF
X%
X/DMF {
X  /psz xdef
X  /nam xdef
X  nam findfont psz scalefont setfont
X} bdef
X 
X%
X%  /abcd (xxx) str-concat  ==> /abcdxxx
X%
X/str-concatstr 64 string def
X
X/str-concat {
X  /xxx xdef
X  /nam xdef
X  /namstr nam str-concatstr cvs def
X  /newnam namstr length xxx length add string def
X  newnam 0 namstr putinterval
X  newnam namstr length xxx putinterval
X  newnam cvn 
X} bdef
X 
X%
X%  /abcdef 2 str-strip ==> /cdef
X%
X/str-strip {
X  /num xdef
X  /nam xdef
X  /namstr nam tempstr cvs def
X  /newlen namstr length num sub def
X  namstr num newlen getinterval
X  cvn
X} bdef
X 
X%
X%  <old-dict> copydict ==> new-dict on stack
X%
X/copydict {
X  dup length 1 add dict /newdict xdef
X    {1 index /FID ne
X      {newdict 3 1 roll put}
X      {pop pop}
X     ifelse
X    } forall 
X  newdict
X} bdef
X 
X%
X%  <font-type> DefineCMEncoding
X%
X/DefineCMEncoding {
X  /EncodeType xdef
X 
X  /CMEncoding 256 array def
X  /Times-Roman findfont /Encoding get aload pop CMEncoding astore pop
X 
X  EncodeType 11 eq {Do-CM-rm-encoding} if
X  EncodeType 12 eq {Do-CM-it-encoding} if
X  EncodeType 13 eq {Do-CM-tt-encoding} if
X} bdef
X 
X%
X%  Do special mappings for the various CM-font types.  Characters that
X%  get "covered up" are repositioned in the range (128,128+32).
X%
X/Do-standard-CM-encodings {
X  CMEncoding
X  dup 0 /.notdef put
X  dup 1 /.notdef put
X  dup 2 /.notdef put
X  dup 3 /.notdef put
X  dup 4 /.notdef put
X  dup 5 /.notdef put
X  dup 6 /.notdef put
X  dup 7 /.notdef put
X 
X  dup 8 /.notdef put
X  dup 9 /.notdef put
X  dup 10 /.notdef put
X  dup 11 /.notdef put
X  dup 12 /fi put
X  dup 13 /fl put
X  dup 14 /.notdef put
X  dup 15 /.notdef put
X 
X  dup 16 /dotlessi put
X  dup 17 /.notdef put
X  dup 18 /grave put
X  dup 19 /acute put
X  dup 20 /caron put
X  dup 21 /breve put
X  dup 22 /macron put
X  dup 23 /ring put
X 
X  dup 24 /cedilla put
X  dup 25 /germandbls put
X  dup 26 /ae put
X  dup 27 /oe put
X  dup 28 /oslash put
X  dup 29 /AE put
X  dup 30 /OE put
X  dup 31 /Oslash put
X  dup 127 /dieresis put
X
X  dup 128 /space put
X  dup 129 /quotedbl put
X  dup 130 /sterling put
X  dup 131 /dollar put
X  dup 132 /less put
X  dup 133 /greater put
X  dup 134 /backslash put
X  dup 135 /asciicircum put
X  dup 136 /underscore put
X  dup 137 /braceleft put
X  dup 138 /bar put
X  dup 139 /braceright put
X  dup 140 /asciitilde put
X  pop
X} bdef
X 
X/Do-CM-rm-encoding {
X  Do-standard-CM-encodings
X  CMEncoding
X  dup 32 /.notdef put
X  dup 34 /quotedblright put
X  dup 60 /exclamdown put
X  dup 62 /questiondown put
X  dup 92 /quotedblleft put
X  dup 94 /circumflex put
X  dup 95 /dotaccent put
X  dup 123 /endash put
X  dup 124 /emdash put
X  dup 125 /hungarumlaut put
X  dup 126 /tilde put
X  pop
X} bdef
X 
X/Do-CM-it-encoding {
X  Do-standard-CM-encodings
X  CMEncoding
X  dup 32 /.notdef put
X  dup 34 /quotedblright put
X  dup 36 /sterling put
X  dup 60 /exclamdown put
X  dup 62 /questiondown put
X  dup 92 /quotedblleft put
X  dup 94 /circumflex put
X  dup 95 /dotaccent put
X  dup 123 /endash put
X  dup 124 /emdash put
X  dup 125 /hungarumlaut put
X  dup 126 /tilde put
X  pop
X} bdef
X 
X/Do-CM-tt-encoding {
X  Do-standard-CM-encodings
X  CMEncoding
X  dup 12 /.notdef put
X  dup 13 /quotesingle put
X  dup 14 /exclamdown put
X  dup 15 /questiondown put
X  pop
X} bdef
X
X%
X%  <int-font-name> <ext-font-name> <pt-sz(pix)> <type> <loaded-fg> DefineCMFont
X%
X%    type 10: "as-is" PostScript font
X%    type 11: CM-mapped PostScript font - roman
X%    type 12: CM-mapped PostScript font - text italic 
X%    type 13: CM-mapped PostScript font - typewriter type 
X%
X/int-dict-name {int (-dict) str-concat} bdef
X/int-dict {int (-dict) str-concat cvx load} bdef
X
X/DF {
X  true  % signal that the font is already loaded
X  DefineCMFont
X} bdef
X 
X/DNF {
X  false  % signal that the font is not already loaded
X  DefineCMFont
X} bdef
X
X/DefineCMFont {
X  /loaded xdef
X  /typ xdef
X  /psz xdef
X  /ext xdef
X  /int xdef
X 
X  typ 10 ne 
X    { % font_type = 11, 12, 13
X    loaded not
X      { /fnam ext 3 str-strip def
X        fnam findfont copydict /newdict xdef 
X        typ DefineCMEncoding
X        newdict /Encoding CMEncoding put
X        ext newdict definefont pop
X      } if
X%    int-dict-name ext findfont psz scalefont def
X%    currentdict int [int-dict /setfont cvx] cvx put
X    currentdict int [ext findfont psz scalefont /setfont cvx] cvx put
X    }
X    { % font_type = 10
X%    /fnam ext def
X%    int-dict-name fnam findfont psz scalefont def
X%    currentdict int [int-dict /setfont cvx] cvx put
X    currentdict int [ext findfont psz scalefont /setfont cvx] cvx put
X    }
X  ifelse
X} bdef 
X 
X%
X%  <int-font-name> <ext-font-name> <pt-sz(pix)> <PXL mag> <num-chars>
X%      [llx lly urx ury] <newfont-fg> DefinePXLFont
X%
X
X/PXLF {
X  true  % signal that the font is already loaded
X  DefinePXLFont
X} bdef
X 
X/PXLNF {
X  false  % signal that the font is not already loaded
X  DefinePXLFont
X} bdef
X
X/PXLBuildCharDict 17 dict def
X 
X/CMEncodingArray 256 array def
X0 1 255 {CMEncodingArray exch dup tempstr cvs cvn put} for
X
X/RasterConvert {RasterScaleFactor div} bdef
X 
X/TransformBBox {
X  aload pop
X 
X  /BB-ury xdef
X  /BB-urx xdef
X  /BB-lly xdef
X  /BB-llx xdef
X 
X  [BB-llx RasterConvert BB-lly RasterConvert 
X   BB-urx RasterConvert BB-ury RasterConvert]
X} bdef
X
X/DefinePXLFont {
X  /newfont xdef
X  /bb xdef
X  /num xdef
X  /psz xdef
X  /dsz xdef
X  /pxlmag xdef
X  /ext xdef
X  /int xdef
X 
X  /fnam ext (-) str-concat pxlmag tempstr cvs str-concat def
X 
X  newfont not {
X    int-dict-name 13 dict def
X   
X    int-dict begin
X      /FontType 3 def
X      /FontMatrix [1 dsz div 0 0 1 dsz div 0 0] def
X      /FontBBox bb TransformBBox def
X      /Encoding CMEncodingArray def
X      /BuildChar
X        { 
X          PXLBuildCharDict begin
X            /char xdef
X            /fontdict xdef
X
X            fontdict /CharDict get /Char-Info get char get aload pop
X
X            /rasters xdef
X            /cols xdef
X            /rows xdef
X            /wx xdef
X            /ury xdef
X            /urx xdef
X            /lly xdef
X            /llx xdef
X
X            rows 0 lt
X              { /rows rows neg def
X                /runlength 1 def }
X              { /runlength 0 def }
X             ifelse
X 
X            wx 0 
X            llx RasterConvert lly RasterConvert 
X            urx RasterConvert ury RasterConvert setcachedevice
X            rows 0 ne
X              {
X	      gsave
X		llx .5 add lly .5 add translate
X                cols rows scale % work around NeWS bugs
X		true rasters imagemaskcanvas
X              grestore
X              } if
X            end
X        } def
X        /CharDict 1 dict def
X	  CharDict /Char-Info num array put
X      end
X      fnam int-dict definefont pop
X    } if 
X
X%  int-dict-name fnam findfont psz scalefont def
X%  currentdict int [int-dict /setfont cvx] cvx put
X  currentdict int [fnam findfont psz scalefont /setfont cvx] cvx put
X} bdef 
X 
X%
X%  <int-font-name> <code> <wx> <llx> <lly> <urx> <ury> <rows> <cols> <runlength> <rasters> PXLC
X%
X/PXLC {
X 
X  /rasters xdef
X  /runlength xdef
X  /cols xdef
X  /rows xdef
X  /ury xdef
X  /urx xdef
X  /lly xdef
X  /llx xdef
X  /wx xdef
X  /code xdef
X  /int xdef
X 
X  % See if the long or short format is required
X%  true cols CKSZ rows CKSZ ury CKSZ urx CKSZ lly CKSZ llx CKSZ 
X    TackRunLengthToRows
X    int-dict /CharDict get /Char-Info get code 
X    [llx lly urx ury wx rows cols % rasters => build canvas for NeWS
X	cols rows 1 [RasterScaleFactor 0 0 RasterScaleFactor neg 0 0]
X        GenerateRasters buildimage
X    ] put
X} bdef
X 
X/CKSZ {abs 127 le and} bdef
X/TackRunLengthToRows {runlength 0 ne {/rows rows neg def} if} bdef
X 
X%
X%  <wx> <dsz> <psz> <llx> <lly> <urx> <ury> <rows> <cols> <runlength> <rasters> PLOTC
X%
X/PLOTC {
X  /rasters xdef
X  /runlength xdef
X  /cols xdef
X  /rows xdef
X  /ury xdef
X  /urx xdef
X  /lly xdef
X  /llx xdef
X  /psz xdef
X  /dsz xdef
X  /wx xdef
X 
X  % "Plot" a character's raster pattern.
X  rows 0 ne
X    {
X    gsave
X      currentpoint translate
X      psz dsz div dup scale
X%                cols rows scale % work around NeWS bugs
X%                llx ury moveto  % NeWS ignores imagemask matrix
X      cols rows true 
X      RasterScaleFactor 0 0 RasterScaleFactor neg llx .5 add neg ury .5 add 
X        tempmatrix astore
X      GenerateRasters imagemask
X    grestore
X    } if
X  wx x
X} bdef
X 
X% Routine to generate rasters for "imagemask".
X/GenerateRasters {
X  rasters
X  runlength 1 eq {RunLengthToRasters} if
X} bdef
X 
X% Routine to convert from runlength encoding back to rasters.
X/RunLengthToRasters {
X  % ...not done yet...
X} bdef
X 
X%
X%  These procedures handle bitmap processing.
X%
X%  <bitmap columns> <bitmap rows> <bitmap pix/inch> <magnification> BMbeg
X%
X/BMbeg {
X  /BMmagnification xdef
X  /BMresolution xdef
X  /BMrows xdef
X  /BMcols xdef
X
X  /BMcurrentrow 0 def
X  gsave
X    0.0 setgray
X    Resolution BMresolution div dup scale
X    currentpoint translate
X    BMmagnification 1000.0 div dup scale
X    0.0 BMrows moveto
X    BMrows dup scale
X    currentpoint translate
X    /BMCheckpoint save def
X  } bdef
X
X/BMend {
X  BMCheckpoint restore
X  grestore
X  } bdef
X
X%
X%  <hex raster bitmap> <rows> BMswath 
X%
X/BMswath {
X  /rows xdef
X  /rasters xdef
X
X  BMcols rows true
X  [BMrows 0 0 BMrows neg 0 BMcurrentrow neg]
X  rasters
X  imagemask
X
X  /BMcurrentrow BMcurrentrow rows add def
X  BMcurrentrow % save this on the stack around a restore...
X  BMCheckpoint restore
X  /BMcurrentrow xdef
X  /BMCheckpoint save def
X  } bdef
X
X(end of common prolog) VMSDebug 
X
Xend
X 
Xsystemdict /setpacking known 
X  {savepackingmode setpacking}
X  if
X
X% 
X% End of included prolog section.
X%

END_OF_FILE
echo shar: NEWLINE appended to \"'dvips.pro'\"
if test 17433 -ne `wc -c <'dvips.pro'`; then
    echo shar: \"'dvips.pro'\" unpacked with wrong size!
fi
# end of 'dvips.pro'
fi
if test -f 'dviview' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'dviview'\"
else
echo shar: Extracting \"'dviview'\" \(201 characters\)
sed "s/^X//" >'dviview' <<'END_OF_FILE'
Xif [ "$#" != "1" ]
Xthen
X	echo "usage: $0 file.dvi"
X	exit 1
Xfi
Xdvips -nodialog -OPT $NEWSHOME/lib/dvips.opt -FNT $NEWSHOME/lib/dvips.fnt -PRO $NEWSHOME/lib/dvips.pro -dvi $1 -ps - | psmung | psview -a4

END_OF_FILE
echo shar: NEWLINE appended to \"'dviview'\"
if test 202 -ne `wc -c <'dviview'`; then
    echo shar: \"'dviview'\" unpacked with wrong size!
fi
chmod +x 'dviview'
# end of 'dviview'
fi
if test -f 'psmung.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'psmung.c'\"
else
echo shar: Extracting \"'psmung.c'\" \(4474 characters\)
sed "s/^X//" >'psmung.c' <<'END_OF_FILE'
X/* psmung.c
X *
X * This program takes the output of ArborText's dvips and mungs it for NeWS
X * previewing. This consists of putting all of the font definitions into
X * the end of the prologue.
X * Fonts definitions are started by lines of the form
X *
X *   XP /F25 /cmr10 .... RP
X *
X * Character definitions are started by lines of the form
X *
X *   XP /F25 100 ....
X *   .... RP
X */
X
X#include <stdio.h>
X#include <ctype.h>
X
X/* Reading and Writing files is done a line at a time by the functions
X *
X *   char * GetLine(FILE *stream, char *line)
X *          PutLine(FILE *stream, char *line)
X */
X
X
Xchar line[BUFSIZ];
X
X#define GetLine(stream,line) fgets(line,BUFSIZ,stream)
X#define PutLine(stream,line) fputs(line,stream)
X
X
X/* search states */
X#define SCANNING 0
X#define SKIPPING 1
X#define COPYING 2
X
X
X#define GetNumber(num,ptr) while (isdigit(*ptr)) num = num * 10 + *ptr++ - '0'
X#define SkipSpace(ptr) while (isspace(*ptr)) ptr++
X
X
Xstruct FontInfo {
X  struct FontInfo *next;
X  int number;
X  char named;
X  char bits[256];
X} *Fontlist;
X
X#define GetNamed(fptr) ((*fptr).named)
X#define SetNamed(fptr) (*fptr).named = 1
X
X/*#define GetLetter(fptr,letter) ((*fptr).bits[letter>>3] & (1<<(letter&3)))
X#define SetLetter(fptr,letter) (*fptr).bits[letter>>3] |= (1<<(letter&3))*/
X#define GetLetter(fptr,letter) ((*fptr).bits[letter])
X#define SetLetter(fptr,letter) (*fptr).bits[letter] = 1
X
X
X/* find font array if available, create and clear otherwise */
Xstruct FontInfo *FindFont(font)
X     int font;
X{
X  struct FontInfo *fptr = Fontlist;
X
X  while (fptr) { /* linear search for font number */
X    if ((*fptr).number == font)
X      return fptr;
X    fptr = (*fptr).next;
X  }
X  /* number not found: create new entry and link in */
X  fptr = (struct FontInfo *)calloc((unsigned)1,
X				   (unsigned)sizeof(struct FontInfo));
X  (*fptr).next = Fontlist;
X  (*fptr).number = font;
X  Fontlist = fptr;
X  return fptr;
X}
X
X
X/* test if 'RP' found and chop before it */
Xint FoundRP(str)
X     char *str;
X{
X  while (*str) {
X    if (*str++ == 'R')
X      if (*str == 'P') {
X	*str = '\0';
X	*--str = '\n';
X	return 1;
X      }
X  }
X  return 0;
X}
X
X
X/* Here we go, here we go, here we go... */
Xmain(argc,argv)
X     int argc;
X     char *argv[];
X{
X  int state;
X  FILE *pages;
X  char *tmpname="/tmp/ps.XXXXXX";
X
X  Fontlist = NULL; /* initialise font list */
X
X  /* (re)open stdin file */
X  /* (re)open stdout file */
X  
X  pages = fopen(mktemp(tmpname),"w+"); /* open pages file */
X
X  while (GetLine(stdin,line) && strncmp(line,"%%EndProlog",11))
X    PutLine(stdout,line); /* pass header straight through */
X
X  PutLine(pages,line); /* save first non-header line */
X
X  PutLine(stdout,"XP\n");
X
X  state = SCANNING;
X  while (GetLine(stdin,line)) {
X    switch (state) {
X    case SCANNING: /* scan for XP lines */
X      if (!strncmp(line,"XP /F",5)) { /* XP_/F found */
X	char *cptr = &line[5];
X	int fontnum = 0;
X	struct FontInfo *fontptr;
X
X	GetNumber(fontnum,cptr); /* parse font number */
X	SkipSpace(cptr); /* skip white space */
X	fontptr = FindFont(fontnum); /* find font record */
X
X	if (*cptr == '/') { /* font definition found */
X	  if (GetNamed(fontptr)) { /* check if font definition already done */
X	    if (!FoundRP(line))
X	      state = SKIPPING;
X	  }
X	  else {
X	    SetNamed(fontptr);
X	    if (!FoundRP(line))
X	      state = COPYING;
X	    PutLine(stdout,&line[3]); /* put line without XP & RP */
X	  }
X	}
X	else if (isdigit(*cptr)) { /* character definition found */
X	  int letter = 0;
X	  GetNumber(letter,cptr); /* parse char number */
X	  if (!GetNamed(fontptr))
X	    fprintf(stderr,"Warning: font %d not defined (char %d)\n",
X		    fontnum,letter);
X	  if (GetLetter(fontptr,letter)) { /* check if letter already done */
X	    if (!FoundRP(line))
X	      state = SKIPPING;
X	  }
X	  else {
X	    SetLetter(fontptr,letter);
X	    if (!FoundRP(line))
X	      state = COPYING;
X	    PutLine(stdout,&line[3]); /* put line without XP & RP */
X	  }
X	}
X	else fprintf(stderr,"Ignoring line:\n  %s",line);
X      } else PutLine(pages,line);
X      break;
X    case SKIPPING: /* skipping to RP */
X      if (FoundRP(line))
X	state = SCANNING;
X      break;
X    case COPYING: /* copying to RP */
X      if (FoundRP(line)) /* FoundRP chops line */
X	state = SCANNING;
X      PutLine(stdout,line);
X      break;
X    }
X  }
X
X  PutLine(stdout,"RP\n");
X
X  rewind(pages); /* goto start of pages file */
X  while (GetLine(pages,line))
X    PutLine(stdout,line); /* copy pages to output */
X
X  fclose(pages); /* close pages file */
X  /* delete pages file */
X}

END_OF_FILE
echo shar: NEWLINE appended to \"'psmung.c'\"
if test 4475 -ne `wc -c <'psmung.c'`; then
    echo shar: \"'psmung.c'\" unpacked with wrong size!
fi
# end of 'psmung.c'
fi
echo shar: End of archive 2 \(of 2\).
cp /dev/null ark2isdone
MISSING=""
for I in 1 2 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked both archives.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
Angus Duggan, Department of Computer Science,	| <This space for hire>
University of Edinburgh, JCMB,			| USENET: ajcd@lfcs.ed.ac.uk
The King's Buildings, Mayfield Road,		| JANET:  ajcd@uk.ac.ed.lfcs
Edinburgh, EH9 3JZ, Scotland.	| OR:  ajcd%lfcs.ed.ac.uk@nsfnet-relay.ac.uk