(FILECREATED " 1-Jul-87 20:24:45" {ICE}<KOOMEN>LISPUSERS>KOTO>FILEWATCH.;6 44796  

      changes to:  (FNS FW-FILTERED-FILE? FW-INIT-PROPS)

      previous date: "27-May-87 15:32:11" {ICE}<KOOMEN>LISPUSERS>KOTO>FILEWATCH.;5)


(* Copyright (c) 1986, 1987 by Johannes A. G. M. Koomen. All rights reserved.)

(PRETTYCOMPRINT FILEWATCHCOMS)

(RPAQQ FILEWATCHCOMS [(* ;;; 
"FILEWATCH is a facility for keeping an eye on the status of open files.  It maintains a display containing the names of open files and their file pointer positions including a percentage bar."
			   )
	(* ;;; "Interface")
	(FNS FILEWATCH FILEWATCHPROP)
	(* ;;; "Implementation")
	(COMS (DECLARE: DONTCOPY (RECORDS FW-OFD))
	      (INITRECORDS FW-OFD))
	(FNS FW-ADJUST-PLACEMENT FW-ADJUST-REGION FW-AFTERMOVEFN FW-BUTTONEVENTFN FW-CHANGE-ANCHOR 
	     FW-CHANGE-JUSTIFICATION FW-CHANGE-POSITION FW-CLOSE-CMD FW-CLOSE-OLD-OFD-WINDOWS 
	     FW-CLOSEFN FW-CREATE-OFD FW-CREATE-OFD-LIST FW-CREATE-OFD-WINDOWS FW-CREATEW 
	     FW-FILTERED-FILE? FW-FORGET-CMD FW-INIT FW-INIT-MENUS FW-INIT-PROPS FW-INTERACT FW-LOOP 
	     FW-MOVE-OFD-WINDOWS FW-MOVEW FW-OFD-EXISTS? FW-PERCENTAGE FW-RE-INIT FW-RECALL-CMD 
	     FW-REPAINTFN FW-RESET FW-RESIZE-OFD FW-SHAPEW FW-SORT-FN FW-UPDATE-OFD-WINDOW 
	     FW-UPDATE-OFD-WINDOWS FW-WIPE)
	[INITVARS (FW-OFDList)
		  (FW-Commands (QUOTE (FORGET FORGET-MANY RECALL RECALL-MANY CLOSE CLOSE-MANY MOVE 
					      SET-ANCHOR SET-POSITION SET-JUSTIFICATION QUIT)))
		  (FW-Properties (BQUOTE (FONT (GACHA 8)
					       ALL-FILES?
					       (\, (EQ MAKESYSNAME (QUOTE KOTO)))
					       POSITION
					       (\, (CREATEPOSITION SCREENWIDTH 0))
					       ANCHOR BOTTOM-RIGHT SHADE (\, GRAYSHADE)
					       INTERVAL 1000]
	(P (FW-INIT-MENUS))
	(DECLARE: DONTEVAL@LOAD DOEVAL@COMPILE DONTCOPY COMPILERVARS (ADDVARS (NLAMA)
									      (NLAML)
									      (LAMA FILEWATCHPROP])



(* ;;; 
"FILEWATCH is a facility for keeping an eye on the status of open files.  It maintains a display containing the names of open files and their file pointer positions including a percentage bar."
)




(* ;;; "Interface")

(DEFINEQ

(FILEWATCH
  [LAMBDA (COMMAND)                                        (* Koomen "15-May-87 01:47")
    (DECLARE (GLOBALVARS FW-Running?))
    (PROG [(FW-PROC (FIND.PROCESS (QUOTE FileWatcher]
	    (SELECTQ (SELECTQ [if (OR (LITATOM COMMAND)
					      (STRINGP COMMAND))
				      then (SETQ COMMAND (MKATOM (U-CASE COMMAND]
				  (ON (if (NULL FW-PROC)
					  then (QUOTE ON)))
				  [(OFF QUIT)
				    (if FW-PROC
					then (SETQ COMMAND (QUOTE OFF]
				  (MENU (SETQ COMMAND NIL)
					  (QUOTE MENU))
				  (if (OR COMMAND FW-PROC)
				      then (QUOTE MENU)
				    else (QUOTE ON)))
		       [ON (SETQ FW-PROC (ADD.PROCESS (LIST (FUNCTION FW-LOOP))
							  (QUOTE NAME)
							  (QUOTE FileWatcher)
							  (QUOTE RESTARTABLE)
							  (QUOTE HARDRESET]
		       (OFF (SETQ FW-PROC (SETQ FW-Running? NIL)))
		       (MENU (if (NULL FW-PROC)
				   then (FILEWATCH (QUOTE ON))
					  (BLOCK))
			       (FW-INTERACT NIL COMMAND))
		       NIL)
	    (RETURN FW-PROC])

(FILEWATCHPROP
  [LAMBDA FILEWATCH#ARGS                                     (* Koomen "12-Jan-87 21:31")
    (DECLARE (GLOBALVARS FW-Properties FW-ReInit?))
    (if (EQ FILEWATCH#ARGS 1)
	then (LET ((PROPNAME (ARG FILEWATCH#ARGS 1)))
		    (LISTGET FW-Properties PROPNAME))
      elseif (EQ FILEWATCH#ARGS 2)
	then (LET* ((PROPNAME (ARG FILEWATCH#ARGS 1))
		      (PROPVALUE (ARG FILEWATCH#ARGS 2))
		      (OLDPROPVALUE (LISTGET FW-Properties PROPNAME)))
		     (if (NOT (EQUAL PROPVALUE OLDPROPVALUE))
			 then (LISTPUT FW-Properties PROPNAME PROPVALUE)
				(SETQ FW-ReInit? T))
		 OLDPROPVALUE)
      else (ERROR "FILEWATCH: Expecting 1 or 2 args -- " FILEWATCH#ARGS])
)



(* ;;; "Implementation")

(DECLARE: DONTCOPY 
[DECLARE: EVAL@COMPILE 

(DATATYPE FW-OFD (FILESTREAM FULLNAME NAMEWIDTH LEFT BOTTOM WIDTH HEIGHT OFDLEFT OFDBOTTOM OFDWIDTH 
			       OFDHEIGHT OFDWINDOW OFDSTREAM OFDSTATUS CURPOS EOFPOS PCTPOS 
			       CURPOSXOFFSET EOFPOSXOFFSET PCTPOSXOFFSET PCTREGION WRITING? RANDOM?))
]
(/DECLAREDATATYPE (QUOTE FW-OFD)
		  (QUOTE (POINTER POINTER POINTER POINTER POINTER POINTER POINTER POINTER POINTER 
				  POINTER POINTER POINTER POINTER POINTER POINTER POINTER POINTER 
				  POINTER POINTER POINTER POINTER POINTER POINTER))
		  (QUOTE ((FW-OFD 0 POINTER)
			  (FW-OFD 2 POINTER)
			  (FW-OFD 4 POINTER)
			  (FW-OFD 6 POINTER)
			  (FW-OFD 8 POINTER)
			  (FW-OFD 10 POINTER)
			  (FW-OFD 12 POINTER)
			  (FW-OFD 14 POINTER)
			  (FW-OFD 16 POINTER)
			  (FW-OFD 18 POINTER)
			  (FW-OFD 20 POINTER)
			  (FW-OFD 22 POINTER)
			  (FW-OFD 24 POINTER)
			  (FW-OFD 26 POINTER)
			  (FW-OFD 28 POINTER)
			  (FW-OFD 30 POINTER)
			  (FW-OFD 32 POINTER)
			  (FW-OFD 34 POINTER)
			  (FW-OFD 36 POINTER)
			  (FW-OFD 38 POINTER)
			  (FW-OFD 40 POINTER)
			  (FW-OFD 42 POINTER)
			  (FW-OFD 44 POINTER)))
		  (QUOTE 46))
)
(/DECLAREDATATYPE (QUOTE FW-OFD)
		  (QUOTE (POINTER POINTER POINTER POINTER POINTER POINTER POINTER POINTER POINTER 
				  POINTER POINTER POINTER POINTER POINTER POINTER POINTER POINTER 
				  POINTER POINTER POINTER POINTER POINTER POINTER))
		  (QUOTE ((FW-OFD 0 POINTER)
			  (FW-OFD 2 POINTER)
			  (FW-OFD 4 POINTER)
			  (FW-OFD 6 POINTER)
			  (FW-OFD 8 POINTER)
			  (FW-OFD 10 POINTER)
			  (FW-OFD 12 POINTER)
			  (FW-OFD 14 POINTER)
			  (FW-OFD 16 POINTER)
			  (FW-OFD 18 POINTER)
			  (FW-OFD 20 POINTER)
			  (FW-OFD 22 POINTER)
			  (FW-OFD 24 POINTER)
			  (FW-OFD 26 POINTER)
			  (FW-OFD 28 POINTER)
			  (FW-OFD 30 POINTER)
			  (FW-OFD 32 POINTER)
			  (FW-OFD 34 POINTER)
			  (FW-OFD 36 POINTER)
			  (FW-OFD 38 POINTER)
			  (FW-OFD 40 POINTER)
			  (FW-OFD 42 POINTER)
			  (FW-OFD 44 POINTER)))
		  (QUOTE 46))
(DEFINEQ

(FW-ADJUST-PLACEMENT
  [LAMBDA (OFDLIST)                                          (* Koomen "12-Jan-87 21:19")

          (* * Recursively (post-order) position each window, so that the first element ends up on top of the display.
	  Note that, for downward-growing lists, the sorter actually forces reverse sort.)


    (DECLARE (GLOBALVARS FW-WindowBottom FW-WindowBottomDelta))
    (if OFDLIST
	then (FW-ADJUST-PLACEMENT (CDR OFDLIST))
	       (PROG ((OFD (CAR OFDLIST)))
		       (SELECTQ (fetch (FW-OFD OFDSTATUS) of OFD)
				  ((NEW CURRENT)
				    (replace (FW-OFD BOTTOM) of OFD with FW-WindowBottom)
				    (if (OR (NEQ (fetch (FW-OFD OFDWIDTH) of OFD)
						       (fetch (FW-OFD WIDTH) of OFD))
						(NEQ (fetch (FW-OFD OFDHEIGHT) of OFD)
						       (fetch (FW-OFD HEIGHT) of OFD)))
					then (FW-SHAPEW OFD)
					       (replace (FW-OFD OFDSTATUS) of OFD
						  with (QUOTE NEW))
				      elseif (OR (NEQ (fetch (FW-OFD LEFT) of OFD)
							    (fetch (FW-OFD OFDLEFT) of OFD))
						     (NEQ (fetch (FW-OFD BOTTOM) of OFD)
							    (fetch (FW-OFD OFDBOTTOM) of OFD)))
					then (FW-MOVEW OFD))
				    (SETQ FW-WindowBottom (IPLUS FW-WindowBottom 
								     FW-WindowBottomDelta)))
				  (FORGOTTEN)
				  (SHOULDNT (CONS "Unexpected OFDSTATUS : " (fetch
							(FW-OFD OFDSTATUS) of OFD])

(FW-ADJUST-REGION
  [LAMBDA NIL                                                (* Koomen "12-Jan-87 21:29")
    (DECLARE (GLOBALVARS FW-Anchor FW-Justified? FW-OFDList FW-Position FW-WindowBottom 
			     FW-WindowBottomDelta FW-WindowHeight WBorder))
    [if FW-Justified?
	then                                               (* Recompute maximum name field width)
	       (PROG (NAMEWIDTH (MAXNAMEWIDTH 0))
		       [for OFD in FW-OFDList do (SELECTQ (fetch (FW-OFD OFDSTATUS)
								     of OFD)
								  ((NEW CURRENT)
								    (SETQ NAMEWIDTH
								      (fetch (FW-OFD NAMEWIDTH)
									 of OFD))
								    (if (IGREATERP NAMEWIDTH 
										     MAXNAMEWIDTH)
									then (SETQ MAXNAMEWIDTH 
										 NAMEWIDTH)))
								  (FORGOTTEN)
								  (SHOULDNT
								    (CONS "Unexpected OFDSTATUS : "
									    (fetch (FW-OFD 
											OFDSTATUS)
									       of OFD]
		       (for OFD in FW-OFDList do (FW-RESIZE-OFD OFD MAXNAMEWIDTH]
    (SETQ FW-WindowBottom (fetch (POSITION YCOORD) of FW-Position))
    (SETQ FW-WindowBottomDelta (IDIFFERENCE FW-WindowHeight (IQUOTIENT WBorder 2)))
    (SELECTQ FW-Anchor
	       ((TOP-LEFT TOP-RIGHT)
		 (SETQ FW-WindowBottom (IDIFFERENCE FW-WindowBottom FW-WindowHeight))
		 (SETQ FW-WindowBottomDelta (IMINUS FW-WindowBottomDelta)))
	       ((BOTTOM-LEFT BOTTOM-RIGHT))
	       (ERROR "Unsupported anchor spec: " FW-Anchor])

(FW-AFTERMOVEFN
  [LAMBDA (W)                                                (* Koomen "12-Jan-87 21:20")
    (DECLARE (GLOBALVARS FW-OFDList))
    (if (NEQ (QUOTE FileWatcher)
		 (PROCESS.NAME (THIS.PROCESS)))
	then (for OFD in FW-OFDList when (EQ W (fetch (FW-OFD OFDWINDOW) of OFD))
		  bind REGION DELTAX DELTAY OLDPOS
		  do (SETQ REGION (WINDOWREGION W))
		       (SETQ DELTAX (IDIFFERENCE (fetch (REGION LEFT) of REGION)
						     (fetch (FW-OFD OFDLEFT) of OFD)))
		       (SETQ DELTAY (IDIFFERENCE (fetch (REGION BOTTOM) of REGION)
						     (fetch (FW-OFD OFDBOTTOM) of OFD)))
		       (SETQ OLDPOS (FILEWATCHPROP (QUOTE POSITION)))
		       [FILEWATCHPROP (QUOTE POSITION)
					(create POSITION
						  XCOORD ← (IPLUS DELTAX (fetch (POSITION
											XCOORD)
										of OLDPOS))
						  YCOORD ← (IPLUS DELTAY (fetch (POSITION
											YCOORD)
										of OLDPOS]
		       (RETURN])

(FW-BUTTONEVENTFN
  [LAMBDA (W)                                                (* Koomen "16-Apr-87 15:28")
    (DECLARE (GLOBALVARS LASTMOUSEBUTTONS))
    (if (MOUSESTATE (ONLY RIGHT))
	then (FW-INTERACT W)
      elseif (MOUSESTATE (ONLY MIDDLE))
	then (FW-MOVE-OFD-WINDOWS (QUOTE POSITION))
      elseif (MOUSESTATE (ONLY LEFT))
	then (FW-REPAINTFN W))
    NIL])

(FW-CHANGE-ANCHOR
  [LAMBDA NIL                                                (* Koomen "16-Apr-87 15:55")
    (DECLARE (GLOBALVARS PROMPTWINDOW))
    (PROG [NEWANCHOR (OLDANCHOR (FILEWATCHPROP (QUOTE ANCHOR]
	    (CLRPROMPT)
	    (printout PROMPTWINDOW "Current anchor is " OLDANCHOR T T)
	    (printout PROMPTWINDOW "Indicate new anchor: ")
	    [SETQ NEWANCHOR (MENU (create MENU
						CENTERFLG ← T
						TITLE ← "Anchor: "
						ITEMS ← (QUOTE (("Top Left" (QUOTE TOP-LEFT))
								     ("Top Right" (QUOTE TOP-RIGHT))
								     ("Bottom Left" (QUOTE 
										      BOTTOM-LEFT))
								     ("Bottom Right" (QUOTE 
										     BOTTOM-RIGHT]
	    (if (AND NEWANCHOR (NEQ NEWANCHOR OLDANCHOR))
		then (FILEWATCHPROP (QUOTE ANCHOR)
					NEWANCHOR])

(FW-CHANGE-JUSTIFICATION
  [LAMBDA NIL                                                (* Koomen "16-Apr-87 15:55")
    (DECLARE (GLOBALVARS PROMPTWINDOW))
    (PROG [NEWJUST? (OLDJUST? (FILEWATCHPROP (QUOTE JUSTIFIED?]
	    (CLRPROMPT)
	    (printout PROMPTWINDOW "Window justification is " OLDJUST? T T)
	    (SETQ NEWJUST? (MOUSECONFIRM "Turn justification on?"))
	    (if (NEQ NEWJUST? OLDJUST?)
		then (FILEWATCHPROP (QUOTE JUSTIFIED?)
					NEWJUST?])

(FW-CHANGE-POSITION
  [LAMBDA NIL                                                (* Koomen "16-Apr-87 15:48")
    (DECLARE (GLOBALVARS FW-OFDList PROMPTWINDOW))
    (PROG ((OLDPOS (FILEWATCHPROP (QUOTE POSITION)))
	     NEWPOS BOX R)
	    (for OFD in FW-OFDList when (EQ (fetch (FW-OFD OFDSTATUS) of OFD)
						    (QUOTE CURRENT))
	       do (SETQ R (WINDOWREGION (fetch (FW-OFD OFDWINDOW) of OFD)))
		    (SETQ BOX (if BOX
				    then (UNIONREGIONS BOX R)
				  else R)))
	    (if BOX
		then (SETQ NEWPOS (GETBOXPOSITION (fetch (REGION WIDTH) of BOX)
							(fetch (REGION HEIGHT) of BOX)
							(fetch (REGION LEFT) of BOX)
							(fetch (REGION BOTTOM) of BOX)))
                                                             (* ;; 
							     
"Now translate since anchor may not have been bottom-left")
		       [SETQ NEWPOS (create POSITION
						XCOORD ← (IPLUS (fetch (POSITION XCOORD)
								       of OLDPOS)
								    (IDIFFERENCE
								      (fetch (POSITION XCOORD)
									 of NEWPOS)
								      (fetch (REGION LEFT)
									 of BOX)))
						YCOORD ← (IPLUS (fetch (POSITION YCOORD)
								       of OLDPOS)
								    (IDIFFERENCE
								      (fetch (POSITION YCOORD)
									 of NEWPOS)
								      (fetch (REGION BOTTOM)
									 of BOX]
	      else (CLRPROMPT)
		     (printout PROMPTWINDOW "Current position is " OLDPOS T T)
		     (printout PROMPTWINDOW "Indicate new position: ")
		     (SETQ NEWPOS (GETPOSITION)))
	    (if (NOT (EQUAL NEWPOS OLDPOS))
		then (FILEWATCHPROP (QUOTE POSITION)
					NEWPOS])

(FW-CLOSE-CMD
  [LAMBDA (W MANY?)                                          (* Koomen "27-May-87 15:29")
    (DECLARE (GLOBALVARS FW-OFDList))
    (if (AND W (NOT MANY?))
	then (for OFD in FW-OFDList when (EQ W (fetch (FW-OFD OFDWINDOW) of OFD))
		  do (CLOSEF? (fetch (FW-OFD FILESTREAM) of OFD))
		       (RETURN))
      else (PROG (OPEN-FILES CLOSE-FILE)
		     (SETQ OPEN-FILES (OPENP))
		     (if (NULL OPEN-FILES)
			 then (PROMPTPRINT "FileWatch: no open files.")
				(RETURN))
		 CLOSE-ANOTHER
		     (SETQ CLOSE-FILE (MENU (create MENU
							  TITLE ← "Select file to close: "
							  ITEMS ← OPEN-FILES)))
		     (if (NULL CLOSE-FILE)
			 then (RETURN))
		     (CLOSEF? CLOSE-FILE)
		     (BLOCK)                               (* ; "Give FileWatch a chance")
		     (if (AND MANY? (SETQ OPEN-FILES (OPENP)))
			 then (GO CLOSE-ANOTHER])

(FW-CLOSE-OLD-OFD-WINDOWS
  [LAMBDA NIL                                                (* Koomen " 1-Oct-86 23:48")
    (DECLARE (GLOBALVARS FW-OFDList))
    (for OFD in FW-OFDList do (SELECTQ (fetch (FW-OFD OFDSTATUS) of OFD)
					       (OLD (CLOSEW (fetch (FW-OFD OFDWINDOW)
								 of OFD)))
					       ((NEW CURRENT FORGOTTEN))
					       (SHOULDNT (CONS "Unexpected OFDSTATUS : "
								   (fetch (FW-OFD OFDSTATUS)
								      of OFD])

(FW-CLOSEFN
  [LAMBDA (W)                                                (* Koomen " 2-Oct-86 00:17")
    (DECLARE (GLOBALVARS FW-OFDList FW-OpenFiles FW-Reset?))
    (if (NEQ (PROCESS.NAME (THIS.PROCESS))
		 (QUOTE FileWatcher))
	then (for OFD in FW-OFDList when (EQ W (fetch (FW-OFD OFDWINDOW) of OFD))
		  do (replace (FW-OFD OFDSTATUS) of OFD with (QUOTE FORGOTTEN))
		       (RETURN))                           (* Force recomputing OFDList)
	       (push FW-OpenFiles T)
	       (SETQ FW-Reset? T])

(FW-CREATE-OFD
  [LAMBDA (FULLNAME FILESTREAM)                            (* Koomen "29-Sep-86 23:14")
    (DECLARE (GLOBALVARS FW-Font))
    (FW-RESIZE-OFD (create FW-OFD
			       FILESTREAM ← FILESTREAM
			       FULLNAME ← FULLNAME
			       NAMEWIDTH ← (STRINGWIDTH FULLNAME FW-Font)
			       EOFPOS ← (if (RANDACCESSP FILESTREAM)
					      then (GETEOFPTR FILESTREAM)
					    else (GETFILEINFO FILESTREAM (QUOTE LENGTH)))
			       WRITING? ← (OPENP FILESTREAM (QUOTE OUTPUT))
			       RANDOM? ← (RANDACCESSP FILESTREAM)
			       OFDSTATUS ← (QUOTE NEW])

(FW-CREATE-OFD-LIST
  [LAMBDA NIL                                                (* Koomen " 1-Oct-86 23:43")
    (DECLARE (GLOBALVARS FW-OFDList FW-OpenFiles FW-SortFn))
    (for FILESTREAM in FW-OpenFiles bind FULLNAME eachtime (SETQ FULLNAME (FULLNAME
								       FILESTREAM))
       unless (OR (FW-FILTERED-FILE? FULLNAME)
		      (FW-OFD-EXISTS? FULLNAME FILESTREAM))
       do (push FW-OFDList (FW-CREATE-OFD FULLNAME FILESTREAM)))
    [SETQ FW-OFDList (for OFD in FW-OFDList join (SELECTQ
							   (fetch (FW-OFD OFDSTATUS) of OFD)
							   ((NEW CURRENT FORGOTTEN)
							     (LIST OFD))
							   (OLD (CLOSEW (fetch (FW-OFD OFDWINDOW)
									     of OFD))
								NIL)
							   (SHOULDNT (CONS 
									"Unexpected OFDSTATUS : "
									       (fetch (FW-OFD
											  OFDSTATUS)
										  of OFD]
    (if FW-SortFn
	then (SORT FW-OFDList (FUNCTION FW-SORT-FN])

(FW-CREATE-OFD-WINDOWS
  [LAMBDA NIL                                                (* Koomen "16-Apr-87 15:29")
    (DECLARE (GLOBALVARS FW-Font FW-OFDList))
    (FW-ADJUST-REGION)
    (for OFD in FW-OFDList bind OFDWINDOW OFDSTREAM unless (fetch (FW-OFD OFDWINDOW)
								      of OFD)
       do (SETQ OFDWINDOW (FW-CREATEW OFD))
	    (SETQ OFDSTREAM (WINDOWPROP OFDWINDOW (QUOTE DSP)))
	    (replace (FW-OFD OFDSTREAM) of OFD with OFDSTREAM)
	    (DSPFONT FW-Font OFDSTREAM)
	    (WINDOWPROP OFDWINDOW (QUOTE RIGHTBUTTONFN)
			  (FUNCTION FW-BUTTONEVENTFN))
	    (WINDOWPROP OFDWINDOW (QUOTE BUTTONEVENTFN)
			  (FUNCTION FW-BUTTONEVENTFN))
	    (WINDOWPROP OFDWINDOW (QUOTE REPAINTFN)
			  (FUNCTION FW-REPAINTFN))
	    (WINDOWPROP OFDWINDOW (QUOTE RESHAPEFN)
			  (FUNCTION NILL))
	    (WINDOWPROP OFDWINDOW (QUOTE CLOSEFN)
			  (FUNCTION FW-CLOSEFN))
	    (WINDOWPROP OFDWINDOW (QUOTE AFTERMOVEFN)
			  (FUNCTION FW-AFTERMOVEFN)))
    (FW-ADJUST-PLACEMENT FW-OFDList])

(FW-CREATEW
  [LAMBDA (OFD)                                              (* Koomen "29-Sep-86 23:16")
    (replace (FW-OFD OFDWINDOW) of OFD with (CREATEW (create REGION
								       LEFT ←
								       (replace (FW-OFD OFDLEFT)
									  of OFD
									  with (fetch
										   (FW-OFD LEFT)
										    of OFD))
								       BOTTOM ←
								       (replace (FW-OFD OFDBOTTOM)
									  of OFD
									  with (fetch
										   (FW-OFD BOTTOM)
										    of OFD))
								       WIDTH ←
								       (replace (FW-OFD OFDWIDTH)
									  of OFD
									  with (fetch
										   (FW-OFD WIDTH)
										    of OFD))
								       HEIGHT ←
								       (replace (FW-OFD OFDHEIGHT)
									  of OFD
									  with (fetch
										   (FW-OFD HEIGHT)
										    of OFD)))
							     NIL NIL T])

(FW-FILTERED-FILE?
  [LAMBDA (FULLNAME)                                       (* Koomen " 1-Jul-87 20:22")
    (DECLARE (GLOBALVARS FW-Filters))                    (* ;; 
							     
"filters are precompiled for matching.  Note that the system function DIRECTORY.MATCH.SETUP has stripped off the host, so we have to match it seperatedly."
)
    (for FILTER in FW-Filters thereis (AND (DIRECTORY.MATCH (CAR FILTER)
								      (FILENAMEFIELD FULLNAME
										       (QUOTE
											 HOST)))
						   (DIRECTORY.MATCH (CDR FILTER)
								      FULLNAME])

(FW-FORGET-CMD
  [LAMBDA (W MANY?)                                          (* Koomen "27-May-87 15:27")
    (DECLARE (GLOBALVARS FW-OFDList))
    (if (AND W (NOT MANY?))
	then (CLOSEW W)
      else (PROG (CURRENT-OFDS FORGET-OFD)
		     (SETQ CURRENT-OFDS (for OFD in FW-OFDList
					     when (EQ (fetch (FW-OFD OFDSTATUS) of OFD)
							  (QUOTE CURRENT))
					     collect OFD))
		     (if (NULL CURRENT-OFDS)
			 then (PROMPTPRINT "FileWatch: no current files.")
				(RETURN))
		 FORGET-ANOTHER
		     [SETQ FORGET-OFD (MENU (create MENU
							  TITLE ← "Select file to forget: "
							  ITEMS ←
							  (for OFD in CURRENT-OFDS
							     collect (LIST (fetch (FW-OFD
											  FULLNAME)
										  of OFD)
									       (KWOTE OFD]
		     (if (NULL FORGET-OFD)
			 then (RETURN))
		     (CLOSEW (fetch (FW-OFD OFDWINDOW) of FORGET-OFD))
		     (if (AND MANY? (SETQ CURRENT-OFDS (REMOVE FORGET-OFD CURRENT-OFDS)))
			 then (GO FORGET-ANOTHER])

(FW-INIT
  [LAMBDA NIL                                                (* Koomen "23-Sep-86 22:33")
    (DECLARE (GLOBALVARS FW-Running?))

          (* * Clean up possible left-overs from a previously killed FileWatch process, then initialize the world)


    (FW-WIPE)
    (FW-RE-INIT)
    (FW-RESET)
    (SETQ FW-Running? T])

(FW-INIT-MENUS
  [LAMBDA NIL                                                (* Koomen "15-May-87 01:50")
    (DECLARE (GLOBALVARS BackgroundMenu BackgroundMenuCommands FW-Commands FW-InteractMenu))

          (* * When changing the list of control menu items, do (SETQ FW-InteractMenu))


    (PROG [(ITEMS (QUOTE (("Forget File" (QUOTE FORGET)
					     "Stop watching this file"
					     (SUBITEMS ("Forget Many Files" (QUOTE FORGET-MANY)
									    
								    "Stop watching several files")))
			       ("Recall File" (QUOTE RECALL)
					      "Start watching a forgotten file again"
					      (SUBITEMS ("Recall Many Files" (QUOTE RECALL-MANY)
									     
						   "Start watching several forgotten files again")))
			       ("" NIL "No-op")
			       ("Close File" (QUOTE CLOSE)
					     "Close this file (user beware!)"
					     (SUBITEMS ("Close Many Files" (QUOTE CLOSE-MANY)
									   "Close several files")))
			       ("" NIL "No-op")
			       ("Move Display" (QUOTE MOVE)
					       "Change the display orientation specs"
					       (SUBITEMS ("Set Anchor" (QUOTE SET-ANCHOR)
								       
							   "Corner of the display to be anchored")
							 ("Set Position" (QUOTE SET-POSITION)
									 
						       "Position of display (relative to anchor)")
							 ("Set Justification" (QUOTE 
										SET-JUSTIFICATION)
									      
			      "Windows to be shrunk or grown depending on maximum filename width")))
			       ("Quit File Watcher" (QUOTE QUIT)
						    ""]
	    (if (NOT (type? MENU FW-InteractMenu))
		then (SETQ FW-InteractMenu (create MENU
							 TITLE ← "FileWatch:"
							 CENTERFLG ← T
							 MENUOFFSET ← (QUOTE (-1 . 58))
							 CHANGEOFFSETFLG ← (QUOTE Y)
							 ITEMS ← ITEMS)))
	    (if (NULL (CDDDR (FASSOC (QUOTE FileWatch)
					     BackgroundMenuCommands)))
		then                                       (* ;; "Not there, or no subitems (older version)")
		       (for C in FW-Commands
			  do (SETQ ITEMS (SUBST [BQUOTE (QUOTE (FILEWATCH
									   (QUOTE (\, C]
						      (BQUOTE (QUOTE (\, C)))
						      ITEMS)))
		       [push BackgroundMenuCommands (BQUOTE (FileWatch
								  (QUOTE (FILEWATCH (QUOTE
											  ON)))
								  
 "Display and continuously update list of open files and and the location of their file pointers"
								  (SUBITEMS (\,@ ITEMS]
		       (SETQ BackgroundMenu])

(FW-INIT-PROPS
  [LAMBDA NIL                                                (* Koomen " 1-Jul-87 20:22")
    (DECLARE (GLOBALVARS FW-AllFiles? FW-Anchor FW-Filters FW-Font FW-Interval FW-Justified? 
			     FW-Position FW-Properties FW-Shade FW-SortFn))
    [SETQ FW-AllFiles? (NOT (NULL (LISTGET FW-Properties (QUOTE ALL-FILES?]
    (SETQ FW-Anchor (OR [CAR (MEMB (LISTGET FW-Properties (QUOTE ANCHOR))
					   (QUOTE (TOP-LEFT TOP-RIGHT BOTTOM-LEFT BOTTOM-RIGHT]
			    (QUOTE BOTTOM-LEFT)))          (* ;; 
							     
"precompile filters for matching.  Note that the system function DIRECTORY.MATCH.SETUP strips off the host, so we have to match it seperatedly."
)
    (SETQ FW-Filters (for FILTER inside (LISTGET FW-Properties (QUOTE FILTERS))
			  join (if (OR (STRINGP FILTER)
					     (LITATOM FILTER))
				     then (SETQ FILTER (DIRECTORY.FILL.PATTERN FILTER))
					    (LIST (CONS (DIRECTORY.MATCH.SETUP
							      (OR (FILENAMEFIELD FILTER
										     (QUOTE HOST))
								    "*"))
							    (DIRECTORY.MATCH.SETUP FILTER)))
				   else (printout PROMPTWINDOW 0 
						    "FileWatch:  filter not a string or symbol: "
						    T FILTER " ignored." T)
					  NIL)))
    [SETQ FW-Font (FONTCREATE (LISTGET FW-Properties (QUOTE FONT]
    [SETQ FW-Interval (FIXP (LISTGET FW-Properties (QUOTE INTERVAL]
    [SETQ FW-Justified? (NOT (NULL (LISTGET FW-Properties (QUOTE JUSTIFIED?]
    (SETQ FW-Position (OR (POSITIONP (LISTGET FW-Properties (QUOTE POSITION)))
			      (create POSITION
					XCOORD ← 0
					YCOORD ← 0)))
    [SETQ FW-Shade (SMALLP (LISTGET FW-Properties (QUOTE SHADE]
    (SETQ FW-SortFn (LET [(FN (LISTGET FW-Properties (QUOTE SORTFN]
		           (if (AND (LITATOM FN)
					(GETD FN))
			       then FN])

(FW-INTERACT
  [LAMBDA (W MENUCMD)                                        (* Koomen "15-May-87 01:03")
    (DECLARE (GLOBALVARS FW-InteractMenu FW-Running?))
    (SELECTQ (OR MENUCMD (SETQ MENUCMD (MENU FW-InteractMenu)))
	       (NIL NIL)
	       (FORGET (FW-FORGET-CMD W))
	       (FORGET-MANY (FW-FORGET-CMD W T))
	       (RECALL (FW-RECALL-CMD))
	       (RECALL-MANY (FW-RECALL-CMD T))
	       (CLOSE (FW-CLOSE-CMD W))
	       (CLOSE-MANY (FW-CLOSE-CMD W T))
	       (MOVE (FW-MOVE-OFD-WINDOWS))
	       (SET-ANCHOR (FW-MOVE-OFD-WINDOWS (QUOTE ANCHOR)))
	       (SET-POSITION (FW-MOVE-OFD-WINDOWS (QUOTE POSITION)))
	       (SET-JUSTIFICATION (FW-MOVE-OFD-WINDOWS (QUOTE JUSTIFIED?)))
	       (QUIT (SETQ FW-Running? NIL))
	       (PROMPTPRINT "Unrecognized FileWatch Control Menu command: " MENUCMD])

(FW-LOOP
  [LAMBDA NIL                                                (* Koomen " 8-Oct-86 12:57")
    (DECLARE (GLOBALVARS FW-AllFiles? FW-Interval FW-OpenFiles FW-ReInit? FW-Reset? FW-Running? 
			     \OPENFILES))
    (bind OPENFILES first (FW-INIT) while FW-Running?
       do [SETQ OPENFILES (if FW-AllFiles?
				  then \OPENFILES
				else                       (* Watch User visible files only.)
				       (for F in (OPENP) collect (GETSTREAM F]
	    (if (OR FW-Reset? FW-ReInit? (NOT (EQUAL OPENFILES FW-OpenFiles)))
		then (if FW-ReInit?
			   then (FW-RE-INIT))
		       (FW-RESET)
		       (if (SETQ FW-OpenFiles (APPEND OPENFILES))
			   then (FW-CREATE-OFD-LIST)
				  (FW-CREATE-OFD-WINDOWS)
			 else (FW-CLOSE-OLD-OFD-WINDOWS))
		       (SETQ FW-ReInit?))
	    (FW-UPDATE-OFD-WINDOWS)
	    (BLOCK FW-Interval)
       finally (FW-WIPE])

(FW-MOVE-OFD-WINDOWS
  [LAMBDA (WHAT)                                             (* Koomen "16-Apr-87 15:55")
    (if (OR (NULL WHAT)
		(EQ WHAT (QUOTE ANCHOR)))
	then (FW-CHANGE-ANCHOR))
    (if (OR (NULL WHAT)
		(EQ WHAT (QUOTE POSITION)))
	then (FW-CHANGE-POSITION))
    (if (OR (NULL WHAT)
		(EQ WHAT (QUOTE JUSTIFIED?)))
	then (FW-CHANGE-JUSTIFICATION])

(FW-MOVEW
  [LAMBDA (OFD)                                              (* Koomen "29-Sep-86 23:10")
    (MOVEW (fetch (FW-OFD OFDWINDOW) of OFD)
	     (replace (FW-OFD OFDLEFT) of OFD with (fetch (FW-OFD LEFT) of OFD))
	     (replace (FW-OFD OFDBOTTOM) of OFD with (fetch (FW-OFD BOTTOM) of OFD])

(FW-OFD-EXISTS?
  [LAMBDA (FULLNAME FILESTREAM)                            (* Koomen " 1-Oct-86 23:42")
    (DECLARE (GLOBALVARS FW-OFDList FW-ReInit?))
    (for OFD in FW-OFDList when (AND (EQ FULLNAME (fetch (FW-OFD FULLNAME) of OFD))
					     (EQ FILESTREAM (fetch (FW-OFD FILESTREAM)
								 of OFD))
					     (EQ (OPENP FILESTREAM (QUOTE OUTPUT))
						   (fetch (FW-OFD WRITING?) of OFD)))
       do (SELECTQ (fetch (FW-OFD OFDSTATUS) of OFD)
		       (OLD (replace (FW-OFD OFDSTATUS) of OFD with (if FW-ReInit?
									      then (QUOTE NEW)
									    else (QUOTE CURRENT)))
			    (RETURN T))
		       ((NEW CURRENT FORGOTTEN)
			 (RETURN T))
		       (SHOULDNT (CONS "Unexpected OFDSTATUS : " (fetch (FW-OFD OFDSTATUS)
									of OFD])

(FW-PERCENTAGE
  [LAMBDA (X Y)                                              (* Koomen "24-Mar-87 15:45")
                                                             (* ;; 
							     
"Desperately tries to use SMALLP's and avoid doing IQUOTIENT's or creating FIXP's or FLOATP's.")
    (if (ILEQ X 0)
	then 0
      elseif (IGEQ X Y)
	then 100
      else (PROG (Z)
		     (if (IGREATERP Y (CONSTANT (LRSH MAX.SMALLP 1)))
			 then (SETQ Y (IQUOTIENT Y 100))
		       elseif (ILEQ X (CONSTANT (IQUOTIENT MAX.SMALLP 200)))
			 then (RETURN (IQUOTIENT (IPLUS (ITIMES X 200)
								Y)
						       (LLSH Y 1)))
		       elseif [AND (IGREATERP X (LRSH Y 1))
				       (ILEQ (SETQ Z (IDIFFERENCE Y X))
					       (CONSTANT (IQUOTIENT MAX.SMALLP 200]
			 then [RETURN (IDIFFERENCE 100 (IQUOTIENT (IPLUS (ITIMES Z 200)
										   Y)
									  (LLSH Y 1]
		       else (SETQ Z (IQUOTIENT MAX.SMALLP Y))
			      (SETQ X (ITIMES Z X))
			      (SETQ Y (IQUOTIENT (ITIMES Z Y)
						     100)))
		     (RETURN (IQUOTIENT (IPLUS X (LRSH Y 1))
					    Y])

(FW-RE-INIT
  [LAMBDA NIL                                                (* Koomen "12-Jan-87 21:22")

          (* * Called from FW-INIT, or from FW-LOOP because a prop has changed.)


    (DECLARE (GLOBALVARS FW-CurPosTab FW-EofPosTab FW-FieldWidth FW-Font FW-OFDList 
			     FW-PercentHeight FW-PercentTab FW-PercentWidth FW-SeprWidth 
			     FW-WindowBottom FW-WindowHeight FW-WindowNoNameWidth WBorder))
    (FW-INIT-PROPS)
    (SETQ FW-SeprWidth (STRINGWIDTH "AA" FW-Font))
    (SETQ FW-FieldWidth (STRINGWIDTH "99999999" FW-Font))
    (SETQ FW-PercentWidth (ITIMES 2 FW-FieldWidth))
    [SETQ FW-PercentHeight (IDIFFERENCE (FONTHEIGHT FW-Font)
					    (ITIMES 2 (ADD1 (FONTPROP FW-Font (QUOTE DESCENT]
    (SETQ FW-CurPosTab FW-SeprWidth)
    (SETQ FW-EofPosTab (IPLUS FW-CurPosTab FW-FieldWidth FW-SeprWidth))
    (SETQ FW-PercentTab (IPLUS FW-EofPosTab FW-FieldWidth FW-SeprWidth))
    (SETQ FW-WindowNoNameWidth (WIDTHIFWINDOW (IPLUS FW-PercentTab FW-FieldWidth 
							   FW-PercentWidth FW-SeprWidth)
						  WBorder))
    (SETQ FW-WindowBottom 0)
    (SETQ FW-WindowHeight (HEIGHTIFWINDOW (FONTHEIGHT FW-Font)
					      NIL WBorder))
    (for OFD in FW-OFDList
       do (DSPFONT FW-Font (fetch (FW-OFD OFDSTREAM) of OFD))
	    (replace (FW-OFD NAMEWIDTH) of OFD with (STRINGWIDTH (fetch (FW-OFD FULLNAME)
									    of OFD)
									 FW-Font))
	    (FW-RESIZE-OFD OFD])

(FW-RECALL-CMD
  [LAMBDA (MANY?)                                            (* Koomen "14-May-87 23:46")
    (DECLARE (GLOBALVARS FW-OFDList FW-Reset?))
    (PROG (FORGOTTEN-OFDS RECALL-OFD)
	    (SETQ FORGOTTEN-OFDS (for OFD in FW-OFDList when (EQ (fetch (FW-OFD OFDSTATUS)
									      of OFD)
									   (QUOTE FORGOTTEN))
				      collect OFD))
	    (if (NULL FORGOTTEN-OFDS)
		then (PROMPTPRINT "FileWatch: no forgotten files.")
		       (RETURN))
	RECALL-ANOTHER
	    [SETQ RECALL-OFD (MENU (create MENU
						 TITLE ← "Select file to recall: "
						 CENTERFLG ← T
						 ITEMS ← (for OFD in FORGOTTEN-OFDS
							      collect (LIST (fetch
										  (FW-OFD FULLNAME)
										   of OFD)
										(KWOTE OFD]
	    (if (NULL RECALL-OFD)
		then (RETURN))
	    (replace (FW-OFD OFDSTATUS) of RECALL-OFD with (if (OPENP (fetch
										  (FW-OFD FULLNAME)
										   of RECALL-OFD))
								     then (FW-UPDATE-OFD-WINDOW
									      RECALL-OFD T)
									    (QUOTE CURRENT)
								   else (PROMPTPRINT 
							       "FileWatch: file has been closed.")
									  (QUOTE OLD)))
	    (SETQ FW-Reset? T)
	    (if (AND MANY? (SETQ FORGOTTEN-OFDS (REMOVE RECALL-OFD FORGOTTEN-OFDS)))
		then (GO RECALL-ANOTHER])

(FW-REPAINTFN
  [LAMBDA (W)                                                (* Koomen "25-Sep-86 00:44")
    (DECLARE (GLOBALVARS FW-OFDList))
    (for OFD in FW-OFDList when (EQ W (fetch (FW-OFD OFDWINDOW) of OFD))
       do (if (OPENP (fetch (FW-OFD OFDSTREAM) of OFD))
		then (FW-UPDATE-OFD-WINDOW OFD T))
	    (RETURN])

(FW-RESET
  [LAMBDA NIL                                                (* Koomen "29-Sep-86 23:20")
    (DECLARE (GLOBALVARS FW-OFDList))
    (for OFD in FW-OFDList do (SELECTQ (fetch (FW-OFD OFDSTATUS) of OFD)
					       (CURRENT (replace (FW-OFD OFDSTATUS) of OFD
							   with (QUOTE OLD)))
					       ((OLD FORGOTTEN))
					       (SHOULDNT (CONS "Unexpected OFDSTATUS : "
								   (fetch (FW-OFD OFDSTATUS)
								      of OFD])

(FW-RESIZE-OFD
  [LAMBDA (OFD MAXNAMEWIDTH)                                 (* Koomen "12-Jan-87 21:23")

          (* * If MAXNAMEWIDTH=NIL, uses OFD's own NAMEWIDTH)


    (DECLARE (GLOBALVARS FW-Anchor FW-CurPosTab FW-EofPosTab FW-PercentHeight FW-PercentTab 
			     FW-PercentWidth FW-Position FW-WindowBottom FW-WindowHeight 
			     FW-WindowNoNameWidth))
    (PROG [(NAMEWIDTH (OR MAXNAMEWIDTH (fetch (FW-OFD NAMEWIDTH) of OFD]
	    (replace (FW-OFD WIDTH) of OFD with (IPLUS FW-WindowNoNameWidth NAMEWIDTH))
	    (replace (FW-OFD HEIGHT) of OFD with FW-WindowHeight)
	    (replace (FW-OFD LEFT) of OFD with (SELECTQ FW-Anchor
								((TOP-LEFT BOTTOM-LEFT)
								  (fetch (POSITION XCOORD)
								     of FW-Position))
								((TOP-RIGHT BOTTOM-RIGHT)
								  (IDIFFERENCE (fetch
										   (POSITION XCOORD)
										    of FW-Position)
										 (fetch
										   (FW-OFD WIDTH)
										    of OFD)))
								(ERROR "Unsupported anchor spec: " 
									 FW-Anchor)))
	    (replace (FW-OFD BOTTOM) of OFD with FW-WindowBottom)
	    (replace (FW-OFD CURPOSXOFFSET) of OFD with (IPLUS FW-CurPosTab NAMEWIDTH))
	    (replace (FW-OFD EOFPOSXOFFSET) of OFD with (IPLUS FW-EofPosTab NAMEWIDTH))
	    (replace (FW-OFD PCTPOSXOFFSET) of OFD with (IPLUS FW-PercentTab NAMEWIDTH))
	    (replace (FW-OFD PCTREGION) of OFD
	       with (create REGION
				LEFT ← NIL
				BOTTOM ← NIL
				WIDTH ← FW-PercentWidth
				HEIGHT ← FW-PercentHeight))
	    (RETURN OFD])

(FW-SHAPEW
  [LAMBDA (OFD)                                              (* Koomen "29-Sep-86 23:09")
    (SHAPEW (fetch (FW-OFD OFDWINDOW) of OFD)
	      (create REGION
			LEFT ← (replace (FW-OFD OFDLEFT) of OFD with (fetch (FW-OFD LEFT)
										of OFD))
			BOTTOM ← (replace (FW-OFD OFDBOTTOM) of OFD with (fetch
										   (FW-OFD BOTTOM)
										    of OFD))
			WIDTH ← (replace (FW-OFD OFDWIDTH) of OFD with (fetch (FW-OFD
											  WIDTH)
										  of OFD))
			HEIGHT ← (replace (FW-OFD OFDHEIGHT) of OFD with (fetch
										   (FW-OFD HEIGHT)
										    of OFD])

(FW-SORT-FN
  [LAMBDA (OFD1 OFD2)                                        (* Koomen "24-Sep-86 23:24")
    (DECLARE (GLOBALVARS FW-Anchor FW-SortFn))
    (SELECTQ FW-Anchor
	       ((TOP-LEFT TOP-RIGHT)                         (* growing downwards *)
		 (APPLY* FW-SortFn (fetch (FW-OFD FULLNAME) of OFD2)
			   (fetch (FW-OFD FULLNAME) of OFD1)))
	       ((BOTTOM-LEFT BOTTOM-RIGHT)                   (* growing upwards *)
		 (APPLY* FW-SortFn (fetch (FW-OFD FULLNAME) of OFD1)
			   (fetch (FW-OFD FULLNAME) of OFD2)))
	       (ERROR "Unsupported anchor spec: " FW-Anchor])

(FW-UPDATE-OFD-WINDOW
  [LAMBDA (OFD NEW?)                                         (* Koomen "27-Apr-87 11:57")
    (DECLARE (GLOBALVARS FW-PercentHeight FW-PercentWidth FW-Shade))
    (PROG ((OFDSTREAM (fetch (FW-OFD OFDSTREAM) of OFD))
	     (FILESTREAM (fetch (FW-OFD FILESTREAM) of OFD))
	     (OLDCURPOS (fetch (FW-OFD CURPOS) of OFD))
	     (OLDEOFPOS (fetch (FW-OFD EOFPOS) of OFD))
	     (OLDPCTPOS (fetch (FW-OFD PCTPOS) of OFD))
	     (PCTREGION (fetch (FW-OFD PCTREGION) of OFD))
	     (BOXBORDER 1)
	     NEWCURPOS NEWEOFPOS NEWPCTPOS X Y)
	    (if (NOT (OPENP FILESTREAM))
		then 

          (* * May just have created some windows, in which case there may have been a BLOCK underneath during which this 
	  file was closed, so make sure file is still open)


		       (RETURN))
	    (SETQ NEWCURPOS (GETFILEPTR FILESTREAM))
	    (SETQ NEWEOFPOS (if (NOT (fetch (FW-OFD WRITING?) of OFD))
				  then OLDEOFPOS
				elseif (NOT (fetch (FW-OFD RANDOM?) of OFD))
				  then NEWCURPOS
				else (GETEOFPTR FILESTREAM)))
	    (if (AND (FIXP NEWCURPOS)
			 (FIXP NEWEOFPOS))
		then (if (ILESSP NEWEOFPOS NEWCURPOS)
			   then (SETQ NEWEOFPOS NEWCURPOS))
	      elseif (FIXP NEWCURPOS)
		then (SETQ NEWEOFPOS NEWCURPOS)
	      elseif (FIXP NEWEOFPOS)
		then (SETQ NEWCURPOS NEWEOFPOS)
	      else (SETQ NEWCURPOS (SETQ NEWEOFPOS 0)))
	    (SETQ NEWPCTPOS (FW-PERCENTAGE NEWCURPOS NEWEOFPOS))
	    (if NEW?
		then (DSPRESET OFDSTREAM)
		       (printout OFDSTREAM (fetch (FW-OFD FULLNAME) of OFD))
		       (replace (FW-OFD OFDSTATUS) of OFD with (QUOTE CURRENT)))
	    (if (OR NEW? (NOT (EQUAL NEWCURPOS OLDCURPOS)))
		then (DSPXPOSITION (fetch (FW-OFD CURPOSXOFFSET) of OFD)
				       OFDSTREAM)
		       (printout OFDSTREAM .I8 NEWCURPOS)
		       (replace (FW-OFD CURPOS) of OFD with NEWCURPOS))
	    (if (OR NEW? (NOT (EQUAL NEWEOFPOS OLDEOFPOS)))
		then (DSPXPOSITION (fetch (FW-OFD EOFPOSXOFFSET) of OFD)
				       OFDSTREAM)
		       (printout OFDSTREAM .I8 NEWEOFPOS)
		       (replace (FW-OFD EOFPOS) of OFD with NEWEOFPOS))
	    (if (OR NEW? (NOT (EQUAL NEWPCTPOS OLDPCTPOS)))
		then (DSPXPOSITION (fetch (FW-OFD PCTPOSXOFFSET) of OFD)
				       OFDSTREAM)
		       (printout OFDSTREAM .I5 NEWPCTPOS)
		       (printout OFDSTREAM " %% ")
		       [SETQ X (OR (fetch (REGION LEFT) of PCTREGION)
				       (replace (REGION LEFT) of PCTREGION
					  with (IPLUS BOXBORDER (DSPXPOSITION NIL OFDSTREAM]
		       [SETQ Y (OR (fetch (REGION BOTTOM) of PCTREGION)
				       (replace (REGION BOTTOM) of PCTREGION
					  with (ADD1 (DSPYPOSITION NIL OFDSTREAM]
		       (if (OR NEW? (ILESSP NEWPCTPOS (OR OLDPCTPOS 100)))
			   then (GRAYBOXAREA X Y FW-PercentWidth FW-PercentHeight BOXBORDER 
						 BLACKSHADE OFDSTREAM))
		       (replace (REGION WIDTH) of PCTREGION with (IQUOTIENT (ITIMES 
											NEWPCTPOS 
										  FW-PercentWidth)
										    100))
		       (DSPFILL PCTREGION FW-Shade NIL OFDSTREAM)
		       (replace (FW-OFD PCTPOS) of OFD with NEWPCTPOS])

(FW-UPDATE-OFD-WINDOWS
  [LAMBDA NIL                                                (* Koomen " 9-Oct-86 17:18")
    (DECLARE (GLOBALVARS FW-OFDList))
    (for OFD in FW-OFDList do (SELECTQ (fetch (FW-OFD OFDSTATUS) of OFD)
					       (NEW (FW-UPDATE-OFD-WINDOW OFD T))
					       (CURRENT (FW-UPDATE-OFD-WINDOW OFD))
					       ((OLD FORGOTTEN))
					       (SHOULDNT (CONS "Unexpected OFDSTATUS : "
								   (fetch (FW-OFD OFDSTATUS)
								      of OFD])

(FW-WIPE
  [LAMBDA NIL                                                (* Koomen "15-May-87 01:49")
    (DECLARE (GLOBALVARS FW-AllFiles? FW-Anchor FW-CurPosTab FW-EofPosTab FW-FieldWidth 
			     FW-Filters FW-Font FW-FullNameWidth FW-Interval FW-Justified? FW-OFDList 
			     FW-OpenFiles FW-PercentHeight FW-PercentTab FW-PercentWidth FW-Position 
			     FW-ReInit? FW-Reset? FW-Running? FW-SeprWidth FW-Shade FW-SortFn 
			     FW-WindowBottom FW-WindowBottomDelta FW-WindowHeight 
			     FW-WindowNoNameWidth))

          (* * Clean up possible left-overs, then set all private vars to NIL)


    (for OFD in FW-OFDList do (CLOSEW (fetch (FW-OFD OFDWINDOW) of OFD)))
    (SETQ FW-AllFiles?)
    (SETQ FW-Anchor)
    (SETQ FW-CurPosTab)
    (SETQ FW-EofPosTab)
    (SETQ FW-FieldWidth)
    (SETQ FW-Filters)
    (SETQ FW-Font)
    (SETQ FW-FullNameWidth)
    (SETQ FW-Interval)
    (SETQ FW-Justified?)
    (SETQ FW-OFDList)
    (SETQ FW-OpenFiles)
    (SETQ FW-PercentHeight)
    (SETQ FW-PercentWidth)
    (SETQ FW-PercentTab)
    (SETQ FW-Position)
    (SETQ FW-ReInit?)
    (SETQ FW-Reset?)
    (SETQ FW-Running?)
    (SETQ FW-SeprWidth)
    (SETQ FW-Shade)
    (SETQ FW-SortFn)
    (SETQ FW-WindowBottom)
    (SETQ FW-WindowBottomDelta)
    (SETQ FW-WindowHeight)
    (SETQ FW-WindowNoNameWidth])
)

(RPAQ? FW-OFDList )

(RPAQ? FW-Commands (QUOTE (FORGET FORGET-MANY RECALL RECALL-MANY CLOSE CLOSE-MANY MOVE SET-ANCHOR 
				    SET-POSITION SET-JUSTIFICATION QUIT)))

(RPAQ? FW-Properties (BQUOTE (FONT (GACHA 8)
				     ALL-FILES?
				     (\, (EQ MAKESYSNAME (QUOTE KOTO)))
				     POSITION
				     (\, (CREATEPOSITION SCREENWIDTH 0))
				     ANCHOR BOTTOM-RIGHT SHADE (\, GRAYSHADE)
				     INTERVAL 1000)))
(FW-INIT-MENUS)
(DECLARE: DONTEVAL@LOAD DOEVAL@COMPILE DONTCOPY COMPILERVARS 

(ADDTOVAR NLAMA )

(ADDTOVAR NLAML )

(ADDTOVAR LAMA FILEWATCHPROP)
)
(PUTPROPS FILEWATCH COPYRIGHT ("Johannes A. G. M. Koomen" 1986 1987))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (2138 4105 (FILEWATCH 2148 . 3338) (FILEWATCHPROP 3340 . 4103)) (6126 44114 (
FW-ADJUST-PLACEMENT 6136 . 7675) (FW-ADJUST-REGION 7677 . 9240) (FW-AFTERMOVEFN 9242 . 10341) (
FW-BUTTONEVENTFN 10343 . 10763) (FW-CHANGE-ANCHOR 10765 . 11627) (FW-CHANGE-JUSTIFICATION 11629 . 
12144) (FW-CHANGE-POSITION 12146 . 13979) (FW-CLOSE-CMD 13981 . 15012) (FW-CLOSE-OLD-OFD-WINDOWS 15014
 . 15530) (FW-CLOSEFN 15532 . 16135) (FW-CREATE-OFD 16137 . 16806) (FW-CREATE-OFD-LIST 16808 . 17839) 
(FW-CREATE-OFD-WINDOWS 17841 . 18976) (FW-CREATEW 18978 . 19927) (FW-FILTERED-FILE? 19929 . 20557) (
FW-FORGET-CMD 20559 . 21718) (FW-INIT 21720 . 22083) (FW-INIT-MENUS 22085 . 24675) (FW-INIT-PROPS 
24677 . 26711) (FW-INTERACT 26713 . 27610) (FW-LOOP 27612 . 28626) (FW-MOVE-OFD-WINDOWS 28628 . 29079)
 (FW-MOVEW 29081 . 29437) (FW-OFD-EXISTS? 29439 . 30343) (FW-PERCENTAGE 30345 . 31621) (FW-RE-INIT 
31623 . 33188) (FW-RECALL-CMD 33190 . 34644) (FW-REPAINTFN 34646 . 35040) (FW-RESET 35042 . 35557) (
FW-RESIZE-OFD 35559 . 37250) (FW-SHAPEW 37252 . 37956) (FW-SORT-FN 37958 . 38604) (
FW-UPDATE-OFD-WINDOW 38606 . 42122) (FW-UPDATE-OFD-WINDOWS 42124 . 42655) (FW-WIPE 42657 . 44112)))))
STOP