(FILECREATED "14-Dec-84 09:16:36" {ERIS}<LISPNEW>PATCHES>PRESSLINEPATCH.;3 11194 changes to: (VARS PRESSLINEPATCHCOMS) previous date: "13-Dec-84 17:29:17" {ERIS}<LISPNEW>PATCHES>PRESSLINEPATCH.;1) (* Copyright (c) 1984 by Xerox Corporation. All rights reserved.) (PRETTYCOMPRINT PRESSLINEPATCHCOMS) (RPAQQ PRESSLINEPATCHCOMS ((FNS VECPUT ENDVECRUN \DRAWCURVE.PRESS.LINE \PRESS.OUTCHARFN))) (DEFINEQ (VECPUT [LAMBDA (PRSTREAM DX DY HALFVECWIDTH) (* rmk: "13-Dec-84 17:54") (* Send this dx,dy pair to the press file; hold and reverse any strings which run right-to-left on the page.) (PROG ((PRDATA (fetch IMAGEDATA of PRSTREAM)) XPOS YPOS) (COND ((OR (AND (fetch VECMOVINGRIGHT of PRDATA) (ILESSP DX 0)) (AND (NOT (fetch VECMOVINGRIGHT of PRDATA)) (ILESSP 0 DX))) (* We switched direction (LEFT->RIGHT or RIGHT->LEFT). Put out what we've got, and start the new run.) (ENDVECRUN PRSTREAM HALFVECWIDTH) (replace VECMOVINGRIGHT of PRDATA with (NOT (fetch VECMOVINGRIGHT of PRDATA))) (* Switch the direction we think we're moving.) )) (SETQ XPOS (fetch VECCURX of PRDATA)) (* In DOVER spots) (SETQ YPOS (fetch VECCURY of PRDATA)) (replace VECCURX of PRDATA with (IPLUS XPOS DX)) (replace VECCURY of PRDATA with (IPLUS YPOS DY)) (COND [(fetch VECMOVINGRIGHT of PRDATA) (* We're moving right, and are really putting out characters.) (* SPRUCEPAPERTOPSCANS is in dover points) (COND ((AND (IGEQ YPOS HALFVECWIDTH) (ILESSP YPOS (IDIFFERENCE SPRUCEPAPERTOPSCANS HALFVECWIDTH)) (IGEQ XPOS HALFVECWIDTH) (ILESSP XPOS (IDIFFERENCE SPRUCEPAPERRIGHTSCANS HALFVECWIDTH))) (* We're on-paper. Go ahead and display this character.) (COND ((NOT (fetch VECWASDISPLAYING of PRDATA)) (* We haven't been displaying. before really putting out the character,) (SHOW.PRESS PRSTREAM) (SETXY.PRESS PRSTREAM (FIXR (FTIMES MicasPerScan XPOS)) (FIXR (FTIMES MicasPerScan YPOS))) (* So move to where we're emerging onto the paper.) (replace VECWASDISPLAYING of PRDATA with T))) (\BOUT PRSTREAM (VECENCODE DX DY))) (T (* We're off-page. Remember to do a SETXY when we get back on.) (replace VECWASDISPLAYING of PRDATA with NIL] (T (* We're moving left--and so caching characters for later. Don't bother making any checks going this way.) (push (fetch VECSEGCHARS of PRDATA) (CONS DX DY)) (* Just cache the DX,DY pair) ]) (ENDVECRUN [LAMBDA (PRSTREAM HALFVECWIDTH) (* rmk: "13-Dec-84 17:55") (SHOW.PRESS PRSTREAM) (PROG ((PRDATA (fetch IMAGEDATA of PRSTREAM)) ORIGXPOS ORIGYPOS XPOS YPOS WASDISPLAYING ORIGWASDISPLAYING) (COND ((NOT (fetch VECMOVINGRIGHT of PRDATA)) (* We've been moving to the left, so it's time to uncache those characters we saved.) (SETQ XPOS (fetch VECCURX of PRDATA)) (SETQ YPOS (fetch VECCURY of PRDATA)) (SETQ ORIGXPOS (FIXR (FTIMES MicasPerScan XPOS))) (* Remember where the end of the line is, so we can come back here.) (SETQ ORIGYPOS (FIXR (FTIMES MicasPerScan YPOS))) [SETQ ORIGWASDISPLAYING (AND (IGEQ XPOS HALFVECWIDTH) (IGEQ YPOS HALFVECWIDTH) (ILESSP YPOS (IDIFFERENCE SPRUCEPAPERTOPSCANS HALFVECWIDTH) ) (ILESSP XPOS (IDIFFERENCE SPRUCEPAPERRIGHTSCANS HALFVECWIDTH] (SETQ WASDISPLAYING ORIGWASDISPLAYING) (* Decide whether to start out by displaying any characters or not.) (COND (WASDISPLAYING (SETXY.PRESS PRSTREAM ORIGXPOS ORIGYPOS))) (* We may have been adjusting the X and Y position in the PRDATA without actually putting out the file commands) [for CH in (fetch VECSEGCHARS of PRDATA) do (COND [(AND (IGEQ XPOS HALFVECWIDTH) (IGEQ YPOS HALFVECWIDTH) (ILESSP YPOS (IDIFFERENCE SPRUCEPAPERTOPSCANS HALFVECWIDTH)) (ILESSP XPOS (IDIFFERENCE SPRUCEPAPERRIGHTSCANS HALFVECWIDTH))) (* We're on-paper. Go ahead and display the character.) (COND ((NOT WASDISPLAYING) (* We haven't really been displaying characters up to now--we need to reposition.) (SHOW.PRESS PRSTREAM) (SETXY.PRESS PRSTREAM (FIXR (FTIMES MicasPerScan XPOS)) (FIXR (FTIMES MicasPerScan YPOS))) (SETQ WASDISPLAYING T))) (\BOUT PRSTREAM (VECENCODE (IMINUS (CAR CH)) (IMINUS (CDR CH] (T (* We are off-paper. Stop displaying, and remember that we took a hiatus) (SETQ WASDISPLAYING NIL))) (SETQ XPOS (IDIFFERENCE XPOS (CAR CH))) (SETQ YPOS (IDIFFERENCE YPOS (CDR CH] (SHOW.PRESS PRSTREAM) (SETXY.PRESS PRSTREAM ORIGXPOS ORIGYPOS) (replace VECWASDISPLAYING of PRDATA with ORIGWASDISPLAYING))) (replace VECSEGCHARS of PRDATA with NIL]) (\DRAWCURVE.PRESS.LINE [LAMBDA (PRSTREAM X1 Y1 X2 Y2 BRUSH DASHING) (* rmk: "13-Dec-84 16:58") (* Returns T if this is a horizontal or vertical line, hence can be drawn as a rectangle.) (PROG (WIDTH BACKOFF LEFT BOTTOM DIST LB TR (SHAPE (QUOTE ROUND))) (SETQ WIDTH (OR (COND ((LISTP BRUSH) (SETQ SHAPE (CAR BRUSH)) (CADR BRUSH)) (T BRUSH)) 1)) [SELECTQ SHAPE (BUTT (SETQ BACKOFF 0)) (ROUND (RETURN NIL)) (PROGN (SETQ BACKOFF (IQUOTIENT WIDTH 2] (* For butt ends, we want the line to end at the given coordinate position) (* LB is left or bottom, TR is top or right, depending on orientation) (COND ((EQP X1 X2) (* Vertical line) (SETQ LEFT (IDIFFERENCE X1 (IQUOTIENT WIDTH 2))) (* Off to the left or right?) (AND (OR (ILESSP LEFT 0) (IGREATERP (IPLUS LEFT WIDTH) SPRUCEPAPERRIGHTMICAS)) (RETURN T)) (COND ((IGREATERP Y1 Y2) (SETQ LB Y2) (SETQ TR Y1)) (T (SETQ LB Y1) (SETQ TR Y2))) (SETQ LB (IMAX 0 (IDIFFERENCE LB BACKOFF))) (* Clip to page) (SETQ TR (IMIN SPRUCEPAPERTOPMICAS (IPLUS TR BACKOFF))) (SETQ DIST (IDIFFERENCE TR LB)) (OR (IGREATERP DIST 0) (RETURN T)) (SETXY.PRESS PRSTREAM LEFT LB) (* Move to where the line starts) (SHOWRECTANGLE.PRESS PRSTREAM WIDTH DIST) (* Draw the rectangle that will do the job.) (RETURN T)) ((EQP Y1 Y2) (* Horizontal line) (SETQ BOTTOM (IDIFFERENCE Y1 (IQUOTIENT WIDTH 2))) (* Off to the bottom or top?) (AND (OR (ILESSP BOTTOM 0) (IGREATERP (IPLUS BOTTOM WIDTH) SPRUCEPAPERTOPMICAS)) (RETURN T)) (COND ((IGREATERP X1 X2) (SETQ LB X2) (SETQ TR X1)) (T (SETQ LB X1) (SETQ TR X2))) (SETQ LB (IMAX 0 (IDIFFERENCE LB BACKOFF))) (* Clip to page) (SETQ TR (IMIN SPRUCEPAPERRIGHTMICAS (IPLUS TR BACKOFF))) (SETQ DIST (IDIFFERENCE TR LB)) (OR (IGREATERP DIST 0) (RETURN T)) (SETXY.PRESS PRSTREAM LB BOTTOM) (* Move to where the line starts) (SHOWRECTANGLE.PRESS PRSTREAM DIST WIDTH) (* Draw the rectangle that will do the job.) (RETURN T]) (\PRESS.OUTCHARFN [LAMBDA (PRSTREAM CHARCODE) (* rmk: "14-Dec-84 08:55") (* Handle all the special-purpose characters going to a PRESS file) (SELCHARQ CHARCODE (EOL (* New Line) (NEWLINE.PRESS PRSTREAM) (replace (STREAM CHARPOSITION) of PRSTREAM with 0)) [LF (* Line feed--move down, but not over) (\DSPXPOSITION.PRESS PRSTREAM (PROG1 (DSPXPOSITION NIL PRSTREAM) (NEWLINE.PRESS PRSTREAM] (↑L (* Form Feed) (replace (STREAM CHARPOSITION) of PRSTREAM with 0) (NEWPAGE.PRESS PRSTREAM)) (PROG (XPOS (PRDATA (fetch IMAGEDATA of PRSTREAM))) (COND [(AND (IGEQ (PROG1 (SETQ XPOS (fetch PRXPOS of PRDATA)) (add XPOS (\FGETWIDTH (ffetch PRWIDTHSCACHE of PRDATA) CHARCODE))) 0) (ILEQ XPOS SPRUCEPAPERRIGHTMICAS)) (replace PRXPOS of PRDATA with XPOS) (COND ((IGEQ (fetch PRYPOS of PRDATA) 0) (\BOUT PRSTREAM CHARCODE] (T (SHOW.PRESS PRSTREAM) (* Don't put anything out if coordinates are negative) (SETX.PRESS PRSTREAM XPOS]) ) (PUTPROPS PRESSLINEPATCH COPYRIGHT ("Xerox Corporation" 1984)) (DECLARE: DONTCOPY (FILEMAP (NIL (421 11109 (VECPUT 431 . 3564) (ENDVECRUN 3566 . 6570) (\DRAWCURVE.PRESS.LINE 6572 . 9615) (\PRESS.OUTCHARFN 9617 . 11107))))) STOP