(FILECREATED " 8-Jan-86 23:41:04" {QV}<NOTECARDS>1.3K>RHTPATCH020.;5 14177  

      changes to:  (VARS RHTPATCH020COMS)
		   (FNS NC.NoteCardsIconButtonEventFn NC.FlashFileBrowserWin NC.OpenDatabaseFile 
			NC.CreateDatabaseFile NC.ForceDatabaseClose NC.CleanupCardObjects 
			NC.CloseDatabaseFile NC.AbortSession NC.FileBrowserOpen NC.FileBrowserClose 
			NC.FileBrowserCheckpoint NC.FileBrowserAbort NC.FileBrowserCompact 
			NC.FileBrowserInspect&Repair NC.NoteFileFromFileName)

      previous date: " 7-Jan-86 18:59:38" {QV}<NOTECARDS>1.3K>RHTPATCH020.;1)


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

(PRETTYCOMPRINT RHTPATCH020COMS)

(RPAQQ RHTPATCH020COMS ((* * The following allows Notefile ops via Bill VanMelle's new filebrowser.)
			  (* * Have to be sure that latest VanMelle filebrowser.dcom and 
			     tablebrowser.dcom are loaded.)
			  (* * This needs to be added to NOTECARDS coms near the sketch/grapher/etc. 
			     loading. When Nick moves the files to {phylum}, we'll have to update.)
			  (P (LOAD (QUOTE {ERIS}<LISPCORE>LIBRARY>TABLEBROWSER.DCOM))
			     (LOAD (QUOTE {ERIS}<LISPCORE>LIBRARY>FILEBROWSER.DCOM)))
			  (* * Redefined function for NCINTERFACE)
			  (FNS NC.NoteCardsIconButtonEventFn)
			  (* * New stuff for NCINTERFACE)
			  (GLOBALVARS NC.FileBrowserMenuItemsToRemove NC.FileBrowserMenuItemsToAdd 
				      NC.FileBrowserMenuItems NC.FileBrowserPatterns 
				      NC.FileBrowserDefaultPatterns)
			  (VARS (NC.FileBrowserMenuItemsToRemove (QUOTE (Hardcopy See Edit Load 
										  Compile)))
				(NC.FileBrowserMenuItemsToAdd
				  (QUOTE ((------- NILL 
			       "Division between FileBrowser operations and NoteFile operations.")
					  (Open NC.FileBrowserOpen "Open selected Notefiles.")
					  (Close NC.FileBrowserClose "Close selected Notefiles.")
					  (Checkpoint NC.FileBrowserCheckpoint 
					 "Checkpoint the selected Notefiles, saving dirty cards.")
					  (Abort NC.FileBrowserAbort 
			       "Aborts the selected Notefiles losing work since last checkpoint.")
					  (Compact NC.FileBrowserCompact 
						   "Compacts selected Notefiles to target files."
						   (SUBITEMS (Compact% To% Target% File 
									    NC.FileBrowserCompact 
						   "Compacts selected Notefiles to target files.")
							     (Compact% In% Place (
NC.FileBrowserCompact (QUOTE InPlace))
										 
							  "Compacts selected Notefiles in place.")))
					  (Inspect&Repair NC.FileBrowserInspect&Repair 
					    "Inspects and optionally repairs selected Notefiles."
							  (SUBITEMS (Read% Substances
								      (NC.FileBrowserInspect&Repair
									(QUOTE ReadSubstances))
								      
"Inspects and optionally repairs selected Notefiles, but reads every substance.  This slows things WAY down."
								      )))))))
			  (* * Build the menu items for notecards file browser.)
			  (INITVARS (NC.FileBrowserMenuItems (NCONC (for MenuItem in FB.MENU.ITEMS 
									 unless (FMEMB (CAR MenuItem)
										       
								  NC.FileBrowserMenuItemsToRemove)
									 collect MenuItem)
								    NC.FileBrowserMenuItemsToAdd)))
			  (INITVARS (NC.FileBrowserPatterns NIL)
				    (NC.FileBrowserDefaultPatterns (QUOTE ({DSK}*.NOTEFILE))))
			  (* * Functions called from file browser menu.)
			  (FNS NC.FileBrowserOpen NC.FileBrowserClose NC.FileBrowserCheckpoint 
			       NC.FileBrowserAbort NC.FileBrowserCompact NC.FileBrowserInspect&Repair)
			  (FNS NC.FlashFileBrowserWin)))
(* * The following allows Notefile ops via Bill VanMelle's new filebrowser.)

(* * Have to be sure that latest VanMelle filebrowser.dcom and tablebrowser.dcom are loaded.)

(* * This needs to be added to NOTECARDS coms near the sketch/grapher/etc. loading. When Nick 
moves the files to {phylum}, we'll have to update.)

(LOAD (QUOTE {ERIS}<LISPCORE>LIBRARY>TABLEBROWSER.DCOM))
(LOAD (QUOTE {ERIS}<LISPCORE>LIBRARY>FILEBROWSER.DCOM))
(* * Redefined function for NCINTERFACE)

(DEFINEQ

(NC.NoteCardsIconButtonEventFn
  (LAMBDA (Window)                                           (* rht: " 8-Jan-86 18:45")

          (* * Bring up a menu of all notefiles found in the notefiles hash array. Also allow user to open a new notefile.)



          (* * rht 1/7/86: Now handles middle button differently -
	  brings up menu of patterns and creates notefile browser for that pattern.)


    (LET (Menu Selection NoteFileMenu FileName)
         (if (MOUSESTATE MIDDLE)
	     then 

          (* * Middle button brings up a notecards file browser after user selects pattern.)


		    (SETQ Menu (create MENU
					   ITEMS ←(APPEND (UNION NC.FileBrowserPatterns 
								    NC.FileBrowserDefaultPatterns)
							    (QUOTE ((---% New% Pattern% ---(QUOTE
									   New% Pattern)
									 
							   "Make a new Notefile browser pattern."))))
					   TITLE ← "Notefile Browser Pattern"))
		    (if (EQ (SETQ Selection (MENU Menu))
				(QUOTE New% Pattern))
			then                               (* User wants to give us a new pattern.)
			       (SETQ Selection (LET ((NewPattern (NC.AskUser "New pattern? " NIL 
										 NIL T NIL T)))
						      (if NewPattern
							  then (SETQ NC.FileBrowserPatterns
								   (APPEND NC.FileBrowserPatterns
									     (LIST NewPattern))))
						  NewPattern)))
		    (if Selection
			then                               (* See if browser for that pattern already exists, 
							     else create one and stash on the NC icon's window's 
							     proplist.)
			       (OR (NC.FlashFileBrowserWin Selection Window)
				     (LET ((FileBrowserPatterns&Wins (WINDOWPROP Window
										   (QUOTE 
									 FileBrowserPatterns&Wins)))
					   (FileBrowserWin (FILEBROWSER Selection NIL
									  (BQUOTE (MENU.ITEMS
										      , 
									  NC.FileBrowserMenuItems)))))
				          (if FileBrowserPatterns&Wins
					      then (LISTPUT FileBrowserPatterns&Wins Selection 
								FileBrowserWin)
					    else (WINDOWPROP Window (QUOTE 
									 FileBrowserPatterns&Wins)
								 (LIST Selection FileBrowserWin)))))
			  )
	   else
	    (SETQ Menu
	      (create
		MENU
		ITEMS ←(BQUOTE
		  (,@(for NoteFile in (NC.ListOfNoteFiles) bind Stream FileName
			collect (LIST (CONCAT (if (AND (STREAMP (SETQ Stream
									      (fetch (NoteFile
											 Stream)
										 of NoteFile)))
								 (OPENP Stream))
							then
							 (if (WINDOWP (WFROMMENU
									    (fetch (NoteFile Menu)
									       of NoteFile)))
							     then "*"
							   else "$")
						      else "  ")
						    (FILENAMEFIELD (SETQ FileName
								       (fetch (NoteFile 
										     FullFileName)
									  of NoteFile))
								     (QUOTE NAME)))
					  NoteFile
					  (CONCAT "Open NoteFile " FileName 
						    " or bring up its menu.")))
		    ("-- Open new NoteFile --" (QUOTE OPEN)
					       
					 "Open a new notefile - you'll be prompted for the name."
					       (SUBITEMS ("Create but don't open" (QUOTE CREATE)
										  
						      "Create a new notefile, but don't open it.")))))
		))
	    (SELECTQ (SETQ Selection (MENU Menu))
		       (NIL NIL)
		       (OPEN (NC.OpenDatabaseFile))
		       (CREATE (NC.CreateDatabaseFile))
		       (if (type? NoteFile Selection)
			   then (COND
				    ((type? MENU (SETQ NoteFileMenu (fetch (NoteFile Menu)
									   of Selection)))
				      (NC.SetUpNoteFileInterface Selection))
				    ((PROGN (FLASHW PROMPTWINDOW)
					      (NC.YesP (NC.AskUser (CONCAT
									 (SETQ FileName
									   (fetch (NoteFile 
										     FullFileName)
									      of Selection))
									 " is not an open NoteFile."
									 (CHARACTER 13)
									 "Want to open it? ")
								       NIL
								       (QUOTE Yes)
								       T NIL NIL NIL T)))
				      (NC.OpenDatabaseFile FileName)))
			 else (NC.ReportError "NC.NoteCardsIconButtonEventFn"
						  (CONCAT "Notefile " Selection 
							    " is not a notefile!"))))))))
)
(* * New stuff for NCINTERFACE)

(DECLARE: DOEVAL@COMPILE DONTCOPY

(GLOBALVARS NC.FileBrowserMenuItemsToRemove NC.FileBrowserMenuItemsToAdd NC.FileBrowserMenuItems 
	    NC.FileBrowserPatterns NC.FileBrowserDefaultPatterns)
)

(RPAQQ NC.FileBrowserMenuItemsToRemove (Hardcopy See Edit Load Compile))

(RPAQQ NC.FileBrowserMenuItemsToAdd ((------- NILL 
			       "Division between FileBrowser operations and NoteFile operations.")
				       (Open NC.FileBrowserOpen "Open selected Notefiles.")
				       (Close NC.FileBrowserClose "Close selected Notefiles.")
				       (Checkpoint NC.FileBrowserCheckpoint 
					 "Checkpoint the selected Notefiles, saving dirty cards.")
				       (Abort NC.FileBrowserAbort 
			       "Aborts the selected Notefiles losing work since last checkpoint.")
				       (Compact NC.FileBrowserCompact 
						"Compacts selected Notefiles to target files."
						(SUBITEMS (Compact% To% Target% File 
									    NC.FileBrowserCompact 
						   "Compacts selected Notefiles to target files.")
							  (Compact% In% Place (NC.FileBrowserCompact
										(QUOTE InPlace))
									      
							  "Compacts selected Notefiles in place.")))
				       (Inspect&Repair NC.FileBrowserInspect&Repair 
					    "Inspects and optionally repairs selected Notefiles."
						       (SUBITEMS (Read% Substances
								   (NC.FileBrowserInspect&Repair
								     (QUOTE ReadSubstances))
								   
"Inspects and optionally repairs selected Notefiles, but reads every substance.  This slows things WAY down."
								   )))))
(* * Build the menu items for notecards file browser.)


(RPAQ? NC.FileBrowserMenuItems (NCONC (for MenuItem in FB.MENU.ITEMS unless (FMEMB (CAR MenuItem)
										     
								  NC.FileBrowserMenuItemsToRemove)
					     collect MenuItem)
					NC.FileBrowserMenuItemsToAdd))

(RPAQ? NC.FileBrowserPatterns NIL)

(RPAQ? NC.FileBrowserDefaultPatterns (QUOTE ({DSK}*.NOTEFILE)))
(* * Functions called from file browser menu.)

(DEFINEQ

(NC.FileBrowserOpen
  (LAMBDA (Browser Key Item Menu)                            (* rht: " 8-Jan-86 11:36")

          (* * Function called from file browser menu for notefile open.)


    (for FileObject in (FB.SELECTEDFILES Browser) do (NC.OpenDatabaseFile
							       (MKATOM (FB.FETCHFILENAME 
										       FileObject)))))
)

(NC.FileBrowserClose
  (LAMBDA (Browser Key Item Menu)                            (* rht: " 8-Jan-86 12:10")

          (* * Function called from file browser menu for notefile close.)


    (for FileObject in (FB.SELECTEDFILES Browser)
       do (LET* ((FileName (MKATOM (FB.FETCHFILENAME FileObject)))
		   (NoteFile (NC.NoteFileFromFileName FileName)))
	          (if (type? NoteFile NoteFile)
		      then (NC.CloseDatabaseFile NoteFile)
		    else (NC.PrintMsg NIL NIL FileName " is not an open NoteFile!!!"
					  (CHARACTER 13)))))))

(NC.FileBrowserCheckpoint
  (LAMBDA (Browser Key Item Menu)                            (* rht: " 8-Jan-86 12:10")

          (* * Function called from file browser menu for notefile checkpoint.)


    (for FileObject in (FB.SELECTEDFILES Browser)
       do (LET* ((FileName (MKATOM (FB.FETCHFILENAME FileObject)))
		   (NoteFile (NC.NoteFileFromFileName FileName)))
	          (if (type? NoteFile NoteFile)
		      then (NC.CheckpointDatabase NoteFile)
		    else (NC.PrintMsg NIL NIL FileName " is not an open NoteFile!!!"
					  (CHARACTER 13)))))))

(NC.FileBrowserAbort
  (LAMBDA (Browser Key Item Menu)                            (* rht: " 8-Jan-86 12:10")

          (* * Function called from file browser menu for notefile abort.)


    (for FileObject in (FB.SELECTEDFILES Browser)
       do (LET* ((FileName (MKATOM (FB.FETCHFILENAME FileObject)))
		   (NoteFile (NC.NoteFileFromFileName FileName)))
	          (if (type? NoteFile NoteFile)
		      then (NC.AbortSession NoteFile)
		    else (NC.PrintMsg NIL NIL FileName " is not an open NoteFile!!!"
					  (CHARACTER 13)))))))

(NC.FileBrowserCompact
  (LAMBDA (Browser Key Item Menu InPlaceFlg)                 (* rht: " 8-Jan-86 11:37")

          (* * Function called from file browser menu for notefile compact.)


    (for FileObject in (FB.SELECTEDFILES Browser) do (NC.CompactNoteFile
							       (MKATOM (FB.FETCHFILENAME 
										       FileObject))
							       NIL InPlaceFlg))))

(NC.FileBrowserInspect&Repair
  (LAMBDA (Browser Key Item Menu ReadSubstancesFlg)          (* rht: " 8-Jan-86 11:37")

          (* * Function called from file browser menu for notefile inspect&repair.)


    (for FileObject in (FB.SELECTEDFILES Browser) do (NC.ScavengerPhase1
							       (MKATOM (FB.FETCHFILENAME 
										       FileObject))
							       ReadSubstancesFlg))))
)
(DEFINEQ

(NC.FlashFileBrowserWin
  (LAMBDA (Pattern NoteCardsIconWindow)                      (* rht: " 8-Jan-86 18:35")

          (* * Return the file browser window if any, corresponding to given pattern. Expand if shrunken and flash.)


    (LET ((FileBrowserWin (LISTGET (WINDOWPROP NoteCardsIconWindow (QUOTE 
									 FileBrowserPatterns&Wins))
				     Pattern))
	  IconWin)
         (if FileBrowserWin
	     then (if (OPENWP (SETQ IconWin (WINDOWPROP FileBrowserWin (QUOTE ICONWINDOW))
				      ))
			then (EXPANDW IconWin))
		    (FLASHW FileBrowserWin))
     FileBrowserWin)))
)
(PUTPROPS RHTPATCH020 COPYRIGHT ("Xerox Corporation" 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (3972 8367 (NC.NoteCardsIconButtonEventFn 3982 . 8365)) (10381 13438 (NC.FileBrowserOpen
 10391 . 10765) (NC.FileBrowserClose 10767 . 11375) (NC.FileBrowserCheckpoint 11377 . 11996) (
NC.FileBrowserAbort 11998 . 12601) (NC.FileBrowserCompact 12603 . 13010) (NC.FileBrowserInspect&Repair
 13012 . 13436)) (13439 14095 (NC.FlashFileBrowserWin 13449 . 14093)))))
STOP