#!/bin/sh (cat <<\End %!PS-Adobe-3.0 %%IncludeResource: font fat /rightmargin 576 def /leftmargin 72 def /indentamount 27 def /lecture 0 def /line {/lineno lineno 1 add def lineno 1 sub lines exch sub lineskip mul leftmargin exch moveto show } def /indentedline {/lineno lineno 1 add def lineno 1 sub lines exch sub lineskip mul leftmargin exch moveto indentamount mul 0 rmoveto show } def /centerline {/lineno lineno 1 add def lineno 1 sub lines exch sub lineskip mul leftmargin exch moveto dup stringwidth pop rightmargin leftmargin sub exch sub 2 div 0 rmoveto show } def /barline {/bary 8 def /lineno lineno 1 add def lineno 1 sub lines exch sub lineskip mul rightmargin leftmargin sub 2 div leftmargin add exch moveto currentpoint 4 -1 roll rightmargin leftmargin sub 2 div mul barmax div bary neg 0 rmoveto 0 bary 8 sub neg rmoveto dup neg 0 rlineto 0 bary bary add rlineto 0 rlineto 0 bary bary add neg rlineto closepath gsave .25 setgray fill grestore stroke 0 setgray moveto show } def /title {/boxy 12 def /boxx rightmargin leftmargin sub 2 div def /boxarc 12 def newpath /lineno lineno 3 add def lineno 1 sub lines exch sub lineskip mul leftmargin exch moveto gsave currentpoint translate 0 0 0 boxy neg boxx boxy neg boxarc arcto pop pop pop pop boxx dup add boxy neg boxx dup add 0 boxarc arcto pop pop pop pop boxx dup add boxy dup add boxx boxy dup add boxarc arcto pop pop pop pop 0 boxy boxy add 0 0 boxarc arcto pop pop pop pop closepath % gsave .99 setgray fill grestore 2 setlinewidth stroke 0 setgray 2 setlinewidth stroke 0 setgray moveto dup stringwidth pop boxx dup add exch sub 2 div 0 rmoveto show grestore } def /newpage {/lineno 0 def /lineskip 792 lines 1 add div def newpath } def /fat findfont 18 scalefont setfont /prog { /Courier-Bold findfont 18 scalefont setfont /indentamount 6 def} def /endprog { /fat findfont 18 scalefont setfont /indentamount 27 def} def /footer { lecture 0 gt { gsave /fat findfont 10 scalefont setfont 570 20 moveto (.) lecture 2 string cvs show show show grestore } if } def /ps { lineno exch add /lineno exch def gsave leftmargin lines lineno sub lineskip mul translate} def /endps {grestore } def /hback{/lineno lineno .7 sub def} def /qback{/lineno lineno .3 sub def} def /linesreset{/lines 30 def} def linesreset /barmax 1000 def %! CS insignia /inch {72 mul} def /insignia {newpath 0 6 18{ /i exch def 32 -27 i add moveto 9 i add -27 i add lineto -27 i add 9 i add lineto -32 9 i add lineto -32 -27 i add moveto -9 i sub -27 i add lineto 27 i sub 9 i add lineto 32 9 i add lineto} for 0 -30 moveto 30 0 lineto 0 30 lineto -30 0 lineto 0 -30 lineto 32 -27 moveto 32 27 lineto -32 -27 moveto -32 27 lineto closepath} def newpage End count=1 if test "$2" then count=$2 fi nawk -v count=$count ' BEGIN {title=1; program=0} /^\// {print} /^-----/ {print "stroke (" count ") footer showpage newpage"; count=count+1; title=1} /^%include/ {print } /^%ps/ {print " " $2 " " $3 " " $4 " " $5 " " $6 " " $7 " " $8 " " $9 " " } /^%%/ && !/^%%%/ {print $2 " ps"} /^%%%/ && !/^%%%%/{print "endps"} /^--/ && !/^---/ {print "prog"} /^---/ && !/^----/{print "endprog"} title!=0 && /^ / {print "(" $1 " " $2 " " $3 " " $4 " " $5 " " $6 " " $7 " " $8 " " $9 ") title"} /^ / && !/^ / {print "(" $0 ") centerline"} /^ / && !/^ / {print "(" $0 ") 1 indentedline"} /^ / && !/^ / {print "(" $0 ") 2 indentedline"} /^ / && !/^ / {print "(" $0 ") 3 indentedline"} /^ / && !/^ / {print "(" $0 ") 4 indentedline"} title==0 && /^ / {print "(" $0 ") 5 indentedline"} !/^-----/ {title=0} !/^\// && !/^[0-9]/ && !/^ / && !/^--/ && !/^%/ {print "(" $0 ") line"} END {print "stroke (" count ") footer showpage"} ' $1.sl) | loom > $1.ps echo -n "Want a copy on $PRINTER (2-up?) or look with gs? (y, 2, or g) " read ans if test $ans = "y" then lpr $1.ps mv $1.ps ps fi if test $ans = "2" then cat /cmnusr/local/lib/ps/localfonts/fat.ps > ps/$1.2up.ps psmulti -nodecor $1.ps >> ps/$1.2up.ps lpr ps/$1.2up.ps fi if test $ans = "g" then cat /cmnusr/local/lib/ps/localfonts/fat.ps > ps/$1.ps cat $1.ps >> ps/$1.ps gs ps/$1.ps fi echo -n "Want to print a 4-up copy? (y or n) " read ans if test $ans = "y" then cat /cmnusr/local/lib/ps/localfonts/fat.ps > ps/$1.4up.ps psmulti -geom 2x2 -nodecor $1.ps >> ps/$1.4up.ps lpr ps/$1.4up.ps fi echo -n "Want to put a copy out on the home page? (y or n) " read ans if test $ans = "y" then cp $1.ps /u/rs/public_html/cs226/lectures/$1.ps fi rm $1.ps