(FILECREATED " 4-Sep-85 18:20:46" {ERIS}<TEDIT>TEDITHISTORY.;5 25102  

      changes to:  (FNS TEDIT.REDO TEDIT.REDO.INSERTION)

      previous date: "27-Aug-85 15:32:51" {ERIS}<TEDIT>TEDITHISTORY.;4)


(* Copyright (c) 1983, 1984, 1985 by John Sybalsky & Xerox Corporation. All rights reserved.)

(PRETTYCOMPRINT TEDITHISTORYCOMS)

(RPAQQ TEDITHISTORYCOMS ((FILES TEDIT TEXTOFD TEDITLOOKS)
			 (GLOBALVARS TEDIT.HISTORY.TYPELST TEDIT.HISTORYLST)
			 (INITVARS (TEDIT.HISTORY.TYPELST NIL)
				   (TEDIT.HISTORYLST NIL))
			 (RECORDS TEDITHISTORYEVENT)
			 (FNS \TEDIT.HISTORYADD TEDIT.UNDO TEDIT.UNDO.INSERTION TEDIT.UNDO.DELETION 
			      TEDIT.REDO TEDIT.REDO.INSERTION TEDIT.UNDO.MOVE TEDIT.UNDO.REPLACE 
			      TEDIT.REDO.REPLACE TEDIT.REDO.MOVE)))
(FILESLOAD TEDIT TEXTOFD TEDITLOOKS)
(DECLARE: DOEVAL@COMPILE DONTCOPY

(GLOBALVARS TEDIT.HISTORY.TYPELST TEDIT.HISTORYLST)
)

(RPAQ? TEDIT.HISTORY.TYPELST NIL)

(RPAQ? TEDIT.HISTORYLST NIL)
[DECLARE: EVAL@COMPILE 

(RECORD TEDITHISTORYEVENT (THACTION                          (* A LITATOM, specifying what the event was)
				    THPOINT                  (* Was the selection to the left or right?)
				    THLEN                    (* The # of chars involved)
				    THCH#                    (* The starting ch#)
				    THFIRSTPIECE             (* First piece involved)
				    THOLDINFO                (* Old info, for undo)
				    THAUXINFO                (* Auxiliary info about the event, primarily for redo)
				    THTEXTOBJ                (* Place to remember a second textobj, for those like 
							     MOVE who need to remember both a source and a 
							     destination.)
				    )
			  THPOINT ←(QUOTE LEFT))
]
(DEFINEQ

(\TEDIT.HISTORYADD
  [LAMBDA (TEXTOBJ EVENT)                                    (* jds "10-Jan-84 16:26")
                                                             (* Add a new event to the history list.
							     For now, this just re-sets the whole list to be the one
							     event...)
    (replace TXTHISTORY of TEXTOBJ with EVENT])

(TEDIT.UNDO
  [LAMBDA (TEXTOBJ)                                          (* jds "21-May-84 14:10")
                                                             (* Undo the last thing this guy did.)
                                                             (* Format of the history list: 
							     (Selector-kind-of-last-op --info--))
    (PROG ((SEL (fetch SEL of TEXTOBJ))
	   EVENT CH# LEN FIRSTPIECE)
          (COND
	    ((SETQ EVENT (fetch TXTHISTORY of TEXTOBJ))      (* There really is something to UNDO.
							     Decide what, & fix it.)
	      (SETQ LEN (fetch THLEN of EVENT))              (* Length of the text that was 
							     inserted/deleted/changed)
	      (SETQ CH# (fetch THCH# of EVENT))              (* Starting CH# of the change)
	      (SETQ FIRSTPIECE (fetch THFIRSTPIECE of EVENT))
                                                             (* First piece affected by the change)
	      (RESETLST (RESETSAVE (CURSOR WAITINGCURSOR))
			(\SHOWSEL SEL NIL NIL)
			[SELECTQ (fetch THACTION of EVENT)
				 ((Insert Copy Include)      (* It was an insertion)
				   (TEDIT.UNDO.INSERTION TEXTOBJ EVENT LEN CH# FIRSTPIECE))
				 (Delete                     (* It was a deletion)
					 (TEDIT.UNDO.DELETION TEXTOBJ EVENT LEN CH# FIRSTPIECE))
				 (Looks                      (* It was a character-looks change)
					(TEDIT.UNDO.LOOKS TEXTOBJ EVENT LEN CH# FIRSTPIECE))
				 (ParaLooks                  (* It was a PARA looks change)
					    (TEDIT.UNDO.PARALOOKS TEXTOBJ EVENT LEN CH# FIRSTPIECE))
				 (Move (TEDIT.UNDO.MOVE TEXTOBJ EVENT LEN CH# FIRSTPIECE)
                                                             (* He moved some text)
				       )
				 (Replace (TEDIT.UNDO.REPLACE TEXTOBJ EVENT LEN CH# FIRSTPIECE)
                                                             (* He replaced one piece of text with another.)
					  )
				 (Get                        (* He did a GET -- not undoable.)
				      (TEDIT.PROMPTPRINT TEXTOBJ "You can't UNDO a GET." T))
				 (Put                        (* He did a PUT -- not undoable.)
				      (TEDIT.PROMPTPRINT TEXTOBJ "You can't undo a Put." T))
				 (COND
				   ((AND (SETQ UNDOFN (ASSOC (fetch THACTION of EVENT)
							     TEDIT.HISTORY.TYPELST))
					 (SETQ UNDOFN (CADDR UNDOFN)))
                                                             (* TEDIT.HISTORY.TYPELST is an ALST of form 
							     (type redofn undofn))
				     (APPLY* UNDOFN TEXTOBJ EVENT LEN CH# FIRSTPIECE))
				   (T (TEDIT.PROMPTPRINT TEXTOBJ (CONCAT "UNDO not implemented for "
									 (fetch THACTION
									    of EVENT))
							 T]
			(\SHOWSEL SEL NIL T)))
	    (T (TEDIT.PROMPTPRINT TEXTOBJ "Nothing to UNDO." T])

(TEDIT.UNDO.INSERTION
  [LAMBDA (TEXTOBJ EVENT LEN CH# FIRSTPIECE)                 (* jds "27-Aug-85 15:04")
                                                             (* UNDO a prior Insert, Copy, or Include.)
    (PROG (OBJ DELETEFN)
          (replace \INSERTPCVALID of TEXTOBJ with NIL)       (* Keep TEdit from reusing the current cache piece in 
							     the future -- it is probably invalid)
          (\DELETECH CH# (IPLUS CH# LEN)
		     LEN TEXTOBJ)
          (\FIXDLINES (fetch LINES of TEXTOBJ)
		      (fetch SEL of TEXTOBJ)
		      CH#
		      (IPLUS CH# LEN)
		      TEXTOBJ)                               (* Fix the line descriptors & selection)
          (TEDIT.UPDATE.SCREEN TEXTOBJ)                      (* Fix up the display for all this foofaraw)
          (replace POINT of (fetch SEL of TEXTOBJ) with (QUOTE LEFT))
          (\FIXSEL (fetch SEL of TEXTOBJ)
		   TEXTOBJ)                                  (* Really fix the selection)
          (replace THACTION of EVENT with (QUOTE Delete))    (* Make the UNDO be UNDOable, by changing the event to 
							     a deletion.)
      ])

(TEDIT.UNDO.DELETION
  [LAMBDA (TEXTOBJ EVENT LEN CH# FIRSTPIECE)                 (* jds "27-Aug-85 14:59")
                                                             (* UNDO a prior Deletion of text.)
    (PROG ((INSPC# (\CHTOPCNO CH# (fetch PCTB of TEXTOBJ)))
	   (NPC (fetch NEXTPIECE of FIRSTPIECE))
	   (PCTB (fetch PCTB of TEXTOBJ))
	   (SEL (fetch SEL of TEXTOBJ))
	   (OTEXTLEN (fetch TEXTLEN of TEXTOBJ))
	   NEWPIECE INSPC OBJECT INSERTFN)
          (replace \INSERTPCVALID of TEXTOBJ with NIL)       (* Keep future people from stepping on the current 
							     cache piece, which is probably no longer valid.)
          [COND
	    ((IGREATERP CH# (\EDITELT PCTB INSPC#))
	      (SETQ INSPC (\SPLITPIECE (\EDITELT PCTB (ADD1 INSPC#))
				       CH# TEXTOBJ INSPC#))
	      (add INSPC# 1))
	    (T (SETQ INSPC (\EDITELT PCTB (ADD1 INSPC#]
          (SETQ NEWPIECE (create PIECE using FIRSTPIECE))
          (replace THFIRSTPIECE of EVENT with NEWPIECE)
          (bind (TL ← 0) while (ILESSP TL LEN)
	     do (\INSERTPIECE NEWPIECE INSPC TEXTOBJ)        (* Insert the piece back in)
		[COND
		  ([AND (SETQ OBJECT (fetch POBJ of NEWPIECE))
			(SETQ INSERTFN (IMAGEOBJPROP OBJECT (QUOTE WHENINSERTEDFN]
                                                             (* If this is an imageobject, and it has an insertfn, 
							     call it.)
		    (APPLY* INSERTFN OBJECT (\TEDIT.PRIMARYW TEXTOBJ)
			    NIL
			    (TEXTSTREAM TEXTOBJ]
		(SETQ TL (IPLUS TL (fetch PLEN of FIRSTPIECE))) 
                                                             (* Keep track of how much we've re-inserted)
		(SETQ FIRSTPIECE NPC)                        (* Move to the next piece to insert)
		(AND NPC (SETQ NPC (fetch NEXTPIECE of NPC)))
		(SETQ NEWPIECE (create PIECE using FIRSTPIECE)))
                                                             (* Done here because \INSERTPIECE creams the NEXTPIECE 
							     field.)
          (replace TEXTLEN of TEXTOBJ with (IPLUS (fetch TEXTLEN of TEXTOBJ)
						  LEN))      (* Reset the text length and EOF ptr of the text 
							     stream.)
          (\FIXILINES TEXTOBJ SEL CH# LEN OTEXTLEN)          (* Fix the line descriptors & selection)
          (TEDIT.UPDATE.SCREEN TEXTOBJ)                      (* Fix up the display for all this foofaraw)
          (replace CH# of SEL with CH#)                      (* Make the selection point at the re-inserted text)
          (replace CHLIM of SEL with (IPLUS CH# LEN))
          (replace DCH of SEL with LEN)
          (replace POINT of SEL with (fetch THPOINT of EVENT))
          (\TEDIT.SET.SEL.LOOKS SEL (QUOTE NORMAL))
          (\FIXSEL SEL TEXTOBJ)                              (* Really fix the selection)
          (replace THACTION of EVENT with (QUOTE Insert))    (* Make the UNDO be UNDOable, by changing the event to 
							     a insertion.)
      ])

(TEDIT.REDO
  [LAMBDA (TEXTOBJ)                                          (* jds " 4-Sep-85 16:30")
                                                             (* REDO the last thing this guy did.)
    (PROG ((SEL (fetch SEL of TEXTOBJ))
	   EVENT CH)
          (COND
	    ((SETQ EVENT (fetch TXTHISTORY of TEXTOBJ))      (* There really is something to REDO Decide what, & do 
							     it.)
	      (RESETLST (RESETSAVE (CURSOR WAITINGCURSOR))
			(\SHOWSEL SEL NIL NIL)
			(SELECTQ (fetch THACTION of EVENT)
				 [(Insert Copy Include)      (* It was an insertion)
				   (TEDIT.REDO.INSERTION TEXTOBJ EVENT
							 (IMAX 1 (SELECTQ (fetch POINT of SEL)
									  (LEFT (fetch CH#
										   of SEL))
									  (RIGHT (fetch CHLIM
										    of SEL))
									  NIL]
				 (Delete                     (* It was a deletion)
					 (\TEDIT.DELETE SEL TEXTOBJ))
				 (Replace (TEDIT.REDO.REPLACE TEXTOBJ EVENT))
				 [Looks                      (* It was a looks change)
					(TEDIT.REDO.LOOKS TEXTOBJ EVENT
							  (IMAX 1
								(SELECTQ (fetch POINT of SEL)
									 (LEFT (fetch CH#
										  of SEL))
									 (RIGHT (fetch CHLIM
										   of SEL))
									 NIL]
				 [ParaLooks                  (* It was a Paragraph looks change)
					    (TEDIT.REDO.PARALOOKS TEXTOBJ EVENT
								  (IMAX 1
									(SELECTQ (fetch POINT
										    of SEL)
										 (LEFT (fetch CH#
											  of SEL))
										 (RIGHT (fetch CHLIM
											   of SEL))
										 NIL]
				 (Find                       (* EXACT-MATCH SEARCH COMMAND)
				       [RESETLST (RESETSAVE (CURSOR WAITINGCURSOR))
						 (TEDIT.PROMPTPRINT TEXTOBJ "Searching..." T)
						 (SETQ SEL (fetch SEL of TEXTOBJ))
						 (\SHOWSEL SEL NIL NIL)
						 (SETQ CH (TEDIT.FIND TEXTOBJ (fetch THAUXINFO
										 of EVENT)))
						 (COND
						   (CH (TEDIT.PROMPTPRINT TEXTOBJ "done.")
						       (replace CH# of SEL with CH)
						       [replace CHLIM of SEL
							  with (IPLUS CH
								      (NCHARS (fetch THAUXINFO
										 of EVENT]
						       (replace DCH of SEL
							  with (NCHARS (fetch THAUXINFO of EVENT)))
						       (replace POINT of SEL with (QUOTE RIGHT))
						       (\FIXSEL SEL TEXTOBJ)
						       (TEDIT.NORMALIZECARET TEXTOBJ)
						       (\SHOWSEL SEL NIL T))
						   (T (TEDIT.PROMPTPRINT TEXTOBJ "[Not found]"]
				       (replace \INSERTPCVALID of TEXTOBJ with NIL)
                                                             (* Drop the cached piece. WHY??)
				       )
				 ((Move ReplaceMove)         (* He moved some text)
				   (TEDIT.REDO.MOVE TEXTOBJ EVENT (fetch THLEN of EVENT)
						    (IMAX 1 (SELECTQ (fetch POINT of SEL)
								     (LEFT (fetch CH# of SEL))
								     (RIGHT (fetch CHLIM
									       of SEL))
								     NIL))
						    (fetch THFIRSTPIECE of EVENT)))
				 (Get                        (* He did a GET -- not undoable.)
				      (TEDIT.PROMPTPRINT TEXTOBJ "You can't REDO a GET." T))
				 (Put                        (* He did a PUT -- not undoable.)
				      (TEDIT.PROMPTPRINT TEXTOBJ "You can't REDO a PUT." T))
				 (TEDIT.PROMPTPRINT TEXTOBJ (CONCAT "REDO of the action "
								    (fetch THACTION of EVENT)
								    " isn't implemented.")
						    T))
			(\SHOWSEL SEL NIL T)))
	    (T (TEDIT.PROMPTPRINT TEXTOBJ "Nothing to REDO." T])

(TEDIT.REDO.INSERTION
  [LAMBDA (TEXTOBJ EVENT CH#)                                (* jds " 4-Sep-85 16:27")
                                                             (* REDO a prior Insert/Copy/Include of text.)
    (PROG (INSPC INSPC# NPC (SEL (fetch SEL of TEXTOBJ))
		 (PCTB (fetch PCTB of TEXTOBJ))
		 (LEN (fetch THLEN of EVENT))
		 (FIRSTPIECE (create PIECE using (fetch THFIRSTPIECE of EVENT)
						 PNEW ← T))
		 (OTEXTLEN (fetch TEXTLEN of TEXTOBJ))
		 OBJ COPYFN ORIGFIRSTPC)
          (SETQ ORIGFIRSTPC FIRSTPIECE)
          (replace THFIRSTPIECE of EVENT with FIRSTPIECE)    (* So we can UNDO this, and remove the right set of 
							     pieces.)
          (replace \INSERTPCVALID of TEXTOBJ with NIL)       (* Force any further insertions to make new pieces.)
          (SETQ NPC (fetch NEXTPIECE of FIRSTPIECE))
          (SETQ INSPC# (\CHTOPCNO CH# PCTB))                 (* Piece # of the piece we're to insert inside or in 
							     front of)
          (SETQ INSPC (\EDITELT PCTB (ADD1 INSPC#)))
          [SETQ INSPC (COND
	      ((IEQP CH# (\EDITELT PCTB INSPC#))             (* We're inserting just before an existing piece)
		INSPC)
	      (T                                             (* We must split this piece, and insert before the 
							     second part.)
		 (PROG1 (\SPLITPIECE INSPC CH# TEXTOBJ INSPC#)
			(add INSPC# \EltsPerPiece]
          (bind (TL ← 0) while (ILESSP TL LEN)
	     do                                              (* Loop thru the pieces of the prior insertion, 
							     inserting copies of enough of them to cover the length 
							     of the insertion.)
		[COND
		  ((SETQ OBJ (fetch POBJ of FIRSTPIECE))     (* This piece describes an object)
		    [COND
		      [(SETQ COPYFN (IMAGEOBJPROP OBJ (QUOTE COPYFN)))
			(SETQ OBJ (APPLY* COPYFN OBJ (fetch STREAMHINT of TEXTOBJ)
					  (fetch STREAMHINT of TEXTOBJ)))
			(COND
			  ((EQ OBJ (QUOTE DON'T))
			    (TEDIT.PROMPTPRINT TEXTOBJ "COPY of this object not allowed." T)
			    (RETFROM (QUOTE TEDIT.COPY)))
			  (T (replace POBJ of FIRSTPIECE with OBJ]
		      (OBJ (replace POBJ of FIRSTPIECE with (COPY OBJ]
		    (COND
		      ((SETQ COPYFN (IMAGEOBJPROP OBJ (QUOTE WHENCOPIEDFN)))
                                                             (* If there's an eventfn for copying, use it.)
			(APPLY* COPYFN OBJ (WINDOWPROP (CAR (fetch \WINDOW of TEXTOBJ))
						       (QUOTE DSP))
				(fetch STREAMHINT of TEXTOBJ)
				(fetch STREAMHINT of TEXTOBJ]
		(\INSERTPIECE FIRSTPIECE INSPC TEXTOBJ)      (* Insert the piece back in)
		(SETQ TL (IPLUS TL (fetch PLEN of FIRSTPIECE))) 
                                                             (* Keep track of how much we've re-inserted)
		(SETQ FIRSTPIECE (create PIECE using NPC PNEW ← T)) 
                                                             (* Move to the next piece to insert)
		(AND NPC (SETQ NPC (fetch NEXTPIECE of NPC))) 
                                                             (* Done here because \INSERTPIECE creams the NEXTPIECE 
							     field.))
          (\TEDIT.DIFFUSE.PARALOOKS (fetch PREVPIECE of ORIGFIRSTPC)
				    INSPC)                   (* propagate paragraph formatting into the new 
							     insertion)
          (replace TEXTLEN of TEXTOBJ with (IPLUS (fetch TEXTLEN of TEXTOBJ)
						  LEN))      (* Reset the text length and EOF ptr of the text 
							     stream.)
          (\FIXILINES TEXTOBJ SEL CH# LEN OTEXTLEN)          (* Fix the line descriptors & selection)
          (TEDIT.UPDATE.SCREEN TEXTOBJ)                      (* Fix up the display for all this foofaraw)
          (replace CH# of SEL with CH#)                      (* Make the selection point at the re-inserted text)
          (replace CHLIM of SEL with (IPLUS CH# LEN))
          (replace DCH of SEL with LEN)
          (\TEDIT.SET.SEL.LOOKS SEL (QUOTE NORMAL))
          (\FIXSEL SEL TEXTOBJ)                              (* Really fix the selection)
          (replace THACTION of EVENT with (QUOTE Insert))    (* Make the UNDO be UNDOable, by changing the event to 
							     a insertion.)
      ])

(TEDIT.UNDO.MOVE
  [LAMBDA (TEXTOBJ EVENT LEN CH# FIRSTPIECE)                 (* jds " 6-Mar-85 21:12")
                                                             (* UNDO a MOVE command)
    (PROG ((TOOBJ (fetch THAUXINFO of EVENT))
	   (FROMOBJ (fetch THTEXTOBJ of EVENT))
	   (SOURCECH# (fetch THOLDINFO of EVENT))
	   (CH# (fetch THCH# of EVENT))
	   TOSEL TOTEXTLEN)
          (\SHOWSEL (fetch SEL of TOOBJ)
		    NIL NIL)                                 (* Turn off the selections in the old source and target
							     documents)
          (\SHOWSEL (fetch SEL of FROMOBJ)
		    NIL NIL)
          (\DELETECH CH# (IPLUS CH# LEN)
		     LEN FROMOBJ)                            (* Delete the characters we moved, from the place we 
							     moved them to)
          (\FIXDLINES (fetch LINES of FROMOBJ)
		      (fetch SEL of FROMOBJ)
		      CH#
		      (IPLUS CH# LEN)
		      FROMOBJ)
          (replace CH# of (fetch SEL of FROMOBJ) with (replace CHLIM of (fetch SEL of FROMOBJ)
							 with CH#))
                                                             (* Make this document's selection be a point sel at the
							     place the text used to be.)
          (replace DCH of (fetch SEL of FROMOBJ) with 0)
          (replace POINT of (fetch SEL of FROMOBJ) with (QUOTE LEFT))
                                                             (* Mark lines for update, and fix the selection)
          (SETQ TOTEXTLEN (fetch TEXTLEN of TOOBJ))          (* The pre-insertion len of the place the text is 
							     returning to, for the line udpater below)
          (\TEDIT.INSERT.PIECES TOOBJ SOURCECH# (fetch THFIRSTPIECE of EVENT)
				LEN)

          (* Put the pieces we moved back where they came from (no need to copy them, since we did that on the original move.)
)


          (\FIXILINES TOOBJ (fetch SEL of TOOBJ)
		      SOURCECH# LEN TOTEXTLEN)               (* Mark lines that need updating, and fix up the 
							     selection)
          (add (fetch TEXTLEN of TOOBJ)
	       LEN)                                          (* Update the text length of the erstwhile move source)
          (TEDIT.UPDATE.SCREEN FROMOBJ)                      (* Update the erstwhile text location's image.)
          (COND
	    ((NEQ FROMOBJ TOOBJ)                             (* If they aren't the same document, we need to update 
							     the other document image as well.)
	      (TEDIT.UPDATE.SCREEN TOOBJ)))
          (\FIXSEL (fetch SEL of TOOBJ)
		   TOOBJ)                                    (* Fix up the selections so their images will be OK)
          (\FIXSEL (fetch SEL of FROMOBJ)
		   FROMOBJ)
          (\COPYSEL (fetch SEL of FROMOBJ)
		    TEDIT.SELECTION)                         (* It's handy to think of this as the last selection 
							     made, also.)
          (replace THACTION of EVENT with (QUOTE Move))
          (replace THTEXTOBJ of EVENT with TOOBJ)
          (replace THAUXINFO of EVENT with FROMOBJ)
          (replace THOLDINFO of EVENT with CH#)
          (replace THCH# of EVENT with SOURCECH#)
          (\SHOWSEL (fetch SEL of TOOBJ)
		    NIL T)
          (\SHOWSEL (fetch SEL of FROMOBJ)
		    NIL T])

(TEDIT.UNDO.REPLACE
  [LAMBDA (TEXTOBJ EVENT LEN CH# FIRSTPIECE)                 (* jds " 6-Mar-85 21:12")
    (PROG ((OLDEVENT (fetch THOLDINFO of EVENT))
	   (CH# (fetch THCH# of EVENT))
	   (SEL (fetch SEL of TEXTOBJ)))
          (\SHOWSEL SEL NIL NIL)
          (TEDIT.UNDO.INSERTION TEXTOBJ EVENT LEN CH# FIRSTPIECE)
          (\SHOWSEL SEL NIL NIL)
          (TEDIT.UNDO.DELETION TEXTOBJ OLDEVENT (fetch THLEN of OLDEVENT)
			       CH#
			       (fetch THFIRSTPIECE of OLDEVENT))
          (replace THOLDINFO of OLDEVENT with EVENT)
          (replace THACTION of OLDEVENT with (QUOTE Replace))
          (replace THOLDINFO of EVENT with NIL)
          (\TEDIT.HISTORYADD TEXTOBJ OLDEVENT)
          (replace CH# of SEL with CH#)
          (replace CHLIM of SEL with (IPLUS CH# (fetch THLEN of OLDEVENT)))
          (replace DCH of SEL with (fetch THLEN of OLDEVENT))
          (replace POINT of SEL with (fetch THPOINT of EVENT))
          (replace THPOINT of OLDEVENT with (fetch THPOINT of EVENT))
          (\FIXSEL SEL TEXTOBJ)
          (\SHOWSEL SEL NIL T])

(TEDIT.REDO.REPLACE
  [LAMBDA (TEXTOBJ EVENT)                                    (* jds " 6-Mar-85 22:04")
    (PROG ((OLDEVENT (fetch THOLDINFO of EVENT))
	   (CH# (fetch CH# of (fetch SEL of TEXTOBJ)))
	   (SEL (fetch SEL of TEXTOBJ)))
          (\SHOWSEL SEL NIL NIL)
          (\DELETECH (fetch CH# of SEL)
		     (fetch CHLIM of SEL)
		     (IDIFFERENCE (fetch CHLIM of SEL)
				  (fetch CH# of SEL))
		     TEXTOBJ)
          (\FIXDLINES (fetch LINES of TEXTOBJ)
		      SEL
		      (fetch CH# of SEL)
		      (fetch CHLIM of SEL)
		      TEXTOBJ)
          (replace POINT of SEL with (QUOTE LEFT))
          (TEDIT.REDO.INSERTION TEXTOBJ EVENT CH#)
          (replace THOLDINFO of EVENT with (SETQ OLDEVENT (fetch TXTHISTORY of TEXTOBJ)))
          (replace THACTION of OLDEVENT with (QUOTE Replace))
          (replace THACTION of EVENT with (QUOTE Replace))
          (replace THCH# of EVENT with CH#)
          (\TEDIT.HISTORYADD TEXTOBJ EVENT])

(TEDIT.REDO.MOVE
  [LAMBDA (TEXTOBJ EVENT LEN CH# FIRSTPIECE)                 (* jds " 6-Mar-85 21:13")
    (PROG ((FROMOBJ TEXTOBJ)
	   (SOURCECH# (fetch THOLDINFO of EVENT))
	   (OLDCH# (fetch THCH# of EVENT))
	   (SEL (fetch SEL of TEXTOBJ))
	   (MOVESEL (fetch MOVESEL of TEXTOBJ))
	   OLDCHLIM)
          (replace CH# of MOVESEL with OLDCH#)
          (replace CHLIM of MOVESEL with (IPLUS OLDCH# LEN))
          (replace DCH of MOVESEL with LEN)
          (replace SET of MOVESEL with T)
          (\FIXSEL MOVESEL TEXTOBJ)
          (\TEDIT.SET.SEL.LOOKS MOVESEL (QUOTE MOVE))
          (TEDIT.MOVE MOVESEL SEL])
)
(PUTPROPS TEDITHISTORY COPYRIGHT ("John Sybalsky & Xerox Corporation" 1983 1984 1985))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (1752 24993 (\TEDIT.HISTORYADD 1762 . 2142) (TEDIT.UNDO 2144 . 5112) (
TEDIT.UNDO.INSERTION 5114 . 6373) (TEDIT.UNDO.DELETION 6375 . 9672) (TEDIT.REDO 9674 . 13473) (
TEDIT.REDO.INSERTION 13475 . 18174) (TEDIT.UNDO.MOVE 18176 . 21792) (TEDIT.UNDO.REPLACE 21794 . 23085)
 (TEDIT.REDO.REPLACE 23087 . 24254) (TEDIT.REDO.MOVE 24256 . 24991)))))
STOP