(FILECREATED "28-Sep-85 22:55:55" {DSK2}FILEBROWSER.;29 105478 

      changes to:  (FNS FB.COPY/RENAME.MANY FB.UPDATEBROWSERITEMS FB.ABORT.UPDATE FB.CLEANUP.UPDATE 
			FB.EXPUNGECOMMAND FB.CLOSE&EXPUNGE FB.GET.NEW.FILE.SPEC FB.DELVER.FILES 
			FB.MAYBE.EXPUNGE FB.UPDATECOMMAND FB.NEWPATTERNCOMMAND FB.COPY/RENAME.COMMAND 
			FB.COPY/RENAME.ONE FB.EXPUNGE?.MENU)
		   (RECORDS FILEBROWSER)
		   (VARS FILEBROWSERCOMS)

      previous date: "19-Sep-85 16:49:38" {DSK2}FILEBROWSER.;24)


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

(PRETTYCOMPRINT FILEBROWSERCOMS)

(RPAQQ FILEBROWSERCOMS [(COMS (FILES ATTACHEDWINDOW ICONW TABLEBROWSER)
			      (INITVARS (FB.EXPUNGE?MENU)
					(FB.ICONFONT (FONTCREATE (QUOTE HELVETICA)
								 8
								 (QUOTE MRR)))
					(FB.BROWSERFONT (FONTCREATE (QUOTE GACHA)
								    10
								    (QUOTE MRR)))
					(FB.PROMPTFONT (FONTCREATE (QUOTE GACHA)
								   8
								   (QUOTE MRR)))
					(FB.PROMPTLINES 3)
					(FB.MENUFONT (FONTCREATE (QUOTE HELVETICA)
								 10
								 (QUOTE MRR)))
					(FB.OVERFLOW.MAXABSOLUTE 30)
					(FB.OVERFLOW.MAXFRAC .06))
			      (VARS FB.CLOSEMENUITEMS FB.MENU.ITEMS FB.DEFAULT.INFO 
				    FB.DEFAULT.NAME.WIDTH FB.INFOFIELDS FB.INFOSHADE FB.INFOMENUITEMS 
				    FB.ITEMUNSELECTEDSHADE FB.ITEMSELECTEDSHADE)
			      (COMS (BITMAPS FILEDRAWER)
				    (VARS FILEDRAWERREGION)))
	(COMS (* Entries)
	      (FNS FB FILEBROWSER FB.PRINTFN FB.COPYFN)
	      (* Setup)
	      (FNS FB.STARTUP FB.MAKERIGIDWINDOW))
	(COMS (* commands and major subfunctions)
	      (FNS FB.MENU.WHENSELECTEDFN FB.COMMANDSELECTEDFN FB.SUBITEMP FB.MAKE.BROWSER.BUSY)
	      (FNS FB.SELECTEDFILES FB.TABLEBROWSER FB.FETCHFILENAME)
	      (FNS FB.DELETECOMMAND FB.DELVERCOMMAND FB.DELVER.FILES FB.DELETE.FILE FB.UNDELETE.FILE 
		   FB.UNDELETECOMMAND FB.UNDELETEALLCOMMAND FB.HARDCOPYCOMMAND FB.LOADCOMMAND 
		   FB.EDITCOMMAND FB.EDITLISPFILE FB.COMPILECOMMAND FB.OPERATE.ON.FILES 
		   FB.COPYCOMMAND FB.RENAMECOMMAND FB.COPY/RENAME.COMMAND FB.COPY/RENAME.ONE 
		   FB.COPY/RENAME.MANY FB.MAYBE.INSERT.FILE FB.GET.NEW.FILE.SPEC)
	      (FNS FB.UPDATECOMMAND FB.MAYBE.EXPUNGE FB.UPDATEBROWSERITEMS FB.CLEANUP.UPDATE 
		   FB.ABORT.UPDATE FB.MAYBE.WIDEN.NAMES FB.CREATE.FILEBUCKET FB.ADD.FILEGROUP 
		   FB.INSERT.DIRECTORY FB.ADD.FILE FB.INSERT.FILE FB.ANALYZE.PATTERN 
		   FB.GETALLFILEINFO)
	      (FNS FB.SORT.VERSIONS FB.DECREASING.VERSION FB.INCREASING.VERSION 
		   FB.NAMES.DECREASING.VERSION FB.NAMES.INCREASING.VERSION)
	      (FNS FB.EXPUNGECOMMAND FB.REMOVE.FILE FB.COUNT.FILE.CHANGE FB.NEWPATTERNCOMMAND 
		   FB.SETNEWPATTERN FB.NEWINFOCOMMAND FB.GET.NEWPATTERN FB.OPTIONSCOMMAND))
	(COMS (* window functions)
	      (FNS FB.PROMPTWPRINT FB.PROMPTFORINPUT FB.INFOMENU.SHADEINITIALSELECTIONS 
		   FB.\ItemWithTag)
	      (FNS FB.MAKECOUNTERWINDOW FB.COUNTERW.REDISPLAYFN FB.UPDATE.COUNTERS 
		   FB.DISPLAY.COUNTERS FB.COUNTER.STRING)
	      (FNS FB.MAKEHEADINGWINDOW FB.HEADINGW.REDISPLAYFN FB.HEADINGW.RESHAPEFN 
		   FB.HEADINGW.DISPLAY)
	      (FNS FB.ICONFN FB.SCROLLFN FB.UPDATE.HEADING.EXTENT FB.INFOMENU.WHENSELECTEDFN 
		   FB.CLOSEFN FB.EXPUNGE?.MENU FB.AFTERCLOSEFN FB.CLOSE&EXPUNGE)
	      (FNS FB.FASTSEECOMMAND FB.FASTSEE.ONEFILE FB.SEEFULLFN FB.SEEBUTTONFN))
	(DECLARE: EVAL@COMPILE DONTCOPY (FILES (SOURCE)
					       TABLEBROWSERDECLS)
		  (RECORDS INFOFIELD FILEBUCKET FILEBROWSER)
		  (CONSTANTS FB.MORE.BORDER)
		  (GLOBALVARS FB.ICONFONT FB.BROWSERFONT FB.PROMPTFONT FB.MENUFONT FB.EXPUNGE?MENU 
			      FILEDRAWER FB.CLOSEMENUITEMS FB.MENU.ITEMS FB.DEFAULT.INFO 
			      INFOLISTINGWIDTHS FB.INFOSHADE FB.INFOMENUITEMS FB.ITEMUNSELECTEDSHADE 
			      FB.ITEMSELECTEDSHADE DIRCOMMANDS FB.PROMPTLINES FB.INFOFIELDS 
			      WindowTitleDisplayStream FILEDRAWERREGION FB.DEFAULT.NAME.WIDTH 
			      FB.OVERFLOW.MAXABSOLUTE FB.OVERFLOW.MAXFRAC WBorder))
	(INITRECORDS FILEBROWSER)
	(SYSRECORDS FILEBROWSER)
	(DECLARE: DONTEVAL@LOAD DOCOPY (ADDVARS (BackgroundMenuCommands ("FileBrowser"
									  (QUOTE (FILEBROWSER))
									  
						"Opens a filebrowser window; prompts for pattern")))
		  (VARS (BackgroundMenu)))
	(DECLARE: DONTEVAL@LOAD DOEVAL@COMPILE DONTCOPY COMPILERVARS (ADDVARS (NLAMA FB)
									      (NLAML)
									      (LAMA FB.PROMPTWPRINT])
(FILESLOAD ATTACHEDWINDOW ICONW TABLEBROWSER)

(RPAQ? FB.EXPUNGE?MENU )

(RPAQ? FB.ICONFONT (FONTCREATE (QUOTE HELVETICA)
			       8
			       (QUOTE MRR)))

(RPAQ? FB.BROWSERFONT (FONTCREATE (QUOTE GACHA)
				  10
				  (QUOTE MRR)))

(RPAQ? FB.PROMPTFONT (FONTCREATE (QUOTE GACHA)
				 8
				 (QUOTE MRR)))

(RPAQ? FB.PROMPTLINES 3)

(RPAQ? FB.MENUFONT (FONTCREATE (QUOTE HELVETICA)
			       10
			       (QUOTE MRR)))

(RPAQ? FB.OVERFLOW.MAXABSOLUTE 30)

(RPAQ? FB.OVERFLOW.MAXFRAC .06)

(RPAQQ FB.CLOSEMENUITEMS (("Expunge deleted files" (QUOTE EXPUNGE)
						   "Erases all files still marked 'deleted'")
			  ("Don't expunge" (QUOTE NOEXPUNGE)
					   
"Proceeds (closes or updates browser) without expunging deleted files.
Your deletions are thus ignored.")))

(RPAQQ FB.MENU.ITEMS [(Delete FB.DELETECOMMAND 
	       "Marks selected files for deletion.  
  (Use EXPUNGE to remove files from system)"
			      (SUBITEMS ("Delete Selected Files" FB.DELETECOMMAND 
							 "Marks the selected files for deletion.")
					("Delete Old Versions" FB.DELVERCOMMAND 
"Marks for deletion old versions of all files in the browser.
You specify how many versions to keep.")))
		      (Undelete FB.UNDELETECOMMAND "Removes deletion mark for selected files"
				(SUBITEMS ("Undelete ALL Files" FB.UNDELETEALLCOMMAND 
					    "Removes deletion mark from all files in the browser")))
		      (Copy FB.COPYCOMMAND 
			    "Copies selected files (prompts for new file name/directory)")
		      (Rename FB.RENAMECOMMAND 
			      "Renames (moves) selected files (prompts for new name/directory)")
		      (Hardcopy FB.HARDCOPYCOMMAND "Produces hardcopy of selected files")
		      (See FB.FASTSEECOMMAND 
			   "Displays selected files one at a time in a separate window"
			   (SUBITEMS ("Fast SEE Pretty" FB.FASTSEECOMMAND 
			      "Views file quickly, uses font information, no scrolling backwards")
				     ("Fast SEE Unformatted" (FB.FASTSEECOMMAND T)
							     
			       "Views file quickly, shows raw characters, no scrolling backwards")
				     ("Scrollable & Pretty" (FB.EDITCOMMAND READONLY)
							    
				  "Views file with font information in a fully scrollable window")))
		      (Edit FB.EDITCOMMAND 
	 "Calls an editor on the selected files:
  DEDIT for LISP source & TEDIT for other files"
			    (SUBITEMS (TEDIT (FB.EDITCOMMAND TEDIT)
					     "Calls TEdit (text editor) on selected files")
				      (DEDIT (FB.EDITCOMMAND DEDIT)
					     "Calls DEdit (Lisp editor) on selected files")))
		      (Load FB.LOADCOMMAND "LOADs selected files" (SUBITEMS (LOAD FB.LOADCOMMAND 
								"Performs LOAD on selected files")
									    ("Load PROP"
									      (FB.LOADCOMMAND PROP)
									      
						     "Loads the selected files with LDFLG = PROP")
									    ("Load SYSLOAD"
									      (FB.LOADCOMMAND SYSLOAD)
									      
						 "System-loads the files (fast but not undoable)")
									    (LOADFROM (FB.LOADCOMMAND
											LOADFROM)
										      
							    "Performs LOADFROM on selected files")
									    (LOADCOMP (FB.LOADCOMMAND
											LOADCOMP)
										      
							    "Performs LOADCOMP on selected files")))
		      (Compile FB.COMPILECOMMAND "Compiles selected LISP source files"
			       (SUBITEMS (TCOMPL (FB.COMPILECOMMAND TCOMPL)
						 "Does TCOMPL on selected files")
					 (BCOMPL FB.COMPILECOMMAND "Does BCOMPL on selected files")))
		      (Expunge FB.EXPUNGECOMMAND 
			 "Permanently removes from the file system all files marked for deletion")
		      (Recompute FB.UPDATECOMMAND 
				 "Recomputes set of files satisfying selection pattern"
				 (SUBITEMS ("Same Pattern" FB.UPDATECOMMAND 
					     "Recomputes set of files satisfying current pattern")
					   ("New Pattern" FB.NEWPATTERNCOMMAND 
					"Prompts for a new selection pattern and updates browser")
					   ("New Info" FB.NEWINFOCOMMAND 
					   "Change the set of file attributes that are displayed"])

(RPAQQ FB.DEFAULT.INFO (SIZE CREATIONDATE AUTHOR))

(RPAQQ FB.DEFAULT.NAME.WIDTH 140)

(RPAQQ FB.INFOFIELDS ((LENGTH "  Length" 70 (FIX 8))
		      (SIZE "Pages" 50 (FIX 5))
		      (BYTESIZE "Bits" 40 (FIX 3))
		      (TYPE "Type" 55)
		      (CREATIONDATE "Created" 170)
		      (READDATE "Read" 170)
		      (WRITEDATE "Written" 180)
		      (AUTHOR "Author" 120)))

(RPAQQ FB.INFOSHADE 32800)

(RPAQQ FB.INFOMENUITEMS ((Length LENGTH "Toggles Length display")
			 (ByteSize BYTESIZE "Toggles ByteSize display")
			 (Pages SIZE "Toggles Pages display")
			 (Type TYPE "Toggles Type display")
			 (Created CREATIONDATE "Toggles Created display")
			 (Written WRITEDATE "Toggles Written display")
			 (Read READDATE "Toggles Read display")
			 (Author AUTHOR "Toggles Author display")))

(RPAQQ FB.ITEMUNSELECTEDSHADE 0)

(RPAQQ FB.ITEMSELECTEDSHADE 4672)

(RPAQ FILEDRAWER (READBITMAP))
(83 70
"OOOOOOOOOOOOOOOOOOOON@@@"
"OOOOOOOOOOOOOOOOOOOON@@@"
"L@@@@@@@@@@@@@@@@@@@F@@@"
"L@@@@@@@@@@@@@@@@@@@F@@@"
"LOOOOOOOOOOOOOOOOOONF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LH@@@@@GOOOOOL@@@@@BF@@@"
"LH@@@@@D@@@@@D@@@@@BF@@@"
"LH@@@@@D@@@@@D@@@@@BF@@@"
"LH@@@@@DCOOOHD@@@@@BF@@@"
"LH@@@@@D@@@@@D@@@@@BF@@@"
"LH@@@@@DOOOOND@@@@@BF@@@"
"LH@@@@@D@@@@@D@@@@@BF@@@"
"LH@@@@@D@@@@@D@@@@@BF@@@"
"LH@@@@@GOOOOOL@@@@@BF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LH@@@@@COOOOOH@@@@@BF@@@"
"LH@@@@@COOOOOH@@@@@BF@@@"
"LH@@@@@B@@@@@H@@@@@BF@@@"
"LH@@@@@A@@@@A@@@@@@BF@@@"
"LH@@@@@@OOOON@@@@@@BF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LH@@@@@@@@@@@@@@@@@BF@@@"
"LOOOOOOOOOOOOOOOOOONF@@@"
"L@@@@@@@@@@@@@@@@@@@F@@@"
"L@@@@@@@@@@@@@@@@@@@F@@@"
"OOOOOOOOOOOOOOOOOOOON@@@"
"OOOOOOOOOOOOOOOOOOOON@@@")

(RPAQQ FILEDRAWERREGION (5 5 73 40))



(* Entries)

(DEFINEQ

(FB
  [NLAMBDA PATTERN                                           (* bvm: " 4-Sep-85 22:13")

          (* * FILEBROWSER entry from top-level exec: FB PATTERN ... PROPS ...)


    (LET ((PAT&PROPS (NLAMBDA.ARGS PATTERN)))
         (FILEBROWSER (CAR PAT&PROPS)
		      (CDR PAT&PROPS)))
    NIL])

(FILEBROWSER
  [LAMBDA (FILESPEC DESIREDPROPS REGION)                     (* bvm: "18-Sep-85 19:07")
    (PROG ((TITLEFONT (DSPFONT NIL WindowTitleDisplayStream))
	   (BROWSERFONTHEIGHT (FONTPROP FB.BROWSERFONT (QUOTE HEIGHT)))
	   BROWSER PROMPTWHEIGHT COUNTERHEIGHT COMMANDMENUWINDOW COMMANDMENUWIDTH BROWSERWIDTH 
	   BROWSERWINDOW COMMANDMENU HEADINGW COUNTERW)
          (PROGN                                             (* Figure out the size of the fixed pieces before 
							     prompting for a region)
		 (SETQ COMMANDMENU
		   (create MENU
			   MENUFONT ← FB.MENUFONT
			   ITEMS ← FB.MENU.ITEMS
			   CENTERFLG ← T
			   MENUCOLUMNS ← 1
			   WHENSELECTEDFN ←(FUNCTION FB.MENU.WHENSELECTEDFN)
			   TITLE ← "FB Commands"))
		 (SETQ COMMANDMENUWIDTH (fetch (MENU IMAGEWIDTH) of COMMANDMENU))
		 [SETQ PROMPTWHEIGHT (HEIGHTIFWINDOW (ITIMES FB.PROMPTLINES (FONTPROP FB.PROMPTFONT
										      (QUOTE HEIGHT]
		 (SETQ COUNTERHEIGHT (HEIGHTIFWINDOW (FONTPROP TITLEFONT (QUOTE HEIGHT))
						     T)))
          [PROGN                                             (* First make the main window, carved out of the space 
							     in REGION leftover after the fixed parts are accounted 
							     for)
		 [OR REGION (SETQ REGION (GETREGION (PROG1 (IPLUS COMMANDMENUWIDTH 
								  FB.DEFAULT.NAME.WIDTH 
								  TB.LEFT.MARGIN)
                                                             (* Min width is menu plus enough space to print a name)
							   )
						    (PROG1 (IPLUS PROMPTWHEIGHT COUNTERHEIGHT
								  (ITIMES 6 BROWSERFONTHEIGHT))
                                                             (* Min height is prompt window plus counter window plus
							     heading plus 5 lines of files)
							   ]
		 [SETQ BROWSERWINDOW (CREATEW (create REGION using REGION WIDTH ←(SETQ BROWSERWIDTH
								     (IDIFFERENCE
								       (fetch (REGION WIDTH)
									  of REGION)
								       COMMANDMENUWIDTH))
								   HEIGHT ←(IDIFFERENCE
								     (fetch (REGION HEIGHT)
									of REGION)
								     (IPLUS COUNTERHEIGHT 
									    PROMPTWHEIGHT 
									    BROWSERFONTHEIGHT]
		 (DSPFONT FB.BROWSERFONT BROWSERWINDOW)
		 [WINDOWPROP BROWSERWINDOW (QUOTE FILEBROWSER)
			     (SETQ BROWSER (create FILEBROWSER
						   BROWSERWINDOW ← BROWSERWINDOW
						   BROWSERFONT ← FB.BROWSERFONT
						   OVERFLOWSPACING ←(ITIMES 3 (CHARWIDTH
									      (CHARCODE a)
									      FB.BROWSERFONT))
						   SORTBY ←(FUNCTION FB.NAMES.DECREASING.VERSION]
		 (replace (FILEBROWSER TABLEBROWSER) of BROWSER
		    with (TB.MAKE.BROWSER NIL BROWSERWINDOW (LIST (QUOTE PRINTFN)
								  (FUNCTION FB.PRINTFN)
								  (QUOTE COPYFN)
								  (FUNCTION FB.COPYFN)
								  (QUOTE USERDATA)
								  BROWSER
								  (QUOTE CLOSEFN)
								  (FUNCTION FB.CLOSEFN)
								  (QUOTE AFTERCLOSEFN)
								  (FUNCTION FB.AFTERCLOSEFN]
          (PROGN                                             (* Atop this sits the black heading window, with labels
							     for each column in browser)
		 (FB.MAKEHEADINGWINDOW BROWSERWINDOW BROWSERWIDTH BROWSERFONTHEIGHT FB.BROWSERFONT))
          (PROGN                                             (* Atop that is the counter window, whose title 
							     contains the file pattern)
		 (FB.MAKECOUNTERWINDOW BROWSERWINDOW TITLEFONT BROWSERWIDTH COUNTERHEIGHT))
          (PROGN                                             (* Main command menu sits on the right side)
		 (SETQ COMMANDMENUWINDOW (MENUWINDOW COMMANDMENU))
		 (ATTACHWINDOW COMMANDMENUWINDOW BROWSERWINDOW (QUOTE RIGHT)
			       (QUOTE TOP)))
          [PROGN                                             (* Finally the prompt window atop it all)
		 (replace (FILEBROWSER PROMPTWINDOW) of BROWSER with (FB.MAKERIGIDWINDOW
								       (GETPROMPTWINDOW BROWSERWINDOW 
										   FB.PROMPTLINES 
										    FB.PROMPTFONT]
          (PROGN                                             (* Now make them all open. For some reason, attaching 
							     the menu didn't open it)
		 (TOTOPW BROWSERWINDOW))
          (WINDOWPROP BROWSERWINDOW (QUOTE SCROLLFN)
		      (FUNCTION FB.SCROLLFN))
          (COND
	    [DESIREDPROPS                                    (* User specifies which attributes to use)
			  (for X on DESIREDPROPS do (OR (FB.\ItemWithTag (CAR X)
									 FB.INFOMENUITEMS)
							(AND (LISTP DIRCOMMANDS)
							     (MISSPELLED? (CAR X)
									  99 DIRCOMMANDS NIL X]
	    (T (SETQ DESIREDPROPS FB.DEFAULT.INFO)))
          (replace (FILEBROWSER INFOMENUCHOICES) of BROWSER with DESIREDPROPS)
          (WINDOWPROP BROWSERWINDOW (QUOTE ICONFN)
		      (FUNCTION FB.ICONFN))
          (ADD.PROCESS (LIST (FUNCTION FB.STARTUP)
			     BROWSER COMMANDMENU (KWOTE FILESPEC))
		       (QUOTE NAME)
		       (QUOTE FB-Update)
		       (QUOTE BEFOREEXIT)
		       (QUOTE DON'T))
          (RETURN BROWSERWINDOW])

(FB.PRINTFN
  [LAMBDA (TBROWSER ITEM WINDOW)                             (* bvm: "18-Sep-85 11:46")
    (LET ((FBROWSER (TB.USERDATA TBROWSER))
	  (FDATA (fetch TIDATA of ITEM))
	  XPOS INFOWANTED FILEINFO NEXTPOS HEADING INFO VERSION FORMAT TEMP CHEAT ACTUALNEXT CHAR0)
         (COND
	   ((fetch (FILEBUCKET DIRECTORYP) of FDATA)
	     (PRIN1 "  " WINDOW)))
         (PRIN1 (fetch (FILEBUCKET PRINTNAME) of FDATA)
		WINDOW)
         (COND
	   ((SETQ VERSION (fetch (FILEBUCKET VERSION) of FDATA))
	     (PRINTOUT WINDOW (QUOTE ;)
		       .I1 VERSION)))
         (SETQ NEXTPOS (fetch (FILEBROWSER INFOSTART) of FBROWSER))
         (COND
	   ((SETQ INFOWANTED (fetch (FILEBROWSER INFODISPLAYED) of FBROWSER))
	     (SETQ FILEINFO (fetch (FILEBUCKET FILEINFO) of FDATA))
	     (for SPEC in FB.INFOFIELDS when (FMEMB (SETQ HEADING (fetch INFONAME of SPEC))
						    INFOWANTED)
		do (SETQ FORMAT (fetch INFOFORMAT of SPEC))
		   (SETQ INFO (LISTGET FILEINFO HEADING))
		   (COND
		     ([OR (LESSP (SETQ XPOS (DSPXPOSITION NIL WINDOW))
				 (SETQ ACTUALNEXT NEXTPOS))
			  (COND
			    ([AND FORMAT (FIXP INFO)
				  (IGREATERP [SETQ TEMP
					       (IDIFFERENCE
						 (CADR FORMAT)
						 (SETQ CHEAT
						   (IPLUS 1 (IQUOTIENT (IDIFFERENCE XPOS NEXTPOS)
								       (SETQ CHAR0
									 (CHARWIDTH
									   (CHARCODE 0)
									   (fetch (FILEBROWSER 
										      BROWSERFONT)
									      of FBROWSER]
					     1)
				  (ILESSP INFO (EXPT 10 (SUB1 TEMP]
                                                             (* Next field is numeric and has some leading blanks, 
							     so cheat it)
			      (SETQ FORMAT (LIST (QUOTE FIX)
						 TEMP))
			      (SETQ ACTUALNEXT (IPLUS NEXTPOS (ITIMES CHEAT CHAR0]
		       (TB.CLEAR.LINE TBROWSER ITEM XPOS (DIFFERENCE ACTUALNEXT XPOS))
		       (DSPXPOSITION ACTUALNEXT WINDOW))
		     (INFO                                   (* Need some space before next item)
			   (PRIN1 " " WINDOW)))
		   [COND
		     (INFO (COND
			     ((AND FORMAT (FIXP INFO))       (* Get numbers to line up)
			       (PRINTNUM FORMAT INFO WINDOW))
			     (T (PRIN1 INFO WINDOW]
		   (add NEXTPOS (fetch INFOWIDTH of SPEC])

(FB.COPYFN
  [LAMBDA (TBROWSER ITEM)                                    (* bvm: " 8-Sep-85 18:06")
    (BKSYSBUF (fetch (FILEBUCKET FILENAME) of (fetch TIDATA of ITEM])
)



(* Setup)

(DEFINEQ

(FB.STARTUP
  [LAMBDA (BROWSER COMMANDMENU FILESPEC)                     (* bvm: "18-Sep-85 22:18")
    (RESETLST (FB.MAKE.BROWSER.BUSY BROWSER (FASSOC (QUOTE Recompute)
						    (fetch (MENU ITEMS) of COMMANDMENU))
				    COMMANDMENU)
	      (COND
		(FILESPEC (replace PATTERN of BROWSER with (SETQ FILESPEC (DIRECTORY.FILL.PATTERN
							       FILESPEC)))
			  (FB.UPDATEBROWSERITEMS BROWSER))
		(T (FB.NEWPATTERNCOMMAND BROWSER])

(FB.MAKERIGIDWINDOW
  [LAMBDA (WINDOW)                                           (* bvm: "22-Jul-85 16:14")

          (* * make the argument window immutable w/r/to attachedwindow package)


    (LET [(HEIGHT (fetch (REGION HEIGHT) of (WINDOWPROP WINDOW (QUOTE REGION]
         (WINDOWPROP WINDOW (QUOTE MINSIZE)
		     (CONS 0 HEIGHT))
         (WINDOWPROP WINDOW (QUOTE MAXSIZE)
		     (CONS SCREENWIDTH HEIGHT))
     WINDOW])
)



(* commands and major subfunctions)

(DEFINEQ

(FB.MENU.WHENSELECTEDFN
  [LAMBDA (Item Menu Key)                                    (* bvm: "18-Sep-85 17:16")
    (ADD.PROCESS (LIST (FUNCTION FB.COMMANDSELECTEDFN)
		       (KWOTE Item)
		       (KWOTE Menu)
		       (KWOTE Key))
		 (QUOTE NAME)
		 (PACK* (QUOTE FB-)
			(CAR Item))
		 (QUOTE BEFOREEXIT)
		 (QUOTE DON'T])

(FB.COMMANDSELECTEDFN
  [LAMBDA (ITEM MENU KEY)                                    (* bvm: "14-Sep-85 15:53")
    (RESETLST (LET* [(REALITEM ITEM)
		     (WINDOW (WINDOWPROP (WFROMMENU MENU)
					 (QUOTE MAINWINDOW)))
		     (FBROWSER (WINDOWPROP WINDOW (QUOTE FILEBROWSER]
		    [COND
		      ((NOT (MEMBER ITEM (fetch (MENU ITEMS) of MENU)))
                                                             (* A subitem -- fetch main item)
			(SETQ ITEM (for I in (fetch (MENU ITEMS) of MENU) thereis (FB.SUBITEMP ITEM I]
		    (COND
		      ((FB.MAKE.BROWSER.BUSY FBROWSER ITEM MENU)
			(LET ((FN (CADR REALITEM))
			      (PWINDOW (fetch (FILEBROWSER PROMPTWINDOW) of FBROWSER))
			      EXTRA)
			     (COND
			       ((OPENWP PWINDOW)
				 (CLEARW PWINDOW)))
			     [COND
			       ((LISTP FN)
				 (SETQ EXTRA (CADR FN))
				 (SETQ FN (CAR FN]
			     (APPLY* FN FBROWSER KEY REALITEM MENU EXTRA)))
		      (T                                     (* Used to be (FB.PROMPTWPRINT WINDOW 
							     "This filebrowser is busy") but that trashes the prompt
							     window)
			 (FLASHWINDOW WINDOW])

(FB.SUBITEMP
  [LAMBDA (SUBITEM ITEM)                                     (* bvm: "22-Jul-85 15:08")

          (* * True if SUBITEM appears among the subitems of ITEM or descendents)


    (LET ((SUB (CADDDR ITEM)))
         (AND SUB (EQ (CAR (LISTP SUB))
		      (QUOTE SUBITEMS))
	      (OR (MEMBER SUBITEM SUB)
		  (for I in (CDR SUB) thereis (FB.SUBITEMP SUBITEM I])

(FB.MAKE.BROWSER.BUSY
  [LAMBDA (BROWSER ITEM MENU DONTWAIT)                       (* bvm: "14-Sep-85 15:59")

          (* * Makes browser "busy" doing ITEM of MENU. Must be called under RESETLST)


    (COND
      ((OBTAIN.MONITORLOCK (fetch (FILEBROWSER TBLOCK) of BROWSER)
			   DONTWAIT T)
	(RESETSAVE NIL (LIST (FUNCTION [LAMBDA (ITEM MENU)
				 (SHADEITEM ITEM MENU FB.ITEMUNSELECTEDSHADE])
			     ITEM MENU))
	(SHADEITEM ITEM MENU FB.ITEMSELECTEDSHADE)
	T])
)
(DEFINEQ

(FB.SELECTEDFILES
  [LAMBDA (BROWSER NOERRORFLG)                               (* bvm: "12-Sep-85 18:33")
    (COND
      ((TB.COLLECT.ITEMS (fetch (FILEBROWSER TABLEBROWSER) of BROWSER)
			 (QUOTE SELECTED)))
      ((NOT NOERRORFLG)
	(FB.PROMPTWPRINT BROWSER T "No files are selected")
	NIL])

(FB.TABLEBROWSER
  [LAMBDA (FILEBROWSER)                                      (* bvm: "18-Sep-85 19:06")
    (fetch (FILEBROWSER TABLEBROWSER) of FILEBROWSER])

(FB.FETCHFILENAME
  [LAMBDA (ITEM)                                             (* bvm: "12-Sep-85 00:09")
    (fetch (FILEBUCKET FILENAME) of (fetch TIDATA of ITEM])
)
(DEFINEQ

(FB.DELETECOMMAND
  [LAMBDA (BROWSER)                                          (* bvm: "12-Sep-85 15:44")
    (TB.MAP.SELECTED.ITEMS (fetch (FILEBROWSER TABLEBROWSER) of BROWSER)
			   (FUNCTION FB.DELETE.FILE))
    (FB.UPDATE.COUNTERS BROWSER])

(FB.DELVERCOMMAND
  [LAMBDA (FBROWSER)                                         (* bvm: "18-Sep-85 12:15")
    (LET ((NVERSIONS (FB.PROMPTFORINPUT "Number of versions to keep: " "1" FBROWSER T))
	  TBROWSER NDELETED FILES)
         (COND
	   ((NOT NVERSIONS)
	     NIL)
	   ([NOT (FIXP (SETQ NVERSIONS (MKATOM NVERSIONS]
	     (FB.PROMPTWPRINT FBROWSER T "?? " NVERSIONS " not an integer."))
	   (T [SETQ FILES (TB.COLLECT.ITEMS (SETQ TBROWSER (fetch (FILEBROWSER TABLEBROWSER)
							      of FBROWSER))
					    (FUNCTION (LAMBDA (BROWSER ITEM)
						(NOT (fetch TIUNSELECTABLE of ITEM]
	      (SETQ NDELETED (FB.DELVER.FILES TBROWSER (SELECTQ (fetch (FILEBROWSER SORTBY)
								   of FBROWSER)
								(FB.NAMES.DECREASING.VERSION 
                                                             (* Just right)
											     FILES)
								(FB.NAMES.INCREASING.VERSION
                                                             (* Close, but no cigar)
								  (FB.SORT.VERSIONS
								    FILES
								    (FUNCTION FB.DECREASING.VERSION)))
								(SORT FILES (FUNCTION 
								      FB.NAMES.DECREASING.VERSION)))
					      NVERSIONS))
	      (FB.UPDATE.COUNTERS FBROWSER (QUOTE DELETED))
	      (FB.PROMPTWPRINT FBROWSER T "Done, " NDELETED " files marked for deletion."])

(FB.DELVER.FILES
  [LAMBDA (TBROWSER FILES NVERSIONS)                         (* bvm: "27-Sep-85 13:08")
    (for FILE in FILES
       bind (#DELETED ← 0)
	    (#SEENSOFAR ← 0)
	    THISNAME LASTNAME LASTSUBDIR
       do                                                    (* Files now all lined up, decreasing version.
							     Just pass by NVERSIONS of each file)
	  (COND
	    [(AND (STRING-EQUAL (SETQ THISNAME (fetch (FILEBUCKET PRINTNAME)
						  of (fetch TIDATA of FILE)))
				LASTNAME)
		  (STRING-EQUAL (fetch (FILEBUCKET SUBDIRECTORY) of (fetch TIDATA of FILE))
				LASTSUBDIR))
	      (COND
		((GREATERP (add #SEENSOFAR 1)
			   NVERSIONS)
		  (COND
		    ((FB.DELETE.FILE TBROWSER FILE)
		      (add #DELETED 1]
	    (T (SETQ LASTNAME THISNAME)
	       (SETQ LASTSUBDIR (fetch (FILEBUCKET SUBDIRECTORY) of (fetch TIDATA of FILE)))
	       (SETQ #SEENSOFAR 1)))
       finally (RETURN #DELETED])

(FB.DELETE.FILE
  [LAMBDA (TBROWSER ITEM)                                    (* bvm: "18-Sep-85 12:06")
    (COND
      ((NOT (fetch TIDELETED of ITEM))
	(LET ((FBROWSER (TB.USERDATA TBROWSER))
	      SIZE)
	     (TB.DELETE.ITEM TBROWSER ITEM)
	     (add (fetch (FILEBROWSER DELETEDFILES) of FBROWSER)
		  1)
	     (COND
	       ((SETQ SIZE (fetch (FILEBUCKET SIZE) of (fetch TIDATA of ITEM)))
		 (add (fetch (FILEBROWSER DELETEDPAGES) of FBROWSER)
		      SIZE)))
	 T])

(FB.UNDELETE.FILE
  [LAMBDA (TBROWSER ITEM)                                    (* bvm: "10-Sep-85 15:40")
    (COND
      ((fetch TIDELETED of ITEM)
	(LET ((FBROWSER (TB.USERDATA TBROWSER))
	      SIZE)
	     (TB.UNDELETE.ITEM TBROWSER ITEM)
	     (add (fetch (FILEBROWSER DELETEDFILES) of FBROWSER)
		  -1)
	     (COND
	       ((SETQ SIZE (fetch (FILEBUCKET SIZE) of (fetch TIDATA of ITEM)))
		 (add (fetch (FILEBROWSER DELETEDPAGES) of FBROWSER)
		      (IMINUS SIZE])

(FB.UNDELETECOMMAND
  [LAMBDA (BROWSER)                                          (* bvm: "12-Sep-85 15:44")
    (TB.MAP.SELECTED.ITEMS (fetch (FILEBROWSER TABLEBROWSER) of BROWSER)
			   (FUNCTION FB.UNDELETE.FILE))
    (FB.UPDATE.COUNTERS BROWSER])

(FB.UNDELETEALLCOMMAND
  [LAMBDA (BROWSER)                                          (* bvm: "18-Sep-85 12:20")
    (TB.MAP.ITEMS (fetch (FILEBROWSER TABLEBROWSER) of BROWSER)
		  (FUNCTION FB.UNDELETE.FILE))
    (FB.UPDATE.COUNTERS BROWSER])

(FB.HARDCOPYCOMMAND
  [LAMBDA (BROWSER KEY)                                      (* bvm: "12-Sep-85 18:03")
    (APPLY (FUNCTION LISTFILES)
	   (for ITEM in (FB.SELECTEDFILES BROWSER) collect (FB.FETCHFILENAME ITEM])

(FB.LOADCOMMAND
  [LAMBDA (BROWSER KEY ITEM MENU LOADOP)                     (* bvm: "18-Sep-85 17:16")
    (LET ((FILES (FB.SELECTEDFILES BROWSER)))
         (AND FILES (ADD.PROCESS (LIST (FUNCTION FB.OPERATE.ON.FILES)
				       (KWOTE (OR LOADOP (FUNCTION LOAD)))
				       (KWOTE FILES))
				 (QUOTE NAME)
				 (QUOTE LOAD)
				 (QUOTE BEFOREEXIT)
				 (QUOTE DON'T])

(FB.EDITCOMMAND
  [LAMBDA (BROWSER KEY ITEM MENU OPTION)                     (* bvm: "18-Sep-85 22:11")
    (for FILE in (FB.SELECTEDFILES BROWSER)
       do
	(COND
	  ((AND (NOT (FILENAMEFIELD (SETQ FILE (FB.FETCHFILENAME FILE))
				    (QUOTE NAME)))
		(NOT (FILENAMEFIELD FILE (QUOTE EXTENSION)))
		(DIRECTORYNAMEP FILE))                       (* Item is a directory, so open a sub filebrowser on 
							     it)
	    (FILEBROWSER (PACKFILENAME.STRING (QUOTE VERSION)
					      NIL
					      (QUOTE NAME)
					      (QUOTE *)
					      (QUOTE EXTENSION)
					      (QUOTE *)
					      (QUOTE BODY)
					      FILE)
			 (fetch INFODISPLAYED of BROWSER)))
	  (T
	    (SELECTQ
	      OPTION
	      [READONLY                                      (* From SEE command)
		(COND
		  ((NOT (GETD (QUOTE OPENTEXTSTREAM)))
		    (FB.FASTSEECOMMAND BROWSER KEY ITEM MENU))
		  (T (RESETLST (LET ((WINDOW (CREATEW NIL FILE))
				     (STR (OPENSTREAM FILE (QUOTE INPUT)))
				     SRC)
				    [COND
				      ((LISPSOURCEFILEP STR)
					(RESETSAVE NIL (LIST (QUOTE CLOSEF)
							     STR))
					(SETQ STR (LET ((NSTR (OPENTEXTSTREAM)))
						       (COPY.TEXT.TO.IMAGE STR NSTR)
						   NSTR)))
				      ((NOT (RANDACCESSP STR))
					(RESETSAVE NIL (LIST (QUOTE CLOSEF)
							     STR))
					(SETQ STR
					  (LET [(NSTR (OPENSTREAM (QUOTE {NODIRCORE})
								  (QUOTE BOTH)
								  (QUOTE NEW)
								  NIL
								  (LIST (LIST (QUOTE TYPE)
									      (GETFILEINFO
										STR
										(QUOTE TYPE]
					       (COPYBYTES STR NSTR)
					   NSTR]
				    (OPENTEXTSTREAM STR WINDOW NIL NIL (QUOTE (READONLY T]
	      (TEDIT (TEDIT (MKATOM FILE)))
	      (DEDIT (FB.EDITLISPFILE FILE BROWSER))
	      (COND
		((LISPSOURCEFILEP FILE)
		  (FB.EDITLISPFILE FILE BROWSER))
		(T (TEDIT (MKATOM FILE])

(FB.EDITLISPFILE
  [LAMBDA (FILE BROWSER)                                     (* bvm: "12-Sep-85 18:05")
    (PROG (ROOT)
          [COND
	    ((NOT (STREQUAL (CDAR (GETPROP (SETQ ROOT (U-CASE (ROOTFILENAME FILE)))
					   (QUOTE FILEDATES)))
			    FILE))
	      (COND
		[(MOUSECONFIRM (CONCAT "The file " FILE 
				       " is not loaded or is not current. (LOADFROM '"
				       FILE ")?")
			       NIL
			       (fetch (FILEBROWSER PROMPTWINDOW) of BROWSER))
		  (LISPXEVAL (BQUOTE (LOADFROM , (KWOTE (MKATOM FILE]
		(T (RETURN]
          (LISPXEVAL (BQUOTE (EDITDEF (QUOTE , ROOT)
				      (QUOTE FILES])

(FB.COMPILECOMMAND
  [LAMBDA (BROWSER KEY ITEM MENU COMPILEOP)                  (* bvm: "18-Sep-85 17:16")
    (LET ((FILES (FB.SELECTEDFILES BROWSER)))
         (AND FILES (ADD.PROCESS (LIST (FUNCTION FB.OPERATE.ON.FILES)
				       (KWOTE (OR COMPILEOP (FUNCTION BCOMPL)))
				       (KWOTE FILES))
				 (QUOTE NAME)
				 (QUOTE COMPILE)
				 (QUOTE BEFOREEXIT)
				 (QUOTE DON'T])

(FB.OPERATE.ON.FILES
  [LAMBDA (FN FILELIST)                                      (* bvm: "25-Jul-85 12:05")
    (LET (LDFLG)
         (SELECTQ FN
		  ((PROP SYSLOAD)
		    (SETQ LDFLG FN)
		    (SETQ FN (QUOTE LOAD)))
		  NIL)
         [LISPXEVAL (CONS (QUOTE PROGN)
			  (for FILEENTRY in FILELIST collect
						      (CONS FN (CONS (KWOTE (MKATOM (FB.FETCHFILENAME
										      FILEENTRY)))
								     (AND LDFLG (LIST (KWOTE LDFLG]
         (CLOSEW (TTYDISPLAYSTREAM])

(FB.COPYCOMMAND
  [LAMBDA (BROWSER)                                          (* bvm: "12-Sep-85 15:48")
    (FB.COPY/RENAME.COMMAND BROWSER (QUOTE Copy)
			    (FUNCTION COPYFILE])

(FB.RENAMECOMMAND
  [LAMBDA (BROWSER)                                          (* bvm: "12-Sep-85 15:48")
    (FB.COPY/RENAME.COMMAND BROWSER (QUOTE Rename)
			    (FUNCTION RENAMEFILE])

(FB.COPY/RENAME.COMMAND
  [LAMBDA (FBROWSER CMD MOVEFN)                              (* bvm: "27-Sep-85 13:06")
    (LET ((FILELIST (FB.SELECTEDFILES FBROWSER)))
         (COND
	   ((NULL FILELIST))
	   ((CDR FILELIST)
	     (FB.COPY/RENAME.MANY FBROWSER FILELIST CMD MOVEFN))
	   (T                                                (* Just one file)
	      (LET* ((OLDNAME (FB.FETCHFILENAME (CAR FILELIST)))
		     (NEWNAME (FB.GET.NEW.FILE.SPEC OLDNAME FBROWSER CMD)))
		    (COND
		      (NEWNAME (FB.COPY/RENAME.ONE FBROWSER (CAR FILELIST)
						   OLDNAME NEWNAME CMD MOVEFN])

(FB.COPY/RENAME.ONE
  [LAMBDA (FBROWSER ITEM OLDNAME NEWNAME CMD MOVEFN)         (* bvm: "27-Sep-85 12:42")

          (* * Copies or renames a single file ITEM from OLDNAME to NEWNAME and updates browser accordingly)


    (LET (ACTUALNEWNAME CHANGETYPE)
         (COND
	   [(SETQ ACTUALNEWNAME (APPLY* MOVEFN OLDNAME NEWNAME))
	     (FB.PROMPTWPRINT FBROWSER T OLDNAME (SELECTQ CMD
							  (Copy " copied to ")
							  (Rename " renamed to ")
							  (SHOULDNT))
			      ACTUALNEWNAME)
	     [COND
	       ((EQ CMD (QUOTE Rename))
		 (FB.REMOVE.FILE (fetch (FILEBROWSER TABLEBROWSER) of FBROWSER)
				 FBROWSER ITEM)
		 (SETQ CHANGETYPE (COND
		     ((fetch TIDELETED of ITEM)
		       (QUOTE BOTH))
		     (T (QUOTE TOTAL]                        (* And then we need to see if ACTUALNEWNAME belongs in 
							     this or some other browser)
	     [COND
	       ((FB.MAYBE.INSERT.FILE FBROWSER ACTUALNEWNAME ITEM CMD)
		 (OR CHANGETYPE (SETQ CHANGETYPE (QUOTE TOTAL]
	     (COND
	       (CHANGETYPE (FB.UPDATE.COUNTERS FBROWSER CHANGETYPE]
	   (T (FB.PROMPTWPRINT FBROWSER T "Could not " (L-CASE CMD)
			       OLDNAME " to " ACTUALNEWNAME])

(FB.COPY/RENAME.MANY
  [LAMBDA (FBROWSER FILELIST CMD MOVEFN)                     (* bvm: "28-Sep-85 22:50")
    (PROG (PREFIX OLDNAME FIELDS)
          (COND
	    ((NULL (SETQ PREFIX (FB.PROMPTFORINPUT (CONCAT CMD " " (LENGTH FILELIST)
							   " files to which directory? ")
						   (DIRECTORYNAME T)
						   FBROWSER T)))
                                                             (* Aborted)
	      )
	    ((STRPOS "*" PREFIX)
	      (FB.PROMPTWPRINT FBROWSER "Sorry, patterns not supported"))
	    ([AND (OR (LISTGET (SETQ FIELDS (UNPACKFILENAME.STRING PREFIX))
			       (QUOTE HOST))
		      (LISTGET FIELDS (QUOTE DIRECTORY))
		      (LISTGET FIELDS (QUOTE DEVICE)))
		  (OR (LISTGET FIELDS (QUOTE NAME))
		      (LISTGET FIELDS (QUOTE EXTENSION))
		      (LISTGET FIELDS (QUOTE VERSION]        (* Not a pure directory specification, and not just a 
							     simple directory name)
	      (FB.PROMPTWPRINT FBROWSER "Not a well-formed directory specification."))
	    (T                                               (* Now make sure the files are sorted by increasing 
							     version, so that multiple versions get copied in the 
							     right order)
	       (SELECTQ (fetch (FILEBROWSER SORTBY) of FBROWSER)
			(FB.NAMES.INCREASING.VERSION         (* Okay))
			[FB.NAMES.DECREASING.VERSION (SETQ FILELIST (FB.SORT.VERSIONS
							 FILELIST
							 (FUNCTION FB.INCREASING.VERSION]
			(SORT FILELIST (FUNCTION FB.NAMES.INCREASING.VERSION)))
	       (SETQ PREFIX (\ADD.CONNECTED.DIR PREFIX))
	       (for ITEM in FILELIST do (FB.COPY/RENAME.ONE FBROWSER ITEM (SETQ OLDNAME (
								FB.FETCHFILENAME ITEM))
							    (PACKFILENAME.STRING (QUOTE DIRECTORY)
										 PREFIX
										 (QUOTE VERSION)
										 NIL
										 (QUOTE BODY)
										 OLDNAME)
							    CMD MOVEFN])

(FB.MAYBE.INSERT.FILE
  [LAMBDA (FBROWSER NEWNAME OLDITEM CMD)                     (* bvm: "19-Sep-85 16:30")

          (* * If NEWNAME matches the pattern of files displayed in FBROWSER, insert it in that browser and return T.
	  OLDITEM is the tableitem that formed the source of NEWNAME. CMD is the command that created NEWNAME -- Copy or 
	  Rename)


    (LET (FILEINFO N FULLNAME CRDATE CRDATE2 ITEMDATA VERSION NEWITEM)
         (COND
	   ((AND (DIRECTORY.MATCH (fetch (FILEBROWSER PREPAREDPATTERN) of FBROWSER)
				  NEWNAME)
		 (STRING-EQUAL [SUBSTRING NEWNAME 1 (SETQ N (SUB1 (fetch (FILEBROWSER DIRECTORYSTART)
								     of FBROWSER]
			       (SUBSTRING (fetch (FILEBROWSER PATTERN) of FBROWSER)
					  1 N)))             (* NEWNAME belongs in this browser, so add it)
	     (for TAIL on (SETQ FILEINFO (fetch (FILEBUCKET FILEINFO) of (fetch TIDATA of OLDITEM)))
		by (CDDR TAIL) do (SELECTQ (CAR TAIL)
					   ((WRITEDATE READDATE)
                                                             (* Copy or Rename does not preserve these fields)
					     (RPLACA (CDR TAIL)
						     NIL))
					   [AUTHOR (COND
						     ((NEQ CMD (QUOTE Rename))
                                                             (* On Copy, author changes to current user.
							     Don't try to guess)
						       (RPLACA (CDR TAIL)
							       NIL]
					   NIL))
	     (SETQ NEWITEM (FB.CREATE.FILEBUCKET FBROWSER NEWNAME FILEINFO))
	     (COND
	       ([AND [NULL (fetch (FILEBUCKET VERSION) of (SETQ ITEMDATA (fetch TIDATA of NEWITEM]
		     (SETQ FULLNAME (INFILEP NEWNAME))
		     (OR [NULL (SETQ CRDATE (LISTGET FILEINFO (QUOTE CREATIONDATE]
			 (AND (SETQ CRDATE (IDATE CRDATE))
			      (SETQ CRDATE2 (GETFILEINFO FULLNAME (QUOTE ICREATIONDATE)))
			      (IEQP CRDATE2 CRDATE]

          (* Grumble. IFS version of Rename does not return a full file name, due to shortcoming in ftp protocol.
	  Have to assume that it's the newest version. If creation date of old file is available, verify that they agree)


		 (SETQ NEWITEM (FB.CREATE.FILEBUCKET FBROWSER [SETQ NEWNAME
						       (PACKFILENAME.STRING (QUOTE BODY)
									    NEWNAME
									    (QUOTE EXTENSION)
									    ""
									    (QUOTE VERSION)
									    (FILENAMEFIELD
									      FULLNAME
									      (QUOTE VERSION]
						     FILEINFO))
                                                             (* Canonicalize NEWNAME -- some cases where final 
							     period was left out)
		 ))
	     (COND
	       ((AND (EQ CMD (QUOTE Rename))
		     (fetch TISELECTED of OLDITEM))          (* If old item was selected, keep the renamed version 
							     selected as well)
		 (replace TISELECTED of NEWITEM with T)))
	     (FB.INSERT.FILE FBROWSER NEWITEM)
	     T])

(FB.GET.NEW.FILE.SPEC
  [LAMBDA (OLDNAME BROWSER CMD)                              (* bvm: "27-Sep-85 14:12")

          (* For Copy and Rename commands, derives a new name to copy/rename to from OLDNAME. PREFIX if given is a DIRECTORY 
	  spec; if not given, we prompt for a destination file. Returns NIL if user aborts)


    (LET (NEWNAME NAMEFIELD)
         (COND
	   ((NULL (SETQ NEWNAME (FB.PROMPTFORINPUT (CONCAT CMD " file " OLDNAME (SELECTQ
							     CMD
							     (Rename " to be: ")
							     (Copy " to new file name: ")
							     (SHOULDNT)))
						   (PACKFILENAME.STRING (QUOTE DIRECTORY)
									(DIRECTORYNAME T)
									(QUOTE VERSION)
									NIL
									(QUOTE BODY)
									OLDNAME)
						   BROWSER T)))
                                                             (* Aborted)
	     )
	   ([NULL (SETQ NAMEFIELD (LISTGET (UNPACKFILENAME.STRING NEWNAME)
					   (QUOTE NAME]      (* Assume directory spec)
	     (SETQ NEWNAME (PACKFILENAME.STRING (QUOTE DIRECTORY)
						NEWNAME
						(QUOTE VERSION)
						NIL
						(QUOTE BODY)
						OLDNAME)))
	   ((EQ (NCHARS NAMEFIELD)
		0)                                           (* Directory spec with some more pieces after it?)
	     (FB.PROMPTWPRINT BROWSER "Failed, malformed name")
	     (SETQ NEWNAME NIL)))
         (COND
	   (NEWNAME (\ADD.CONNECTED.DIR NEWNAME])
)
(DEFINEQ

(FB.UPDATECOMMAND
  [LAMBDA (BROWSER)                                          (* bvm: "27-Sep-85 12:30")
    (COND
      ((FB.MAYBE.EXPUNGE BROWSER (QUOTE Recompute))
	(FB.UPDATEBROWSERITEMS BROWSER])

(FB.MAYBE.EXPUNGE
  [LAMBDA (BROWSER COMMAND)                                  (* bvm: "27-Sep-85 12:30")

          (* * If BROWSER has files marked for deletion, ask whether user wants to expunge them. Returns T if it is okay to 
	  proceed, NIL if not (user aborted or expunge failed))


    (COND
      ((EQ (fetch (FILEBROWSER DELETEDFILES) of BROWSER)
	   0)
	T)
      (T (FB.PROMPTWPRINT BROWSER 
			 "Some files are marked for deletion.
Do you want to expunge them first?")
	 (SELECTQ (MENU (FB.EXPUNGE?.MENU))
		  (EXPUNGE                                   (* Do expunge in another process, not here in mouse)
			   (FB.EXPUNGECOMMAND BROWSER NIL NIL NIL COMMAND))
		  (NOEXPUNGE T)
		  NIL])

(FB.UPDATEBROWSERITEMS
  [LAMBDA (BROWSER)                                          (* bvm: "27-Sep-85 14:55")
    (RESETLST (PROG ((WINDOW (fetch (FILEBROWSER BROWSERWINDOW) of BROWSER))
		     (TBROWSER (fetch (FILEBROWSER TABLEBROWSER) of BROWSER))
		     (TITLEWINDOW (fetch (FILEBROWSER COUNTERWINDOW) of BROWSER))
		     PATTERN INFOWANTED FILEGENERATOR FILENAME)
		    (OR (SETQ PATTERN (fetch PATTERN of BROWSER))
			(RETURN))
		    (RESETSAVE NIL (LIST (FUNCTION FB.CLEANUP.UPDATE)
					 BROWSER))
		    (replace (FILEBROWSER UPDATEPROC) of BROWSER with (THIS.PROCESS))
                                                             (* So that CLOSE can abort it)
		    (WINDOWADDPROP WINDOW (QUOTE CLOSEFN)
				   (FUNCTION FB.ABORT.UPDATE)
				   T)
		    (FB.PROMPTWPRINT BROWSER T "Enumerating " PATTERN (QUOTE ...))
		    (replace (FILEBROWSER INFODISPLAYED) of BROWSER with (SETQ INFOWANTED
									   (fetch (FILEBROWSER 
										  INFOMENUCHOICES)
									      of BROWSER)))
		    (WINDOWPROP TITLEWINDOW (QUOTE TITLE)
				(CONCAT PATTERN " browser"))
		    (CLEARW TITLEWINDOW)
		    (TB.REPLACE.ITEMS TBROWSER NIL)
		    (replace (FILEBROWSER INFOSTART) of BROWSER
		       with (IPLUS [replace (FILEBROWSER NAMEOVERHEAD) of BROWSER
				      with (IPLUS (DSPLEFTMARGIN NIL WINDOW)
						  (CHARWIDTH (CHARCODE SPACE)
							     (fetch (FILEBROWSER BROWSERFONT)
								of BROWSER]
				   FB.DEFAULT.NAME.WIDTH))
		    [replace (FILEBROWSER PAGECOUNT?) of BROWSER
		       with (CAR (OR (MEMB (QUOTE SIZE)
					   INFOWANTED)
				     (MEMB (QUOTE LENGTH)
					   INFOWANTED]
		    [replace (FILEBROWSER DELETEDFILES) of BROWSER
		       with (replace (FILEBROWSER DELETEDPAGES) of BROWSER
			       with (replace (FILEBROWSER TOTALPAGES) of BROWSER
				       with (replace (FILEBROWSER TOTALFILES) of BROWSER
					       with 0]
		    (replace (FILEBROWSER PATTERNPARSED?) of BROWSER with (replace (FILEBROWSER
										     OVERFLOWWIDTHS)
									     of BROWSER with NIL))
		    [SETQ FILEGENERATOR (\GENERATEFILES PATTERN INFOWANTED (QUOTE (SORT RESETLST]
		    (FB.HEADINGW.DISPLAY BROWSER (fetch HEADINGWINDOW of BROWSER))
		    (while (SETQ FILENAME (\GENERATENEXTFILE FILEGENERATOR))
		       bind PREVSUBDIR LASTFILE LASTFILENAME LASTSUBDIR OTHERFILES NEWFILEITEM 
			    NEWFILEDATA
		       do [COND
			    ((LISTP FILENAME)
			      (SETQ FILENAME (CONCATCODES FILENAME]
			  [SETQ NEWFILEDATA (fetch TIDATA of (SETQ NEWFILEITEM
							       (FB.CREATE.FILEBUCKET BROWSER FILENAME
										     (
FB.GETALLFILEINFO FILENAME FILEGENERATOR INFOWANTED]
			  [COND
			    ((AND LASTFILE (STRING-EQUAL (fetch (FILEBUCKET PRINTNAME) of NEWFILEDATA)
							 LASTFILENAME)
				  (STRING-EQUAL (fetch (FILEBUCKET SUBDIRECTORY) of NEWFILEDATA)
						LASTSUBDIR))
                                                             (* This file same name as previous one, so save it in 
							     case we need to sort versions)
                                                             (* Last clause is in case you have to identically named
							     files in a row but in different subdirectories)
			      (push OTHERFILES NEWFILEITEM))
			    (T (COND
				 (LASTFILE (FB.ADD.FILEGROUP TBROWSER BROWSER LASTFILE OTHERFILES 
							     PREVSUBDIR)))
			       (SETQ OTHERFILES NIL)
			       (SETQ PREVSUBDIR LASTSUBDIR)
			       (SETQ LASTFILE NEWFILEITEM)
			       (SETQ LASTFILENAME (fetch (FILEBUCKET PRINTNAME) of NEWFILEDATA))
			       (SETQ LASTSUBDIR (fetch (FILEBUCKET SUBDIRECTORY) of NEWFILEDATA]
		       finally (AND LASTFILE (FB.ADD.FILEGROUP TBROWSER BROWSER LASTFILE OTHERFILES 
							       PREVSUBDIR)))
		    (COND
		      ((EQ (TB.NUMBER.OF.ITEMS TBROWSER)
			   0)
			(FB.PROMPTWPRINT BROWSER (QUOTE CLEAR)
					 "No files in group " PATTERN))
		      (T (FB.PROMPTWPRINT BROWSER (QUOTE done))
			 (FB.MAYBE.WIDEN.NAMES BROWSER)))
		    (FB.UPDATE.HEADING.EXTENT BROWSER WINDOW)
		    (FB.DISPLAY.COUNTERS BROWSER])

(FB.CLEANUP.UPDATE
  [LAMBDA (BROWSER)                                          (* bvm: "27-Sep-85 14:55")

          (* * Cleans up after an Update, whether aborted or not)


    (LET ((WINDOW (fetch (FILEBROWSER BROWSERWINDOW) of BROWSER)))
         (WINDOWDELPROP WINDOW (QUOTE CLOSEFN)
			(FUNCTION FB.ABORT.UPDATE))
         (replace (FILEBROWSER UPDATEPROC) of BROWSER with NIL)
         (COND
	   (RESETSTATE (FB.PROMPTWPRINT BROWSER " aborted."])

(FB.ABORT.UPDATE
  [LAMBDA (WINDOW)                                           (* bvm: "27-Sep-85 15:10")

          (* * CLOSEFN on browser window during Update -- aborts it.)


    (LET ((BROWSER (WINDOWPROP WINDOW (QUOTE FILEBROWSER)))
	  PROCESS)
         (COND
	   ((AND BROWSER (SETQ PROCESS (fetch (FILEBROWSER UPDATEPROC) of BROWSER)))
	     (DEL.PROCESS PROCESS)
	     (ALLOW.BUTTON.EVENTS)
	     (while (PROCESSP PROCESS) do (BLOCK))           (* Wait for process to die -- should be 
							     (PROCESS.RESULT PROCESS T) but that has a bug)
	     NIL])

(FB.MAYBE.WIDEN.NAMES
  [LAMBDA (BROWSER)                                          (* bvm: "19-Sep-85 14:39")

          (* * Examines the OVERFLOWWIDTHS field to see if we should widen the name area of the browser, shoving everything 
	  else to the right)


    (LET ((OVERFLOW (fetch (FILEBROWSER OVERFLOWWIDTHS) of BROWSER))
	  THRESHOLD)
         (COND
	   (OVERFLOW                                         (* See if enough files were too wide for print spec)
		     (SETQ THRESHOLD (IMIN (IMAX (FIXR (FTIMES (fetch (FILEBROWSER TOTALFILES)
								  of BROWSER)
							       FB.OVERFLOW.MAXFRAC))
						 1)
					   FB.OVERFLOW.MAXABSOLUTE))
		     (for PAIR in OVERFLOW when (LESSP (SETQ THRESHOLD (IDIFFERENCE THRESHOLD
										    (CADR PAIR)))
						       0)
			do                                   (* Stop here! Any further than this and we would have 
							     more than the max files overflowing)
			   (replace (FILEBROWSER INFOSTART) of BROWSER with (CAR PAIR))
			   (FB.HEADINGW.DISPLAY BROWSER (fetch HEADINGWINDOW of BROWSER))
			   (TB.REDISPLAY.ITEMS (fetch (FILEBROWSER TABLEBROWSER) of BROWSER))
			   (RETURN])

(FB.CREATE.FILEBUCKET
  [LAMBDA (BROWSER FILENAME FILEINFO)                        (* bvm: "18-Sep-85 12:31")
    (COND
      ((NULL (fetch (FILEBROWSER PATTERNPARSED?) of BROWSER))
	(FB.ANALYZE.PATTERN BROWSER FILENAME)))
    (LET ((STARTOFNAME (fetch (FILEBROWSER NAMESTART) of BROWSER))
	  (LASTCHAR (NCHARS FILENAME))
	  LASTDIR SUBDIR VERSION CH PRINTLENGTH)
         [while (DIGITCHARP (SETQ CH (NTHCHARCODE FILENAME LASTCHAR))) do (SETQ LASTCHAR
									    (SUB1 LASTCHAR))
	    finally                                          (* not a version char)
		    (COND
		      ((OR (EQ CH (CHARCODE ;))
			   (EQ CH (CHARCODE %.)))            (* Pull off the version from the end, so that we can 
							     sort with it, etc)
			(SETQ VERSION (SUBATOM FILENAME (ADD1 LASTCHAR)))
			(SETQ LASTCHAR (SUB1 LASTCHAR)))
		      (T (SETQ LASTCHAR NIL]
         (for (N ← STARTOFNAME) do (SELCHARQ (NTHCHARCODE FILENAME (add N 1))
					     (> (SETQ LASTDIR N))
					     (NIL (RETURN))
					     NIL))
         [COND
	   (LASTDIR (SETQ STARTOFNAME (ADD1 LASTDIR))
		    (OR (fetch (FILEBROWSER NOSUBDIRECTORIES) of BROWSER)
			(SETQ SUBDIR (SUBSTRING FILENAME 1 LASTDIR]
         (SETQ PRINTLENGTH (IPLUS (STRINGWIDTH (SUBSTRING FILENAME STARTOFNAME)
					       (fetch (FILEBROWSER BROWSERFONT) of BROWSER))
				  (fetch (FILEBROWSER NAMEOVERHEAD) of BROWSER)))
         [COND
	   ((GEQ PRINTLENGTH (fetch (FILEBROWSER INFOSTART) of BROWSER))

          (* Name is longer than allotted space in browser. Shall we allot more space? Don't know until we're thru.
	  For now, record a list of elements (width occurrences), where each name is recorded in the closest entry)


	     (LET ((OVERFLOW (fetch (FILEBROWSER OVERFLOWWIDTHS) of BROWSER))
		   (SPACING (fetch (FILEBROWSER OVERFLOWSPACING) of BROWSER)))
	          (COND
		    ((OR (NULL OVERFLOW)
			 (GREATERP PRINTLENGTH (CAAR OVERFLOW)))
		      (replace (FILEBROWSER OVERFLOWWIDTHS) of BROWSER
			 with (CONS (LIST PRINTLENGTH 1)
				    OVERFLOW)))
		    (T (for (TAIL ← OVERFLOW) bind PREVTAIL
			  when [OR [NULL (SETQ TAIL (CDR (SETQ PREVTAIL TAIL]
				   (GREATERP PRINTLENGTH (CAR (CAR TAIL]
			  do                                 (* Longer than some previously recorded length, so 
							     either add a new entry or bump the preceding one)
			     (COND
			       ((ILESSP PRINTLENGTH (IDIFFERENCE (CAR (CAR PREVTAIL))
								 SPACING))
				 (RPLACD PREVTAIL (CONS (LIST PRINTLENGTH 1)
							TAIL)))
			       (T (add (CADR (CAR PREVTAIL))
				       1)))
			     (RETURN]
         (create TABLEITEM
		 TIDATA ←(create FILEBUCKET
				 FILENAME ← FILENAME
				 FILEINFO ← FILEINFO
				 PRINTNAME ←(SUBSTRING FILENAME STARTOFNAME LASTCHAR)
				 VERSION ← VERSION
				 VERSIONLESSNAME ←(COND
				   (LASTCHAR (SUBSTRING FILENAME 1 LASTCHAR))
				   (T FILENAME))
				 SIZE ←(SELECTQ (fetch (FILEBROWSER PAGECOUNT?) of BROWSER)
						(SIZE (LISTGET FILEINFO (QUOTE SIZE)))
						(LENGTH (AND (SETQ LASTCHAR (LISTGET FILEINFO
										     (QUOTE LENGTH)))
							     (FOLDHI LASTCHAR BYTESPERPAGE)))
						NIL)
				 SUBDIRECTORY ← SUBDIR])

(FB.ADD.FILEGROUP
  [LAMBDA (TBROWSER FBROWSER LASTFILE OTHERFILES LASTSUBDIR)
                                                             (* bvm: "18-Sep-85 10:33")
    (LET (THISSUBDIR)
         (COND
	   ((AND (NOT (fetch (FILEBROWSER NOSUBDIRECTORIES) of FBROWSER))
		 (NEQ (SETQ THISSUBDIR (fetch (FILEBUCKET SUBDIRECTORY) of (fetch TIDATA
									      of LASTFILE)))
		      LASTSUBDIR)
		 (NOT (STRING-EQUAL THISSUBDIR LASTSUBDIR)))
                                                             (* Subsequent files have a different subdirectory, so 
							     insert a non-selectable line item here)
	     (FB.INSERT.DIRECTORY TBROWSER FBROWSER THISSUBDIR)))
         (COND
	   (OTHERFILES (for ITEM in (SORT (CONS LASTFILE OTHERFILES)
					  (FUNCTION FB.DECREASING.VERSION))
			  do (FB.ADD.FILE TBROWSER FBROWSER ITEM)))
	   (T (FB.ADD.FILE TBROWSER FBROWSER LASTFILE])

(FB.INSERT.DIRECTORY
  [LAMBDA (TBROWSER FBROWSER SUBDIRECTORY BEFOREITEM)        (* bvm: "18-Sep-85 12:32")
    (TB.INSERT.ITEM TBROWSER (create TABLEITEM
				     TIUNSELECTABLE ← T
				     TIDATA ←(create FILEBUCKET
						     FILENAME ←[OR
						       SUBDIRECTORY
						       (SETQ SUBDIRECTORY
							 (SUBSTRING (fetch (FILEBROWSER PATTERN)
								       of FBROWSER)
								    1
								    (SUB1 (fetch (FILEBROWSER 
											NAMESTART)
									     of FBROWSER]
						     PRINTNAME ←(SUBSTRING SUBDIRECTORY
									   (fetch (FILEBROWSER 
										   DIRECTORYSTART)
									      of FBROWSER))
						     VERSIONLESSNAME ← SUBDIRECTORY
						     DIRECTORYP ← T))
		    BEFOREITEM])

(FB.ADD.FILE
  [LAMBDA (TBROWSER FBROWSER ITEM BEFOREITEM)                (* bvm: "10-Sep-85 15:31")

          (* * Inserts one file in TBROWSER / FBROWSER before item BEFOREITEM or at end if BEFOREITEM is NIL)


    (LET [(SIZE (fetch (FILEBUCKET SIZE) of (fetch TIDATA of ITEM]
         (COND
	   (SIZE (add (fetch (FILEBROWSER TOTALPAGES) of FBROWSER)
		      SIZE)))
         (add (fetch (FILEBROWSER TOTALFILES) of FBROWSER)
	      1)
         (TB.INSERT.ITEM TBROWSER ITEM BEFOREITEM])

(FB.INSERT.FILE
  [LAMBDA (BROWSER FILE)                                     (* bvm: "19-Sep-85 16:42")
    (LET ((TBROWSER (fetch (FILEBROWSER TABLEBROWSER) of BROWSER))
	  (FBSORTFN (fetch (FILEBROWSER SORTBY) of BROWSER))
	  (MYSUBDIR (fetch (FILEBUCKET SUBDIRECTORY) of (fetch TIDATA of FILE)))
	  (NOSUBDIRS (fetch (FILEBROWSER NOSUBDIRECTORIES) of BROWSER))
	  OTHERDIR NEXTITEM PREVITEM N)
         [SETQ NEXTITEM (TB.FIND.ITEM TBROWSER (FUNCTION (LAMBDA (BROWSER ITEM)
					  (AND (NOT (fetch TIUNSELECTABLE of ITEM))
					       (APPLY* FBSORTFN FILE ITEM]
         (COND
	   ((AND NEXTITEM (NOT NOSUBDIRS)
		 (NEQ (SETQ N (fetch TI# of NEXTITEM))
		      1)
		 [fetch TIUNSELECTABLE of (SETQ PREVITEM (TB.NTH.ITEM TBROWSER (SUB1 N]
		 (NOT (STRING-EQUAL (fetch (FILEBUCKET SUBDIRECTORY) of (fetch TIDATA of NEXTITEM))
				    MYSUBDIR)))

          (* * We sort before NEXTITEM, but it's preceded by a subdirectory line that isn't ours, so insert in front of the 
	  subdirectory)


	     (SETQ NEXTITEM PREVITEM)))
         (TB.INSERT.ITEM TBROWSER FILE NEXTITEM)
         [COND
	   (NOSUBDIRS)
	   ((AND NEXTITEM (NOT (fetch TIUNSELECTABLE of NEXTITEM))
		 (STRING-EQUAL (SETQ OTHERDIR (fetch (FILEBUCKET SUBDIRECTORY)
						 of (fetch TIDATA of NEXTITEM)))
			       MYSUBDIR))

          (* All ok -- next item is not a subdirectory line, and its subdir is the same as mine, so I must be properly 
	  qualified already)


	     )
	   (T 

          (* * Inserted at end, or newly inserted item has different subdirectory from the item that follows it)


	      (COND
		((AND NEXTITEM (NOT (fetch TIUNSELECTABLE of NEXTITEM)))
                                                             (* Need subdirectory id in front of next file)
		  (FB.INSERT.DIRECTORY TBROWSER BROWSER OTHERDIR NEXTITEM)))
	      (COND
		([COND
		    ((EQ (SETQ N (fetch TI# of FILE))
			 1)                                  (* Inserted at front, needs qualification if it has a 
							     subdir)
		      (NOT (NULL MYSUBDIR)))
		    (T (NOT (STRING-EQUAL [fetch (FILEBUCKET SUBDIRECTORY)
					     of (fetch TIDATA of (SETQ PREVITEM (TB.NTH.ITEM
								     TBROWSER
								     (SUB1 N]
					  MYSUBDIR]          (* Need id in front of new file as well)
		  (FB.INSERT.DIRECTORY TBROWSER BROWSER MYSUBDIR FILE]
         (FB.COUNT.FILE.CHANGE BROWSER FILE (QUOTE ADD])

(FB.ANALYZE.PATTERN
  [LAMBDA (BROWSER SAMPLE)                                   (* bvm: "12-Sep-85 18:07")

          (* * Figures out what the "real pattern" is from SAMPLE, one of the files that is claimed to match the pattern.
	  Sets the NAMESTART field to where the pattern ends and the distinguishable names start. Also resets PATTERN to be 
	  the canonicalized pattern)


    (LET ((PATTERN (fetch (FILEBROWSER PATTERN) of BROWSER))
	  (PATHOSTEND 0)
	  (SAMPLEHOSTEND 0)
	  LASTPATDIR STARTOFNAME)
         (do (SELCHARQ (NTHCHARCODE PATTERN (add PATHOSTEND 1))
		       (' (add PATHOSTEND 1))
		       [}                                    (* End of directory, now look for end of matchable 
							     pattern)
			  (RETURN (for (N ← PATHOSTEND) do (SELCHARQ (NTHCHARCODE PATTERN
										  (add N 1))
								     (' (add N 1))
								     ((: >)
								       (SETQ LASTPATDIR N))
								     ((NIL * #)
                                                             (* End of pattern or wildcard, can't match beyond here)
								       (RETURN))
								     NIL]
		       (NIL                                  (* End of file name without end of brace?)
			    (RETURN (SETQ PATHOSTEND 0)))
		       NIL))

          (* * From PATHOSTEND thru LASTPATDIR is now a segment that ought to appear in SAMPLE)


         (do (SELCHARQ (NTHCHARCODE SAMPLE (add SAMPLEHOSTEND 1))
		       (' (add SAMPLEHOSTEND 1))
		       (}                                    (* End of directory)
			  (RETURN))
		       (NIL                                  (* End of file name without end of brace?)
			    (RETURN (SETQ SAMPLEHOSTEND 0)))
		       NIL))
         [COND
	   [(AND LASTPATDIR (SETQ STARTOFNAME (STRPOS (SUBSTRING PATTERN (ADD1 PATHOSTEND)
								 LASTPATDIR)
						      SAMPLE
						      (ADD1 SAMPLEHOSTEND)
						      NIL NIL T UPPERCASEARRAY)))
                                                             (* Anything before the first match of the pattern is 
							     assumed to be canonicalization added by the device)
	     (SETQ PATTERN (CONCAT (SUBSTRING SAMPLE 1 (SUB1 STARTOFNAME))
				   (SUBSTRING PATTERN (ADD1 LASTPATDIR]
	   (T                                                (* Should only happen for devices without directories)
	      (SETQ STARTOFNAME (ADD1 SAMPLEHOSTEND))
	      (COND
		([OR (NEQ PATHOSTEND SAMPLEHOSTEND)
		     (NOT (STREQUAL (SUBSTRING PATTERN 1 PATHOSTEND)
				    (SUBSTRING SAMPLE 1 PATHOSTEND]
                                                             (* At least canonicalize the host part)
		  (SETQ PATTERN (CONCAT (SUBSTRING SAMPLE 1 SAMPLEHOSTEND)
					(SUBSTRING PATTERN (ADD1 PATHOSTEND]
         (FB.SETNEWPATTERN BROWSER PATTERN)
         (WINDOWPROP (fetch (FILEBROWSER COUNTERWINDOW) of BROWSER)
		     (QUOTE TITLE)
		     (CONCAT PATTERN " browser"))
         (replace (FILEBROWSER PATTERNPARSED?) of BROWSER with T)
         (replace (FILEBROWSER DIRECTORYSTART) of BROWSER with (ADD1 SAMPLEHOSTEND))
         (replace (FILEBROWSER NAMESTART) of BROWSER with STARTOFNAME])

(FB.GETALLFILEINFO
  [LAMBDA (FILE GENERATOR ATTRIBUTES)                        (* bvm: "11-Sep-85 12:34")
    (for ATTR in ATTRIBUTES bind INFO RESULT when (SETQ INFO (\GENERATEFILEINFO GENERATOR ATTR))
       do (push RESULT ATTR INFO) finally (RETURN RESULT])
)
(DEFINEQ

(FB.SORT.VERSIONS
  [LAMBDA (ITEMS SORTFN)                                     (* bvm: "18-Sep-85 11:36")

          (* * Sort ITEMS so that equal names are sorted by version according to SORTFN. Assumes that ITEMS are already sorted
	  by name)


    (LET ((TAIL ITEMS)
	  PREVTAIL NEXTTAIL NEWTAIL THISNAME)
         [while (CDR TAIL) do (COND
				[[STRING-EQUAL [SETQ THISNAME (fetch (FILEBUCKET PRINTNAME)
								 of (fetch TIDATA
								       of (CAR TAIL]
					       (fetch (FILEBUCKET PRINTNAME)
						  of (fetch TIDATA of (CADR TAIL]
                                                             (* Same name as next, so gather up all equal names)
				  (SETQ NEXTTAIL (CDDR TAIL))
				  (while [AND NEXTTAIL (STRING-EQUAL THISNAME
								     (fetch (FILEBUCKET PRINTNAME)
									of (fetch TIDATA
									      of (CAR NEXTTAIL]
				     do (SETQ NEXTTAIL (CDR NEXTTAIL)))
				  (SETQ NEWTAIL (SORT (until (EQ TAIL NEXTTAIL) collect (pop TAIL))
						      SORTFN))
                                                             (* Now splice NEWTAIL into list between PREVTAIL and 
							     NEXTTAIL)
				  (COND
				    (PREVTAIL (RPLACD PREVTAIL NEWTAIL))
				    (T (SETQ ITEMS NEWTAIL)))
				  (COND
				    ((SETQ TAIL NEXTTAIL)
				      (RPLACD (SETQ PREVTAIL (LAST NEWTAIL))
					      NEXTTAIL]
				(T (SETQ TAIL (CDR (SETQ PREVTAIL TAIL]
     ITEMS])

(FB.DECREASING.VERSION
  [LAMBDA (X Y)                                              (* bvm: "18-Sep-85 11:03")

          (* * Comparefn for sorting a group of same named files by decreasing version. Null version considered high)


    (AND (SETQ Y (fetch (FILEBUCKET VERSION) of (fetch TIDATA of Y)))
	 (OR [NOT (SETQ X (fetch (FILEBUCKET VERSION) of (fetch TIDATA of X]
	     (IGREATERP X Y])

(FB.INCREASING.VERSION
  [LAMBDA (X Y)                                              (* bvm: "18-Sep-85 11:06")

          (* * Comparefn for sorting a group of same named files by increasing version. Null version considered high)


    (OR [NOT (SETQ Y (fetch (FILEBUCKET VERSION) of (fetch TIDATA of Y]
	(AND (SETQ X (fetch (FILEBUCKET VERSION) of (fetch TIDATA of X)))
	     (ILESSP X Y])

(FB.NAMES.DECREASING.VERSION
  [LAMBDA (X Y)                                              (* bvm: "18-Sep-85 12:37")

          (* * Comparison function for sorting file names in alphabetical order, decreasing versions)


    (SELECTQ (ALPHORDER (fetch (FILEBUCKET VERSIONLESSNAME) of (SETQ X (fetch TIDATA of X)))
			(fetch (FILEBUCKET VERSIONLESSNAME) of (SETQ Y (fetch TIDATA of Y)))
			UPPERCASEARRAY)
	     (LESSP T)
	     [EQUAL (AND (SETQ Y (fetch (FILEBUCKET VERSION) of Y))
			 (OR (NOT (SETQ X (fetch (FILEBUCKET VERSION) of X)))
			     (IGREATERP X Y]
	     NIL])

(FB.NAMES.INCREASING.VERSION
  [LAMBDA (X Y)                                              (* bvm: "18-Sep-85 12:33")

          (* * Comparison function for sorting file names in alphabetical order, increasing versions)


    (SELECTQ (ALPHORDER (fetch (FILEBUCKET VERSIONLESSNAME) of (SETQ X (fetch TIDATA of X)))
			(fetch (FILEBUCKET VERSIONLESSNAME) of (SETQ Y (fetch TIDATA of Y)))
			UPPERCASEARRAY)
	     (LESSP T)
	     [EQUAL (OR (NOT (SETQ Y (fetch (FILEBUCKET VERSION) of Y)))
			(AND (SETQ X (fetch (FILEBUCKET VERSION) of X))
			     (ILESSP X Y]
	     NIL])
)
(DEFINEQ

(FB.EXPUNGECOMMAND
  [LAMBDA (FBROWSER KEY ITEM MENU CMD)                       (* bvm: "27-Sep-85 14:25")
    (PROG ((TBROWSER (fetch (FILEBROWSER TABLEBROWSER) of FBROWSER))
	   (NDELETED 0)
	   FILES FILENAME FAILED FILE)
          (COND
	    [(SETQ FILES (TB.COLLECT.ITEMS TBROWSER (QUOTE DELETED)))
	      (FB.PROMPTWPRINT FBROWSER T "Expunging deleted files...")
	      [for ITEM in FILES do (COND
				      ((DELFILE (SETQ FILENAME (FB.FETCHFILENAME ITEM)))
					(add NDELETED 1)
					(FB.REMOVE.FILE TBROWSER FBROWSER ITEM)
					(FB.UPDATE.COUNTERS FBROWSER (QUOTE BOTH)))
				      (T (FB.PROMPTWPRINT FBROWSER T "Couldn't expunge " FILENAME)
					 (SETQ FAILED T]
	      (FB.PROMPTWPRINT FBROWSER (COND
				 ((EQ NDELETED 0)
				   "
No")
				 (T (CONCAT (COND
					      (FAILED "
Done, but only ")
					      (T "done, "))
					    NDELETED)))
			       " files expunged.")
	      (COND
		(FAILED (COND
			  (CMD (FB.PROMPTWPRINT FBROWSER "  " CMD " aborted.")))
			(RETURN]
	    (T (FB.PROMPTWPRINT FBROWSER T "No files were marked for deletion")))
          (RETURN T])

(FB.REMOVE.FILE
  [LAMBDA (TBROWSER FBROWSER ITEM)                           (* bvm: "19-Sep-85 15:46")

          (* * Removes ITEM from browser display, counts its removal)


    (LET ((N (fetch TI# of ITEM))
	  PREVITEM NEXTITEM NEXTNEXTITEM)
         [COND
	   ((AND (NEQ N 1)
		 [fetch TIUNSELECTABLE of (SETQ PREVITEM (TB.NTH.ITEM TBROWSER (SUB1 N]
		 (OR [NULL (SETQ NEXTITEM (TB.NTH.ITEM TBROWSER (ADD1 N]
		     (fetch TIUNSELECTABLE of NEXTITEM)))    (* ITEM is between two subdirectory lines, so remove at
							     least the preceding line)
	     (TB.REMOVE.ITEM TBROWSER PREVITEM)
	     (COND
	       ([AND NEXTITEM (SETQ NEXTNEXTITEM (TB.NTH.ITEM TBROWSER (ADD1 N)))
		     (COND
		       [(EQ (add N -1)
			    1)                               (* N decremented because of the remove above.
							     Now removing first file, so see if next file has no 
							     subdir)
			 (NULL (fetch (FILEBUCKET SUBDIRECTORY) of (fetch TIDATA of NEXTNEXTITEM]
		       (T (STRING-EQUAL (fetch (FILEBUCKET SUBDIRECTORY)
					   of (fetch TIDATA of NEXTNEXTITEM))
					(fetch (FILEBUCKET SUBDIRECTORY)
					   of (fetch TIDATA of (TB.NTH.ITEM TBROWSER (SUB1 N]
                                                             (* The next subdirectory line is superfluous, because 
							     the file after it and the file before us have the same 
							     subdirectory)
		 (TB.REMOVE.ITEM TBROWSER NEXTITEM]
         (TB.REMOVE.ITEM TBROWSER ITEM)
         (FB.COUNT.FILE.CHANGE FBROWSER ITEM (QUOTE REMOVE])

(FB.COUNT.FILE.CHANGE
  [LAMBDA (FBROWSER ITEM FLG)                                (* bvm: "12-Sep-85 00:27")

          (* * Account for the addition or removal of ITEM from FBROWSER -- FLG is ADD or REMOVE)


    (LET ((SIGN (SELECTQ FLG
			 (ADD 1)
			 (REMOVE -1)
			 (SHOULDNT)))
	  (SIZE (LISTGET (fetch FILEINFO of (fetch TIDATA of ITEM))
			 (QUOTE SIZE)))
	  (DELETEDP (fetch TIDELETED of ITEM)))
         (replace (FILEBROWSER TOTALFILES) of FBROWSER with (add (fetch (FILEBROWSER TOTALFILES)
								    of FBROWSER)
								 SIGN))
         [COND
	   (DELETEDP (replace (FILEBROWSER DELETEDFILES) of FBROWSER
			with (add (fetch (FILEBROWSER DELETEDFILES) of FBROWSER)
				  SIGN]
         (COND
	   (SIZE (add (fetch (FILEBROWSER TOTALPAGES) of FBROWSER)
		      (SETQ SIZE (ITIMES SIZE SIGN)))
		 (COND
		   (DELETEDP (add (fetch (FILEBROWSER DELETEDPAGES) of FBROWSER)
				  SIZE])

(FB.NEWPATTERNCOMMAND
  [LAMBDA (BROWSER)                                          (* bvm: "27-Sep-85 12:31")
    (LET (PATTERN)
         (COND
	   ((AND (FB.MAYBE.EXPUNGE BROWSER "New Pattern")
		 (SETQ PATTERN (FB.GET.NEWPATTERN BROWSER)))
	     (FB.SETNEWPATTERN BROWSER PATTERN)
	     (FB.UPDATEBROWSERITEMS BROWSER])

(FB.SETNEWPATTERN
  [LAMBDA (FBROWSER PATTERN)                                 (* bvm: "12-Sep-85 18:07")
    (LET (ICON)
         (replace (FILEBROWSER PATTERN) of FBROWSER with PATTERN)
         (replace (FILEBROWSER PREPAREDPATTERN) of FBROWSER with (DIRECTORY.MATCH.SETUP PATTERN))
         (replace (FILEBROWSER PATTERNPARSED?) of FBROWSER with NIL)
         (COND
	   ((SETQ ICON (WINDOWPROP (fetch (FILEBROWSER BROWSERWINDOW) of FBROWSER)
				   (QUOTE ICONWINDOW)))      (* Change the icon label)
	     (ICONW.TITLE ICON PATTERN)))
     PATTERN])

(FB.NEWINFOCOMMAND
  [LAMBDA (BROWSER)                                          (* bvm: "18-Sep-85 23:37")
    (LET ((WINDOW (fetch (FILEBROWSER BROWSERWINDOW) of BROWSER))
	  (INFOMENUW (fetch (FILEBROWSER INFOMENUW) of BROWSER))
	  REG)
         (COND
	   ((NOT (OPENWP INFOMENUW))
	     [SETQ INFOMENUW
	       (MENUWINDOW (create MENU
				   ITEMS ← FB.INFOMENUITEMS
				   MENUROWS ← 2
				   TITLE ← "Info Options"
				   CENTERFLG ← T
				   MENUFONT ← FB.MENUFONT
				   WHENSELECTEDFN ←(FUNCTION FB.INFOMENU.WHENSELECTEDFN]
	     (ATTACHWINDOW INFOMENUW WINDOW (QUOTE BOTTOM)
			   (QUOTE JUSTIFY)
			   (QUOTE LOCALCLOSE))
	     [COND
	       ((LESSP [fetch (REGION BOTTOM) of (SETQ REG (WINDOWPROP INFOMENUW (QUOTE REGION]
		       0)                                    (* Bump whole window up on screen so we can see it)
		 (MOVEW WINDOW (create POSITION
				       XCOORD ←(fetch (REGION LEFT) of REG)
				       YCOORD ←(fetch (REGION HEIGHT) of REG]
	     (FB.INFOMENU.SHADEINITIALSELECTIONS INFOMENUW (fetch INFOMENUCHOICES of BROWSER))
	     (replace INFOMENUW of BROWSER with INFOMENUW)
	     (WINDOWADDPROP INFOMENUW (QUOTE CLOSEFN)
			    [FUNCTION (LAMBDA (W)
				(AND (SETQ W (WINDOWPROP (MAINWINDOW W T)
							 (QUOTE FILEBROWSER)))
				     (replace INFOMENUW of W with NIL]
			    T)))
         (FB.PROMPTWPRINT BROWSER (QUOTE CLEAR)
			  
	  "Select from the lower menu which attributes are to be displayed,
then click Recompute"])

(FB.GET.NEWPATTERN
  [LAMBDA (BROWSER)                                          (* bvm: "12-Sep-85 18:10")
    (LET* ((OLDPATTERN (fetch PATTERN of BROWSER))
	   (PATTERN (FB.PROMPTFORINPUT (COND
					 (OLDPATTERN "New file group description: ")
					 (T "File group description: "))
				       OLDPATTERN BROWSER T)))
          (COND
	    (PATTERN (DIRECTORY.FILL.PATTERN PATTERN])

(FB.OPTIONSCOMMAND
  [LAMBDA (BROWSER)                                          (* bvm: "13-Sep-85 16:13")
    (FB.PROMPTWPRINT BROWSER 
		     "Please use the Options roll-out submenu to select the option you desire."])
)



(* window functions)

(DEFINEQ

(FB.PROMPTWPRINT
  [LAMBDA U                                                  (* bvm: "12-Sep-85 18:35")
    (COND
      ((ILESSP U 2)
	(ERROR "not enough args to PROMPTWPRINT"))
      (T (LET ((WINDOW (fetch (FILEBROWSER PROMPTWINDOW) of (ARG U 1)))
	       THING)                                        (* CAR is window, CDR is height in lines)
	      (for ITEM from 2 to U do (SELECTQ (SETQ THING (ARG U ITEM))
						(T (TERPRI WINDOW))
						(CLEAR (CLEARW WINDOW))
						(FRESH (FRESHLINE WINDOW))
						(PRIN1 THING WINDOW])

(FB.PROMPTFORINPUT
  [LAMBDA (PROMPT DEFAULT BROWSER ABORTFLG)                  (* bvm: "18-Sep-85 11:18")

          (* * Prompt for input for browser BROWSER with question PROMPT offering default answer DEFAULT.
	  If ABORTFLG is true and response is NIL, prints "... aborted")


    (LET* ((PWINDOW (fetch (FILEBROWSER PROMPTWINDOW) of BROWSER))
	   (PROMPTWIDTH (STRINGWIDTH PROMPT PWINDOW))
	   (WINDOWWIDTH (WINDOWPROP PWINDOW (QUOTE WIDTH)))
	   RESULT)
          (CLEARW PWINDOW)
          [COND
	    ((IGREATERP (IPLUS PROMPTWIDTH (STRINGWIDTH (OR DEFAULT "XXX")
							PWINDOW))
			WINDOWWIDTH)                         (* Prompt plus default response will overflow the width
							     of the window, so be a nice guy and break it up)
	      (for I from (DIFFERENCE (NCHARS PROMPT)
				      4)
		 to 10 by -1 bind (EXCESSWIDTH ←(IDIFFERENCE PROMPTWIDTH WINDOWWIDTH))
		 when (AND (EQ (NTHCHARCODE PROMPT I)
			       (CHARCODE SPACE))
			   (IGREATERP (STRINGWIDTH (SUBSTRING PROMPT I)
						   PWINDOW)
				      EXCESSWIDTH))
		 do (RETURN (SETQ PROMPT (CONCAT (SUBSTRING PROMPT 1 (SUB1 I))
						 "
"
						 (SUBSTRING PROMPT (ADD1 I]
          [SETQ RESULT (CAR (NLSETQ (PROMPTFORWORD PROMPT DEFAULT NIL PWINDOW NIL (QUOTE TTY)
						   (CHARCODE (CR ESC]
          (COND
	    ((AND (NULL RESULT)
		  ABORTFLG)
	      (PRINTOUT PWINDOW "... aborted")))
          (TERPRI PWINDOW)
      RESULT])

(FB.INFOMENU.SHADEINITIALSELECTIONS
  [LAMBDA (MENUWINDOW INITIALSELECTIONS)                     (* bvm: "11-Sep-85 14:52")
    (LET* ([MENU (CAR (WINDOWPROP MENUWINDOW (QUOTE MENU]
	   (MENUITEMS (fetch (MENU ITEMS) of MENU)))
          (for SELECTION in INITIALSELECTIONS do (SHADEITEM (FB.\ItemWithTag SELECTION MENUITEMS)
							    MENU FB.INFOSHADE MENUWINDOW])

(FB.\ItemWithTag
  [LAMBDA (TAG ITEMS)                                        (* hdj "16-Sep-84 16:16")

          (* * search a menu's items for one with tag TAG)


    (for ITEM in ITEMS do (COND
			    ((EQ (CADR ITEM)
				 TAG)
			      (RETURN ITEM])
)
(DEFINEQ

(FB.MAKECOUNTERWINDOW
  [LAMBDA (BROWSERWINDOW FONT WIDTH HEIGHT)                  (* bvm: "19-Sep-85 14:42")
    (LET ((COUNTERW (CREATEW (create REGION
				     LEFT ← 0
				     BOTTOM ← 0
				     HEIGHT ← HEIGHT
				     WIDTH ← WIDTH)
			     "File Browser Window" NIL T)))
         (FB.MAKERIGIDWINDOW COUNTERW)
         (DSPFONT FONT COUNTERW)
         (ATTACHWINDOW COUNTERW BROWSERWINDOW (QUOTE TOP))
         (replace COUNTERWINDOW of (WINDOWPROP BROWSERWINDOW (QUOTE FILEBROWSER)) with COUNTERW)
         (WINDOWPROP COUNTERW (QUOTE REPAINTFN)
		     (FUNCTION FB.COUNTERW.REDISPLAYFN))
         (WINDOWPROP COUNTERW (QUOTE RESHAPEFN)
		     (FUNCTION FB.COUNTERW.REDISPLAYFN))
         (WINDOWPROP COUNTERW (QUOTE PAGEFULLFN)
		     (FUNCTION NILL))
     COUNTERW])

(FB.COUNTERW.REDISPLAYFN
  [LAMBDA (COUNTERWINDOW)                                    (* bvm: "11-Sep-85 12:44")
    (CLEARW COUNTERWINDOW)
    (FB.DISPLAY.COUNTERS (WINDOWPROP (MAINWINDOW COUNTERWINDOW T)
				     (QUOTE FILEBROWSER])

(FB.UPDATE.COUNTERS
  [LAMBDA (FBROWSER TYPE)                                    (* bvm: "13-Sep-85 15:56")
    (LET* ((COUNTERW (fetch COUNTERWINDOW of FBROWSER))
	   (XPOSPAIRS (fetch (FILEBROWSER COUNTERPOSITIONS) of FBROWSER))
	   (TOTAL (fetch (FILEBROWSER TOTALFILES) of FBROWSER))
	   (TOTALPAGES (fetch (FILEBROWSER TOTALPAGES) of FBROWSER))
	   (DEL (fetch (FILEBROWSER DELETEDFILES) of FBROWSER))
	   (DELPAGES (fetch (FILEBROWSER DELETEDPAGES) of FBROWSER))
	   (PAGESTRING (fetch (FILEBROWSER COUNTERPAGESTRING) of FBROWSER))
	   (HEIGHT (WINDOWPROP COUNTERW (QUOTE HEIGHT)))
	   HERE LABELS)
          [SETQ LABELS (LIST (COND
			       ((fetch (FILEBROWSER SHOWUNDELETED?) of FBROWSER)
				 (FB.COUNTER.STRING FBROWSER (IDIFFERENCE TOTAL DEL)
						    (IDIFFERENCE TOTALPAGES DELPAGES)))
			       ((NEQ TYPE (QUOTE DELETED))   (* Don't need to update total if only deleted count 
							     changed)
				 (FB.COUNTER.STRING FBROWSER TOTAL TOTALPAGES)))
			     (AND (NEQ TYPE (QUOTE TOTAL))
				  (FB.COUNTER.STRING FBROWSER DEL DELPAGES]
          (DSPXPOSITION 0 COUNTERW)
          (for LAB in LABELS as PAIR in XPOSPAIRS when LAB
	     do (DSPXPOSITION (CAR PAIR)
			      COUNTERW)
		(PRIN3 LAB COUNTERW)
		(PRIN3 PAGESTRING COUNTERW)
		(BLTSHADE WHITESHADE COUNTERW (SETQ HERE (DSPXPOSITION NIL COUNTERW))
			  0
			  (IDIFFERENCE (CADR PAIR)
				       HERE)
			  HEIGHT
			  (QUOTE REPLACE])

(FB.DISPLAY.COUNTERS
  [LAMBDA (FBROWSER)                                         (* bvm: "11-Sep-85 15:45")
    (LET* ((COUNTERW (fetch COUNTERWINDOW of FBROWSER))
	   (TOTAL (fetch (FILEBROWSER TOTALFILES) of FBROWSER))
	   (TOTALPAGES (fetch (FILEBROWSER TOTALPAGES) of FBROWSER))
	   (DEL (fetch (FILEBROWSER DELETEDFILES) of FBROWSER))
	   (DELPAGES (fetch (FILEBROWSER DELETEDPAGES) of FBROWSER))
	   (COUNTERWIDTH (WINDOWPROP COUNTERW (QUOTE WIDTH)))
	   (COUNTERFONT (DSPFONT NIL COUNTERW))
	   (SECTIONWIDTH (IQUOTIENT COUNTERWIDTH 2))
	   [THRESHOLDWIDTH (IDIFFERENCE SECTIONWIDTH (ITIMES 2 (CHARWIDTH (CHARCODE a)
									  COUNTERFONT]
	   (HEIGHT (WINDOWPROP COUNTERW (QUOTE HEIGHT)))
	   PAGESTRING MAXWIDTH HERE LABELS)
          [SETQ LABELS (LIST [COND
			       [(fetch (FILEBROWSER SHOWUNDELETED?) of FBROWSER)
				 (LIST "Undeleted: " (FB.COUNTER.STRING FBROWSER (IDIFFERENCE TOTAL 
											      DEL)
									(IDIFFERENCE TOTALPAGES 
										     DELPAGES]
			       (T (LIST "Total: " (FB.COUNTER.STRING FBROWSER TOTAL TOTALPAGES]
			     (LIST "Deleted: " (FB.COUNTER.STRING FBROWSER DEL DELPAGES]
          (DSPXPOSITION 0 COUNTERW)
          (DSPRIGHTMARGIN MAX.SMALLP COUNTERW)
          (LINELENGTH MAX.SMALLP COUNTERW)
          (SETQ MAXWIDTH 0)
          [for LAB in LABELS do (SETQ MAXWIDTH (IMAX MAXWIDTH (IPLUS (STRINGWIDTH (CAR LAB)
										  COUNTERFONT)
								     (STRINGWIDTH (CADR LAB)
										  COUNTERFONT]
          (COND
	    ((NOT (fetch (FILEBROWSER PAGECOUNT?) of FBROWSER))
	      (SETQ PAGESTRING ""))
	    ((IGREATERP (PLUS MAXWIDTH (STRINGWIDTH (SETQ PAGESTRING " pages")
						    COUNTERFONT))
			THRESHOLDWIDTH)                      (* Try a shorter word)
	      (SETQ PAGESTRING " pgs")))
          [COND
	    ((IGREATERP (PLUS MAXWIDTH (STRINGWIDTH PAGESTRING COUNTERFONT))
			THRESHOLDWIDTH)                      (* The long labels are too long, so abbreviate them.
							     Only have to do this for very narrow windows)
	      (for LAB in LABELS do (RPLACA LAB (CONCAT (SUBSTRING (CAR LAB)
								   1 3)
							": "]
          [replace (FILEBROWSER COUNTERPOSITIONS) of FBROWSER
	     with (for LAB in LABELS as NEXTPOS from SECTIONWIDTH by SECTIONWIDTH
		     collect (PRIN3 (CAR LAB)
				    COUNTERW)
			     (LIST (DSPXPOSITION NIL COUNTERW)
				   (PROGN (PRIN3 (CADR LAB)
						 COUNTERW)
					  (PRIN3 PAGESTRING COUNTERW)
					  (BLTSHADE WHITESHADE COUNTERW (SETQ HERE (DSPXPOSITION
							NIL COUNTERW))
						    0
						    (IDIFFERENCE NEXTPOS HERE)
						    HEIGHT
						    (QUOTE REPLACE))
					  (DSPXPOSITION NEXTPOS COUNTERW)
					  NEXTPOS]
          (replace (FILEBROWSER COUNTERPAGESTRING) of FBROWSER with PAGESTRING])

(FB.COUNTER.STRING
  [LAMBDA (FBROWSER NFILES NPAGES)                           (* bvm: "11-Sep-85 11:44")
    (COND
      ((fetch (FILEBROWSER PAGECOUNT?) of FBROWSER)
	(CONCAT NFILES " / " NPAGES))
      (T (MKSTRING NFILES])
)
(DEFINEQ

(FB.MAKEHEADINGWINDOW
  [LAMBDA (BROWSERWINDOW WIDTH HEIGHT FONT)                  (* bvm: "19-Sep-85 14:39")
    (LET ((HEADINGW (CREATEW (create REGION
				     LEFT ← 0
				     BOTTOM ← 0
				     WIDTH ← WIDTH
				     HEIGHT ← HEIGHT)
			     NIL 0 T)))
         (DSPFONT FONT HEADINGW)
         (WINDOWPROP HEADINGW (QUOTE REPAINTFN)
		     (FUNCTION FB.HEADINGW.REDISPLAYFN))
         (WINDOWPROP HEADINGW (QUOTE RESHAPEFN)
		     (FUNCTION FB.HEADINGW.RESHAPEFN))
         (FB.MAKERIGIDWINDOW HEADINGW)
         (ATTACHWINDOW HEADINGW BROWSERWINDOW (QUOTE TOP))
         (DSPTEXTURE BLACKSHADE HEADINGW)                    (* This is a white on black window)
         (DSPOPERATION (QUOTE INVERT)
		       HEADINGW)
         (DSPFILL NIL BLACKSHADE (QUOTE REPLACE)
		  HEADINGW)
         (replace HEADINGWINDOW of (WINDOWPROP BROWSERWINDOW (QUOTE FILEBROWSER)) with HEADINGW)
     HEADINGW])

(FB.HEADINGW.REDISPLAYFN
  [LAMBDA (WINDOW)                                           (* bvm: "19-Sep-85 14:39")
    (FB.HEADINGW.DISPLAY (WINDOWPROP (WINDOWPROP WINDOW (QUOTE MAINWINDOW))
				     (QUOTE FILEBROWSER))
			 WINDOW])

(FB.HEADINGW.RESHAPEFN
  [LAMBDA (WINDOW)                                           (* bvm: "19-Sep-85 14:39")

          (* * Redraw the heading window after a reshape)


    (LET [(FBROWSER (WINDOWPROP (WINDOWPROP WINDOW (QUOTE MAINWINDOW))
				(QUOTE FILEBROWSER]
         (CLEARW WINDOW)
         (FB.HEADINGW.DISPLAY FBROWSER WINDOW)
         (FB.UPDATE.HEADING.EXTENT FBROWSER WINDOW])

(FB.HEADINGW.DISPLAY
  [LAMBDA (FBROWSER WINDOW)                                  (* bvm: "18-Sep-85 21:56")
    (LET ((NEXTPOS (fetch (FILEBROWSER INFOSTART) of FBROWSER))
	  (HEADINGS (fetch (FILEBROWSER INFODISPLAYED) of FBROWSER)))
         (DSPRIGHTMARGIN 32000 WINDOW)
         (DSPFILL NIL BLACKSHADE (QUOTE REPLACE)
		  WINDOW)
         (DSPXPOSITION (IPLUS TB.LEFT.MARGIN WBorder)
		       WINDOW)
         (PRIN3 "Name" WINDOW)
         (for SPEC in FB.INFOFIELDS when (FMEMB (fetch INFONAME of SPEC)
						HEADINGS)
	    do (DSPXPOSITION NEXTPOS WINDOW)
	       (PRIN3 (fetch (INFOFIELD INFOLABEL) of SPEC)
		      WINDOW)
	       (add NEXTPOS (fetch (INFOFIELD INFOWIDTH) of SPEC])
)
(DEFINEQ

(FB.ICONFN
  [LAMBDA (WINDOW OLDICON)                                   (* bvm: "11-Sep-85 14:52")
    (OR OLDICON (TITLEDICONW (create TITLEDICON
				     ICON ← FILEDRAWER
				     TITLEREG ← FILEDRAWERREGION)
			     (fetch PATTERN of (WINDOWPROP WINDOW (QUOTE FILEBROWSER)))
			     FB.ICONFONT NIL NIL NIL (QUOTE FILE])

(FB.SCROLLFN
  [LAMBDA (WINDOW HORIZ VERT CONTINUOUS?)                    (* bvm: "14-Sep-85 15:56")

          (* * Scroll FB window up/down and right/left. In right/left case, tell heading window to scroll also)



          (* * only scroll an integral number of text lines)


    (RESETLST (LET [(FBROWSER (WINDOWPROP WINDOW (QUOTE FILEBROWSER]
	           (COND
		     ((OBTAIN.MONITORLOCK (fetch (FILEBROWSER TBLOCK) of FBROWSER)
					  T T)
		       (COND
			 ((NEQ HORIZ 0)
			   (COND
			     ((fetch EXTENTCHANGED of FBROWSER)
			       (FB.UPDATE.HEADING.EXTENT FBROWSER WINDOW)))
			   (SCROLLW (fetch HEADINGWINDOW of FBROWSER)
				    HORIZ VERT CONTINUOUS?))
			 ((NEQ VERT 0)                       (* Horizontal extent might change as we print new items
							     to the window -- be conservative)
			   (replace EXTENTCHANGED of FBROWSER with T)))
		       (SCROLLBYREPAINTFN WINDOW HORIZ VERT CONTINUOUS?))
		     (T (TB.BROWSER.BUSY (fetch (FILEBROWSER TABLEBROWSER) of FBROWSER])

(FB.UPDATE.HEADING.EXTENT
  [LAMBDA (FBROWSER WINDOW)                                  (* bvm: "19-Sep-85 14:32")

          (* * Keep the heading window with the same horizontal extent as the main window so that they scroll together 
	  correctly)


    (LET [(EXT (WINDOWPROP WINDOW (QUOTE EXTENT]
         [COND
	   (EXT (WINDOWPROP (fetch HEADINGWINDOW of FBROWSER)
			    (QUOTE EXTENT)
			    (create REGION
				    LEFT ← 0
				    BOTTOM ← 0
				    WIDTH ←(fetch (REGION WIDTH) of EXT)
				    HEIGHT ← -1]
         (replace EXTENTCHANGED of FBROWSER with NIL])

(FB.INFOMENU.WHENSELECTEDFN
  [LAMBDA (ITEM MENU KEY)                                    (* bvm: "18-Sep-85 11:51")
    (LET* ((INFO (CADR ITEM))
	   (WINDOW (WINDOWPROP (WFROMMENU MENU)
			       (QUOTE MAINWINDOW)))
	   (BROWSER (WINDOWPROP WINDOW (QUOTE FILEBROWSER)))
	   (CHOSEN (fetch (FILEBROWSER INFOMENUCHOICES) of BROWSER)))
          [COND
	    ((FMEMB INFO CHOSEN)
	      (SHADEITEM ITEM MENU WHITESHADE)
	      (SETQ CHOSEN (REMOVE INFO CHOSEN)))
	    (T (SHADEITEM ITEM MENU FB.INFOSHADE)
	       (SETQ CHOSEN (CONS INFO CHOSEN]
          (replace (FILEBROWSER INFOMENUCHOICES) of BROWSER with CHOSEN])

(FB.CLOSEFN
  [LAMBDA (TBROWSER WINDOW FLG)                              (* bvm: "14-Sep-85 15:56")
                                                             (* did you really want to close up shop?)
    (COND
      ((NEQ (TB.NUMBER.OF.ITEMS TBROWSER (QUOTE DELETED))
	    0)
	(SELECTQ (MENU (FB.EXPUNGE?.MENU))
		 (EXPUNGE                                    (* Do expunge in another process, not here in mouse)
			  (FUNCTION FB.CLOSE&EXPUNGE))
		 (NOEXPUNGE NIL)
		 (QUOTE DON'T])

(FB.EXPUNGE?.MENU
  [LAMBDA NIL                                                (* bvm: "27-Sep-85 13:08")
    (OR FB.EXPUNGE?MENU
	(SETQ FB.EXPUNGE?MENU
	  (create MENU
		  ITEMS ← FB.CLOSEMENUITEMS
		  MENUROWS ← 2
		  CENTERFLG ← T
		  TITLE ← "Do what with deleted files?"
		  MENUFONT ← FB.BROWSERFONT])

(FB.AFTERCLOSEFN
  [LAMBDA (TBROWSER WINDOW)                                  (* bvm: "12-Sep-85 15:12")

          (* * Snap circularities before window vanishes)


    (LET ((FBROWSER (WINDOWPROP WINDOW (QUOTE FILEBROWSER)
				NIL)))
         (replace (FILEBROWSER TABLEBROWSER) of FBROWSER with NIL)
         (TB.USERDATA TBROWSER NIL])

(FB.CLOSE&EXPUNGE
  [LAMBDA (TBROWSER WINDOW FLG)                              (* bvm: "27-Sep-85 14:27")
    (LET ((BROWSER (TB.USERDATA TBROWSER))
	  MENU ITEM)
         [find W in (ATTACHEDWINDOWS WINDOW) suchthat (AND [SETQ MENU (CAR (WINDOWPROP W
										       (QUOTE MENU]
							   (EQ 1 (fetch (MENU MENUCOLUMNS)
								    of MENU]
         (SETQ ITEM (ASSOC (QUOTE Expunge)
			   (fetch (MENU ITEMS) of MENU)))
         (RESETLST (FB.MAKE.BROWSER.BUSY BROWSER ITEM MENU)
		   (COND
		     ((FB.EXPUNGECOMMAND BROWSER NIL NIL NIL FLG)
                                                             (* Expunge succeeded. Unshade the Expunge item before 
							     we shrink, or else it will still be shaded when we 
							     expand)
		       (SHADEITEM ITEM MENU FB.ITEMUNSELECTEDSHADE)
		       (TB.FINISH.CLOSE TBROWSER (fetch (FILEBROWSER BROWSERWINDOW) of BROWSER)
					FLG])
)
(DEFINEQ

(FB.FASTSEECOMMAND
  [LAMBDA (BROWSER KEY ITEM MENU UNFORMATTED)                (* bvm: "18-Sep-85 23:22")
    (PROG (FILELIST SEEWINDOW)
          (OR (SETQ FILELIST (FB.SELECTEDFILES BROWSER))
	      (RETURN))

          (* * if the last created see window is in use, or there isn't one, create a new one)


          [COND
	    ((OR [NOT (WINDOWP (SETQ SEEWINDOW (fetch SEEWINDOW of BROWSER]
		 (WINDOWPROP SEEWINDOW (QUOTE INUSE)))
	      (SETQ SEEWINDOW (CREATEW NIL "SEE window"))
	      (DSPSCROLL T SEEWINDOW)
	      (replace SEEWINDOW of BROWSER with SEEWINDOW)
	      (WINDOWPROP SEEWINDOW (QUOTE PAGEFULLFN)
			  (FUNCTION FB.SEEFULLFN))
	      (WINDOWADDPROP SEEWINDOW (QUOTE CLOSEFN)
			     (FUNCTION (LAMBDA (W)
				 (WINDOWPROP W (QUOTE INUSE)
					     NIL)
				 (DEL.PROCESS (WINDOWPROP W (QUOTE PROCESS]
          (RESETSAVE (WINDOWPROP SEEWINDOW (QUOTE INUSE)
				 T)
		     (LIST (FUNCTION WINDOWPROP)
			   SEEWINDOW
			   (QUOTE INUSE)
			   NIL))
          (RESETSAVE (WINDOWPROP SEEWINDOW (QUOTE PROCESS)
				 (THIS.PROCESS))
		     (LIST (FUNCTION WINDOWPROP)
			   SEEWINDOW
			   (QUOTE PROCESS)
			   NIL))
          (TTYDISPLAYSTREAM SEEWINDOW)                       (* Has to be our TTYDISPLAYSTREAM in order for page 
							     holding to work)
          (for TAIL on FILELIST do (ERSETQ (FB.FASTSEE.ONEFILE (FB.FETCHFILENAME (CAR TAIL))
							       SEEWINDOW UNFORMATTED (CDR TAIL])

(FB.FASTSEE.ONEFILE
  [LAMBDA (FILE WINDOW UNFORMATTED MORE)                     (* bvm: "18-Sep-85 23:28")
    (RESETLST (WINDOWPROP WINDOW (QUOTE TITLE)
			  (CONCAT "Viewing " FILE))
	      (CLEARW WINDOW)
	      [WINDOWPROP WINDOW (QUOTE MORETYPE)
			  (COND
			    (MORE (QUOTE YETMOREBUTTONS))
			    (T (QUOTE LASTMOREBUTTONS]
	      [RESETSAVE NIL (LIST (QUOTE CLOSEF)
				   (SETQ FILE (OPENSTREAM FILE (QUOTE INPUT)
							  NIL
							  (QUOTE ((SEQUENTIAL T]
	      (RESETSAVE NIL (LIST [FUNCTION (LAMBDA (WINDOW)
				       (AND RESETSTATE (OPENWP WINDOW)
					    (WINDOWPROP WINDOW (QUOTE TITLE)
							(CONCAT (WINDOWPROP WINDOW (QUOTE TITLE))
								" -- " "Aborted"]
				   WINDOW))
	      (COND
		(UNFORMATTED (COPYBYTES FILE WINDOW))
		(T (PFCOPYBYTES FILE WINDOW)))
	      (WINDOWPROP WINDOW (QUOTE TITLE)
			  (CONCAT (WINDOWPROP WINDOW (QUOTE TITLE))
				  " -- " "Finished"))
	      (COND
		(MORE                                        (* Wait for OK to proceed)
		      (FB.SEEFULLFN (WINDOWPROP WINDOW (QUOTE DSP))
				    (QUOTE FINISHEDMOREBUTTONS])

(FB.SEEFULLFN
  [LAMBDA (DSP PROP)                                         (* bvm: "18-Sep-85 23:29")
                                                             (* PAGEFULLFN for a fast SEE window)
    (LET* [(WINDOW (WFROMDS DSP))
	   [BUTTONS (WINDOWPROP WINDOW (OR PROP (SETQ PROP (WINDOWPROP WINDOW (QUOTE MORETYPE]
	   (EVENT (WINDOWPROP WINDOW (QUOTE MOREEVENT]
          (COND
	    ((NOT BUTTONS)
	      (SETQ BUTTONS (create MENU
				    ITEMS ←[SELECTQ PROP
						    [YETMOREBUTTONS (QUOTE (("More" MORE 
							    "View another screenfull of the file")
									     (" Next File " NEXT 
						     "Abort view of this file, go on to next one")
									     ("Abort" ABORT 
						    "Abort viewing of this and any further files"]
						    [FINISHEDMOREBUTTONS (QUOTE ((" Next File "
										    NEXT 
								    "Go on to view the next file")
										  ("Abort" ABORT 
						     "Abort the SEE command -- see no more files"]
						    (QUOTE ((" More " MORE 
							    "View another screenfull of the file")
							     (" Abort " ABORT 
						    "Abort view; allow this window to be re-used"]
				    MENUROWS ← 1
				    WHENSELECTEDFN ←(FUNCTION FB.SEEBUTTONFN)
				    CENTERFLG ← T))
	      (SETQ BUTTONS (ADDMENU BUTTONS (CREATEW (CREATEREGION 0 0 (WIDTHIFWINDOW
								      (fetch (MENU IMAGEWIDTH)
									 of BUTTONS)
								      FB.MORE.BORDER)
								    (HEIGHTIFWINDOW
								      (fetch (MENU IMAGEHEIGHT)
									 of BUTTONS)
								      NIL FB.MORE.BORDER))
						      NIL FB.MORE.BORDER T)
				     NIL T))
	      (WINDOWPROP WINDOW PROP BUTTONS)))
          [COND
	    ((NOT EVENT)
	      (WINDOWPROP WINDOW (QUOTE MOREEVENT)
			  (SETQ EVENT (CREATE.EVENT (WINDOWPROP WINDOW (QUOTE TITLE]
          (ATTACHWINDOW BUTTONS WINDOW (COND
			  ([GREATERP (fetch (REGION HEIGHT) of (WINDOWPROP BUTTONS (QUOTE REGION)))
				     (fetch (REGION BOTTOM) of (WINDOWPROP WINDOW (QUOTE REGION]
			    (QUOTE TOP))
			  (T (QUOTE BOTTOM)))
			(QUOTE LEFT))
          (do (TOTOPW BUTTONS)
	      (AWAIT.EVENT EVENT) repeatuntil (WINDOWPROP WINDOW (QUOTE MOREOK)
							  NIL])

(FB.SEEBUTTONFN
  [LAMBDA (ITEM MENU)                                        (* bvm: "18-Sep-85 23:22")

          (* * WHENSELECTEDFN for the More/Abort menu)


    (LET* ((MENUW (WFROMMENU MENU))
	   (WINDOW (MAINWINDOW MENUW)))
          (DETACHWINDOW MENUW)
          (CLOSEW MENUW)
          (SELECTQ (CADR ITEM)
		   [MORE (WINDOWPROP WINDOW (QUOTE MOREOK)
				     T)
			 (NOTIFY.EVENT (WINDOWPROP WINDOW (QUOTE MOREEVENT]
		   [NEXT (PROCESS.EVAL (WINDOWPROP WINDOW (QUOTE PROCESS))
				       (QUOTE (ERROR!]
		   [ABORT (PROCESS.EVAL (WINDOWPROP WINDOW (QUOTE PROCESS))
					(QUOTE (RESET]
		   (SHOULDNT])
)
(DECLARE: EVAL@COMPILE DONTCOPY 
(FILESLOAD (SOURCE)
	   TABLEBROWSERDECLS)

[DECLARE: EVAL@COMPILE 

(RECORD INFOFIELD (INFONAME INFOLABEL INFOWIDTH INFOFORMAT))

(RECORD FILEBUCKET (FILENAME FILEINFO PRINTNAME VERSION VERSIONLESSNAME SIZE SORTVALUE DIRECTORYP 
			     SUBDIRECTORY))

(DATATYPE FILEBROWSER ((NOSUBDIRECTORIES FLAG)               (* True if we don't want separate subdirectory lines --
							     subdirs then included in name)
		       (EXTENTCHANGED FLAG)                  (* True after a vertical scroll, which could have 
							     changed the horizontal extent)
		       (SHOWUNDELETED? FLAG)                 (* True if counter window should show "Undeleted" 
							     rather than "Total" counts)
		       (PATTERNPARSED? FLAG)                 (* True if PREPAREDPATTERN, NAMESTART, DIRECTORYSTART 
							     are valid)
		       (NIL 4 FLAG)
		       (TABLEBROWSER POINTER)                (* Pointer to TABLEBROWSER object controlling the 
							     browser)
		       (BROWSERWINDOW POINTER)               (* Main window)
		       (COUNTERWINDOW POINTER)               (* Window that counts files, pages, deletions)
		       (HEADINGWINDOW POINTER)               (* Window with headings for browser columns)
		       (INFOMENUW POINTER)                   (* Window containing choices for info to be displayed, 
							     or NIL if none yet)
		       (PROMPTWINDOW POINTER)                (* GETPROMPTWINDOW BROWSERWINDOW)
		       (INFODISPLAYED POINTER)               (* List of attributes to be displayed)
		       (PATTERN POINTER)                     (* Directory pattern being enumerated)
		       (PREPAREDPATTERN POINTER)             (* DIRECTORY.MATCH.SETUP of same)
		       (SEEWINDOW POINTER)                   (* Primary window used by FAST SEE command)
		       (BROWSERFONT POINTER)                 (* Font of BROWSERWINDOW)
		       (SORTBY POINTER)                      (* Sorting function or NIL for default sort)
		       (NAMESTART WORD)                      (* Index of first character in file name beyond the 
							     common prefix shared by all)
		       (DIRECTORYSTART WORD)                 (* Index of first character of directory in file names)
		       (INFOSTART WORD)                      (* X position in browser where first col of info is 
							     displayed)
		       (NAMEOVERHEAD WORD)                   (* This plus width of name gives is how much to allow 
							     before INFOSTART)
		       (OVERFLOWSPACING WORD)                (* Increment between sizes considered for INFOSTART)
		       (NIL WORD)
		       (TOTALFILES WORD)                     (* Total number of files, deleted files, pages, deleted
							     pages at the moment)
		       (DELETEDFILES WORD)
		       (TOTALPAGES POINTER)
		       (DELETEDPAGES POINTER)
		       (PAGECOUNT? POINTER)                  (* True if INFOCHOICES includes SIZE or LENGTH, so that
							     we can count pages)
		       (COUNTERPOSITIONS POINTER)            (* List of pairs (left right) describing regions where 
							     the values of the counters are displayed)
		       (COUNTERPAGESTRING POINTER)           (* String to print after file/page count)
		       (OVERFLOWWIDTHS POINTER)              (* List of (xpos occurrences) describing files whose 
							     names exceed default INFOSTART)
		       (INFOMENUCHOICES POINTER)             (* Selections user has made in Info window, not 
							     necessarily the info currently displayed)
		       (UPDATEPROC POINTER)                  (* Process doing an Update (Recompute))
		       ))
]
(/DECLAREDATATYPE (QUOTE FILEBROWSER)
		  (QUOTE (FLAG FLAG FLAG FLAG FLAG FLAG FLAG FLAG POINTER POINTER POINTER POINTER 
			       POINTER POINTER POINTER POINTER POINTER POINTER POINTER POINTER WORD 
			       WORD WORD WORD WORD WORD WORD WORD POINTER POINTER POINTER POINTER 
			       POINTER POINTER POINTER POINTER))
		  (QUOTE ((FILEBROWSER 0 (FLAGBITS . 0))
			  (FILEBROWSER 0 (FLAGBITS . 16))
			  (FILEBROWSER 0 (FLAGBITS . 32))
			  (FILEBROWSER 0 (FLAGBITS . 48))
			  (FILEBROWSER 0 (FLAGBITS . 64))
			  (FILEBROWSER 0 (FLAGBITS . 80))
			  (FILEBROWSER 0 (FLAGBITS . 96))
			  (FILEBROWSER 0 (FLAGBITS . 112))
			  (FILEBROWSER 0 POINTER)
			  (FILEBROWSER 2 POINTER)
			  (FILEBROWSER 4 POINTER)
			  (FILEBROWSER 6 POINTER)
			  (FILEBROWSER 8 POINTER)
			  (FILEBROWSER 10 POINTER)
			  (FILEBROWSER 12 POINTER)
			  (FILEBROWSER 14 POINTER)
			  (FILEBROWSER 16 POINTER)
			  (FILEBROWSER 18 POINTER)
			  (FILEBROWSER 20 POINTER)
			  (FILEBROWSER 22 POINTER)
			  (FILEBROWSER 24 (BITS . 15))
			  (FILEBROWSER 25 (BITS . 15))
			  (FILEBROWSER 26 (BITS . 15))
			  (FILEBROWSER 27 (BITS . 15))
			  (FILEBROWSER 28 (BITS . 15))
			  (FILEBROWSER 29 (BITS . 15))
			  (FILEBROWSER 30 (BITS . 15))
			  (FILEBROWSER 31 (BITS . 15))
			  (FILEBROWSER 32 POINTER)
			  (FILEBROWSER 34 POINTER)
			  (FILEBROWSER 36 POINTER)
			  (FILEBROWSER 38 POINTER)
			  (FILEBROWSER 40 POINTER)
			  (FILEBROWSER 42 POINTER)
			  (FILEBROWSER 44 POINTER)
			  (FILEBROWSER 46 POINTER)))
		  (QUOTE 48))

(DECLARE: EVAL@COMPILE 

(RPAQQ FB.MORE.BORDER 8)

(CONSTANTS FB.MORE.BORDER)
)

(DECLARE: DOEVAL@COMPILE DONTCOPY

(GLOBALVARS FB.ICONFONT FB.BROWSERFONT FB.PROMPTFONT FB.MENUFONT FB.EXPUNGE?MENU FILEDRAWER 
	    FB.CLOSEMENUITEMS FB.MENU.ITEMS FB.DEFAULT.INFO INFOLISTINGWIDTHS FB.INFOSHADE 
	    FB.INFOMENUITEMS FB.ITEMUNSELECTEDSHADE FB.ITEMSELECTEDSHADE DIRCOMMANDS FB.PROMPTLINES 
	    FB.INFOFIELDS WindowTitleDisplayStream FILEDRAWERREGION FB.DEFAULT.NAME.WIDTH 
	    FB.OVERFLOW.MAXABSOLUTE FB.OVERFLOW.MAXFRAC WBorder)
)
)
(/DECLAREDATATYPE (QUOTE FILEBROWSER)
		  (QUOTE (FLAG FLAG FLAG FLAG FLAG FLAG FLAG FLAG POINTER POINTER POINTER POINTER 
			       POINTER POINTER POINTER POINTER POINTER POINTER POINTER POINTER WORD 
			       WORD WORD WORD WORD WORD WORD WORD POINTER POINTER POINTER POINTER 
			       POINTER POINTER POINTER POINTER))
		  (QUOTE ((FILEBROWSER 0 (FLAGBITS . 0))
			  (FILEBROWSER 0 (FLAGBITS . 16))
			  (FILEBROWSER 0 (FLAGBITS . 32))
			  (FILEBROWSER 0 (FLAGBITS . 48))
			  (FILEBROWSER 0 (FLAGBITS . 64))
			  (FILEBROWSER 0 (FLAGBITS . 80))
			  (FILEBROWSER 0 (FLAGBITS . 96))
			  (FILEBROWSER 0 (FLAGBITS . 112))
			  (FILEBROWSER 0 POINTER)
			  (FILEBROWSER 2 POINTER)
			  (FILEBROWSER 4 POINTER)
			  (FILEBROWSER 6 POINTER)
			  (FILEBROWSER 8 POINTER)
			  (FILEBROWSER 10 POINTER)
			  (FILEBROWSER 12 POINTER)
			  (FILEBROWSER 14 POINTER)
			  (FILEBROWSER 16 POINTER)
			  (FILEBROWSER 18 POINTER)
			  (FILEBROWSER 20 POINTER)
			  (FILEBROWSER 22 POINTER)
			  (FILEBROWSER 24 (BITS . 15))
			  (FILEBROWSER 25 (BITS . 15))
			  (FILEBROWSER 26 (BITS . 15))
			  (FILEBROWSER 27 (BITS . 15))
			  (FILEBROWSER 28 (BITS . 15))
			  (FILEBROWSER 29 (BITS . 15))
			  (FILEBROWSER 30 (BITS . 15))
			  (FILEBROWSER 31 (BITS . 15))
			  (FILEBROWSER 32 POINTER)
			  (FILEBROWSER 34 POINTER)
			  (FILEBROWSER 36 POINTER)
			  (FILEBROWSER 38 POINTER)
			  (FILEBROWSER 40 POINTER)
			  (FILEBROWSER 42 POINTER)
			  (FILEBROWSER 44 POINTER)
			  (FILEBROWSER 46 POINTER)))
		  (QUOTE 48))
[ADDTOVAR SYSTEMRECLST

(DATATYPE FILEBROWSER ((NOSUBDIRECTORIES FLAG)
		       (EXTENTCHANGED FLAG)
		       (SHOWUNDELETED? FLAG)
		       (PATTERNPARSED? FLAG)
		       (NIL 4 FLAG)
		       (TABLEBROWSER POINTER)
		       (BROWSERWINDOW POINTER)
		       (COUNTERWINDOW POINTER)
		       (HEADINGWINDOW POINTER)
		       (INFOMENUW POINTER)
		       (PROMPTWINDOW POINTER)
		       (INFODISPLAYED POINTER)
		       (PATTERN POINTER)
		       (PREPAREDPATTERN POINTER)
		       (SEEWINDOW POINTER)
		       (BROWSERFONT POINTER)
		       (SORTBY POINTER)
		       (NAMESTART WORD)
		       (DIRECTORYSTART WORD)
		       (INFOSTART WORD)
		       (NAMEOVERHEAD WORD)
		       (OVERFLOWSPACING WORD)
		       (NIL WORD)
		       (TOTALFILES WORD)
		       (DELETEDFILES WORD)
		       (TOTALPAGES POINTER)
		       (DELETEDPAGES POINTER)
		       (PAGECOUNT? POINTER)
		       (COUNTERPOSITIONS POINTER)
		       (COUNTERPAGESTRING POINTER)
		       (OVERFLOWWIDTHS POINTER)
		       (INFOMENUCHOICES POINTER)
		       (UPDATEPROC POINTER)))
]
(DECLARE: DONTEVAL@LOAD DOCOPY 

(ADDTOVAR BackgroundMenuCommands ("FileBrowser" (QUOTE (FILEBROWSER))
						"Opens a filebrowser window; prompts for pattern"))


(RPAQQ BackgroundMenu NIL)
)
(DECLARE: DONTEVAL@LOAD DOEVAL@COMPILE DONTCOPY COMPILERVARS 

(ADDTOVAR NLAMA FB)

(ADDTOVAR NLAML )

(ADDTOVAR LAMA FB.PROMPTWPRINT)
)
(PUTPROPS FILEBROWSER COPYRIGHT ("Xerox Corporation" 1983 1984 1985))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (11161 19651 (FB 11171 . 11493) (FILEBROWSER 11495 . 16912) (FB.PRINTFN 16914 . 19451) (
FB.COPYFN 19453 . 19649)) (19670 20668 (FB.STARTUP 19680 . 20183) (FB.MAKERIGIDWINDOW 20185 . 20666)) 
(20713 23339 (FB.MENU.WHENSELECTEDFN 20723 . 21104) (FB.COMMANDSELECTEDFN 21106 . 22380) (FB.SUBITEMP 
22382 . 22817) (FB.MAKE.BROWSER.BUSY 22819 . 23337)) (23340 24061 (FB.SELECTEDFILES 23350 . 23683) (
FB.TABLEBROWSER 23685 . 23868) (FB.FETCHFILENAME 23870 . 24059)) (24062 42066 (FB.DELETECOMMAND 24072
 . 24349) (FB.DELVERCOMMAND 24351 . 25784) (FB.DELVER.FILES 25786 . 26839) (FB.DELETE.FILE 26841 . 
27399) (FB.UNDELETE.FILE 27401 . 27959) (FB.UNDELETECOMMAND 27961 . 28242) (FB.UNDELETEALLCOMMAND 
28244 . 28517) (FB.HARDCOPYCOMMAND 28519 . 28771) (FB.LOADCOMMAND 28773 . 29205) (FB.EDITCOMMAND 29207
 . 31313) (FB.EDITLISPFILE 31315 . 32043) (FB.COMPILECOMMAND 32045 . 32488) (FB.OPERATE.ON.FILES 32490
 . 33055) (FB.COPYCOMMAND 33057 . 33257) (FB.RENAMECOMMAND 33259 . 33465) (FB.COPY/RENAME.COMMAND 
33467 . 34102) (FB.COPY/RENAME.ONE 34104 . 35384) (FB.COPY/RENAME.MANY 35386 . 37438) (
FB.MAYBE.INSERT.FILE 37440 . 40574) (FB.GET.NEW.FILE.SPEC 40576 . 42064)) (42067 62519 (
FB.UPDATECOMMAND 42077 . 42302) (FB.MAYBE.EXPUNGE 42304 . 43065) (FB.UPDATEBROWSERITEMS 43067 . 47656)
 (FB.CLEANUP.UPDATE 47658 . 48172) (FB.ABORT.UPDATE 48174 . 48814) (FB.MAYBE.WIDEN.NAMES 48816 . 50124
) (FB.CREATE.FILEBUCKET 50126 . 53739) (FB.ADD.FILEGROUP 53741 . 54736) (FB.INSERT.DIRECTORY 54738 . 
55520) (FB.ADD.FILE 55522 . 56082) (FB.INSERT.FILE 56084 . 58802) (FB.ANALYZE.PATTERN 58804 . 62205) (
FB.GETALLFILEINFO 62207 . 62517)) (62520 66413 (FB.SORT.VERSIONS 62530 . 64121) (FB.DECREASING.VERSION
 64123 . 64585) (FB.INCREASING.VERSION 64587 . 65045) (FB.NAMES.DECREASING.VERSION 65047 . 65730) (
FB.NAMES.INCREASING.VERSION 65732 . 66411)) (66414 73794 (FB.EXPUNGECOMMAND 66424 . 67647) (
FB.REMOVE.FILE 67649 . 69393) (FB.COUNT.FILE.CHANGE 69395 . 70463) (FB.NEWPATTERNCOMMAND 70465 . 70822
) (FB.SETNEWPATTERN 70824 . 71474) (FB.NEWINFOCOMMAND 71476 . 73142) (FB.GET.NEWPATTERN 73144 . 73558)
 (FB.OPTIONSCOMMAND 73560 . 73792)) (73824 76796 (FB.PROMPTWPRINT 73834 . 74448) (FB.PROMPTFORINPUT 
74450 . 76068) (FB.INFOMENU.SHADEINITIALSELECTIONS 76070 . 76497) (FB.\ItemWithTag 76499 . 76794)) (
76797 83002 (FB.MAKECOUNTERWINDOW 76807 . 77673) (FB.COUNTERW.REDISPLAYFN 77675 . 77938) (
FB.UPDATE.COUNTERS 77940 . 79592) (FB.DISPLAY.COUNTERS 79594 . 82739) (FB.COUNTER.STRING 82741 . 83000
)) (83003 85516 (FB.MAKEHEADINGWINDOW 83013 . 84013) (FB.HEADINGW.REDISPLAYFN 84015 . 84274) (
FB.HEADINGW.RESHAPEFN 84276 . 84707) (FB.HEADINGW.DISPLAY 84709 . 85514)) (85517 90655 (FB.ICONFN 
85527 . 85891) (FB.SCROLLFN 85893 . 87022) (FB.UPDATE.HEADING.EXTENT 87024 . 87662) (
FB.INFOMENU.WHENSELECTEDFN 87664 . 88372) (FB.CLOSEFN 88374 . 88911) (FB.EXPUNGE?.MENU 88913 . 89240) 
(FB.AFTERCLOSEFN 89242 . 89621) (FB.CLOSE&EXPUNGE 89623 . 90653)) (90656 96653 (FB.FASTSEECOMMAND 
90666 . 92317) (FB.FASTSEE.ONEFILE 92319 . 93569) (FB.SEEFULLFN 93571 . 95933) (FB.SEEBUTTONFN 95935
 . 96651)))))
STOP