(FILECREATED "17-AUG-83 16:19:02" {PHYLUM}<SYBALSKY>TEDITHCPY.;33 26162  

      changes to:  (FNS TEDIT.PRESS.HARDCOPY TEDIT.IP.HARDCOPY)

      previous date: " 9-AUG-83 14:02:31" {PHYLUM}<SYBALSKY>TEDITHCPY.;32)


(PRETTYCOMPRINT TEDITHCPYCOMS)

(RPAQQ TEDITHCPYCOMS [(FNS TEDIT.HARDCOPY TEDIT.PRESS.HARDCOPY TEDIT.IP.HARDCOPY TEDIT.HCPYFILE 
			   TEDIT.PRESSFILE TEDIT.IPFILE \TEDIT.HCPYFMTLINE \TEDIT.PRESS.DISPLAYLINE 
			   \TEDIT.IP.DISPLAYLINE \TEDIT.IPFONTS \TEDIT.IPFONTNUM)
		      (RECORDS Rectangle)
		      (MACROS UPDATE/HCPY/LOOKS)
		      (INITVARS (TEditHcpyMode (QUOTE PRESS)))
		      (P [TEDIT.ADD.MENUITEM TEDIT.DEFAULT.MENU (QUOTE (Hardcopy (QUOTE 
										   TEDIT.HARDCOPY]
			 (TEDIT.ADD.MENUITEM TEDIT.DEFAULT.MENU (QUOTE ("Press File" (QUOTE 
										   TEDIT.HCPYFILE])
(DEFINEQ

(TEDIT.HARDCOPY
  [LAMBDA (STREAM FILE DONTSEND BREAKPAGETITLE)              (* jds " 3-AUG-83 09:47")
                                                             (* Send the text to the printer.)
    (DECLARE (GLOBALVARS PRINTERMODE))
    (SELECTQ PRINTERMODE
	     (PRESS                                          (* Send to a PRESS printer)
		    (TEDIT.PRESS.HARDCOPY STREAM FILE DONTSEND BREAKPAGETITLE))
	     ((IP INTERPRESS)                                (* Send it to an INTERPRESS printer)
	       (TEDIT.IP.HARDCOPY STREAM FILE DONTSEND BREAKPAGETITLE))
	     (SHOULDNT])

(TEDIT.PRESS.HARDCOPY
  [LAMBDA (STREAM FILE DONTSEND BREAKPAGETITLE)              (* jds "17-AUG-83 13:57")
                                                             (* Send the text to the printer.)
    (PROG ((CHNO 1)
	   (TEXTOBJ (COND
		      ((type? STREAM STREAM)                 (* If we were given a TEXTOFD, grab the textobj instead)
			(fetch F3 of STREAM))
		      (T STREAM)))
	   TEXTLEN THISLINE LINE YBOT REGION OCURSOR FORCEPAGE (FORCENEXTPAGE NIL))
          (SETQ TEXTLEN (fetch TEXTLEN of TEXTOBJ))
          (SETQ THISLINE (fetch THISLINE of TEXTOBJ))
          (SETQ REGION (PressOutFile (OR FILE (QUOTE {CORE}TEDIT.PRESS))
				     NIL
				     (FONTCREATE (QUOTE GACHA)
						 10)
				     1 PRESSDEFAULTREGION))
                                                             (* Print in the usual region on the page)
          (SETQ YBOT (fetch cornery of PRESSBOUNDBOX))       (* Starting line bottom value)
          (SETQ LINE (create LINEDESCRIPTOR
			     LEFTMARGIN ←(fetch originx of PRESSPAGEREGION)))
                                                             (* Line descriptor used to print the lines)
          (while (ILESSP CHNO TEXTLEN)
	     do (SETQ FORCEPAGE FORCENEXTPAGE)
		(SETQ FORCENEXTPAGE (\TEDIT.HCPYFMTLINE TEXTOBJ (IDIFFERENCE (fetch cornerx
										of PRESSBOUNDBOX)
									     (fetch originx
										of PRESSPAGEREGION))
							CHNO THISLINE LINE)
		  (add (fetch LEFTMARGIN of LINE)
		       (fetch originx of PRESSPAGEREGION)))
		(SETQ CHNO (ADD1 (fetch CHARLIM of LINE)))
		(COND
		  ((OR FORCEPAGE (ILESSP (SETQ YBOT (IDIFFERENCE YBOT (fetch LHEIGHT of LINE)))
					 (fetch originy of PRESSBOUNDBOX)))
                                                             (* If this line would print off-page, time to start a 
							     new one.)
		    (PressClosePage)
		    (PressStartPage)
		    (PressNewPage REGION)
		    (SETQ YBOT (IDIFFERENCE (fetch cornery of PRESSBOUNDBOX)
					    (fetch LHEIGHT of LINE)))
		    (SETQ FORCEPAGE NIL)))
		(replace YBOT of LINE with YBOT)
		(replace YBASE of LINE with (IPLUS YBOT (fetch DESCENT of LINE)))
		(\TEDIT.PRESS.DISPLAYLINE TEXTOBJ LINE THISLINE))
          [PressClose (COND
			(BREAKPAGETITLE)
			([OR (NOT (fetch TXTFILE of TEXTOBJ))
			     (type? STREAM (fetch FULLNAME of (fetch TXTFILE of TEXTOBJ)))
			     (type? STRINGP (fetch FULLNAME of (fetch TXTFILE of TEXTOBJ]
			  "Tedit Press Output")
			(T (fetch FULLNAME of (fetch TXTFILE of TEXTOBJ]
          [OR DONTSEND (EMPRESS (OR FILE (QUOTE {CORE}TEDIT.PRESS]
          (OR FILE (DELFILE (QUOTE {CORE}TEDIT.PRESS)))
          (printout PROMPTWINDOW "(Hardcopy Complete)" T])

(TEDIT.IP.HARDCOPY
  [LAMBDA (STREAM FILE DONTSEND BREAKPAGETITLE)              (* jds "17-AUG-83 13:58")
                                                             (* Send the text to an INTERIP printer)
    (PROG ((CHNO 1)
	   (TEXTOBJ (COND
		      ((type? STREAM STREAM)                 (* If we were given a TEXTOFD, grab the textobj instead)
			(fetch F3 of STREAM))
		      (T STREAM)))
	   IPSTREAM IPDATA TEXTLEN THISLINE LINE YBOT REGION OCURSOR FORCEPAGE (FORCENEXTPAGE NIL))
          (SETQ TEXTLEN (fetch TEXTLEN of TEXTOBJ))
          (SETQ THISLINE (fetch THISLINE of TEXTOBJ))
          [SETQ IPSTREAM (OPENIPSTREAM (OR FILE (QUOTE {CORE}TEDIT.IP))
				       NIL NIL (\TEDIT.IPFONTS (fetch PCTB of TEXTOBJ]
                                                             (* Print in the usual region on the page)
          (SETQ IPDATA (fetch IPDATA of IPSTREAM))
          (SETQ YBOT (fetch IPTOP of IPDATA))                (* Starting line bottom value)
          (SETQ LINE (create LINEDESCRIPTOR
			     LEFTMARGIN ←(fetch IPLEFT of IPDATA)))
                                                             (* Line descriptor used to print the lines)
          (while (ILESSP CHNO TEXTLEN)
	     do                                              (* Loop, creating text lines to go to printer)
		(SETQ FORCEPAGE FORCENEXTPAGE)               (* Remember if we're to start a new page before this 
							     line)
		(SETQ FORCENEXTPAGE (\TEDIT.HCPYFMTLINE TEXTOBJ (fetch IPRIGHT of IPDATA)
							CHNO THISLINE LINE))
                                                             (* And before the newly-formatted line)
		(SETQ CHNO (ADD1 (fetch CHARLIM of LINE)))
		(COND
		  ((OR FORCEPAGE (ILESSP (SETQ YBOT (IDIFFERENCE YBOT (fetch LHEIGHT of LINE)))
					 (fetch IPBOTTOM of IPDATA)))
                                                             (* If this line would print off-page, time to start a 
							     new one.)
		    (NEWPAGE.IP IPSTREAM)
		    (SETQ YBOT (IDIFFERENCE (fetch IPTOP of IPDATA)
					    (fetch LHEIGHT of LINE)))
		    (SETQ FORCEPAGE NIL)))
		(replace YBOT of LINE with YBOT)             (* Place the line vertically)
		(replace YBASE of LINE with (IPLUS YBOT (fetch DESCENT of LINE)))
		(\TEDIT.IP.DISPLAYLINE IPSTREAM TEXTOBJ LINE THISLINE) 
                                                             (* And push the line into the IP stream))
          (CLOSEF IPSTREAM)                                  (* Close out the IP Master cleanly)
          (OR DONTSEND (NSPRINT NIL (OR FILE (QUOTE {CORE}TEDIT.IP))
				NIL BREAKPAGETITLE))         (* Transmit the file to the printer)
          (OR FILE (DELFILE (QUOTE {CORE}TEDIT.IP)))         (* And delete the temporary file)
          (printout PROMPTWINDOW "(Hardcopy Complete)" T])

(TEDIT.HCPYFILE
  [LAMBDA (STREAM FILE DONTSEND BREAKPAGETITLE)              (* jds " 3-AUG-83 09:46")
                                                             (* Send this text to a hardcopy file, depending on which
							     kind is currently selected.)
    (DECLARE (GLOBALVARS PRINTERMODE))
    (SELECTQ PRINTERMODE
	     (PRESS                                          (* Send to a PRESS printer)
		    (TEDIT.PRESSFILE STREAM FILE DONTSEND BREAKPAGETITLE))
	     ((IP INTERPRESS)                                (* Send to an INTERPRESS printer)
	       (TEDIT.IPFILE STREAM FILE DONTSEND BREAKPAGETITLE))
	     (SHOULDNT])

(TEDIT.PRESSFILE
  [LAMBDA (STREAM FILE DONTSEND BREAKPAGETITLE)              (* jds " 3-AUG-83 11:37")
                                                             (* Build a press file, and don't send it to the printer.
							     User gets to choose a name.)
    (TEDIT.PRESS.HARDCOPY STREAM (TEDIT.GETINPUT "Name for Press file: ")
			  T NIL])

(TEDIT.IPFILE
  [LAMBDA (STREAM FILE DONTSEND BREAKPAGETITLE)              (* jds " 3-AUG-83 11:35")
                                                             (* Send the text to the printer.)
    (TEDIT.IP.HARDCOPY STREAM (TEDIT.GETINPUT "Name for Press file: ")
		       T NIL])

(\TEDIT.HCPYFMTLINE
  [LAMBDA (TEXTOBJ WIDTH CH#1 THISLINE OLINE)                (* jds " 6-JUL-83 13:51")
                                                             (* Given a starting place, format the next line of text.
							     Return the LINEDESCRIPTOR; reusing OLINE if it's given.)
    (PROG (TX (LINE (OR OLINE (create LINEDESCRIPTOR
				      RIGHTMARGIN ← WIDTH)))
	      DX
	      (CH#B CH#1)
	      TXB CH (FORCEEND NIL)
	      (CHLIST (fetch CHARS of THISLINE))
	      (WLIST (fetch WIDTHS of THISLINE))
	      (LOOKS (fetch LOOKS of THISLINE))
	      (GATHERBLANK T)
	      (T1SPACE NIL)
	      TXB1 DXB FMTSPEC 1STLN LOOK#B (TLEN 0)
	      (TEXTLEN (ffetch TEXTLEN of TEXTOBJ))
	      FONTWIDTHS
	      (CHNO (ADD1 CH#1))
	      (LOOKNO 0)
	      (ASCENT 0)
	      (DESCENT 0)
	      (PREVSP 0)
	      (#BLANKS 0)
	      FONT CLOOKS TEXTSTREAM (CTRL\L\SEEN NIL))
          (SETQ TEXTSTREAM (fetch STREAMHINT of TEXTOBJ))
          (freplace CHARLIM of LINE with TEXTLEN)            (* Force each new line to find its true CHARLIM.)
          (freplace NEW of LINE with T)
          (freplace DIRTY of LINE with NIL)
          (freplace CHAR1 of LINE with CH#1)
          (freplace CR\END of LINE with NIL)
          [COND
	    [(AND (ILEQ CH#1 TEXTLEN)
		  (NOT (ZEROP TEXTLEN)))
	      (\SETUPGETCH CH#1 TEXTOBJ)
	      (UPDATE/HCPY/LOOKS)
	      (\EDITSETA LOOKS 0 TEDIT.CURRENT.CHARLOOKS)
	      [SETQ FMTSPEC (\TEDIT.HCPYFMTSPEC (OR (fetch PPARALOOKS of (fetch F5 of TEXTSTREAM))
						    (fetch FMTSPEC of TEXTOBJ]
	      [SETQ 1STLN (AND (fetch F5 of TEXTSTREAM)
			       (fetch PREVPIECE of (fetch F5 of TEXTSTREAM))
			       (fetch PPARALAST of (fetch PREVPIECE of (fetch F5 of TEXTSTREAM)))
			       (IEQP (fetch FW7 of TEXTSTREAM)
				     (fetch COFFSET of TEXTSTREAM))
			       (IEQP (fetch FW6 of TEXTSTREAM)
				     (fetch CPAGE of TEXTSTREAM]
	      [SETQ TX (SETQ TXB (replace LEFTMARGIN of LINE with (COND
								    (1STLN (fetch 1STLEFTMAR
									      of FMTSPEC))
								    (T (fetch LEFTMAR of FMTSPEC]
	      [replace RIGHTMARGIN of LINE with (SETQ WIDTH
						  (COND
						    ([AND (fetch FORMATTEDP of TEXTOBJ)
							  (NOT (ZEROP (fetch RIGHTMAR of FMTSPEC]
						      (fetch RIGHTMAR of FMTSPEC))
						    (T WIDTH]
	      (SETQ TXB1 WIDTH)
	      [for old TLEN from 0 to 254 as old CHNO from CH#1 to TEXTLEN
		 do (SETQ CH (\BIN TEXTSTREAM))              (* Get the next character for the line.)
		    (COND
		      ((NOT (EQCLOOKS CLOOKS TEDIT.CURRENT.CHARLOOKS))
                                                             (* The font has changed. Mark it, save the info, and 
							     update ascent &c)
			(add LOOKNO 1)                       (* Fix the counter of charlooks changes)
			(UPDATE/HCPY/LOOKS)                  (* Update FONT and CLOOKS, ASCENT &co.)
			(\EDITSETA LOOKS LOOKNO CLOOKS)      (* Save the new looks for selection/display)
			(\EDITSETA CHLIST TLEN 400)          (* Put a marker in the character list to denote a looks 
							     change)
			(\WORDSETA WLIST TLEN 0)             (* Force a font-change to zero width)
			(add TLEN 1)                         (* Account for the dummy marker/looks in TLEN)
			))
		    (COND
		      (CH [SETQ DX (COND
			      ((SMALLP CH)                   (* CH is really a character)
				(\GETWIDTH FONTWIDTHS CH))
			      (T                             (* CH is an object)
				 (PROG1 [OR (fetch XSIZE of (fetch OBJREF of CH))
					    (PROGN (APPLY* (fetch SIZEFN
							      of (fetch OBJREF of CH))
							   CH)
						   (fetch XSIZE of (fetch OBJREF of CH]
					[SETQ ASCENT (IMAX ASCENT (fetch YASC
								     of (fetch OBJREF of CH]
					(SETQ DESCENT (IMAX DESCENT (fetch YDESC
								       of (fetch OBJREF of CH]
                                                             (* Get CH's X width.)
			  (SELCHARQ CH
				    (SPACE                   (* CH is a <Space>. Remember it, in case we need to 
							     break the line.)
					   (COND
					     (GATHERBLANK (SETQ TXB1 TX)
							  (SETQ GATHERBLANK NIL)))
					   (SETQ CH#B CHNO)
					   (\EDITSETA CHLIST TLEN PREVSP)
					   (\WORDSETA WLIST TLEN DX)
					   (SETQ PREVSP (ADD1 TLEN))
					   (OR T1SPACE (SETQ T1SPACE TX))
					   (SETQ TX (IPLUS TX DX))
					   (SETQ TXB TX)
					   (SETQ DXB DX)
					   (SETQ LOOK#B LOOKNO)
					   (add #BLANKS 1))
				    (CR                      (* Ch is a <Return>. Force an end to the line.)
					(freplace CHARLIM of LINE with CHNO)
					(SETQ FORCEEND T)
					(\EDITSETA CHLIST TLEN 13)
					(\WORDSETA WLIST TLEN (SETQ DX (IMAX DX 6)))
					(SETQ TXB1 TX)
					(OR T1SPACE (SETQ T1SPACE TX))
					(replace CR\END of LINE with T)
					(SETQ TX (IPLUS TX DX))
					(RETURN))
				    (TAB                     (* Try to be reasonable with tabs.
							     This will create trouble when doing fast-case 
							     insert/delete, but Pah! for now.)
					 (COND
					   (GATHERBLANK (SETQ TXB1 TX)
							(SETQ GATHERBLANK NIL)))
					 (SETQ CH#B CHNO)
					 (SETQ DX 1270)      (* For now, make all TABs be 1/2in spaces.)
					 (\EDITSETA CHLIST TLEN PREVSP)
					 (\WORDSETA WLIST TLEN DX)
					 (SETQ PREVSP (ADD1 TLEN))
					 (add #BLANKS 1)
					 (OR T1SPACE (SETQ T1SPACE TX))
					 (SETQ TX (IPLUS TX DX))
					 (SETQ TXB TX)
					 (SETQ DXB DX)
					 (SETQ LOOK#B LOOKNO))
				    (↑L                      (* Force a page break after this line)
					(SETQ CTRL\L\SEEN T)
					(\WORDSETA WLIST TLEN 0)
					(\EDITSETA CHLIST TLEN (CHARCODE SPACE))
					(SETQ DX 0))
				    (PROGN (SETQ GATHERBLANK T)
					   (COND
					     ((AND (IGREATERP (SETQ TX (IPLUS TX DX))
							      WIDTH)
						   T1SPACE)
                                                             (* We're past the right margin;
							     stop formatting at the last blank.)
					       (SETQ FORCEEND T)
					       (freplace CHARLIM of LINE with CH#B)
					       (SETQ TX TXB)
					       (SETQ DX DXB)
					       (SETQ LOOKNO LOOK#B)
					       (RETURN))
					     (T              (* We're not past the right margin yet, or we haven't 
							     yet seen a place to do the break.)
						(\EDITSETA CHLIST TLEN CH)
						(\WORDSETA WLIST TLEN DX]
	      (COND
		((AND (IEQP TLEN 255)
		      (ILESSP CHNO TEXTLEN))                 (* This line is too long for us to format??)
		  (CLRPROMPT)
		  (printout PROMPTWINDOW "Line too long to format: " LINE)
		  (printout PROMPTWINDOW T "First Ch#:  " (fetch CHAR1 of LINE)
			    T "Text:  ")
		  (for I from 0 to 15 do (PRIN1 (CHARACTER (\EDITELT CHLIST I))
						PROMPTWINDOW))
		  (printout PROMPTWINDOW "..." T]
	    (T                                               (* No text to go in this line;
							     set Ascent/Descent to the default font from the window.)
	       (SETQ ASCENT (FONTPROP (DSPFONT NIL (fetch DS of TEXTOBJ))
				      (QUOTE ASCENT))
		 (SETQ DESCENT (FONTPROP (DSPFONT NIL (fetch DS of TEXTOBJ))
					 (QUOTE DESCENT)))
		 (SETQ FMTSPEC (\TEDIT.HCPYFMTSPEC (fetch FMTSPEC of TEXTOBJ)))
		 [SETQ 1STLN (AND (fetch F5 of TEXTSTREAM)
				  (fetch PREVPIECE of (fetch F5 of TEXTSTREAM))
				  (fetch PPARALAST of (fetch PREVPIECE of (fetch F5 of TEXTSTREAM)))
				  (IEQP (fetch FW6 of TEXTSTREAM)
					(fetch CPAGE of TEXTSTREAM))
				  (IEQP (fetch FW7 of TEXTSTREAM)
					(fetch COFFSET of TEXTSTREAM]
		 [SETQ TX (SETQ TXB (replace LEFTMARGIN of LINE
				       with (COND
					      (1STLN (fetch 1STLEFTMAR of FMTSPEC))
					      (T (fetch LEFTMAR of FMTSPEC]
		 [replace RIGHTMARGIN of LINE with (SETQ WIDTH
						     (COND
						       ([AND (fetch FORMATTEDP of TEXTOBJ)
							     (NOT (ZEROP (fetch RIGHTMAR
									    of FMTSPEC]
							 (fetch RIGHTMAR of FMTSPEC))
						       (T WIDTH]
		 (SETQ TXB1 WIDTH]
          (COND
	    ((ZEROP (freplace LHEIGHT of LINE with (IPLUS ASCENT DESCENT)))
	      (replace LHEIGHT of LINE with 12)))            (* Line's height (or 12 for an empty line))
          (replace ASCENT of LINE with ASCENT)
          (replace DESCENT of LINE with DESCENT)
          (freplace CHARTOP of LINE with (COND
					   ((IGEQ CHNO TEXTLEN)
					     \EditEOFChar#)
					   (T CHNO)))
          (COND
	    (FORCEEND NIL)
	    (T (SETQ CHNO (SUB1 CHNO))
	       (SETQ TLEN (SUB1 TLEN))
	       (SETQ TXB1 TX)))                              (* If we ran off the end of the text, then keep true 
							     space left on the line.)
          (freplace LXLIM of LINE with TX)
          (freplace DESC of THISLINE with LINE)
          [freplace LEN of THISLINE
	     with (IMIN 254 (COND
			  ((ILESSP TEXTLEN CH#1)
			    -1)
			  (T (IPLUS LOOKNO (IDIFFERENCE (IMIN (fetch CHARLIM of LINE)
							      TEXTLEN)
							(fetch CHAR1 of LINE]
          (freplace SPACELEFT of LINE with (IDIFFERENCE WIDTH TXB1))
          (freplace FIRSTSPACE of LINE with (OR T1SPACE TX))
          (\DOFORMATTING TEXTOBJ LINE FMTSPEC THISLINE #BLANKS PREVSP 1STLN)
          (RETURN CTRL\L\SEEN])

(\TEDIT.PRESS.DISPLAYLINE
  [LAMBDA (TEXTOBJ LINE THISLINE)                            (* jds " 2-JUN-83 13:13")
                                                             (* Display the line of text LINE in the edit window 
							     where it belongs.)
                                                             (* If possible, use the information cached in THISLINE)
    (PROG ((CH 0)
	   (CHLIST (fetch CHARS of THISLINE))
	   (WLIST (fetch WIDTHS of THISLINE))
	   (LOOKS (fetch LOOKS of THISLINE))
	   (DS (fetch DS of TEXTOBJ))
	   (TEXTLEN (fetch TEXTLEN of TEXTOBJ))
	   (CHCOUNT 0)
	   \PCHARSLEFT \PSTRING \PFILE FONT OFONT)
          (SETY.PRESS (fetch YBOT of LINE))
          (SETX.PRESS (fetch LEFTMARGIN of LINE))
          (COND
	    ((ILEQ (fetch CHAR1 of LINE)
		   TEXTLEN)                                  (* Only display the line if it appears before the end of
							     the text!)
	      [COND
		((NEQ (fetch DESC of THISLINE)
		      LINE)                                  (* Format the line to our specs)
		  (SETQ LINE (\TEDIT.HCPYFMTLINE TEXTOBJ NIL (fetch CHAR1 of LINE)
						 THISLINE LINE]
                                                             (* Use the characters cached in THISLINE.)
	      [PressFont (SETQ OFONT (FONTCOPY (fetch CLFONT of (\EDITELT LOOKS 0))
					       (QUOTE DEVICE)
					       (QUOTE PRESS]
	      (bind ((LOOKNO ← 1)
		     (TX ←(fetch LEFTMARGIN of LINE))
		     DX)
		 for I from 0 to (fetch LEN of THISLINE)
		 do (SETQ CH (\EDITELT CHLIST I))
		    (SETQ DX (\WORDELT WLIST I))
		    [SELECTQ CH
			     (400 (OR (ZEROP CHCOUNT)
				      (SHOW.PRESS CHCOUNT))
				  (SETQ CHCOUNT 0)
				  (PressFont (FONTCOPY (fetch CLFONT of (\EDITELT LOOKS LOOKNO))
						       (QUOTE DEVICE)
						       (QUOTE PRESS)))
				  (add LOOKNO 1))
			     ((9 32)                         (* TAB: use the width from the cache to decide the right
							     formatting.)
			       (OR (ZEROP CHCOUNT)
				   (SHOW.PRESS CHCOUNT))
			       (SETQ CHCOUNT 0)
			       (SETX.PRESS (IPLUS TX DX)))
			     (13                             (* It's a CR)
				 NIL)
			     (COND
			       ((SMALLP CH)
				 (\BOUT PRESSOUTSTRM CH)
				 (add CHCOUNT 1))
			       (T                            (* CH is an object.)
				  (OR (ZEROP CHCOUNT)
				      (SHOW.PRESS CHCOUNT))
				  (SETQ CHCOUNT 0)
				  (APPLY* (fetch DISPLAYFN of CH)
					  CH
					  (QUOTE PRESS))
				  (SETX.PRESS (IPLUS TX DX]
		    (add TX DX)
		 finally (OR (ZEROP CHCOUNT)
			     (SHOW.PRESS CHCOUNT])

(\TEDIT.IP.DISPLAYLINE
  [LAMBDA (IPSTREAM TEXTOBJ LINE THISLINE)                   (* jds "13-APR-83 14:04")
                                                             (* Display the line of text LINE in the edit window 
							     where it belongs.)
                                                             (* If possible, use the information cached in THISLINE)
    (PROG ((CH 0)
	   (CHLIST (fetch CHARS of THISLINE))
	   (WLIST (fetch WIDTHS of THISLINE))
	   (LOOKS (fetch LOOKS of THISLINE))
	   (DS (fetch DS of TEXTOBJ))
	   (TEXTLEN (fetch TEXTLEN of TEXTOBJ))
	   (CHCOUNT 0)
	   (IPDATA (fetch IPDATA of IPSTREAM))
	   \PCHARSLEFT \PSTRING \PFILE FONT OFONT)
          (SETXY.IP IPSTREAM (fetch LEFTMARGIN of LINE)
		    (fetch YBOT of LINE))
          (COND
	    ((ILEQ (fetch CHAR1 of LINE)
		   TEXTLEN)                                  (* Only display the line if it appears before the end of
							     the text!)
	      [COND
		((NEQ (fetch DESC of THISLINE)
		      LINE)                                  (* Format the line to our specs)
		  (SETQ LINE (\TEDIT.HCPYFMTLINE TEXTOBJ NIL (fetch CHAR1 of LINE)
						 THISLINE LINE]
                                                             (* Use the characters cached in THISLINE.)
	      [SETFONT.IP IPSTREAM (\TEDIT.IPFONTNUM (fetch IPFONTARRAY of IPDATA)
						     (FONTCOPY (fetch CLFONT of (\EDITELT LOOKS 0))
							       (QUOTE DEVICE)
							       (QUOTE PRESS]
	      (bind ((LOOKNO ← 1)
		     (TX ←(fetch LEFTMARGIN of LINE))
		     DX)
		 for I from 0 to (fetch LEN of THISLINE)
		 do (SETQ CH (\EDITELT CHLIST I))
		    (SETQ DX (\WORDELT WLIST I))
		    [SELECTC CH
			     (400 (OR (ZEROP CHCOUNT)
				      (SHOW.IP IPSTREAM))
				  (SETQ CHCOUNT 0)
				  [SETFONT.IP IPSTREAM (\TEDIT.IPFONTNUM (fetch IPFONTARRAY
									    of IPDATA)
									 (FONTCOPY
									   (fetch CLFONT
									      of (\EDITELT LOOKS 
											   LOOKNO))
									   (QUOTE DEVICE)
									   (QUOTE PRESS]
				  (add LOOKNO 1))
			     (9                              (* TAB: use the width from the cache to decide the right
							     formatting.)
				(OR (ZEROP CHCOUNT)
				    (SHOW.IP IPSTREAM))
				(SETQ CHCOUNT 0)
				(SETXREL.IP IPSTREAM DX))
			     (13                             (* It's a CR)
				 NIL)
			     (COND
			       ((SMALLP CH)
				 (INTERPRESS.OUTCHARFN IPSTREAM CH)
				 (add CHCOUNT 1))
			       (T                            (* CH is an object.)
				  (OR (ZEROP CHCOUNT)
				      (SHOW.IP IPSTREAM))
				  (SETQ CHCOUNT 0)
				  (APPLY* (fetch DISPLAYFN of CH)
					  CH
					  (QUOTE PRESS))
				  (SETXREL.IP IPSTREAM DX]
		    (add TX DX)
		 finally (OR (ZEROP CHCOUNT)
			     (SHOW.IP IPSTREAM])

(\TEDIT.IPFONTS
  [LAMBDA (PCTB)                                             (* jds "14-APR-83 09:49")
                                                             (* Scan a PCTB, and return a map of the fonts it uses.)
    (PROG ((FONTS NIL)
	   FONT FONTARRAY)
          (for I from (ADD1 \FirstPieceOffset) to (SUB1 (ELT PCTB \PCTBLastPieceOffset))
	     by \EltsPerPiece when (NOT (FMEMB (SETQ FONT (FONTCOPY (fetch CLFONT
								       of (fetch PLOOKS
									     of (ELT PCTB I)))
								    (QUOTE DEVICE)
								    (QUOTE PRESS)))
					       FONTS))
	     do (SETQ FONTS (CONS FONT FONTS)))
          (RETURN (for I from 1 as F in FONTS collect (LIST I F])

(\TEDIT.IPFONTNUM
  [LAMBDA (IPFONTS FONT)                                     (* jds "12-APR-83 14:34")
    (for I from 1 to (ARRAYSIZE IPFONTS) when (EQ (ELT IPFONTS I)
						  FONT)
       do (RETURN I])
)
[DECLARE: EVAL@COMPILE 

(RECORD Rectangle (origin . corner)
		  (RECORD origin (originx . originy)
			  originx ← 0 originy ← 0)
		  (RECORD corner (cornerx . cornery)
			  cornerx ← 0 cornery ← 0))
]
(DECLARE: EVAL@COMPILE 

(PUTPROPS UPDATE/HCPY/LOOKS MACRO [NIL (PROGN (SETQ FONT (FONTCOPY TEDIT.CURRENT.FONT (QUOTE DEVICE)
								   (QUOTE PRESS)))
					      (SETQ CLOOKS TEDIT.CURRENT.CHARLOOKS)
					      (SETQ ASCENT (IMAX ASCENT (fetch \SFAscent
									   of FONT)))
					      (SETQ DESCENT (IMAX DESCENT (fetch \SFDescent
									     of FONT)))
					      (SETQ FONTWIDTHS (fetch \SFWidths of FONT])
)

(RPAQ? TEditHcpyMode (QUOTE PRESS))
[TEDIT.ADD.MENUITEM TEDIT.DEFAULT.MENU (QUOTE (Hardcopy (QUOTE TEDIT.HARDCOPY]
[TEDIT.ADD.MENUITEM TEDIT.DEFAULT.MENU (QUOTE ("Press File" (QUOTE TEDIT.HCPYFILE]
(DECLARE: DONTCOPY
  (FILEMAP (NIL (815 25285 (TEDIT.HARDCOPY 825 . 1440) (TEDIT.PRESS.HARDCOPY 1442 . 4371) (
TEDIT.IP.HARDCOPY 4373 . 7394) (TEDIT.HCPYFILE 7396 . 8066) (TEDIT.PRESSFILE 8068 . 8437) (
TEDIT.IPFILE 8439 . 8738) (\TEDIT.HCPYFMTLINE 8740 . 18593) (\TEDIT.PRESS.DISPLAYLINE 18595 . 21336) (
\TEDIT.IP.DISPLAYLINE 21338 . 24301) (\TEDIT.IPFONTS 24303 . 25047) (\TEDIT.IPFONTNUM 25049 . 25283)))
))
STOP