(FILECREATED "17-Jul-84 12:16:52" {ERIS}<LISP>FUGUE.6>PATCHES>CHATPATCH.;1 4172   

      changes to:  (VARS CHATPATCHCOMS)
		   (FNS CHAT.HANDLECHARACTER))


(* Copyright (c) 1984 by Xerox Corporation. All rights reserved.)

(PRETTYCOMPRINT CHATPATCHCOMS)

(RPAQQ CHATPATCHCOMS ((FNS CHAT.HANDLECHARACTER)))
(DEFINEQ

(CHAT.HANDLECHARACTER
  [LAMBDA (CHAR)                                             (* bvm: "17-Jul-84 12:16")
    (DECLARE (USEDFREE WINDOW DSP OUTSTREAM DINGED EATLF EATCRLF EATTOCRLF AUTOLF TTYWIDTH TTYHEIGHT 
		       XPOS YPOS ADDRESSING IDMODE ROLLMODE BLINKMODE FONT PLAINFONT CHATBOLDFONT 
		       FONTWIDTH FONTHEIGHT FONTDESCENT HOMEPOS)
	     (GLOBALVARS INVERTWINDOWFN))                    (* Here and/or below)
    (PROG NIL
          [COND
	    ((EQ CHAR (CHARCODE BELL))
	      (RETURN (COND
			((NOT DINGED)
			  (APPLY* INVERTWINDOWFN WINDOW)     (* Complement window)
			  (SETQ DINGED T]
          (COND
	    (DINGED (APPLY* INVERTWINDOWFN WINDOW)
		    (SETQ DINGED NIL)))
          (COND
	    ((AND AUTOLF (OR (NEQ CHAR (CHARCODE CR))
			     (NOT EATTOCRLF)))

          (* We last received a CR, so DM wants auto LF after it. However, we postpone doing so until the next char is 
	  received, so that we get scroll holding right)


	      (CHAT.DOWN)
	      (SETQ AUTOLF NIL)))
          [COND
	    (ADDRESSING (COND
			  ((CHAT.ADDRESS CHAR)
			    (RETURN]
          [COND
	    ((AND (IGEQ CHAR (CHARCODE SPACE))
		  (ILESSP CHAR (CHARCODE DEL)))              (* Normal char)
	      (SETQ EATLF (SETQ EATCRLF NIL))
	      (RETURN (COND
			((NOT EATTOCRLF)                     (* Print the char)
			  (COND
			    (IDMODE                          (* Spec discourages this, but what the hell...)
				    (CHAT.ADDCHAR)))
			  (CHAT.PRINTCHAR CHAR]
          [COND
	    (EATLF (SETQ EATLF NIL)                          (* LF is ignored after CR)
		   (COND
		     ((EQ CHAR (CHARCODE LF))
		       (RETURN]
          [COND
	    (EATCRLF                                         (* We just wrapped around, so ignore CR and/or LF if 
							     next)
		     (COND
		       ((EQ CHAR (CHARCODE CR))
			 (SETQ EATLF T)
			 (RETURN (SETQ EATCRLF NIL)))
		       (T                                    (* Intervening control characters do not stop the 
							     eating, except for a few inconsistent exceptions...)
			  (SELCHARQ CHAR
				    ((↑B ↑\ ↑↑ ↑←)
				      (SETQ EATCRLF NIL))
				    NIL]
          (SELCHARQ CHAR
		    [LF (COND
			  (IDMODE (CHAT.ADDLINE))
			  (T (CHAT.DOWN]
		    (CR (SETQ EATTOCRLF NIL)
			(CHAT.NEWLINE T))
		    [BS (COND
			  (IDMODE (CHAT.DELCHAR))
			  (T (CHAT.LEFT]
		    (↑W                                      (* Erase to end of line)
			(CHAT.ERASE.TO.EOL))
		    (↑L                                      (* Start of cursor address)
			(SETQ ADDRESSING -1))
		    (↑B                                      (* Homes cursor, cancels some modes)
			(CHAT.HOME)
			(CHAT.CLEARMODES))
		    (↑X                                      (* Cancel --resets modes)
			(CHAT.CLEARMODES)
			(SETQ ROLLMODE))
		    ((↑↑ ↑←)                                 (* Master Reset -- Clears screen, modes)
		      (CHAT.CLEAR))
		    [↑\                                      (* Forward space)
			(COND
			  ((NOT EATTOCRLF)
			    (COND
			      (IDMODE (CHAT.ADDCHAR))
			      (T (CHAT.RIGHT]
		    [↑Z                                      (* Up)
			(COND
			  (IDMODE (CHAT.DELETELINE))
			  (T (CHAT.UP]
		    [(↑N ↑O)                                 (* Enter blink mode, enter protected mode.
							     Do both as embolden)
		      (COND
			((NOT BLINKMODE)
			  (SETQ BLINKMODE T)
			  (DSPFONT [SETQ FONT (OR CHATBOLDFONT (SETQ CHATBOLDFONT
						    (FONTCOPY PLAINFONT (QUOTE WEIGHT)
							      (QUOTE BOLD]
				   DSP]
		    (↑P                                      (* Enter i/d mode)
			(SETQ IDMODE T))
		    (↑%]                                     (* Set roll mode)
			 (SETQ ROLLMODE T))
		    NIL])
)
(PUTPROPS CHATPATCH COPYRIGHT ("Xerox Corporation" 1984))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (319 4092 (CHAT.HANDLECHARACTER 329 . 4090)))))
STOP