(FILECREATED " 4-Sep-84 12:21:35" {ICE}<TRILLIUM>BIRTHDAY84>BETA>TRI-EVENTS.;3 9320   

      changes to:  (FNS SENSE.KEYSTROKE BEGIN.EVENT SETUP.EVENT.MODE SETUP.RECORDING)

      previous date: "17-Aug-84 22:55:30" {ICE}<TRILLIUM>BIRTHDAY84>BETA>TRI-EVENTS.;1)


(* Copyright (c) 1984 by Xerox Corporation)

(PRETTYCOMPRINT TRI-EVENTSCOMS)

(RPAQQ TRI-EVENTSCOMS [(VARS (EVENT.MODE (QUOTE OFF))
			     (RECORDED.EVENTS)
			     (PLAYBACK.EVENTS)
			     (RECORDED.DELAYS)
			     (PLAYBACK.DELAYS)
			     (RECORDED.KEYSTROKES)
			     (PLAYBACK.KEYSTROKES)
			     (EVENT.START.TIME)
			     (EVENT.FINISH.TIME)
			     (EVENT.MODE.MENU))
		       (FNS BEGIN.EVENT END.EVENT GET.EVENT.MODE.MENU GET.IN.INTERFACE LOAD.SESSION 
			    PLAYBACK.EVENTS SAVE.SESSION SETUP.EVENT.MODE SETUP.PLAYBACK 
			    SETUP.RECORDING)
		       (FNS SENSE.KEYSTROKE)
		       (DECLARE: DONTEVAL@LOAD DOEVAL@COMPILE DONTCOPY COMPILERVARS (ADDVARS
				   (NLAMA)
				   (NLAML)
				   (LAMA])

(RPAQQ EVENT.MODE OFF)

(RPAQQ RECORDED.EVENTS NIL)

(RPAQQ PLAYBACK.EVENTS NIL)

(RPAQQ RECORDED.DELAYS NIL)

(RPAQQ PLAYBACK.DELAYS NIL)

(RPAQQ RECORDED.KEYSTROKES NIL)

(RPAQQ PLAYBACK.KEYSTROKES NIL)

(RPAQQ EVENT.START.TIME NIL)

(RPAQQ EVENT.FINISH.TIME NIL)

(RPAQQ EVENT.MODE.MENU NIL)
(DEFINEQ

(BEGIN.EVENT
  [LAMBDA (EVENT)                                            (* PH " 4-Sep-84 10:44")
    (DECLARE (GLOBALVARS EVENT.FINISH.TIME EVENT.MODE EVENT.START.TIME PLAYBACK.DELAYS 
			 RECORDED.DELAYS RECORDED.EVENTS))

          (* * Hans version from Aug. 8)



          (* * (SELECTQ EVENT.MODE (OFF NIL) (RECORDING (SETQ EVENT.START.TIME (CLOCK 0)) (TCONC RECORDED.DELAYS 
	  (IDIFFERENCE EVENT.START.TIME EVENT.FINISH.TIME)) (if EVENT then (TCONC RECORDED.EVENTS EVENT))) 
	  (PLAYBACK (COND ((KEYDOWNP (QUOTE RSHIFT)) (while (KEYDOWNP (QUOTE RSHIFT)) do NIL)) ((KEYDOWNP 
	  (QUOTE LSHIFT)) (TRILLIUM.PAUSE 10)) (T (SETQ EVENT.START.TIME (IPLUS EVENT.FINISH.TIME (CAR PLAYBACK.DELAYS))) 
	  (while (IGREATERP EVENT.START.TIME (CLOCK 0)) do (NILL))))) (ERROR "Unknown EVENT.MODE :" EVENT.MODE)))



          (* * Changes suggested by Tim in message of Aug. 31)


    (SELECTQ EVENT.MODE
	     (OFF NIL)
	     (RECORDING (SETQ EVENT.START.TIME (CLOCK 0))
			(TCONC RECORDED.DELAYS (IDIFFERENCE EVENT.START.TIME EVENT.FINISH.TIME))
			(if EVENT
			    then (TCONC RECORDED.EVENTS EVENT)))
	     [PLAYBACK (COND
			 ((KEYDOWNP (QUOTE RSHIFT))
			   (while (KEYDOWNP (QUOTE RSHIFT)) do NIL))
			 ((KEYDOWNP (QUOTE LSHIFT))
			   (TRILLIUM.PAUSE 10))
			 (T (CAR PLAYBACK.DELAYS)
			    (TRILLIUM.PAUSE EVENT.START.TIME]
	     (ERROR "Unknown EVENT.MODE :" EVENT.MODE])

(END.EVENT
  [LAMBDA NIL                                                (* HaKo " 7-Aug-84 15:58")
    (DECLARE (GLOBALVARS EVENT.FINISH.TIME EVENT.MODE PLAYBACK.DELAYS))
    (SELECTQ EVENT.MODE
	     (OFF NIL)
	     (RECORDING (SETQ EVENT.FINISH.TIME (CLOCK 0)))
	     (PLAYBACK (SETQ PLAYBACK.DELAYS (CDR PLAYBACK.DELAYS)))
	     (ERROR "Unknown EVENT.MODE :" EVENT.MODE])

(GET.EVENT.MODE.MENU
  [LAMBDA (LONG.OR.SHORT)                                    (* HaKo " 8-Aug-84 11:00")
    (DECLARE (GLOBALVARS EVENT.MODE.MENU))
    (OR EVENT.MODE.MENU (SETQ EVENT.MODE.MENU (create MENU
						      TITLE ← "Choose one:"
						      CENTERFLG ← T
						      ITEMS ←(QUOTE ((Turn.Mechanism.Off
									(QUOTE OFF))
								      (Record.Session (QUOTE 
											RECORDING))
								      (Playback.Session (QUOTE 
											 PLAYBACK))
								      ("" NIL)
								      (Load.Session.From.File
									(QUOTE LOAD))
								      (Save.Session.On.File
									(QUOTE SAVE])

(GET.IN.INTERFACE
  [LAMBDA NIL                                                (* TRB "20-JAN-84 14:54")
    (DECLARE (GLOBALVARS CURRENT.INTERFACE.WINDOW LASTMOUSEX LASTMOUSEY))
    (until (INSIDEP (WINDOWPROP CURRENT.INTERFACE.WINDOW (QUOTE REGION))
		    LASTMOUSEX LASTMOUSEY)
       do (GETMOUSESTATE])

(LOAD.SESSION
  [LAMBDA NIL                                                (* HaKo " 7-Aug-84 15:47")
    (PROG (FILENAME FILE)
          (CLRPROMPT)
          (TRILLIUM.PRINTOUT ON PROMPTWINDOW "Name of file to load: ")
          (if (SETQ FILENAME (PROMPT.READ))
	      then (LOAD FILENAME T])

(PLAYBACK.EVENTS
  [LAMBDA NIL                                                (* HaKo " 8-Aug-84 10:34")
                                                             (* to run the playback)
    (DECLARE (GLOBALVARS CURRENT.FRAME CURRENT.INTERFACE.WINDOW EVENT.MODE FRAME.STATUS 
			 PLAYBACK.EVENTS))
    (SETQ FRAME.STATUS "Playing back")
    (INTERFACE.WINDOW.CHANGE.TITLE CURRENT.INTERFACE.WINDOW)
    (ACTIVATE.INITIALIZATIONS CURRENT.FRAME)
    (SYNC.CLOCK T)
    [for EVENT in PLAYBACK.EVENTS bind (SENSEFN PLACEMENT)
       do (SYNC.CLOCK)
	  (if (EQ EVENT (QUOTE $FrameChangeEvent$))
	      then (DO.FRAME.CHANGE)
	    elseif (SETQ SENSEFN (GETPROP (ITEM.TYPE EVENT)
					  (QUOTE SENSE)))
	      then (SETQ PLACEMENT (GET.PARAMQ EVENT PLACEMENT))
		   (APPLY* SENSEFN EVENT T (CAR PLACEMENT)
			   (CADR PLACEMENT]
    (SETQ FRAME.STATUS "Playback Completed")
    (INTERFACE.WINDOW.CHANGE.TITLE CURRENT.INTERFACE.WINDOW)
    (SETQ EVENT.MODE (QUOTE OFF])

(SAVE.SESSION
  [LAMBDA NIL                                                (* HaKo "16-Aug-84 15:00")
    (DECLARE (GLOBALVARS RECORDED.ITEMS))
    (if (CAR RECORDED.ITEMS)
	then (PROG (FILENAME FILE)
	           (CLRPROMPT)
	           (TRILLIUM.PRINTOUT ON PROMPTWINDOW "Name of file to save session on: ")
	           (if (SETQ FILENAME (PROMPT.READ))
		       then [SET (FILECOMS FILENAME)
				 (QUOTE ((HORRIBLEVARS RECORDED.EVENTS)
					  (VARS RECORDED.DELAYS RECORDED.KEYSTROKES]
			    (SETQ FILE (MAKEFILE FILENAME))
			    (TRILLIUM.PRINTOUT ON TRILLIUM.TRACE "Session saved on " FILE)
		     else (TRILLIUM.PRINTOUT ON TRILLIUM.WARNINGS "SAVE.SESSION aborted.")))
      else (TRILLIUM.PRINTOUT ON TRILLIUM.WARNINGS "No previously recorded session to save."])

(SETUP.EVENT.MODE
  [LAMBDA NIL                                                (* PH " 4-Sep-84 11:05")
    (DECLARE (GLOBALVARS EVENT.MODE))
    (SELECTQ (MENU (GET.EVENT.MODE.MENU))
	     (OFF (SETQ EVENT.MODE (QUOTE OFF)))
	     (RECORDING (SETUP.RECORDING))
	     (PLAYBACK (SETUP.PLAYBACK))
	     (LOAD (LOAD.SESSION))
	     (SAVE (SAVE.SESSION))
	     NIL])

(SETUP.PLAYBACK
  [LAMBDA NIL                                                (* HaKo " 8-Aug-84 11:02")
    (DECLARE (GLOBALVARS EVENT.FINISH.TIME EVENT.MODE PLAYBACK.DELAYS PLAYBACK.EVENTS 
			 PLAYBACK.KEYSTROKES RECORDED.DELAYS RECORDED.EVENTS RECORDED.KEYSTROKES))
    (if (CAR RECORDED.EVENTS)
	then (SETQ PLAYBACK.EVENTS (CAR RECORDED.EVENTS))
	     (SETQ PLAYBACK.DELAYS (CAR RECORDED.DELAYS))
	     (SETQ PLAYBACK.KEYSTROKES (CAR RECORDED.KEYSTROKES))
	     (SETQ EVENT.FINISH.TIME (CLOCK 0))
	     (SETQ EVENT.MODE (QUOTE PLAYBACK))
	     (PLAYBACK.EVENTS)
      else (TRILLIUM.PRINTOUT ON TRILLIUM.WARNINGS "No previously recorded session to play back."])

(SETUP.RECORDING
  [LAMBDA NIL                                                (* PH " 4-Sep-84 11:05")
    (DECLARE (GLOBALVARS CURRENT.FRAME CURRENT.INTERFACE CURRENT.INTERFACE.WINDOW EVENT.FINISH.TIME 
			 EVENT.MODE RECORDED.DELAYS RECORDED.EVENTS RECORDED.KEYSTROKES))
    (COND
      ((OR (NULL RECORDED.EVENTS)
	   (CONFIRM "There is a session in memory.  Do you still want to record?"))
	(SETQ RECORDED.EVENTS (CONS))
	(SETQ RECORDED.DELAYS (CONS))
	(SETQ RECORDED.KEYSTROKES (CONS))
	(SETQ EVENT.FINISH.TIME (CLOCK 0))
	(WINDOWPROP CURRENT.INTERFACE.WINDOW (QUOTE TITLE)
		    (CONCAT "TRILLIUM; interface: " (GET.FIELDQ CURRENT.INTERFACE NAME INTERFACE)
			    "; frame: "
			    (GET.FIELDQ CURRENT.FRAME NAME FRAME)
			    "; Not Operating & Recording Session"))
	(SETQ EVENT.MODE (QUOTE RECORDING])
)
(DEFINEQ

(SENSE.KEYSTROKE
  [LAMBDA (ITEM TOUCH XCOORD YCOORD)                         (* PH " 4-Sep-84 12:20")
                                                             (* trb "22-May-84 10:13")
    (DECLARE (GLOBALVARS EVENT.MODE PLAYBACK.KEYSTROKES RECORDED.KEYSTROKES))
    (PROG (KSTROBE)
          (SELECTQ EVENT.MODE
		   [OFF (if (READP T)
			    then (SETQ KSTROBE (PEEKC]
		   (RECORDING (if (READP T)
				  then (SETQ KSTROBE (PEEKC))
				       (TCONC RECORDED.KEYSTROKES KSTROBE)))
		   (PLAYBACK (SETQ KSTROBE (CAR PLAYBACK.KEYSTROKES))
			     (SETQ PLAYBACK.KEYSTROKES (CDR PLAYBACK.KEYSTROKES)))
		   NIL)
          (if KSTROBE
	      then (BEGIN.EVENT ITEM)
		   (CHANGE.CURRENT.VALUE (GET.PARAMQ ITEM KEYSTROKE.CELL)
					 KSTROBE)
		   (if (EQ (GET.PARAMQ ITEM CLEAR.BUFFER)
			   (QUOTE CLEAR.BUFFER))
		       then (CLEARBUF T T))
		   (END.EVENT)
		   (RETURN T])
)
(DECLARE: DONTEVAL@LOAD DOEVAL@COMPILE DONTCOPY COMPILERVARS 

(ADDTOVAR NLAMA )

(ADDTOVAR NLAML )

(ADDTOVAR LAMA )
)
(PUTPROPS TRI-EVENTS COPYRIGHT ("Xerox Corporation" 1984))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (1322 8158 (BEGIN.EVENT 1332 . 2765) (END.EVENT 2767 . 3153) (GET.EVENT.MODE.MENU 3155
 . 3777) (GET.IN.INTERFACE 3779 . 4106) (LOAD.SESSION 4108 . 4419) (PLAYBACK.EVENTS 4421 . 5432) (
SAVE.SESSION 5434 . 6240) (SETUP.EVENT.MODE 6242 . 6637) (SETUP.PLAYBACK 6639 . 7332) (SETUP.RECORDING
 7334 . 8156)) (8159 9107 (SENSE.KEYSTROKE 8169 . 9105)))))
STOP