(DEFINE-FILE-INFO PACKAGE "IL" READTABLE "INTERLISP" BASE 10)
(FILECREATED "12-Jan-88 13:54:52" {QV}<NOTECARDS>1.3LNEXT>PMIPATCH066.;3 60801  

      changes to%:  (FNS NCCollab.OpenNoteFileFn NCHist.AddHistoryCard NCHist.ComputeHistory)
                    (VARS PMIPATCH066COMS)

      previous date%: "17-Dec-87 11:02:14" {QV}<NOTECARDS>1.3KNEXT>PMIPATCH066.;40)


(* "
Copyright (c) 1987, 1988 by Xerox Corporation.  All rights reserved.
")

(PRETTYCOMPRINT PMIPATCH066COMS)

(RPAQQ PMIPATCH066COMS 
       ((DECLARE%: DONTCOPY (PROPS (PMIPATCH066 MAKEFILE-ENVIRONMENT)
                                   (PMIPATCH066 FILETYPE)))
        

(* ;;; "The coms for NCCOLLABORATION, NCCOLLABORATORCARD, and NCHISTORYCARD should be changed to use NC.LoadFileFromDirectories like this:")

        [DECLARE%: COPY FIRST (P (NC.LoadFileFromDirectories 'NCCOLLABORATORCARD)
                                 (NC.LoadFileFromDirectories 'NCHISTORYCARD)
                                 (NC.LoadFileFromDirectories 'NCLOGGER)
                                 (NC.LoadFileFromDirectories 'PMIPATCH067]
        

(* ;;; "New for NCPROGINT")

        (FNS NCP.CoerceToInterestedWindow NCP.NewCardP NCP.NoteFileAddProp)
        

(* ;;; "Changed in NCHISTORYCARD")

        (FNS NCHist.AddHistoryCard NCHist.HistoryCardMakeFn NCHist.HistoryCardWhenSavedFn 
             NCHist.NoteFileWhenOpenedFn NCHist.HistoricizeNoteFile NCHist.CreateHistoryCardTitle)
        

(* ;;; "New in NCHISTORYCARD")

        (RECORDS EventCategory)
        (GLOBALVARS NCHist.HistoryEventsSpecsStylesheet NCHist.HistoryEventHashArray 
               NCHist.LogEventFnHashArray NCHist.HistoryLinkType NCHist.EventCategories 
               NCHist.CardEvents NCHist.CreateLinkEvents NCHist.DeleteLinkEvents NCHist.BrowserEvents 
               NCHist.CardTypeEvents)
        (VARS (NCHist.HistoryLinkType 'History)
              (NCHist.HistoryEventHashArray (HASHARRAY NCLOG.HashArraySize))
              (NCHist.LogEventFnHashArray (HASHARRAY NCLOG.HashArraySize))
              (NCHist.CardEvents (create EventCategory Name ← 'Card% Events MenuItems ←
                                        '(Create% Card |Bring Up Card| Close% Card 
                                                |Change Card Substance| |Change Card Prop List| 
                                                |Change Card Title| Delete% Card) MenuItemsFn ← NIL 
                                        DefaultMenuItems ← '(Create% Card |Change Card Substance| 
                                                                   |Change Card Title| Delete% Card) 
                                        DefaultMenuItemsFn ← NIL MenuChoicesFn ← NIL))
              (NCHist.CreateLinkEvents (create EventCategory Name ← '|Create Link Events| MenuItems ← 
                                              NIL MenuItemsFn ← (FUNCTION 
                                                                   NCHist.CreateLinkEventsMenuItemsFn
                                                                       )
                                              DefaultMenuItems ← NIL DefaultMenuItemsFn ←
                                              (FUNCTION NCHist.CreateLinkEventsDefaultMenuChoicesFn)
                                              MenuChoicesFn ← (FUNCTION 
                                                                 NCHist.CreateLinkEventsMenuChoicesFn
                                                                     )))
              (NCHist.DeleteLinkEvents (create EventCategory Name ← '|Delete Link Events| MenuItems ← 
                                              NIL MenuItemsFn ← (FUNCTION 
                                                                   NCHist.DeleteLinkEventsMenuItemsFn
                                                                       )
                                              DefaultMenuItems ← NIL DefaultMenuItemsFn ←
                                              (FUNCTION NCHist.DeleteLinkEventsDefaultMenuChoicesFn)
                                              MenuChoicesFn ← (FUNCTION 
                                                                 NCHist.DeleteLinkEventsMenuChoicesFn
                                                                     )))
              (NCHist.BrowserEvents (create EventCategory Name ← 'Browser% Events MenuItems ←
                                           '(Recompute% Browser Relayout% Browser) MenuItemsFn ← NIL 
                                           DefaultMenuItems ← '(Recompute% Browser) 
                                           DefaultMenuItemsFn ← NIL MenuChoicesFn ← NIL))
              (NCHist.CardTypeEvents (create EventCategory Name ← '|Card Type Events| MenuItems ←
                                            '(|Add Card Type|) MenuItemsFn ← NIL DefaultMenuItems ← 
                                            NIL DefaultMenuItemsFn ← NIL MenuChoicesFn ← NIL))
              (NCHist.EventCategories (LIST NCHist.CardEvents NCHist.CreateLinkEvents 
                                            NCHist.DeleteLinkEvents NCHist.BrowserEvents 
                                            NCHist.CardTypeEvents)))
        

(* ;;; "General automated history card functions")

        (FNS NCHist.CreateHistoryDate NCHist.ComputeHistory NCHist.GetLogEventFromStream 
             NCHist.ProcessLogEvent NCHist.ChangeHistoryEventSpecs NCHist.AskHistoryEventSpecs 
             NCHist.InitializeHistoryEventsSpecsStylesheet NCHist.InitializeHistoryEventHashArray 
             NCHist.InitializeLogEventFnHashArray NCHist.ConvertPointersToLinks NCHist.TurnLoggingOn 
             NCHist.TurnLoggingOff)
        

(* ;;; "Fns for the various event category functions")

        (FNS NCHist.CreateLinkEventsMenuItemsFn NCHist.CreateLinkEventsDefaultMenuChoicesFn 
             NCHist.CreateLinkEventsMenuChoicesFn NCHist.DeleteLinkEventsMenuItemsFn 
             NCHist.DeleteLinkEventsDefaultMenuChoicesFn NCHist.DeleteLinkEventsMenuChoicesFn)
        

(* ;;; "Fns called to display the events in the History Card")

        (FNS NCHist.EditCard.BeginDisplayFn NCHist.EditCard.EndDisplayFn 
             NCHist.QuitCard.BeginDisplayFn NCHist.QuitCard.EndDisplayFn 
             NCHist.MakeCard.BeginDisplayFn NCHist.MakeCard.EndDisplayFn NCHist.GetNewCardDisplayFn 
             NCHist.DelCardDisplayFn NCHist.CacheCardDisplayFn NCHist.UncacheCardDisplayFn 
             NCHist.SaveCard.BeginDisplayFn NCHist.SaveCard.EndDisplayFn NCHist.PutLinksDisplayFn 
             NCHist.PutMainCardDataDisplayFn NCHist.PutPropListDisplayFn NCHist.PutTitleDisplayFn 
             NCHist.AssignTitle.BeginDisplayFn NCHist.AssignTitle.EndDisplayFn 
             NCHist.MakeLinkDisplayFn NCHist.DelLinkDisplayFn NCHist.RecomputeBrowser.BeginDisplayFn 
             NCHist.RecomputeBrowser.EndDisplayFn NCHist.RelayoutBrowser.BeginDisplayFn 
             NCHist.RelayoutBrowser.EndDisplayFn NCHist.AddCardTypeDisplayFn 
             NCHist.StartLoggingDisplayFn)
        (P (NCHist.InitializeHistoryEventsSpecsStylesheet)
           (NCHist.InitializeHistoryEventHashArray)
           (NCHist.InitializeLogEventFnHashArray))
        

(* ;;; "Changed in NCCOLLABORATION")

        (FNS NCCollab.OpenNoteFileFn)
        

(* ;;; "Add this expression to the end of the file coms for NCCOLLABORATION")

        (P (NCP.AddSessionIconMenuItem 'NoteFile '(| Collaboratize | NCCollab.CollaboratizeNoteFile 
                                                         "Collaboratizes a notefile."))
           (NCP.AddNoteFileIconMenuItem '(Collaboratize NCCollab.CollaboratizeNoteFile 
                                                "Collaboratizes a notefile.") 'Open))
        

(* ;;; "New for NCDATABASE")

        (FNS NC.NoteFileFromUID)
        

(* ;;; "Install the altered History card type")

        (P (NCHist.AddHistoryCard))))
(DECLARE%: DONTCOPY 

(PUTPROPS PMIPATCH066 MAKEFILE-ENVIRONMENT (:PACKAGE "IL" :READTABLE "INTERLISP" :BASE 10))

(PUTPROPS PMIPATCH066 FILETYPE :TCOMPL)
)



(* ;;; 
"The coms for NCCOLLABORATION, NCCOLLABORATORCARD, and NCHISTORYCARD should be changed to use NC.LoadFileFromDirectories like this:"
)

(DECLARE%: COPY FIRST 
(NC.LoadFileFromDirectories 'NCCOLLABORATORCARD)
(NC.LoadFileFromDirectories 'NCHISTORYCARD)
(NC.LoadFileFromDirectories 'NCLOGGER)
(NC.LoadFileFromDirectories 'PMIPATCH067)
)



(* ;;; "New for NCPROGINT")

(DEFINEQ

(NCP.CoerceToInterestedWindow
  [LAMBDA (WinOrCardOrNoteFile)                              (* pmi%: "21-Oct-87 15:56")
          
          (* * pmi 10/21/87%: Created to give prog int users the ability to get a 
          reasonable window from various inputs.)

    (NC.CoerceToInterestedWindow WinOrCardOrNoteFile])

(NCP.NewCardP
  [LAMBDA (Card)                                             (* pmi%: "21-Oct-87 15:54")
          
          (* * pmi 10/21/87%: First created. Allows prog int users to tell if a card has 
          been saved yet.)

    (NC.FetchNewCardFlg Card])

(NCP.NoteFileAddProp
  [LAMBDA (NoteFile PROP NEWVALUE)                           (* pmi%: "23-Oct-87 15:02")
          
          (* * Prog. int. way into NC.NoteFileAddProp.)

    (NC.NoteFileAddProp NoteFile PROP NEWVALUE])
)



(* ;;; "Changed in NCHISTORYCARD")

(DEFINEQ

(NCHist.AddHistoryCard
  [LAMBDA NIL                                                (* ; "Edited 12-Jan-88 12:34 by pmi:")
          
          (* * Add History card type to card type list)
          
          (* * pmi 10/22/87%: Added left button items.)

    (NCP.CreateCardType 'History 'Text `[(MakeFn ,(FUNCTION NCHist.HistoryCardMakeFn]
           `((DisplayedInMenuFlg T)
             (LeftButtonMenuItems ,(APPEND (NC.GetCardTypeField LeftButtonMenuItems 'Text)
                                          '(("----------" (FUNCTION NULL))
                                            (Compute% History (FUNCTION NCHist.ComputeHistory)
                                                   "Computes a history from the current log file.")
                                            (|Change History Event Specs| (FUNCTION 
                                                                       NCHist.ChangeHistoryEventSpecs
                                                                           )
                                                   "Change event specs used to compute a history.")
                                            (|Convert Pointers to Links| (FUNCTION 
                                                                        NCHist.ConvertPointersToLinks
                                                                          )
                                                   "Converts all pointer icons to real links."])

(NCHist.HistoryCardMakeFn
  [LAMBDA (Card Title NoDisplayFlg)                          (* pmi%: "17-Dec-87 10:44")
          
          (* * pmi 10/29/87%: Now turns on logging.)

    (DECLARE (GLOBALVARS NCHist.EventCategories))
    (LET ((NoteFile (NCP.CardNoteFile Card))
          ReturnValue HistoryFileBox DateString)
          
          (* * If one doesn't exist, create a NoteFile use history filebox, otherwise 
          find the old one.)

         (SETQ HistoryFileBox (NCHist.GetHistoryFileBox NoteFile))
          
          (* * Create a text card, then give it a title and file it)

         (SETQ ReturnValue (NCP.ApplySuperTypeFn MakeFn Card Title NoDisplayFlg))
          
          (* Cache the history filebox so that NCP.FileCards won't have to close it.)

         (OR (NCP.CardCachedP HistoryFileBox)
             (NCP.CacheCards HistoryFileBox))
         (NCP.FileCards Card HistoryFileBox)
         (NCP.CardTitle Card (OR Title (NCHist.CreateHistoryCardTitle Card)))
         (NC.NoteFileAddProp NoteFile 'HistoryCards Card)
          
          (* * Put the start time in the beginning of the card's substance in bold face.)

         (SETQ DateString (CONCAT (DATE (DATEFORMAT NO.DATE NO.SECONDS))
                                 " - "))
         (NCP.CardAddText Card (CONCAT DateString (CHARACTER 13))
                'START)
         (TEDIT.LOOKS (NCP.CardSubstance Card)
                '(WEIGHT BOLD) 1 (NCHARS DateString))        (* Turn on logging for automated 
                                                             History cards.)
         (NCP.CardUserDataProp Card 'NCLogInfo (NCLOG.StartLogging NoteFile))
         (NCP.CardUserDataProp Card 'HistoryEventSpecs
                (for EventCategory in NCHist.EventCategories bind CategoryChoices DefaultMenuItemsFn 
                                                                  MenuChoicesFn
                   collect (SETQ CategoryChoices (if (fetch (EventCategory DefaultMenuItems)
                                                        of EventCategory)
                                                   elseif (SETQ DefaultMenuItemsFn
                                                           (fetch (EventCategory DefaultMenuItemsFn)
                                                              of EventCategory))
                                                     then (APPLY* DefaultMenuItemsFn NoteFile)))
                         (if (SETQ MenuChoicesFn (fetch (EventCategory MenuChoicesFn) of 
                                                                                        EventCategory
                                                        ))
                             then (APPLY* MenuChoicesFn CategoryChoices Card NoteFile)
                           else CategoryChoices)))
         ReturnValue])

(NCHist.HistoryCardWhenSavedFn
  [LAMBDA (HistoryCard)                                      (* edited%: "16-Dec-87 12:06")
          
          (* * QuitFn for the History card type. Delete old close time from the History 
          card and insert the current close time in its place.
          Only do this for "current" history cards, i.e.
          ones opened during this session.)

    (if (for Card in (NCP.NoteFileProp (NCP.CardNoteFile HistoryCard)
                            'HistoryCards) when (NCP.ValidCardP Card) thereis (NCP.SameCardP Card 
                                                                                     HistoryCard))
        then (LET ((Stream (NCP.CardSubstance HistoryCard))
                   Time AfterDashPosition CRPosition)
                  [SETQ Time (CONCAT " " (DATE (DATEFORMAT NO.DATE NO.SECONDS]
                  (SETQ AfterDashPosition (ADD1 (TEDIT.FIND Stream "-" 1)))
                  (SETQ CRPosition (TEDIT.FIND Stream (CHARACTER 13)
                                          1))
                  (TEDIT.DELETE Stream AfterDashPosition (IDIFFERENCE CRPosition AfterDashPosition))
                  (NCP.CardAddText HistoryCard Time AfterDashPosition)
                  (TEDIT.LOOKS (NCP.CardSubstance HistoryCard)
                         '(WEIGHT BOLD) AfterDashPosition (NCHARS Time])

(NCHist.NoteFileWhenOpenedFn
  [LAMBDA (NoteFile)                                         (* pmi%: "19-Nov-87 12:41")
          
          (* * Function to be called when we open a NoteFile that has been "Historitized." 
          Creates and opens a new History card for this session)
          
          (* * rht 2/4/87%: Now calls NCP.CreateCard with NoDisplayFlg NIL.)
          
          (* * pmi 10/22/87%: Now places new History card at
          (0, 0) if NCHist.HistoryCardPosition is not set.)

    (DECLARE (GLOBALVARS NCHist.HistoryCardPosition))
    (LET (HistoryCard)
         (NCHist.GetHistoryFileBox NoteFile)
         (NCP.OpenCard (SETQ HistoryCard (NCP.CreateCard 'History NoteFile NIL T))
                (OR NCHist.HistoryCardPosition (SETQ NCHist.HistoryCardPosition
                                                (create POSITION
                                                       XCOORD ← 0
                                                       YCOORD ← 0])

(NCHist.HistoricizeNoteFile
  [LAMBDA (NoteFile)                                         (* rht%: "29-Jun-87 17:03")
          
          (* * Initialize given notefile for History Card use.
          Make a History Use Filebox if none exists and register in the notefile.
          Hang a call to NCHist.NoteFileWhenOpenedFn in the OpenEventsCard for the 
          notefile.)
          
          (* * rht 4/19/87%: Now calls NC.LoadFileFromDirectories rather than FILESLOAD.)

    (if (NCP.OpenNoteFileP NoteFile)
        then (LET ([OpenEventSExp '(PROGN (NC.LoadFileFromDirectories 'NCHISTORYCARD)
                                          (NCHist.NoteFileWhenOpenedFn NoteFile]
                   (OpenEventsCard (NCP.GetOpenEventsCard NoteFile))
                   OpenEventsCardWasCachedFlg)
          
          (* * Add call to NCHist.NoteFileWhenOpenedFn to the open events card substance.)

                  (if (NOT (SETQ OpenEventsCardWasCachedFlg (NCP.ActiveCardP OpenEventsCard)))
                      then (NCP.CacheCards OpenEventsCard))
                  [if (NOT (MEMBER OpenEventSExp (NCP.CardSubstance OpenEventsCard)))
                      then (NCP.CardSubstance OpenEventsCard (CONS OpenEventSExp (NCP.CardSubstance
                                                                                  OpenEventsCard]
                  (if (NOT OpenEventsCardWasCachedFlg)
                      then (NCP.CloseCards OpenEventsCard))
          
          (* * Run the history OpenNoteFileFn now.)

                  (NCHist.NoteFileWhenOpenedFn NoteFile))
      else (NCP.ReportError "NCHist.HistoritizeNoteFile" (CONCAT 
                                                                "Can't historitize closed notefile: " 
                                                                NoteFile])

(NCHist.CreateHistoryCardTitle
  [LAMBDA (Card)                                             (* pmi%: "14-Dec-87 12:06")
          
          (* * Creates title for history card consisting of date and initials.)

    (CONCAT (NCHist.CreateHistoryDate)
           " "
           (NCP.NoteFileProp (NCP.CardNoteFile Card)
                  'Initials])
)



(* ;;; "New in NCHISTORYCARD")

(DECLARE%: EVAL@COMPILE

(DATATYPE EventCategory (Name MenuItems MenuItemsFn DefaultMenuItems DefaultMenuItemsFn MenuChoicesFn
                              ))
)
(/DECLAREDATATYPE 'EventCategory '(POINTER POINTER POINTER POINTER POINTER POINTER)
       '((EventCategory 0 POINTER)
         (EventCategory 2 POINTER)
         (EventCategory 4 POINTER)
         (EventCategory 6 POINTER)
         (EventCategory 8 POINTER)
         (EventCategory 10 POINTER))
       '12)
(DECLARE%: DOEVAL@COMPILE DONTCOPY

(GLOBALVARS NCHist.HistoryEventsSpecsStylesheet NCHist.HistoryEventHashArray 
       NCHist.LogEventFnHashArray NCHist.HistoryLinkType NCHist.EventCategories NCHist.CardEvents 
       NCHist.CreateLinkEvents NCHist.DeleteLinkEvents NCHist.BrowserEvents NCHist.CardTypeEvents)
)

(RPAQQ NCHist.HistoryLinkType History)

(RPAQ NCHist.HistoryEventHashArray (HASHARRAY NCLOG.HashArraySize))

(RPAQ NCHist.LogEventFnHashArray (HASHARRAY NCLOG.HashArraySize))

(RPAQ NCHist.CardEvents (create EventCategory Name ← 'Card% Events MenuItems ←
                               '(Create% Card |Bring Up Card| Close% Card |Change Card Substance| 
                                       |Change Card Prop List| |Change Card Title| Delete% Card) 
                               MenuItemsFn ← NIL DefaultMenuItems ← '(Create% Card 
                                                                            |Change Card Substance| 
                                                                            |Change Card Title| 
                                                                            Delete% Card) 
                               DefaultMenuItemsFn ← NIL MenuChoicesFn ← NIL))

(RPAQ NCHist.CreateLinkEvents (create EventCategory Name ← '|Create Link Events| MenuItems ← NIL 
                                     MenuItemsFn ← (FUNCTION NCHist.CreateLinkEventsMenuItemsFn)
                                     DefaultMenuItems ← NIL DefaultMenuItemsFn ←
                                     (FUNCTION NCHist.CreateLinkEventsDefaultMenuChoicesFn)
                                     MenuChoicesFn ← (FUNCTION NCHist.CreateLinkEventsMenuChoicesFn)))

(RPAQ NCHist.DeleteLinkEvents (create EventCategory Name ← '|Delete Link Events| MenuItems ← NIL 
                                     MenuItemsFn ← (FUNCTION NCHist.DeleteLinkEventsMenuItemsFn)
                                     DefaultMenuItems ← NIL DefaultMenuItemsFn ←
                                     (FUNCTION NCHist.DeleteLinkEventsDefaultMenuChoicesFn)
                                     MenuChoicesFn ← (FUNCTION NCHist.DeleteLinkEventsMenuChoicesFn)))

(RPAQ NCHist.BrowserEvents (create EventCategory Name ← 'Browser% Events MenuItems ←
                                  '(Recompute% Browser Relayout% Browser) MenuItemsFn ← NIL 
                                  DefaultMenuItems ← '(Recompute% Browser) DefaultMenuItemsFn ← NIL 
                                  MenuChoicesFn ← NIL))

(RPAQ NCHist.CardTypeEvents (create EventCategory Name ← '|Card Type Events| MenuItems ←
                                   '(|Add Card Type|) MenuItemsFn ← NIL DefaultMenuItems ← NIL 
                                   DefaultMenuItemsFn ← NIL MenuChoicesFn ← NIL))

(RPAQ NCHist.EventCategories (LIST NCHist.CardEvents NCHist.CreateLinkEvents NCHist.DeleteLinkEvents 
                                   NCHist.BrowserEvents NCHist.CardTypeEvents))



(* ;;; "General automated history card functions")

(DEFINEQ

(NCHist.CreateHistoryDate
  [LAMBDA (Card)                                             (* pmi%: "14-Dec-87 12:06")
          
          (* * Creates date for history card.)

    (LET [(SystemDate (DATE (DATEFORMAT NO.TIME NUMBER.OF.MONTH]
         (CONCAT (NCHist.ShaveLeadingSpace (SUBSTRING SystemDate 4 5))
                "/"
                (NCHist.ShaveLeadingSpace (SUBSTRING SystemDate 1 2))
                "/"
                (NCHist.ShaveLeadingSpace (SUBSTRING SystemDate 7 8])

(NCHist.ComputeHistory
  [LAMBDA (Window)                                           (* ; "Edited 12-Jan-88 12:34 by pmi:")
          
          (* * Computes stuff for History card.)

    (DECLARE (GLOBALVARS NCHist.HistoryEventHashArray NCHist.HistoryLinkType))
    (PROG ((HistoryCard (NCP.CoerceToCard Window))
           NoteFile NCLogInfo ActiveCards)
          (SETQ NoteFile (NCP.CardNoteFile HistoryCard))
          (SETQ NCLogInfo (NCP.CardUserDataProp HistoryCard 'NCLogInfo))
          (SETQ ActiveCards (NC.MapCards NoteFile [FUNCTION (LAMBDA (Card)
                                                              Card]
                                   (FUNCTION NC.ActiveCardP)))
          
          (* * Warn the user about changes to unsaved cards not being logged until a 
          checkpoint is done.)

          (if [for ActiveCard in ActiveCards thereis (AND (NC.CardDirtyP ActiveCard)
                                                          (NEQ ActiveCard (fetch (NoteFile 
                                                                                       LinkLabelsCard
                                                                                        )
                                                                             of NoteFile))
                                                          (NEQ ActiveCard (fetch (NoteFile 
                                                                                        RegistryCard)
                                                                             of NoteFile))
                                                          (NEQ ActiveCard (NCP.LookupCardByName
                                                                           'OpenEventsCard NoteFile]
              then (SELECTQ (NC.AskUserWithMenu '(Yes No Cancel) (CONCAT 
                                "Warning - information about cards not yet saved will not be logged."
                                                                        (CHARACTER 13)
                                                                        
                                                               "Checkpoint before computing history?"
                                                                        )
                                   Window NIL T)
                       (Yes (NCP.CheckpointNoteFiles NoteFile))
                       (No)
                       (Cancel (RETURN NIL))
                       (RETURN NIL)))
          (RETURN (RESETLST
                   [RESETSAVE `(NCLOG.SuspendLogging ,NoteFile ,NCLogInfo) `(NCLOG.StartLogging
                                                                             ,NoteFile
                                                                             ,NCLogInfo]
                   (LET (LoggingStream SectionEndPtr SectionPtrs HistoryEventTypes)
                        (SETQ LoggingStream (fetch (NCLogInfo LoggingStream) of NCLogInfo))
                        (SETQ SectionEndPtr (GETEOFPTR LoggingStream))
                        (SETQ SectionPtrs (NCP.CardUserDataProp HistoryCard 'SectionPtrs))
          
          (* * Compute history for current section if it has not already been computed.)

                        (if (NOT (NCP.ValidLinkTypeP NCHist.HistoryLinkType NoteFile))
                            then (NCP.CreateLinkType NCHist.HistoryLinkType NoteFile))
                        (if (NOT (FMEMB SectionEndPtr SectionPtrs))
                            then (if SectionPtrs
                                     then (SETQ SectionStartPtr (CAR (LAST SectionPtrs)))
                                   else (SETQ SectionStartPtr 0))
                                 (SETQ SectionPtrs (NCONC1 SectionPtrs SectionEndPtr))
                                 (NCP.CardUserDataProp HistoryCard 'SectionPtrs SectionPtrs)
                                 (SETQ HistoryEventTypes) 
          
          (* * Gather up all of the events to be logged for this History card.
          They are stored on the History card, as separate lists for each event category.)

                                 [for HistoryEventList in (NCP.CardUserDataProp HistoryCard
                                                                 'HistoryEventSpecs)
                                    do (for HistoryEventType in HistoryEventList
                                          do (SETQ HistoryEventTypes (APPEND (MKLIST (GETHASH 
                                                                                     HistoryEventType 
                                                                         NCHist.HistoryEventHashArray
                                                                                            ))
                                                                            HistoryEventTypes]
                                 (SETFILEPTR LoggingStream SectionStartPtr)
                                 (while (NOT (EOFP LoggingStream)) first (SKIPSEPRS LoggingStream)
                                    finally (NCP.CardAddText HistoryCard
                                                   (CONCAT (CHARACTER 13)
                                                          "--- "
                                                          (DATE (DATEFORMAT NO.DATE NO.SECONDS))
                                                          " ---"
                                                          (CHARACTER 13)
                                                          (CHARACTER 13))
                                                   'END) do (NCHist.GetLogEventFromStream 
                                                                   LoggingStream HistoryEventTypes 
                                                                   HistoryCard])

(NCHist.GetLogEventFromStream
  [LAMBDA (Stream HistoryEventTypes HistoryCard)             (* pmi%: " 2-Dec-87 11:39")
    (LET (LogEvent EventType)
         (SKIPSEPRS Stream)
         [if (NOT (EOFP Stream))
             then (SETQ LogEvent (READ Stream))
                  (SETQ EventType (CAR LogEvent))
                  (if (FMEMB EventType HistoryEventTypes)
                      then (APPLY (GETHASH EventType NCHist.LogEventFnHashArray)
                                  (CONS HistoryCard (CDR LogEvent]
         LogEvent])

(NCHist.ProcessLogEvent
  [LAMBDA (HistoryCard EventType EventTypeArgs)              (* pmi%: "23-Nov-87 12:15")
    (DECLARE (GLOBALVARS NCLOG.UIDHashArray NCHist.LogEventFnHashArray))
    (APPLY (GETHASH EventType NCHist.LogEventFnHashArray)
           (CONS HistoryCard EventTypeArgs])

(NCHist.ChangeHistoryEventSpecs
  [LAMBDA (Window)                                           (* pmi%: " 2-Dec-87 10:51")
          
          (* * Change the values of the various History event specs)

    (LET ((Card (NCP.CoerceToCard Window)))
         (NC.ProtectedCardOperation Card "History Event Specs" NIL (PROG (HistoryEventSpecs)
                                                                         (SETQ HistoryEventSpecs
                                                                          (
                                                                          NCHist.AskHistoryEventSpecs
                                                                           Window Card))
          
          (* * NC.SetPropListDirtyFlg Card T)

                                                                         (NCP.CardUserDataProp
                                                                          Card
                                                                          'HistoryEventSpecs 
                                                                          HistoryEventSpecs)
                                                                         (NC.ClearMsg Window T])

(NCHist.AskHistoryEventSpecs
  [LAMBDA (MainWindow HistoryCard)                           (* edited%: "15-Dec-87 09:17")
          
          (* * Puts up a stylesheet asking user about events, link types, etc.
          over which to compute the next history. The stylesheet returns a list of n 
          things%: %.)

    (DECLARE (GLOBALVARS NCHist.HistoryEventsSpecsStylesheet NCHist.EventCategories NC.MenuFont))
    (PROG (NoteFile OldEvents Position Choices)
          (SETQ NoteFile (NCP.CardNoteFile HistoryCard))
          (SETQ OldEvents (NCP.CardUserDataProp HistoryCard 'DefaultHistoryEventSpecs))
          (if NCHist.HistoryEventsSpecsStylesheet
            else (NCHist.InitializeHistoryEventsSpecsStylesheet))
          [SETQ Position (AND (WINDOWP MainWindow)
                              (create POSITION
                                     XCOORD ← (fetch (REGION LEFT) of (WINDOWPROP MainWindow
                                                                             'REGION))
                                     YCOORD ← (fetch (REGION TOP) of (WINDOWREGION MainWindow]
          
          (* The stylesheet is in a global var. We only need to provide its position, 
          items, and selections.)

          (STYLE.PROP NCHist.HistoryEventsSpecsStylesheet 'POSITION Position)
          (STYLE.PROP NCHist.HistoryEventsSpecsStylesheet 'ITEMS
                 (for EventCategory in NCHist.EventCategories
                    collect (create MENU
                                   ITEMS ← (if (fetch (EventCategory MenuItems) of EventCategory)
                                             else (APPLY* (fetch (EventCategory MenuItemsFn)
                                                             of EventCategory)
                                                         NoteFile))
                                   MENUFONT ← NC.MenuFont)))
          [STYLE.PROP NCHist.HistoryEventsSpecsStylesheet 'SELECTIONS
                 (OR OldEvents (for EventCategory in NCHist.EventCategories bind DefaultMenuItemsFn
                                  collect (if (fetch (EventCategory DefaultMenuItems) of 
                                                                                        EventCategory
                                                     )
                                            elseif (SETQ DefaultMenuItemsFn (fetch (EventCategory
                                                                                    
                                                                                   DefaultMenuItemsFn
                                                                                    ) of 
                                                                                        EventCategory
                                                                                   ))
                                              then (APPLY* DefaultMenuItemsFn NoteFile]
          (if (SETQ Choices (STYLESHEET NCHist.HistoryEventsSpecsStylesheet))
              then (NCP.CardUserDataProp HistoryCard 'DefaultHistoryEventSpecs Choices)
                   (RETURN (for CategoryChoices in Choices as EventCategory in NCHist.EventCategories
                              bind MenuChoicesFn collect (if (SETQ MenuChoicesFn (fetch (
                                                                                        EventCategory
                                                                                         
                                                                                        MenuChoicesFn
                                                                                         )
                                                                                    of EventCategory)
                                                              )
                                                             then (APPLY* MenuChoicesFn 
                                                                         CategoryChoices HistoryCard 
                                                                         NoteFile)
                                                           else CategoryChoices)))
            else (RETURN OldEvents])

(NCHist.InitializeHistoryEventsSpecsStylesheet
  [LAMBDA NIL                                                (* pmi%: " 2-Dec-87 11:20")
          
          (* * pmi 10/30/87%: Build a stylesheet for the History Event Specs, using the 
          events stored by category in the ASSOC list NCLOG.ListOfEventTypes.)

    (DECLARE (GLOBALVARS NCHist.HistoryEventsSpecsStylesheet NCHist.EventCategories NC.MenuFont))
    (LET (NumCategories)
         (SETQ NumCategories (LENGTH NCHist.EventCategories))
         (SETQ NCHist.HistoryEventsSpecsStylesheet (CREATE.STYLE 'ITEMS
                                                          (from 1 to NumCategories
                                                             collect (create MENU
                                                                            ITEMS ← T))
                                                          'SELECTIONS
                                                          (from 1 to NumCategories collect T)
                                                          'ITEM.TITLES
                                                          (for EventCategory in 
                                                                               NCHist.EventCategories
                                                             collect (fetch (EventCategory Name)
                                                                        of EventCategory))
                                                          'ITEM.TITLE.FONT
                                                          (FONTCOPY NC.MenuFont 'WEIGHT 'BOLD)
                                                          'NEED.NOT.FILL.IN
                                                          (from 1 to NumCategories
                                                             collect 'MULTI)
                                                          'TITLE "History Event Specs?"])

(NCHist.InitializeHistoryEventHashArray
  [LAMBDA NIL
    (DECLARE (GLOBALVARS NCHist.HistoryEventHashArray NCLOG.HashArraySize))
                                                             (* pmi%: "24-Nov-87 13:30")
    (if (HARRAYP NCHist.HistoryEventHashArray)
      else (SETQ NCHist.HistoryEventHashArray (HASHARRAY NCLOG.HashArraySize)))
    (PUTHASH 'Create% Card 'GetNewCard NCHist.HistoryEventHashArray)
    (PUTHASH '|Bring Up Card| 'EditCard.End NCHist.HistoryEventHashArray)
    (PUTHASH 'Close% Card 'QuitCard.End NCHist.HistoryEventHashArray)
    (PUTHASH '|Change Card Substance| 'PutMainCardData NCHist.HistoryEventHashArray)
    (PUTHASH '|Change Card Prop List| 'PutPropList NCHist.HistoryEventHashArray)
    (PUTHASH '|Change Card Title| '(AssignTitle.Begin PutTitle) NCHist.HistoryEventHashArray)
    (PUTHASH 'Delete% Card 'DelCard NCHist.HistoryEventHashArray)
    (PUTHASH 'Create% Link 'MakeLink NCHist.HistoryEventHashArray)
    (PUTHASH 'Delete% Link 'DelLink NCHist.HistoryEventHashArray)
    (PUTHASH 'Recompute% Browser 'RecomputeBrowser.End NCHist.HistoryEventHashArray)
    (PUTHASH 'Relayout% Browser 'RelayoutBrowser.End NCHist.HistoryEventHashArray)
    (PUTHASH '|Add Card Type| 'AddCardType NCHist.HistoryEventHashArray)
    NCHist.HistoryEventHashArray])

(NCHist.InitializeLogEventFnHashArray
  [LAMBDA NIL                                                (* pmi%: "24-Nov-87 13:31")
    (DECLARE (GLOBALVARS NCHist.LogEventFnHashArray NCLOG.HashArraySize))
    (if (HARRAYP NCHist.LogEventFnHashArray)
      else (SETQ NCHist.LogEventFnHashArray (HASHARRAY NCLOG.HashArraySize)))
    (PUTHASH 'GetNewCard 'NCHist.GetNewCardDisplayFn NCHist.LogEventFnHashArray)
    (PUTHASH 'EditCard.End 'NCHist.EditCard.EndDisplayFn NCHist.LogEventFnHashArray)
    (PUTHASH 'QuitCard.End 'NCHist.QuitCard.EndDisplayFn NCHist.LogEventFnHashArray)
    (PUTHASH 'PutMainCardData 'NCHist.PutMainCardDataDisplayFn NCHist.LogEventFnHashArray)
    (PUTHASH 'PutPropList 'NCHist.PutPropListDisplayFn NCHist.LogEventFnHashArray)
    (PUTHASH 'AssignTitle.Begin 'NCHist.AssignTitle.BeginDisplayFn NCHist.LogEventFnHashArray)
    (PUTHASH 'PutTitle 'NCHist.PutTitleDisplayFn NCHist.LogEventFnHashArray)
    (PUTHASH 'DelCard 'NCHist.DelCardDisplayFn NCHist.LogEventFnHashArray)
    (PUTHASH 'MakeLink 'NCHist.MakeLinkDisplayFn NCHist.LogEventFnHashArray)
    (PUTHASH 'DelLink 'NCHist.DelLinkDisplayFn NCHist.LogEventFnHashArray)
    (PUTHASH 'RecomputeBrowser.End 'NCHist.RecomputeBrowser.EndDisplayFn NCHist.LogEventFnHashArray)
    (PUTHASH 'RelayoutBrowser.End 'NCHist.RelayoutBrowser.EndDisplayFn NCHist.LogEventFnHashArray)
    (PUTHASH 'AddCardType 'NCHist.AddCardTypeDisplayFn NCHist.LogEventFnHashArray)
    NCHist.LogEventFnHashArray])

(NCHist.ConvertPointersToLinks
  [LAMBDA (Window)                                           (* pmi%: "25-Nov-87 12:45")
    (LET (PointerIcons)
         (SETQ PointerIcons (TEDIT.LIST.OF.OBJECTS (TEXTOBJ Window)
                                   (FUNCTION NC.PointerIconImageObjP)))
         (for PointerIcon in PointerIcons do (NC.ConvertPointerIconToLinkIcon Window (CAR PointerIcon
                                                                                          )))
         Window])

(NCHist.TurnLoggingOn
  [LAMBDA (Card)                                             (* pmi%: "22-Oct-87 12:10")
          
          (* * Start up logging for this notefile.)

    (NCLOG.StartLogging (NCP.CardNoteFile Card])

(NCHist.TurnLoggingOff
  [LAMBDA (Card)                                             (* pmi%: "22-Oct-87 12:11")
          
          (* * Suspend logging for this notefile.)

    (NCLOG.SuspendLogging (NCP.CardNoteFile Card])
)



(* ;;; "Fns for the various event category functions")

(DEFINEQ

(NCHist.CreateLinkEventsMenuItemsFn
  [LAMBDA (NoteFile)                                         (* pmi%: " 2-Dec-87 11:35")
    (REVERSE (NCP.LinkTypes NoteFile])

(NCHist.CreateLinkEventsDefaultMenuChoicesFn
  [LAMBDA (NoteFile)                                         (* pmi%: " 2-Dec-87 10:23")
    (REMOVE 'History (APPEND (NCP.UserLinkTypes NoteFile)
                            '(FiledCard SubBox])

(NCHist.CreateLinkEventsMenuChoicesFn
  [LAMBDA (Choices HistoryCard NoteFile)                     (* pmi%: " 2-Dec-87 11:22")
    (NCP.CardUserDataProp HistoryCard 'CreateLinkTypesToLog Choices)
    '(Create% Link])

(NCHist.DeleteLinkEventsMenuItemsFn
  [LAMBDA (NoteFile)                                         (* pmi%: " 2-Dec-87 11:35")
    (REVERSE (NCP.LinkTypes NoteFile])

(NCHist.DeleteLinkEventsDefaultMenuChoicesFn
  [LAMBDA (NoteFile)                                         (* pmi%: " 2-Dec-87 10:23")
    (REMOVE 'History (APPEND (NCP.UserLinkTypes NoteFile)
                            '(FiledCard SubBox])

(NCHist.DeleteLinkEventsMenuChoicesFn
  [LAMBDA (Choices HistoryCard NoteFile)                     (* pmi%: " 2-Dec-87 11:22")
    (NCP.CardUserDataProp HistoryCard 'DeleteLinkTypesToLog Choices)
    '(Delete% Link])
)



(* ;;; "Fns called to display the events in the History Card")

(DEFINEQ

(NCHist.EditCard.BeginDisplayFn
  [LAMBDA (HistoryCard EventTime NoteFile Card])

(NCHist.EditCard.EndDisplayFn
  [LAMBDA (HistoryCard EventTime NoteFileNum CardNum)        (* pmi%: "23-Nov-87 15:13")
    (DECLARE (GLOBALVARS NCHist.HistoryLinkType))
    (LET* ((NoteFile (NC.NoteFileFromUID (NCLOG.UIDFromNum NoteFileNum)))
           (Card (NC.CardFromUID (NCLOG.UIDFromNum CardNum)
                        NoteFile)))
          (if (NEQ Card HistoryCard)
              then (NCP.CardAddText HistoryCard "Brought up " 'END)
                   [NC.InsertPointerInText HistoryCard Card NCHist.HistoryLinkType
                          (NCP.CoerceToLinkDisplayMode '(FLOAT FLOAT FLOAT]
                   (NCP.CardAddText HistoryCard (CHARACTER 13)
                          'END])

(NCHist.QuitCard.BeginDisplayFn
  [LAMBDA (HistoryCard EventTime NoteFile Card Don'tDeactivateFlg])

(NCHist.QuitCard.EndDisplayFn
  [LAMBDA (HistoryCard EventTime NoteFileNum CardNum Don'tDeactivateFlg)
                                                             (* pmi%: "23-Nov-87 15:18")
    (DECLARE (GLOBALVARS NCHist.HistoryLinkType))
    (LET* ((NoteFile (NC.NoteFileFromUID (NCLOG.UIDFromNum NoteFileNum)))
           (Card (NC.CardFromUID (NCLOG.UIDFromNum CardNum)
                        NoteFile)))
          (if (NEQ Card HistoryCard)
              then (NCP.CardAddText HistoryCard "Closed " 'END)
                   [NC.InsertPointerInText HistoryCard Card NCHist.HistoryLinkType
                          (NCP.CoerceToLinkDisplayMode '(FLOAT FLOAT FLOAT]
                   (NCP.CardAddText HistoryCard (CHARACTER 13)
                          'END])

(NCHist.MakeCard.BeginDisplayFn
  [LAMBDA (HistoryCard EventTime NoteFileNum CardType Title NewCardNum)
                                                             (* pmi%: "24-Nov-87 17:47")
    NIL])

(NCHist.MakeCard.EndDisplayFn
  [LAMBDA (HistoryCard EventTime NoteFileNum CardType Title CardNum)
                                                             (* pmi%: "23-Nov-87 18:59")
    (DECLARE (GLOBALVARS NCHist.HistoryLinkType))
    (LET* ((NoteFile (NC.NoteFileFromUID (NCLOG.UIDFromNum NoteFileNum)))
           (Card (NC.CardFromUID (NCLOG.UIDFromNum CardNum)
                        NoteFile)))
          (if (NEQ Card HistoryCard)
              then (NCP.CardAddText HistoryCard "Created " 'END)
                   (if CardType
                       then (NCP.CardAddText HistoryCard (MKSTRING CardType)
                                   'END))
                   (NCP.CardAddText HistoryCard " card " 'END)
                   [NC.InsertPointerInText HistoryCard Card NCHist.HistoryLinkType
                          (NCP.CoerceToLinkDisplayMode '(FLOAT FLOAT FLOAT]
                   (if Title
                       then (NCP.CardAddText HistoryCard (CONCAT " with title " Title)
                                   'END))
                   (NCP.CardAddText HistoryCard (CHARACTER 13)
                          'END])

(NCHist.GetNewCardDisplayFn
  [LAMBDA (HistoryCard EventTime NoteFileNum CardNum CardType)
                                                             (* edited%: "14-Dec-87 20:46")
    (DECLARE (GLOBALVARS NCHist.HistoryLinkType))
    (LET* ((NoteFile (NC.NoteFileFromUID (NCLOG.UIDFromNum NoteFileNum)))
           (Card (NC.CardFromUID (NCLOG.UIDFromNum CardNum)
                        NoteFile)))
          (if (AND Card (NEQ Card HistoryCard))
              then (NCP.CardAddText HistoryCard "Created " 'END)
                   (if CardType
                       then (NCP.CardAddText HistoryCard (MKSTRING CardType)
                                   'END))
                   (NCP.CardAddText HistoryCard " card " 'END)
                   [NC.InsertPointerInText HistoryCard Card NCHist.HistoryLinkType
                          (NCP.CoerceToLinkDisplayMode '(FLOAT FLOAT FLOAT]
                   (NCP.CardAddText HistoryCard (CHARACTER 13)
                          'END])

(NCHist.DelCardDisplayFn
  [LAMBDA (HistoryCard EventTime NoteFile Card Title)        (* pmi%: "23-Nov-87 17:40")
    (if (NEQ Card HistoryCard)
        then (NCP.CardAddText HistoryCard (CONCAT "Deleted card '" Title "'" (CHARACTER 13))
                    'END])

(NCHist.CacheCardDisplayFn
  [LAMBDA (HistoryCard EventTime NoteFile Card)              (* pmi%: "20-Nov-87 12:14")
    (NCP.CardAddText HistoryCard (CONCAT "Cached card " Card (CHARACTER 13])

(NCHist.UncacheCardDisplayFn
  [LAMBDA (HistoryCard EventTime NoteFile Card)              (* pmi%: "20-Nov-87 12:14")
    (NCP.CardAddText HistoryCard (CONCAT "Uncached card " Card (CHARACTER 13])

(NCHist.SaveCard.BeginDisplayFn
  [LAMBDA (HistoryCard EventTime NoteFile Card])

(NCHist.SaveCard.EndDisplayFn
  [LAMBDA (HistoryCard EventTime NoteFile Card)              (* pmi%: "20-Nov-87 12:14")
    (NCP.CardAddText HistoryCard (CONCAT "Changed card " Card (CHARACTER 13])

(NCHist.PutLinksDisplayFn
  [LAMBDA (HistoryCard EventTime NoteFile Card)              (* pmi%: "20-Nov-87 12:16")
    (NCP.CardAddText HistoryCard (CONCAT "Put links for card " Card (CHARACTER 13])

(NCHist.PutMainCardDataDisplayFn
  [LAMBDA (HistoryCard EventTime NoteFileNum CardNum)        (* edited%: "15-Dec-87 09:34")
    (DECLARE (GLOBALVARS NCHist.HistoryLinkType))
    (LET* ((NoteFile (NC.NoteFileFromUID (NCLOG.UIDFromNum NoteFileNum)))
           (Card (NC.CardFromUID (NCLOG.UIDFromNum CardNum)
                        NoteFile)))
          (if (AND Card (NEQ Card HistoryCard)
                   (NEQ Card (fetch (NoteFile LinkLabelsCard) of NoteFile))
                   (NEQ Card (fetch (NoteFile RegistryCard) of NoteFile))
                   (NEQ Card (NCP.LookupCardByName 'OpenEventsCard NoteFile)))
              then (NCP.CardAddText HistoryCard "Changed contents of " 'END)
                   [NC.InsertPointerInText HistoryCard Card NCHist.HistoryLinkType
                          (NCP.CoerceToLinkDisplayMode '(FLOAT FLOAT FLOAT]
                   (NCP.CardAddText HistoryCard (CHARACTER 13)
                          'END])

(NCHist.PutPropListDisplayFn
  [LAMBDA (HistoryCard EventTime NoteFileNum CardNum)        (* edited%: "15-Dec-87 09:49")
    (DECLARE (GLOBALVARS NCHist.HistoryLinkType))
    (LET* ((NoteFile (NC.NoteFileFromUID (NCLOG.UIDFromNum NoteFileNum)))
           (Card (NC.CardFromUID (NCLOG.UIDFromNum CardNum)
                        NoteFile)))
          (if (AND Card (NEQ Card HistoryCard)
                   (NEQ Card (fetch (NoteFile LinkLabelsCard) of NoteFile))
                   (NEQ Card (fetch (NoteFile RegistryCard) of NoteFile))
                   (NEQ Card (NCP.LookupCardByName 'OpenEventsCard NoteFile)))
              then (NCP.CardAddText HistoryCard "Changed property list of " 'END)
                   [NC.InsertPointerInText HistoryCard Card NCHist.HistoryLinkType
                          (NCP.CoerceToLinkDisplayMode '(FLOAT FLOAT FLOAT]
                   (NCP.CardAddText HistoryCard (CHARACTER 13)
                          'END])

(NCHist.PutTitleDisplayFn
  [LAMBDA (HistoryCard EventTime NoteFileNum CardNum)        (* edited%: "15-Dec-87 09:53")
    (DECLARE (GLOBALVARS NCHist.HistoryLinkType))
    (LET* ((NoteFile (NC.NoteFileFromUID (NCLOG.UIDFromNum NoteFileNum)))
           (Card (NC.CardFromUID (NCLOG.UIDFromNum CardNum)
                        NoteFile))
           OldTitle)
          (if (AND Card (NEQ Card HistoryCard)
                   (NEQ Card (fetch (NoteFile LinkLabelsCard) of NoteFile))
                   (NEQ Card (fetch (NoteFile RegistryCard) of NoteFile))
                   (NEQ Card (NCP.LookupCardByName 'OpenEventsCard NoteFile)))
              then (NCP.CardAddText HistoryCard "Changed title of " 'END)
                   [NC.InsertPointerInText HistoryCard Card NCHist.HistoryLinkType
                          (NCP.CoerceToLinkDisplayMode '(FLOAT FLOAT FLOAT]
                   (if (SETQ OldTitle (NCP.CardUserDataProp HistoryCard 'Card))
                       then (NCP.CardAddText HistoryCard (CONCAT " from '" OldTitle "' to '"
                                                                (NCP.CardTitle Card)
                                                                "'")
                                   'END)
                            (NCP.CardUserDataProp HistoryCard 'Card NIL))
                   (NCP.CardAddText HistoryCard (CHARACTER 13)
                          'END])

(NCHist.AssignTitle.BeginDisplayFn
  [LAMBDA (HistoryCard EventTime NoteFile Card OldTitle)     (* pmi%: "20-Nov-87 16:53")
    (if (NCP.CardUserDataProp HistoryCard 'Card)
      else (NCP.CardUserDataProp HistoryCard 'Card OldTitle])

(NCHist.AssignTitle.EndDisplayFn
  [LAMBDA (HistoryCard EventTime NoteFile Card NewTitle)     (* pmi%: "20-Nov-87 12:19")
    (NCP.CardAddText HistoryCard (CONCAT " to " NewTitle (CHARACTER 13])

(NCHist.MakeLinkDisplayFn
  [LAMBDA (HistoryCard EventTime NoteFileNum LinkNum SourceCardNum DestinationCardNum Label 
                 AnchorMode DisplayMode)                     (* pmi%: " 2-Dec-87 10:56")
    (DECLARE (GLOBALVARS NCHist.HistoryLinkType))
    (LET* ((NoteFile (NC.NoteFileFromUID (NCLOG.UIDFromNum NoteFileNum)))
           (SourceCard (NC.CardFromUID (NCLOG.UIDFromNum SourceCardNum)
                              NoteFile))
           (DestinationCard (NC.CardFromUID (NCLOG.UIDFromNum DestinationCardNum)
                                   NoteFile)))
          (if [AND (NEQ SourceCard HistoryCard)
                   (MEMBER Label (NCP.CardUserDataProp HistoryCard 'CreateLinkTypesToLog]
              then (NCP.CardAddText HistoryCard (CONCAT "Created " Label " link from ")
                          'END)
                   [NC.InsertPointerInText HistoryCard SourceCard NCHist.HistoryLinkType
                          (NCP.CoerceToLinkDisplayMode '(FLOAT FLOAT FLOAT]
                   (NCP.CardAddText HistoryCard " to " 'END)
                   [NC.InsertPointerInText HistoryCard DestinationCard NCHist.HistoryLinkType
                          (NCP.CoerceToLinkDisplayMode '(FLOAT FLOAT FLOAT]
                   (NCP.CardAddText HistoryCard (CHARACTER 13)
                          'END])

(NCHist.DelLinkDisplayFn
  [LAMBDA (HistoryCard EventTime NoteFileNum LinkNum SourceCardNum DestinationCardNum Label 
                 AnchorMode DisplayMode)                     (* pmi%: " 2-Dec-87 10:56")
    (DECLARE (GLOBALVARS NCHist.HistoryLinkType))
    (LET* ((NoteFile (NC.NoteFileFromUID (NCLOG.UIDFromNum NoteFileNum)))
           (SourceCard (NC.CardFromUID (NCLOG.UIDFromNum SourceCardNum)
                              NoteFile))
           (DestinationCard (NC.CardFromUID (NCLOG.UIDFromNum DestinationCardNum)
                                   NoteFile)))
          (if [AND (NEQ SourceCard HistoryCard)
                   (MEMBER Label (NCP.CardUserDataProp HistoryCard 'DeleteLinkTypesToLog]
              then (NCP.CardAddText HistoryCard (CONCAT "Deleted " Label " link from ")
                          'END)
                   [NC.InsertPointerInText HistoryCard SourceCard NCHist.HistoryLinkType
                          (NCP.CoerceToLinkDisplayMode '(FLOAT FLOAT FLOAT]
                   (NCP.CardAddText HistoryCard " to " 'END)
                   [NC.InsertPointerInText HistoryCard DestinationCard NCHist.HistoryLinkType
                          (NCP.CoerceToLinkDisplayMode '(FLOAT FLOAT FLOAT]
                   (NCP.CardAddText HistoryCard (CHARACTER 13)
                          'END])

(NCHist.RecomputeBrowser.BeginDisplayFn
  [LAMBDA (HistoryCard EventTime NoteFile Card])

(NCHist.RecomputeBrowser.EndDisplayFn
  [LAMBDA (HistoryCard EventTime NoteFileNum CardNum)        (* pmi%: "24-Nov-87 09:39")
    (DECLARE (GLOBALVARS NCHist.HistoryLinkType))
    (LET* ((NoteFile (NC.NoteFileFromUID (NCLOG.UIDFromNum NoteFileNum)))
           (Card (NC.CardFromUID (NCLOG.UIDFromNum CardNum)
                        NoteFile)))
          (if (NEQ Card HistoryCard)
              then (NCP.CardAddText HistoryCard "Recomputed browser " 'END)
                   [NC.InsertPointerInText HistoryCard Card NCHist.HistoryLinkType
                          (NCP.CoerceToLinkDisplayMode '(FLOAT FLOAT FLOAT]
                   (NCP.CardAddText HistoryCard (CHARACTER 13)
                          'END])

(NCHist.RelayoutBrowser.BeginDisplayFn
  [LAMBDA (HistoryCard EventTime NoteFile Card])

(NCHist.RelayoutBrowser.EndDisplayFn
  [LAMBDA (HistoryCard EventTime NoteFileNum CardNum)        (* pmi%: "24-Nov-87 17:44")
    (DECLARE (GLOBALVARS NCHist.HistoryLinkType))
    (LET* ((NoteFile (NC.NoteFileFromUID (NCLOG.UIDFromNum NoteFileNum)))
           (Card (NC.CardFromUID (NCLOG.UIDFromNum CardNum)
                        NoteFile)))
          (if (NEQ Card HistoryCard)
              then (NCP.CardAddText HistoryCard "Re-laid out " 'END)
                   [NC.InsertPointerInText HistoryCard Card NCHist.HistoryLinkType
                          (NCP.CoerceToLinkDisplayMode '(FLOAT FLOAT FLOAT]
                   (NCP.CardAddText HistoryCard (CHARACTER 13)
                          'END])

(NCHist.AddCardTypeDisplayFn
  [LAMBDA (HistoryCard EventTime TypeName)                   (* pmi%: "20-Nov-87 18:20")
    (NCP.CardAddText HistoryCard (CONCAT "Added card type " TypeName (CHARACTER 13))
           'END])

(NCHist.StartLoggingDisplayFn
  [LAMBDA (HistoryCard EventTime NoteFile FullNoteFileName])
)
(NCHist.InitializeHistoryEventsSpecsStylesheet)
(NCHist.InitializeHistoryEventHashArray)
(NCHist.InitializeLogEventFnHashArray)



(* ;;; "Changed in NCCOLLABORATION")

(DEFINEQ

(NCCollab.OpenNoteFileFn
  [LAMBDA (NoteFile)                                         (* ; "Edited 12-Jan-88 13:54 by pmi:")

(* ;;; "This gets called at notefile-open time.")

(* ;;; "pmi 10/21/87: Now prompts for new collaborator name before creating the collaborator card, rather than creating a collaborator card with '??' as the title.")

    (DECLARE (GLOBALVARS NCCollab.NoteFileIconMiddleMenuItems))
    (LET ((UserName (USERNAME))
          Menu CollaboratorCard MenuItemRegion)
         (NCP.AddNoteFileIconMiddleButtonItems NoteFile NCCollab.NoteFileIconMiddleMenuItems)
         [SETQ Menu (NCCollab.MakeCollaboratorsMenu NoteFile '(("-- New Name(s) --" 'NEWNAMES 
                                                        "Create a new collaborator information card."
                                                                      ]
         (NCP.PrintMsg NIL T "Please select Collaborator name(s)")
          
          (* Make Menu be positioned next to UserName if present, otherwise at "NewNames" 
          entry.)

         (SETQ MenuItemRegion (MENUITEMREGION (for Item in (fetch (MENU ITEMS) of Menu)
                                                 when (STREQUAL (U-CASE (CAR Item))
                                                             (U-CASE UserName))
                                                 do (RETURN Item) finally (RETURN Item))
                                     Menu))
         (replace (MENU MENUOFFSET) of Menu with (CONS (fetch (REGION LEFT) of MenuItemRegion)
                                                       (fetch (REGION BOTTOM) of MenuItemRegion)))
         (if (EQ (SETQ CollaboratorCard (MENU Menu))
                 'NEWNAMES)
             then 
          
          (* Create a new card with unknown title if UserName is on menu, else use 
          UserName.)

                  [SETQ CollaboratorCard (NCP.CoerceToCard
                                          (NCP.CreateCard
                                           'Collaborator NoteFile
                                           (if (for Item in (fetch (MENU ITEMS) of Menu)
                                                  thereis (STREQUAL (CAR Item)
                                                                 UserName))
                                               then (NCP.AskUser 
                                                           "Enter new name(s) for collaborator(s): " 
                                                           NIL NIL T (NC.CoerceToInterestedWindow
                                                                      NoteFile))
                                             else UserName]
                  (NCCollab.HangOnCardUntilDone CollaboratorCard "DONE" "Fill in parameters" 
   "Selecting DONE indicates completion of updating this card.  Will allow OpenNoteFile to continue."
                         ))
         (if (NCP.ValidCardP CollaboratorCard)
             then (NCCollab.ChangeCurrentCollaborator NoteFile CollaboratorCard])
)



(* ;;; "Add this expression to the end of the file coms for NCCOLLABORATION")

(NCP.AddSessionIconMenuItem 'NoteFile '(| Collaboratize | NCCollab.CollaboratizeNoteFile 
                                              "Collaboratizes a notefile."))
(NCP.AddNoteFileIconMenuItem '(Collaboratize NCCollab.CollaboratizeNoteFile 
                                     "Collaboratizes a notefile.") 'Open)



(* ;;; "New for NCDATABASE")

(DEFINEQ

(NC.NoteFileFromUID
  [LAMBDA (UID)                                              (* pmi%: "23-Nov-87 14:03")
          
          (* * Recover the notefile with given UID by looking it up in the notefile hash 
          table.)

    (DECLARE (GLOBALVARS NC.NoteFilesHashArray))
    (AND UID (GETHASH UID NC.NoteFilesHashArray])
)



(* ;;; "Install the altered History card type")

(NCHist.AddHistoryCard)
(PUTPROPS PMIPATCH066 COPYRIGHT ("Xerox Corporation" 1987 1988))
(DECLARE%: DONTCOPY
  (FILEMAP (NIL (8494 9372 (NCP.CoerceToInterestedWindow 8504 . 8842) (NCP.NewCardP 8844 . 9126) (
NCP.NoteFileAddProp 9128 . 9370)) (9416 18573 (NCHist.AddHistoryCard 9426 . 10909) (
NCHist.HistoryCardMakeFn 10911 . 13860) (NCHist.HistoryCardWhenSavedFn 13862 . 15261) (
NCHist.NoteFileWhenOpenedFn 15263 . 16293) (NCHist.HistoricizeNoteFile 16295 . 18201) (
NCHist.CreateHistoryCardTitle 18203 . 18571)) (22131 41032 (NCHist.CreateHistoryDate 22141 . 22646) (
NCHist.ComputeHistory 22648 . 28626) (NCHist.GetLogEventFromStream 28628 . 29189) (
NCHist.ProcessLogEvent 29191 . 29495) (NCHist.ChangeHistoryEventSpecs 29497 . 30743) (
NCHist.AskHistoryEventSpecs 30745 . 35202) (NCHist.InitializeHistoryEventsSpecsStylesheet 35204 . 
37215) (NCHist.InitializeHistoryEventHashArray 37217 . 38534) (NCHist.InitializeLogEventFnHashArray 
38536 . 40023) (NCHist.ConvertPointersToLinks 40025 . 40546) (NCHist.TurnLoggingOn 40548 . 40787) (
NCHist.TurnLoggingOff 40789 . 41030)) (41096 42428 (NCHist.CreateLinkEventsMenuItemsFn 41106 . 41281) 
(NCHist.CreateLinkEventsDefaultMenuChoicesFn 41283 . 41535) (NCHist.CreateLinkEventsMenuChoicesFn 
41537 . 41765) (NCHist.DeleteLinkEventsMenuItemsFn 41767 . 41942) (
NCHist.DeleteLinkEventsDefaultMenuChoicesFn 41944 . 42196) (NCHist.DeleteLinkEventsMenuChoicesFn 42198
 . 42426)) (42500 56477 (NCHist.EditCard.BeginDisplayFn 42510 . 42594) (NCHist.EditCard.EndDisplayFn 
42596 . 43322) (NCHist.QuitCard.BeginDisplayFn 43324 . 43427) (NCHist.QuitCard.EndDisplayFn 43429 . 
44224) (NCHist.MakeCard.BeginDisplayFn 44226 . 44440) (NCHist.MakeCard.EndDisplayFn 44442 . 45622) (
NCHist.GetNewCardDisplayFn 45624 . 46644) (NCHist.DelCardDisplayFn 46646 . 46930) (
NCHist.CacheCardDisplayFn 46932 . 47136) (NCHist.UncacheCardDisplayFn 47138 . 47346) (
NCHist.SaveCard.BeginDisplayFn 47348 . 47432) (NCHist.SaveCard.EndDisplayFn 47434 . 47642) (
NCHist.PutLinksDisplayFn 47644 . 47854) (NCHist.PutMainCardDataDisplayFn 47856 . 48852) (
NCHist.PutPropListDisplayFn 48854 . 49851) (NCHist.PutTitleDisplayFn 49853 . 51309) (
NCHist.AssignTitle.BeginDisplayFn 51311 . 51565) (NCHist.AssignTitle.EndDisplayFn 51567 . 51773) (
NCHist.MakeLinkDisplayFn 51775 . 53126) (NCHist.DelLinkDisplayFn 53128 . 54478) (
NCHist.RecomputeBrowser.BeginDisplayFn 54480 . 54572) (NCHist.RecomputeBrowser.EndDisplayFn 54574 . 
55316) (NCHist.RelayoutBrowser.BeginDisplayFn 55318 . 55409) (NCHist.RelayoutBrowser.EndDisplayFn 
55411 . 56145) (NCHist.AddCardTypeDisplayFn 56147 . 56379) (NCHist.StartLoggingDisplayFn 56381 . 56475
)) (56651 59828 (NCCollab.OpenNoteFileFn 56661 . 59826)) (60270 60633 (NC.NoteFileFromUID 60280 . 
60631)))))
STOP