(DEFINE-FILE-INFO PACKAGE "INTERLISP" READTABLE "INTERLISP")
(FILECREATED " 5-Aug-88 16:51:13" {QV}<NOTECARDS>1.3LNEXT>RHTPATCH332.;3 69576  

      changes to%:  (VARS RHTPATCH332COMS)
                    (FNS NCIDEASKETCH.MakeIdeaSketchCard NC.MakeFileBox NC.MakeFileCard 
                         NC.MakeFileCardCore NC.MakeNoteCard NCP.CreateCard NCP.CreateTextCard 
                         NCP.CreateFileBox NCP.CreateBrowserCard NCP.CreateSketchCard 
                         NCP.CreateGraphCard NCP.MakeDocument NCP.MakeLinkIndex NC.MakeBrowserCard 
                         NC.MakeSearchCard NC.MakeLinkIndex NC.MakeDocument)

      previous date%: " 5-Aug-88 12:23:25" {QV}<NOTECARDS>1.3LNEXT>RHTPATCH332.;1)


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

(PRETTYCOMPRINT RHTPATCH332COMS)

(RPAQQ RHTPATCH332COMS
       ((DECLARE%: DONTCOPY (PROPS (RHTPATCH332 MAKEFILE-ENVIRONMENT)
                                   (RHTPATCH332 FILETYPE)))
        [DECLARE%: FIRST (P (NC.LoadFileFromDirectories 'NCSKETCHCARD)
                            (NC.LoadFileFromDirectories 'NCBROWSERCARD)
                            (NC.LoadFileFromDirectories 'NCSEARCHCARD)
                            (NC.LoadFileFromDirectories 'NCLINKINDEXCARD)
                            (NC.LoadFileFromDirectories 'NCDOCUMENTCARD)
                            (NC.LoadFileFromDirectories 'NCIDEASKETCHCARD)
                            (NC.LoadFileFromDirectories 'NCFILECARD]
        
        (* ;; "Fixes and features promised to IDE folks.  Added NewCardPos slot (now implemented as cardtype atom property) which if present, is where new cards of that type are brought up on the screen, assuming RegionOrPosition (passed to NC.DetermineDisplayRegion) is nil.  All card type makefns now take InterestedWindow and RegionOrPosition args.")

        
        (* ;; "New function for NCCARDS")

        (FNS NC.FetchNewCardPos)
        
        (* ;; "Change to NCCARDS")

        (FNS NC.DetermineDisplayRegion NC.MakeNoteCard)
        
        (* ;; "Change to NCPROGINT")

        (FNS NCP.CreateCard NCP.CreateTextCard NCP.CreateFileBox NCP.CreateBrowserCard 
             NCP.CreateSketchCard NCP.CreateGraphCard NCP.MakeDocument NCP.MakeLinkIndex)
        
        (* ;; "Change to NCTEXTCARD")

        (FNS NC.MakeTEditCard)
        
        (* ;; "Change to NCFILEBOXCARD")

        (FNS NC.MakeFileBox)
        
        (* ;; "Change to NCGRAPHCARD")

        (FNS NC.MakeGraphCard)
        
        (* ;; "Change to NCBROWSERCARD")

        (FNS NC.MakeBrowserCard)
        
        (* ;; "Change to NCSKETCHCARD")

        (FNS NC.MakeSketchCard)
        
        (* ;; "Change to NCSEARCHCARD")

        (FNS NC.MakeSearchCard)
        
        (* ;; "Change to NCLINKINDEXCARD")

        (FNS NC.MakeLinkIndex)
        
        (* ;; "Change to NCDOCUMENTCARD")

        (FNS NC.MakeDocument)
        
        (* ;; "Change to NCIDEASKETCHCARD")

        (FNS NCIDEASKETCH.MakeIdeaSketchCard)
        
        (* ;; "Change to NCFILECARD")

        (FNS NC.MakeFileCard NC.MakeFileCardCore)))
(DECLARE%: DONTCOPY 

(PUTPROPS RHTPATCH332 MAKEFILE-ENVIRONMENT (:PACKAGE "INTERLISP" :READTABLE "INTERLISP"))

(PUTPROPS RHTPATCH332 FILETYPE :TCOMPL)
)
(DECLARE%: FIRST 

(NC.LoadFileFromDirectories 'NCSKETCHCARD)

(NC.LoadFileFromDirectories 'NCBROWSERCARD)

(NC.LoadFileFromDirectories 'NCSEARCHCARD)

(NC.LoadFileFromDirectories 'NCLINKINDEXCARD)

(NC.LoadFileFromDirectories 'NCDOCUMENTCARD)

(NC.LoadFileFromDirectories 'NCIDEASKETCHCARD)

(NC.LoadFileFromDirectories 'NCFILECARD)
)



(* ;; 
"Fixes and features promised to IDE folks.  Added NewCardPos slot (now implemented as cardtype atom property) which if present, is where new cards of that type are brought up on the screen, assuming RegionOrPosition (passed to NC.DetermineDisplayRegion) is nil.  All card type makefns now take InterestedWindow and RegionOrPosition args."
)




(* ;; "New function for NCCARDS")

(DEFINEQ

(NC.FetchNewCardPos
  [LAMBDA (Card)                                             (* ; "Edited  9-Jun-88 20:49 by Trigg")

    (* ;; "Get the default NewCardPos for this card.  ")

    (* ;; "This should do a (fetch (Card NewCardPos) of Card) with accessfns set up exactly like DefaultCardWidth slot works.  For now, it's hacked to grab NewCardPos property of card type atom.")

    (GETPROP (NC.FetchType Card)
           'NewCardPos])
)



(* ;; "Change to NCCARDS")

(DEFINEQ

(NC.DetermineDisplayRegion
  [LAMBDA (Card RegionOrPosition)                            (* ; "Edited  9-Jun-88 20:44 by Trigg")

    (* ;; "fgh 11/13/85 Updated to handle Card object.")

    (* ;; "fgh 2/5/86 Changed names DefaultcardWidth to FeatchDefaultWidth ...")

    (* ;; 
    "rht 3/25/87: Changed so as to account for the NoteFile indicator window height if present.")

    (* ;; 
    "pmi 3/31/87: Changed prompt message for placing card to not say '... Card NIL' for a new card.")

    (* ;; "rht 5/16/87: Now takes attached windows into account for cases when RegionOrPosition is a region.  But only when the card's window is already open.")

    (* ;; "rg 9/16/87 now brings up card at old pos if BringUpCardAtOldPos prop is T")

    (* ;; "rht 6/9/88: Now checks to see if card's card type has a non-nil NewCardPos slot if RegionOrPosition is nil.")

    (DECLARE (GLOBALVARS NC.BringUpCardAtOldPosFlg NC.ShowNoteFileOnCards))
    (LET ((Window (NC.FetchWindow Card))
          CardWinRegion TotalWinRegion Region)
         (if (WINDOWP Window)
             then (SETQ CardWinRegion (WINDOWPROP Window 'REGION))
                  (SETQ TotalWinRegion (WINDOWREGION Window)))
         (COND
            [(POSITIONP RegionOrPosition)
             (if (SETQ Region (OR TotalWinRegion (NC.FetchRegion Card)))
                 then (CREATEREGION (fetch (POSITION XCOORD) of RegionOrPosition)
                             (fetch (POSITION YCOORD) of RegionOrPosition)
                             (fetch (REGION WIDTH) of Region)
                             (fetch (REGION HEIGHT) of Region))
               else (CREATEREGION (fetch XCOORD of RegionOrPosition)
                           (fetch YCOORD of RegionOrPosition)
                           (NC.FetchDefaultWidth Card)
                           (NC.FetchDefaultHeight Card]
            ([SETQ Region (OR (REGIONP RegionOrPosition)
                              (AND (OR NC.BringUpCardAtOldPosFlg (NC.GetProp Card '
                                                                        BringUpCardAtOldPos))
                                   (NC.FetchRegion Card]
             (if Window
                 then [create REGION using Region HEIGHT ← (PLUS (fetch HEIGHT of TotalWinRegion)
                                                                 (DIFFERENCE (fetch HEIGHT
                                                                                of Region)
                                                                        (fetch HEIGHT of 
                                                                                        CardWinRegion
                                                                               )))
                                           WIDTH ← (PLUS (fetch WIDTH of TotalWinRegion)
                                                         (DIFFERENCE (fetch WIDTH of Region)
                                                                (fetch WIDTH of CardWinRegion]
               else Region))
            (Window TotalWinRegion)
            (T (LET (Width Height TotalHeight CardTitle NewRegion NewCardPos)
                    (if (SETQ Region (NC.FetchRegion Card))
                        then (SETQ Width (fetch WIDTH of Region))
                             (SETQ Height (fetch HEIGHT of Region))
                      else (SETQ Width (NC.FetchDefaultWidth Card))
                           (SETQ Height (NC.FetchDefaultHeight Card)))
                    (SETQ TotalHeight (if NC.ShowNoteFileOnCards
                                          then (PLUS Height (NC.NoteFileIndicatorWinHeight))
                                        else Height))
                    (if (POSITIONP (SETQ NewCardPos (NC.FetchNewCardPos Card)))
                        then (SETQ NewRegion (CREATEREGION (fetch XCOORD of NewCardPos)
                                                    (fetch YCOORD of NewCardPos)
                                                    Width Height))
                      else (SETQ CardTitle (NC.FetchTitle Card))
                           (replace (REGION HEIGHT) of [SETQ NewRegion
                                                        (GETBOXREGION
                                                         Width TotalHeight (GETMOUSEX)
                                                         (IDIFFERENCE (GETMOUSEY)
                                                                TotalHeight)
                                                         NIL
                                                         (if CardTitle
                                                             then (CONCAT 
                                                             "Please specify location for Note Card "
                                                                         CardTitle)
                                                           else (CONCAT 
                                                                   "Please specify location for new "
                                                                       (NC.RetrieveType Card)
                                                                       " Card"] with Height))
                    NewRegion])

(NC.MakeNoteCard
  [LAMBDA (NoteCardType NoteFile Title NoDisplayFlg TypeSpecificArgs Card InterestedWindow 
                 RegionOrPosition)                           (* ; "Edited  5-Aug-88 15:56 by Trigg")
                                                             (* ; 
                  "Make a new note card of type NoteCardType.  If type note specified, ask the user.")

    (* ;; "rht 2/1/85: Added call to NC.MarkCardDirty.")

    (* ;; "fgh 10/15/85 Added extra DatabaseStream argument for use by caching mechanism")

    (* ;; "fgh 11/11/85: Updated to handle new Card object.")

    (* ;; "fgh 2/5/86 Added call to NC.ApplyFn")

    (* ;; "kirk 15May86 Added call to NC.AttachNoteFileName")

    (* ;; "rht 7/4/86: Now checks for read-only notefile before proceeding.")

    (* ;; "kef 8/4/86: Updated to pass NoteCardType argument on to NC.GetNewCard.")

    (* ;; "rht 7/24/87: Replaced WINDOWPROP thing with call to NC.InstallCopyButtonEventFn.")

    (* ;; "pmi 2/25/88: Added InterestedWindow arg to be passed on to the card type's makefn.")

    (* ;; "rht 8/5/88: Added RegionOrPosition arg and passed to card type's makefn.")

    (DECLARE (GLOBALVARS NC.ShowNoteFileOnCards))
    (if (NC.ReadOnlyNoteFileP NoteFile)
        then NIL
      else (LET (ReturnValue Window)
                (COND
                   ([SETQ NoteCardType (OR NoteCardType (NC.AskNoteCardType (fetch (NoteFile Menu)
                                                                               of NoteFile]
                    (SETQ Card (OR (PROGN (type? Card Card)
                                          Card)
                                   (NC.GetNewCard NoteFile NoteCardType)))
                    (NC.SetNewCardFlg Card T)
                    (NC.ActivateCard Card)
                    (NC.SetType Card NoteCardType)
                    [COND
                       ((OR [NULL (ERSETQ (SETQ ReturnValue (NC.ApplyFn MakeFn Card Title 
                                                                   NoDisplayFlg TypeSpecificArgs 
                                                                   InterestedWindow RegionOrPosition]
                            (NULL ReturnValue))
                        (NC.SetStatus Card 'DELETED)
                        (NC.DeactivateCard Card T))
                       (T (SETQ Window (WINDOWP ReturnValue))
                          [COND
                             ((NULL (NC.RetrieveTitle Card))
                              [SETQ Title (NC.SetTitle Card (SETQ Title
                                                             (COND
                                                                ((STRINGP Title)
                                                                 Title)
                                                                ((AND Title (OR (LITATOM Title)
                                                                                (NUMBERP Title)))
                                                                 (MKSTRING Title))
                                                                (T "Untitled"]
                              (AND Window (WINDOWPROP Window 'TITLE Title)))
                             (T (NC.SetTitle Card (MKSTRING (NC.RetrieveTitle Card]
                          (COND
                             (Window (WINDOWADDPROP Window 'CLOSEFN (FUNCTION NC.QuitCard)
                                            'FIRST)
                                    (WINDOWPROP Window 'NoteCardObject Card)
                                    (NC.InstallCopyButtonEventFn Window)))
                          (NC.SetTitleDirtyFlg Card T)

                          (* ;; "Reset the type in case of recursive calls change the type.  Always want the highest level type in a recursive descent")

                          (NC.SetType Card NoteCardType)     (* ; 
                                             "Insure that a link ptr is set up during the first save")
                          (NC.SetLinksDirtyFlg Card T)
                          (NC.SetPropListDirtyFlg Card T)    (* ; "Mark that substance is dirty.")
                          (NC.MarkCardDirty Card T)
                          (if NC.ShowNoteFileOnCards
                              then (NC.AttachNoteFileName Window]
                    ReturnValue])
)



(* ;; "Change to NCPROGINT")

(DEFINEQ

(NCP.CreateCard
  [LAMBDA (Type NoteFile Title NoDisplayFlg Props ParentFileBoxes TypeSpecificArgs InterestedWindow 
                RegionOrPosition)                            (* ; "Edited  5-Aug-88 15:57 by Trigg")

    (* ;; "Creates a new notecard with given type, title, props and parents.  Any of those args can be nil.  Type being NIL will cause user to be asked.  Makes a card with initially empty substance.")

    (* ;; "rht 11/20/84: Had to add a horrible kluge: if creating a document card in which embedded links may be copied, then need to have document card visible on screen.  This is because ID is currently unattainable from just the Textstream --- need to have a window.  Until that is fixed, we temporarily bring up the document card while it's being filled in.")

    (* ;; "rht 11/17/85: Updated to handle new card and notefile objects.")

    (* ;; "rht 7/10/86: Ripped out the above described document kludge.")

    (* ;; "rht 8/21/86: Now sticks (APPEND Props) on the card's proplist, i.e.  a top level copy.")

    (* ;; "rht 11/16/86: Changed call to NCP.ReportError")

    (* ;; "dsj 9/23/87: Added (NC.RetrievePropList Card) to APPEND to preserve properties set by user's makefn.")

    (* ;; "pmi 12/10/87: Added dsj's change;  see above comment.")

    (* ;; "pmi 2/23/88: Added InterestedWindow argument to passed on to NC.MakeNoteCard.")

    (* ;; "rht 8/5/88: Added RegionOrPosition arg and passed to NC.MakeNoteCard.")

    (if (NCP.CardTypeP Type)
        then (LET (Card CardIdentifier)
                  (if (SETQ CardIdentifier (NC.MakeNoteCard Type NoteFile Title NoDisplayFlg 
                                                  TypeSpecificArgs NIL InterestedWindow 
                                                  RegionOrPosition))
                      then (SETQ Card (if (WINDOWP CardIdentifier)
                                          then (NCP.CardFromWindow CardIdentifier)
                                        else CardIdentifier))
                           (if Props
                               then (NC.SetPropList Card (APPEND Props (NC.RetrievePropList Card)))
                                    (NC.SetPropListDirtyFlg Card T))
                           [for Box in (MKLIST ParentFileBoxes)
                              do (if (NCP.FileBoxP Box)
                                     then (NCP.FileCards Card Box)
                                   else (NCP.ReportError 'NCP.CreateCard (CONCAT Box 
                                                                          " not an existing filebox."
                                                                                ]
                           Card))
      else (NCP.ReportError 'NCP.CreateCard (CONCAT "Unknown card type: " Type))
           NIL])

(NCP.CreateTextCard
  [LAMBDA (NoteFile Title NoDisplayFlg Props ParentFileBoxes InterestedWindow RegionOrPosition)
                                                             (* ; "Edited  5-Aug-88 16:28 by Trigg")

(* ;;; "Creates a new TEXT notecard with given title, props and parents.  Makes a card with initially empty textstream.")

    (* ;; "rht 11/17/85: Updated to handle new card and notefile objects.")

    (* ;; "rht 8/5/88: Added TypeSpecificArgs, InterestedWindow, and RegionOrPosition args and passed to NCP.CreateCard.")

    (NCP.CreateCard 'Text NoteFile Title NoDisplayFlg Props ParentFileBoxes NIL InterestedWindow 
           RegionOrPosition])

(NCP.CreateFileBox
  [LAMBDA (NoteFile Title NoDisplayFlg Props ChildCardsBoxes ParentFileBoxes InterestedWindow 
                 RegionOrPosition)                           (* ; "Edited  5-Aug-88 16:27 by Trigg")

(* ;;; "Creates a new Filebox with given title, props, children and parents.  Does not display the card, but does give it an initial textstream")

    (* ;; "rht 11/17/85: Updated to handle new card and notefile objects.")

    (* ;; "rht 8/5/88: Added TypeSpecificArgs, InterestedWindow, and RegionOrPosition args and passed to NCP.CreateCard.")

    (LET ((Card (NCP.CreateCard 'FileBox NoteFile Title NoDisplayFlg Props ParentFileBoxes NIL 
                       InterestedWindow RegionOrPosition)))
         (NCP.FileCards ChildCardsBoxes Card)
         Card])

(NCP.CreateBrowserCard
  [LAMBDA (NoteFile Title ParamList NoDisplayFlg Props ParentFileBoxes InterestedWindow 
                 RegionOrPosition)                           (* ; "Edited  5-Aug-88 16:02 by Trigg")

    (* ;; "Creates a new browser notecard with given type, title, props, parents, starting ID and link labels.")

    (* ;; "rht 11/17/85: Updated to handle new card and notefile objects.")

    (* ;; "rht 8/21/86: Changed call from NCP.ValidLinkType to NCP.ValidLinkTypeP.")

    (* ;; "rht 11/16/86: Changed call to NCP.ReportError")

    (* ;; "rht 3/7/87: Now properly accepts link types with '←' prefixes.")

    (* ;; "pmi 2/24/88: Now passes NIL as NewParamList if the user didn't specify any parameters.  Also added InterestedWindow argument.")

    (* ;; "rht 8/5/88: Added RegionOrPosition arg and passed to NCP.CreateCard.")

    (LET (ValidLinkTypes LinkTypes NewParamList)
         [SETQ ValidLinkTypes (for LinkType in (SETQ LinkTypes (LISTGET ParamList 'LINKTYPES))
                                 join (COND
                                         ((EQ LinkType 'ALL)
                                          (NCP.LinkTypes NoteFile))
                                         ((EQ LinkType '←ALL)
                                          (NCP.ReverseLinkTypes NoteFile))
                                         ((OR (NCP.ValidLinkTypeP LinkType NoteFile)
                                              (AND (STREQUAL (SUBSTRING LinkType 1 1)
                                                          "←")
                                                   (NCP.ValidLinkTypeP (SUBATOM LinkType 2)
                                                          NoteFile)))
                                          (LIST LinkType))
                                         (T (NCP.ReportError 'NCP.CreateBrowserCard (CONCAT LinkType
                                                                                           
                                                                            " not a valid link type."
                                                                                           ))
                                            NIL]
         (SETQ ValidLinkTypes (INTERSECTION ValidLinkTypes ValidLinkTypes))
         (if (AND LinkTypes (NULL ValidLinkTypes))
             then NIL
           else                                              (* ; 
                    "Make a copy of the user's param list since she may not want it to get rplaca'd.")
                (if ParamList
                    then (SETQ NewParamList (COPY ParamList))
                         (LISTPUT NewParamList 'LINKTYPES ValidLinkTypes)
                  else (SETQ NewParamList NIL))
                (NCP.CreateCard 'Browser NoteFile Title NoDisplayFlg Props ParentFileBoxes 
                       NewParamList InterestedWindow RegionOrPosition])

(NCP.CreateSketchCard
  [LAMBDA (NoteFile Title NoDisplayFlg Props ParentFileBoxes InterestedWindow RegionOrPosition)
                                                             (* ; "Edited  5-Aug-88 16:27 by Trigg")

(* ;;; "Creates a new SKETCH/MAP notecard with given title, props and parents.")

    (* ;; "rht 11/17/85: Updated to handle new card and notefile objects.")

    (* ;; 
    "rht 8/5/88: Added InterestedWindow and RegionOrPosition args and passed to NCP.CreateCard.")

    (NCP.CreateCard 'Sketch NoteFile Title NoDisplayFlg Props ParentFileBoxes NIL InterestedWindow 
           RegionOrPosition])

(NCP.CreateGraphCard
  [LAMBDA (NoteFile Title NoDisplayFlg Props ParentFileBoxes InterestedWindow RegionOrPosition)
                                                             (* ; "Edited  5-Aug-88 16:05 by Trigg")

(* ;;; "Creates a new GRAPH notecard with given title, props and parents.")

    (* ;; "rht 11/17/85: Updated to handle new card and notefile objects.")

    (* ;; 
    "rht 8/5/88: Added InterestedWindow and RegionOrPosition args and passed to NCP.CreateCard.")

    (NCP.CreateCard 'Graph NoteFile Title NoDisplayFlg Props ParentFileBoxes NIL InterestedWindow 
           RegionOrPosition])

(NCP.MakeDocument
  [LAMBDA (NoteFile RootCard ParamProps NoDisplayFlg Props ParentFileBoxes InterestedWindow 
                 RegionOrPosition)                           (* ; "Edited  5-Aug-88 16:30 by Trigg")

    (* ;; "Do a MakeDocument starting from RootCard according to parameters in ParamProps if non-nil.  Otherwise use the default parameters.  Note that ParamProps are *only* used for the duration of this MakeDocument and do not affect the default parameter values.")

    (* ;; "rht 11/17/85: Updated to handle new card and notefile objects.")

    (* ;; "rht 8/25/86: Now passes non-nil QuietFlg to NCP.UncacheCards.")

    (* ;; "rht 11/16/86: Changed call to NCP.ReportError")

    (* ;; "pmi 2/26/88: Now passes ParamProps on down to NC.MakeDocument, which will handle fetching the existing parameters and restoring the original ones.  Also added InterestedWindow argument to be passed on to NCP.CreateCard.")

    (* ;; "rht 8/5/88: Added RegionOrPosition arg and passed to NCP.CreateCard.")

    (LET (CurParams DocCard WasActive)
         (if (NC.ValidCardP RootCard)
             then (AND (NOT (SETQ WasActive (NCP.CardCachedP RootCard)))
                       (NCP.CacheCards RootCard)) 

                  (* ;; "(if ParamProps then (SETQ CurParams (NCP.DocumentParameters ParamProps)))")

                  (SETQ DocCard (NCP.CreateCard 'Document NoteFile NIL NoDisplayFlg Props 
                                       ParentFileBoxes (LIST RootCard ParamProps)
                                       InterestedWindow RegionOrPosition)) 

                  (* ;; "(if ParamProps then (SETPROPLIST 'NC.MakeDocParameters CurParams))")

                  (AND (NOT WasActive)
                       (NCP.UncacheCards RootCard T))
                  DocCard
           else (NCP.ReportError 'NCP.MakeDocument (CONCAT RootCard " not a valid card or filebox."))
                NIL])

(NCP.MakeLinkIndex
  [LAMBDA (NoteFile LinkTypes BackPointersP NoDisplayFlg Props ParentFileBoxes InterestedWindow 
                 RegionOrPosition)                           (* ; "Edited  5-Aug-88 16:49 by Trigg")

(* ;;; "Do a MakeLinkIndex on LinkTypes inserting backpointers according to BackPointersP.")

    (* ;; "rht 11/17/85: Updated to handle new card and notefile objects.")

    (* ;; "rht 11/16/86: Changed call to NCP.ReportError")

    (* ;; 
    "rht 8/5/88: Added RegionOrPosition and InterestedWindow args and passed to NCP.CreateCard.")

    (LET [(ValidLinkTypes (for LinkType in (MKLIST LinkTypes)
                             join (COND
                                     ((EQ LinkType 'ALL)
                                      (NCP.LinkTypes NoteFile))
                                     ((EQ LinkType '←ALL)
                                      (NCP.ReverseLinkTypes NoteFile))
                                     ((NOT (NCP.ValidLinkType LinkType NoteFile))
                                      (NCP.ReportError 'NCP.MakeLinkIndex (CONCAT LinkType 
                                                                           " not a valid link label."
                                                                                 ))
                                      NIL)
                                     (T (LIST LinkType]
         (SETQ ValidLinkTypes (INTERSECTION ValidLinkTypes ValidLinkTypes))
         (if (AND LinkTypes (NULL ValidLinkTypes))
             then NIL
           else (NCP.CreateCard 'LinkIndex NoteFile NIL NoDisplayFlg Props ParentFileBoxes
                       (LIST ValidLinkTypes BackPointersP)
                       InterestedWindow RegionOrPosition])
)



(* ;; "Change to NCTEXTCARD")

(DEFINEQ

(NC.MakeTEditCard
  [LAMBDA (Card Title NoDisplayFlg ParamList InterestedWindow RegionOrPosition)
                                                             (* ; "Edited 11-Jun-88 15:58 by Trigg")
                                                             (* ; 
                                                          "Make up a blank text card and display it.")

    (* ;; "rht 9/10/85: Fixed call to NC.MakeTEditPropsList so prompt window gets fixed up before card is brought up.")

    (* ;; "fgh 11/13/85 Updated to handle Card object.")

    (* ;; "rht 4/11/86: Now passes type to NC.MakeTEditMiddleMenu.")

    (* ;; "rht 5/6/86: Now calls NC.InstallTitleBarLeftMenu and NC.InstallTextTitleBarMiddleMenu.")

    (* ;; 
  "rht 9/8/86: No longer hangs Card off NoteCardObject windowprop.  THis is done in NC.MakeNoteCard.")

    (* ;; "rht 9/19/86: Mod to above fix.  Now calls NC.MakeNewCardWindow a new fn that creates window and hangs Card off windowprop.  Also takes ParamList arg.")

    (* ;; "rht&pmi 11/19/86: Now passes NoteFile arg to NC.MakeTEditPropsList.")

    (* ;; "rht 4/17/87: Now makes a prompt window before opening the window.")

    (* ;; "dsj 9/22/87: Added call to NC.SetTitle so title passing from calling fns works properly.")

    (* ;; "pmi 12/10/87: Added dsj's changes;  see above comments.")

    (* ;; "pmi 2/9/88: Missed a call to NC.SetTitle - it's in there now.")

    (* ;; "rht 6/9/88: Added RegionOrPosition arg and passed to NC.MakeNewCardWindow.  Also InterestedWindow arg.")

    (LET (TextStream Window Type)
         (COND
            (NoDisplayFlg [SETQ TextStream (OPENTEXTSTREAM "" NIL NIL NIL (NC.MakeTEditPropsList
                                                                           NIL
                                                                           (LISTGET ParamList
                                                                                  '
                                                                     Don'tAttachUserSpecifiedPropsFlg
                                                                                  ]
                   (NC.SetSubstance Card TextStream)
                   (NC.SetTitle Card Title)
                   (STREAMPROP TextStream 'NoteCardObject Card)
                   Card)
            (T (SETQ Window (NC.MakeNewCardWindow Card (OR Title "Untitled")
                                   NIL T RegionOrPosition))

               (* ;; "Make a prompt window 'invisibly' so it gets hooked in.")

               (NC.AttachPromptWindowOffScreen Window)
               (NC.SetTitle Card Title)
               (SETQ Type (NC.RetrieveType Card))
               (NC.InstallTitleBarLeftMenu Window Type)
               (NC.InstallTextTitleBarMiddleMenu Window Type)
               (WINDOWADDPROP Window 'SHRINKFN (FUNCTION NC.TextCardShrinkFn))
               (TEDIT NIL Window NIL (NC.MakeTEditPropsList Window (NC.FileBoxP Card T)
                                            (fetch (Card NoteFile) of Card)))
               (until (WINDOWPROP Window 'TEXTSTREAM) do (BLOCK))
               (SETQ TextStream (WINDOWPROP Window 'TEXTSTREAM))
               (NC.SetSubstance Card TextStream)
               (STREAMPROP TextStream 'NoteCardObject Card)
               Window])
)



(* ;; "Change to NCFILEBOXCARD")

(DEFINEQ

(NC.MakeFileBox
  [LAMBDA (Card Title NoDisplayFlg ParamList InterestedWindow RegionOrPosition)
                                                             (* ; "Edited  5-Aug-88 15:43 by Trigg")
                                                             (* ; "Make up a blank contents card, hook it to the user specified parent contents cards, and display it.")

    (* ;; "rht 12/2/84: In NoDisplayFlg case, changed to return ID rather than TextStream.")

    (* ;; "rht 12/8/84: Massive shaving.  Took out code to force filing now (at creation time)")

    (* ;; "rht 9/11/85: Took out insertion of spacer when no markers.")

    (* ;; "fgh 11/13/85 Updated to handle Card object.")

    (* ;; "fgh 2/6/86 Chaged calls to NC.FetchDefaultHeight & NC.FetchDefaultWidth")

    (* ;; "fgh 2/6/86 Removed bug where NC.ClearMsg was deleteing card immediately.")

    (* ;; "rht 4/11/86: Now passes Type and Window to NC.MakeTEditLeftMenu.")

    (* ;; "rht 8/2/86: Now lets NC.MakeTEditPropsList build the props to be passed to TEDIT.")

    (* ;; 
  "rht 9/8/86: Now doesn't create window before calling TEDIT to avoid stupid prompt win popping up.")

    (* ;; "rht 9/19/86: Now applies supertype's MakeFn to cut out redundant code.")

    (* ;; "rht 11/10/86: Now passes NIL as title to Super's makefn.")

    (* ;; "rht 8/5/88: Added RegionOrPosition arg and passed to super's makefn.  Also added ParamList and InterestedWindow args.")

    (DECLARE (GLOBALVARS NC.MarkersInFileBoxesFlg NC.SubBoxMarkerLabel NC.FiledCardMarkerLabel 
                    NC.AlphabetizedFileBoxChildrenFlg))
    (LET ((Spacer (CONCAT (CHARACTER 13)
                         (CHARACTER 13)))
          Window TextStream Type)
         (SETQ Window (WINDOWP (NC.ApplySupersFn MakeFn Card NIL NoDisplayFlg
                                      (if ParamList
                                          then (LISTPUT ParamList 'Don'tAttachUserSpecifiedPropsFlg T
                                                      )
                                        else '(Don'tAttachUserSpecifiedPropsFlg T))
                                      InterestedWindow RegionOrPosition)))
         (SETQ TextStream (NC.FetchSubstance Card))
         (COND
            (NC.MarkersInFileBoxesFlg (TEDIT.INSERT.OBJECT (NC.MakePlaceMarker NC.SubBoxMarkerLabel)
                                             TextStream 1)
                   (TEDIT.INSERT TextStream Spacer 2)
                   (TEDIT.INSERT.OBJECT (NC.MakePlaceMarker NC.FiledCardMarkerLabel)
                          TextStream 4)
                   (TEDIT.INSERT TextStream Spacer 5)))
         (if NC.AlphabetizedFileBoxChildrenFlg
             then (NCP.CardProp Card 'OrderingFn (FUNCTION NC.IDAlphOrder)))
         (if NoDisplayFlg
             then Card
           else Window])
)



(* ;; "Change to NCGRAPHCARD")

(DEFINEQ

(NC.MakeGraphCard
  [LAMBDA (Card Title NoDisplayFlg ParamList InterestedWindow RegionOrPosition)
                                                             (* ; "Edited 11-Jun-88 15:58 by Trigg")

    (* ;; "Creates a StructEdit card.  Alot like a graph card except that it allows editing of underlying NC structure, and doesn't allow an 'insertlink' operation in title bar menu.")

    (* ;; "fgh 11/14/85 Updated to handle Card object.")

    (* ;; "rht 5/5/86: Replaced call to NC.SetupTitleBarMenu with Install calls.")

    (* ;; "fgh 6/30/86 Added NC.GRAPHERCOPYBUTTONEVENTFN to SHOWGRAPH call")

    (* ;; "rht 9/19/86: Mod to above fix.  Now calls NC.MakeNewCardWindow a new fn that creates window and hangs Card off windowprop.")

    (* ;; "pmi 6/23/87: Added the GRAPH.CHANGELABELFN NC.GraphChangeLabelFn to the Graph being created, which will then mark the substance dirty when a label is changed.")

    (* ;; "pmi 4/5/88: Now passes a NIL TOPJUSTIFYFLG to SHOWGRAPH.  This puts the origin at the lower left, the same as in browsers.")

    (* ;; "rht 6/9/88: Added RegionOrPosition arg and passed to NC.MakeNewCardWindow.  Also added ParamList and InterestedWindow args which we ignore.")

    (LET (Window Graph CardType)
         (SETQ Graph (create GRAPH
                            GRAPH.ADDNODEFN ← (FUNCTION NC.GraphAddNodeFn)
                            GRAPH.DELETENODEFN ← (FUNCTION NC.GraphDeleteNodeFn)
                            GRAPH.ADDLINKFN ← (FUNCTION NC.GraphAddLinkFn)
                            GRAPH.DELETELINKFN ← (FUNCTION NC.GraphDeleteLinkFn)
                            GRAPH.MOVENODEFN ← (FUNCTION NC.GraphMoveNodeFn)
                            GRAPH.FONTCHANGEFN ← (FUNCTION NC.GraphFontChangeFn)
                            GRAPH.CHANGELABELFN ← (FUNCTION NC.GraphChangeLabelFn)))
         (NC.SetSubstance Card Graph)
         (COND
            ((NOT NoDisplayFlg)
             (SETQ Window (NC.MakeNewCardWindow Card (OR Title "Untitled")
                                 NIL NIL RegionOrPosition))
             (SETQ CardType (NC.RetrieveType Card))
             (SHOWGRAPH Graph Window (FUNCTION NC.GraphCardLeftButtonFn)
                    (FUNCTION NC.GraphCardMiddleButtonFn)
                    NIL T (FUNCTION NC.GRAPHERCOPYBUTTONEVENTFN))
             (WINDOWADDPROP Window 'SHRINKFN (FUNCTION NC.GraphCardShrinkFn))
             (NC.InstallTitleBarButtonEventFn Window (FUNCTION NC.TitleBarButtonEventFn))
             (NC.InstallTitleBarLeftMenu Window CardType)
             (NC.InstallTitleBarMiddleMenu Window CardType)))
         (OR Window Card])
)



(* ;; "Change to NCBROWSERCARD")

(DEFINEQ

(NC.MakeBrowserCard
  [LAMBDA (Card Title NoDisplayFlg ParamList InterestedWindow RegionOrPosition)
                                                             (* ; "Edited  9-Jun-88 21:16 by Trigg")

    (* ;; "Make a browser card with id Card using root at RootID and the link following predictae specified by Predicate.  IF Root and/or ListOfLinkLabels not specified, ask the user.")

    (* ;; "rht 8/3/84: Changed to call NC.AskLinkLabel with its ReverseLinkLabel parameter set to T.")

    (* ;; "fgh 10/2/84 Changed Link Icons to be image objects in NodeLabel of Graph Npodes rather than annotations on graph nodes.")

    (* ;; "rht 10/19/84: Fixed setting up of browser card's prop list in case NoDisplayFlg is T so we have no Window.  Now NC.MakeLinksLegend returns the label pairs.")

    (* ;; "rht 11/27/84: Removed the WINDOWADDPROP call to put NC.GraphCardCloseFn on the CLOSEFN of the window.  This causes trouble.  NC.QuitCard will get put on by NC.MakeNoteCard and that's enough.")

    (* ;; "rht 1/3/85: Now puts a dummy region of the right size if the NoDisplayFlg is on.")

    (* ;; 
    "rht 1/15/85: Put hooks for AddNode, AddLink, etc.  so editing graph edits underlying structure.")

    (* ;; 
   "rht 2/14/85: Added VerticalFlg and made BrowserSpecs get put on browser's proplist in all cases.")

    (* ;; "rht 4/1/85: Now calls NC.AskBrowserSpecs with additional Don'tAskFlg in case of call from Programmer's interface.")

    (* ;; "rht 11/17/85: Updated to handle new card and notefile objects.")

    (* ;; "rht 2/7/86: Now gets browser format, etc.  via fetch/set fns.")

    (* ;; "rht 5/6/86: Took out call to NC.SetupTitleBarMenu.")

    (* ;; "rht 5/8/86: Added calls to rig title bar properly.")

    (* ;; "rht 7/10/86: Now passes ListOfLinkLabels to NC.AskBrowserSpecs.")

    (* ;; "rht 9/19/86: Mod to above fix.  Now calls NC.MakeNewCardWindow a new fn that creates window and hangs Card off windowprop.")

    (* ;; "pmi 12/5/86: Modified message to NC.SelectNoteCards to mention SHIFT-selection.  Also added GLOBALVARS statement.")

    (* ;; "pmi 12/12/86: Removed obsolete ReturnLinksFlg argument in call to NC.SelectNoteCards.")

    (* ;; "rht 12/16/86: Now checks that NC.MakeLink succeeded before creating a real link icon.  If not, then make a standin for a cross file link icon.")

    (* ;; "rg 3/18/87 added NC.CardSelectionOperation wrapper")

    (* ;; "rht 3/20/87: Removed needless call to NC.ActivateCard.")

    (* ;; "rg 4/2/87 changed wrapper to NCP.WithLockedCards and added NC.IfAllCardsFree wrapper")

    (* ;; "rht 5/26/87: Now handles cross-file links properly, i.e.  uses cross-file link standin in cases when GrowLinkLattice wasn't able to follow into the remote notefile.")

    (* ;; "dwm 1/19/88 Sets ReadOnly prop based upon current NF ReadOnly status")

    (* ;; "pmi 2/29/88: Now asks for specs only if none are specified coming in. A browser created from a browser now prompts for everything.  Also added InterestedWindow argument.")

    (* ;; "rht 6/9/88: Added RegionOrPosition arg and passed to NC.MakeNewCardWindow.")

    (DECLARE (GLOBALVARS NC.SubBoxLinkLabel NC.BrowserContentsLinkLabel NC.SpecialBrowserSpecsFlg 
                    NC.*Graph*BrowserFormat NC.SelectingBrowserSourceMenu))
    (NCP.WithLockedCards
     (PROG ([RootCards (MKLIST (LISTGET ParamList 'ROOTCARDS]
            (ListOfLinkLabels (LISTGET ParamList 'LINKTYPES))
            (BrowserFormat (LISTGET ParamList 'FORMAT))
            (Depth (LISTGET ParamList 'DEPTH))
            (CardType (NC.RetrieveType Card))
            (Don'tAskForRoots (FMEMB 'ROOTCARDS ParamList))
            (Don'tAskForSpecs (OR (FMEMB 'LINKTYPES ParamList)
                                  (FMEMB 'FORMAT ParamList)
                                  (FMEMB 'DEPTH ParamList)))
            Lattice RootNodes Window Graph SpecialBrowserSpecs BrowserSpecs DropVirtualNodesFlg)
           (NC.IfAllCardsFree
            (NC.LockListOfCards RootCards "Make Browser Card")
            (if (NOT NoDisplayFlg)
                then (SETQ Window (NC.MakeNewCardWindow Card (OR Title "Untitled")
                                         NIL NIL RegionOrPosition))
                     (WINDOWADDPROP Window 'SHRINKFN (FUNCTION NC.GraphCardShrinkFn))
                     (SETQ InterestedWindow Window))
            (OR Don'tAskForRoots (SETQ RootCards (NC.SelectNoteCards NIL NIL 
                                                        NC.SelectingBrowserSourceMenu 
                                                        InterestedWindow 
                          "Please shift-select the Cards and/or Boxes the browser should start from."
                                                        T)))
            (COND
               ((EQ RootCards 'DON'T)
                (NC.DeactivateCard Card)
                (CLOSEW Window)
                (RETURN)))
            (NC.HoldTTYProcess)
            [SETQ BrowserSpecs (NC.AskBrowserSpecs InterestedWindow Card ListOfLinkLabels Depth 
                                      BrowserFormat T (if Don'tAskForSpecs
                                                          then 'DONTASK]
            (COND
               ((NULL BrowserSpecs)
                (NC.DeactivateCard Card)
                (CLOSEW Window)
                (RETURN)))
            (SETQ ListOfLinkLabels (CAR BrowserSpecs))
            (SETQ Depth (CADR BrowserSpecs))
            (SETQ BrowserFormat (CADDR BrowserSpecs))        (* ; 
                    "If user wants *GRAPH* format, i.e.  virtual nodes eliminated, then set the flag")
            (if (FMEMB NC.*Graph*BrowserFormat BrowserFormat)
                then (SETQ DropVirtualNodesFlg T))
            [SETQ SpecialBrowserSpecs (COND
                                         (NC.SpecialBrowserSpecsFlg (NC.AskSpecialBrowserSpecs 
                                                                           InterestedWindow))
                                         (T (create SPECIALBROWSERSPECS]
            (OR NoDisplayFlg (NC.PrintMsg InterestedWindow T (CHARACTER 13)
                                    "Computing browser graph. Please wait. ..."))
                                                             (* ; "Create new browser hash array")
            (NC.GetBrowserHashArray Card)                    (* ; 
                                                "Compute lattice breakdth-first starting from roots.")
            (SETQ Lattice (NC.GrowLinkLattice RootCards NIL ListOfLinkLabels Card Depth))
            (SETQ RootNodes (if RootCards
                                then (for RootCard in RootCards collect (NC.GetBrowserNodeID Card 
                                                                               RootCard))
                              else NIL))

            (* ;; 
            "Link destination id information stored in NodeLabel field into a LinkIcon for display")

            (for Node in Lattice bind NodeID (CrossFileLinkModePropList ← (LIST (fetch (Card NoteFile
                                                                                             )
                                                                                   of Card)
                                                                                NIL))
               eachtime (BLOCK)
               do [replace (GRAPHNODE NODELABEL) of Node
                     with (LET (NewLink)
                               (if [AND (NOT (NC.CrossFileLinkCardP (fetch (GRAPHNODE NODELABEL)
                                                                       of Node)))
                                        (SETQ NewLink (NC.MakeLink InterestedWindow 
                                                             NC.BrowserContentsLinkLabel
                                                             (fetch (GRAPHNODE NODELABEL)
                                                                of Node)
                                                             Card NIL NIL NIL NIL NIL
                                                             (NC.ComputeCrossFileLinkMode
                                                              (fetch (GRAPHNODE NODELABEL)
                                                                 of Node)
                                                              CrossFileLinkModePropList 
                                                              InterestedWindow]
                                   then (NC.MakeLinkIcon NewLink)
                                 else (NC.MakeCrossFileLinkIconStandIn (fetch (GRAPHNODE NODELABEL)
                                                                          of Node] 
                                                             (* ; 
                  "Untouch each graph node so that next Recompute will put fresh values on proplist.")
                  (SETQ NodeID (fetch (GRAPHNODE NODEID) of Node))
                  (NC.GraphNodeIDRemProp (NC.CoerceToGraphNodeID NodeID)
                         'TouchedFlg)
                  (NC.GraphNodeIDRemProp (NC.CoerceToGraphNodeID NodeID)
                         'VisitedFlg))
            (SETQ Graph (if (AND Lattice RootNodes)
                            then (LAYOUTGRAPH Lattice RootNodes (SUBST 'LATTICE 
                                                                       NC.*Graph*BrowserFormat 
                                                                       BrowserFormat)
                                        (fetch (SPECIALBROWSERSPECS Font) of SpecialBrowserSpecs)
                                        (fetch (SPECIALBROWSERSPECS MotherD) of SpecialBrowserSpecs)
                                        (fetch (SPECIALBROWSERSPECS PersonalD) of SpecialBrowserSpecs
                                               )
                                        (fetch (SPECIALBROWSERSPECS FamilyD) of SpecialBrowserSpecs))
                          else (create GRAPH)))
            (NC.SetBrowserLinksLegend Card (NC.MakeLinksLegend Graph Window DropVirtualNodesFlg))
            (OR NoDisplayFlg (NC.PrintMsg InterestedWindow NIL "Done!"))
            (NC.SetSubstance Card Graph)
            (NC.SetBrowserLinkLabels Card (OR ListOfLinkLabels (LIST NC.SubBoxLinkLabel)))
            (NC.SetBrowserRoots Card RootCards)
            (NC.SetBrowserFormat Card BrowserFormat)
            (NC.SetBrowserDepth Card Depth)
            (NC.SetSpecialBrowserSpecs Card SpecialBrowserSpecs)
            (NC.SetUserDataProp Card 'ReadOnly (NC.CardReadOnlyOpenP Card))
            (COND
               (NoDisplayFlg (RETURN Card)))
            (WINDOWPROP Window 'GRAPH Graph)
            (NC.InstallTitleBarLeftMenu Window CardType)
            (NC.InstallTitleBarMiddleMenu Window CardType)
            (NC.RelayoutBrowserCard Window)
            (RETURN Window])
)



(* ;; "Change to NCSKETCHCARD")

(DEFINEQ

(NC.MakeSketchCard
  [LAMBDA (Card Title NoDisplayFlg ParamList InterestedWindow RegionOrPosition)
                                                             (* ; "Edited 11-Jun-88 15:58 by Trigg")

    (* ;; "rht 2/1/85: Added windowprop to prevent sketch asking about saving changes.")

    (* ;; "fgh 11/14/85 Updated to handle Card object.")

    (* ;; "rht 5/6/86 Replaced call to NC.SetupTitleBarMenu with calls to NC.InstallTitleBarButtonEventFn and NC.InstallTitleBarLeftMenu and NC.InstallSketchTitleBarMiddleMenu.")

    (* ;; "fgh 6/30/86 Added NC.SK.COPY.BUTTONEVENTFN on Sketch Window.  Added SKETCH.ADD.ELEMENT call when NoDisplayFlg")

    (* ;; "rht 6/11/88: Added RegionOrPosition arg and passed to NC.DetermineDisplayRegion.  Also added ParamList and InterestedWindow args which we ignore.")

    (if NoDisplayFlg
        then (NC.SetSubstance Card (SKETCH.ADD.ELEMENT NIL NIL))
             Card
      else (LET (Window CardType)
                (SETQ CardType (NC.RetrieveType Card))
                [SETQ Window (SKETCHW.CREATE NIL NIL (NC.DetermineDisplayRegion Card RegionOrPosition
                                                            )
                                    (OR Title "Untitled")
                                    NIL
                                    (SKETCH.COMMANDMENU (NC.GetCardTypeField MiddleButtonMenuItems 
                                                               CardType]
                (WINDOWPROP Window 'DONTQUERYCHANGES T)
                (WINDOWPROP Window 'COPYBUTTONEVENTFN (FUNCTION NC.SK.COPY.BUTTONEVENTFN))
                (WINDOWPROP Window 'SHRINKFN (FUNCTION NC.SketchCardShrinkFn))
                (NC.InstallTitleBarButtonEventFn Window (FUNCTION NC.SketchTitleBarButtonEventFn))
                (NC.InstallTitleBarLeftMenu Window CardType)
                (NC.SetSubstance Card (INSURE.SKETCH Window))
                Window])
)



(* ;; "Change to NCSEARCHCARD")

(DEFINEQ

(NC.MakeSearchCard
  [LAMBDA (Card Title NoDisplayFlg ParamList InterestedWindow RegionOrPosition)
                                                             (* ; "Edited  5-Aug-88 13:53 by Trigg")

    (* ;; "Search for cards with specified characteristics and create a list card containing pointers to these cards.  For now search is limited to cards whose title contains a specified string.")

    (* ;; "rht 11/8/84: Fixed some confusion between ListCardID and ID variables.")

    (* ;; "fgh 11/17/85 Updated to handle multiple notefiles and crad objects.")

    (* ;; "rht 4/11/86: changed to call NC.ApplySuper.")

    (* ;; "rht 10/21/86: Now deletes card if no search string specified.")

    (* ;; "rg 3/16/87 NC.DeleteNoteCards -> NC.DeleteNoteCard")

    (* ;; "rht 8/5/88: Added RegionOrPosition arg and passed to super's makefn.  Also added ParamList and InterestedWindow args.")

    (LET ((NoteFile (fetch (Card NoteFile) of Card))
          SearchString HitCards WindowOrCard Window)
         (SPAWN.MOUSE)
         (SETQ WindowOrCard (NC.ApplySupersFn MakeFn Card (OR Title "SearchCard")
                                   NoDisplayFlg ParamList InterestedWindow RegionOrPosition))
         (NC.ActivateCard Card)
         (SETQ Window (AND (WINDOWP WindowOrCard)
                           WindowOrCard))
         (SETQ SearchString (NC.AskUser "Please enter the search string: " NIL NIL T (OR Window 
                                                                                     InterestedWindow
                                                                                         )))
         (if (OR (EQUAL SearchString "")
                 (NOT SearchString))
             then (NC.DeleteNoteCard Card NIL T)
                  NIL
           else [NC.SetTitle Card (SETQ Title (OR Title (CONCAT "Cards with %"" SearchString 
                                                               "%" in title"]
                (AND Window (WINDOWPROP Window 'TITLE Title))
                (RESETLST
                    (RESETSAVE (CURSOR WAITINGCURSOR))
                    (NC.PrintMsg (OR Window InterestedWindow)
                           T "Searching for cards ...")
                    (SETQ HitCards (NC.TitleSearch NoteFile SearchString))
                    (TEDIT.INSERT (NC.FetchSubstance Card)
                           (CONCAT " List compiled on: " (DATE)
                                  (CHARACTER 13)
                                  (CHARACTER 13))
                           1)
                    (for HitCard in HitCards unless (EQ HitCard Card)
                       do (NC.InsertLinkBeforeMarker Card HitCard NC.ListContentsLinkLabel NIL NIL))
                    (NC.PrintMsg (OR Window InterestedWindow)
                           NIL "Done!" (CHARACTER 13)))
                (BLOCK 250)
                (NC.ClearMsg (OR Window InterestedWindow)
                       T)
                WindowOrCard])
)



(* ;; "Change to NCLINKINDEXCARD")

(DEFINEQ

(NC.MakeLinkIndex
  [LAMBDA (Card Title NoDisplayFlg SpecialArgsList InterestedWindow RegionOrPosition)
                                                             (* ; "Edited  5-Aug-88 13:53 by Trigg")

(* ;;; "Gather all instances of a given set of linktypes, printing the titles of cards at the from and to ends of the link.")

    (* ;; "rht 10/24/84: Now callable from Programmer's interface.  If NoDisplayFlg it non-nil, then will build LinkIndex invisibly.  If SpecialArgsList is non-nil, then should be list of (<linklabels> <backpointersP>)")

    (* ;; "rht 9/21/85: Now uses stylesheet for LinkIndexSpecs.  Broke out workhorse code into the function NC.ComputeLinkIndex")

    (* ;; "fgh 11/17/85 Updated to handle Card objects.")

    (* ;; "rht 4/11/86: Took out call to NCP.AddTitleBarMenuItems.  Now done in NC.AddLinkIndexCard.  Also changed to call NC.ApplySuper.")

    (* ;; "rht 9/5/86: Now bails out properly if user aborts in stylesheet.")

    (* ;; "rht 9/19/86: Now passes IndexCard rather than Window to NC.AskLinkIndexSpecs.  Added call to NC.HoldTTYProcess to keep linkindexspecs on top.")

    (* ;; "rg 3/16/87 NC.DeleteNoteCards -> NC.DeleteNoteCard")

    (* ;; "rht 8/5/88: Added RegionOrPosition arg and passed to NC.MakeNewCardWindow.  Also added InterestedWindow arg.")

    (PROG ((LinkLabels (CAR SpecialArgsList))
           (BackLinksFlg (CADR SpecialArgsList))
           Window LinkIndexSpecs)
          (SPAWN.MOUSE)
          (SETQ Window (WINDOWP (NC.ApplySupersFn MakeFn Card (CONCAT "Link Index: " (DATE))
                                       NoDisplayFlg NIL InterestedWindow RegionOrPosition)))
          (if (NOT NoDisplayFlg)
              then (NC.HoldTTYProcess)
                   (SETQ LinkIndexSpecs (NC.AskLinkIndexSpecs Card LinkLabels BackLinksFlg T))
                   (if (NULL LinkIndexSpecs)
                       then (NC.DeleteNoteCard Card NIL T NIL (OR Window InterestedWindow))
                            (RETURN NIL))
                   (SETQ LinkLabels (CAR LinkIndexSpecs))
                   (SETQ BackLinksFlg (CADR LinkIndexSpecs)))
          (NC.ComputeLinkIndex Card LinkLabels BackLinksFlg)
          (RETURN (if NoDisplayFlg
                      then Card
                    else (NC.ClearMsg (OR Window InterestedWindow)
                                T)
                         Window])
)



(* ;; "Change to NCDOCUMENTCARD")

(DEFINEQ

(NC.MakeDocument
  [LAMBDA (Card Title NoDisplayFlg TypeSpecificArgs InterestedWindow RegionOrPosition)
                                                             (* ; "Edited  5-Aug-88 13:47 by Trigg")

    (* ;; "Called from a filebox's title bar.  Makes a document by smashing all the descendant cards's text together.  Ask user if wants numbered section headings and titles.  The former are made from FileBox titles, the latter from notecard titles.  Delete embedded links at the end if the user desires.")

    (* ;; "rht 10/22/84: Hacked to be callable from Programmer's interface.")

    (* ;; "rht 11/17/84: Checks for cancel when choosing rootID and also when setting parameters.")

    (* ;; "rht 8/25/85: Now dumps sketch and graph cards as well as text cards.")

    (* ;; "rht 9/16/85: Now handles cr's around titles using para leading.")

    (* ;; "fgh 11/178/85 Updated to handle Card and NoteFile objects.")

    (* ;; "kirk 27Jun86 Moved NC.RetrieveTitle call so does not break when user Cancels")

    (* ;; "rht 7/31/86: Now checks for card types having ExportSubstanceFn prop.")

    (* ;; "kirk 8/22/86 Fix of free use of NoteFile var")

    (* ;; "rht 10/15/86: Integrated markM's changes and fixed box numbering.")

    (* ;; "rht 11/17/86: Now calls NC.ApplySupersFn rather than NC.MakeNoteCard.")

    (* ;; "pmi 12/5/86: Modified message to NC.SelectNoteCards to mention SHIFT-selection.")

    (* ;; "pmi 12/12/86: Removed obsolete ReturnLinksFlg argument in call to NC.SelectNoteCards.")

    (* ;; "rg 3/16/87 NC.DeleteNoteCards -> NC.DeleteNoteCard")

    (* ;; 
   "rg 3/18/87 added NC.CardSelectionOperation wrapper.  Still needs ProtectedCardOperation wrapper!")

    (* ;; "rg 4/2/87 changed NC.CardSelectionOperation to NCP.WithLockedCards")

    (* ;; "rht 4/17/87: No longer bugs user for confirm of delete when cancel'ing.")

    (* ;; "rht 6/4/87: Now stashes on doc card a prop list of destination notefiles of cross-file links encountered during creation of contents.")

    (* ;; "pmi 2/25/88: Replaced CardIdentifier argument with TypeSpecificArgs, and added InterestedWindow argument.  The task of figuring out the parameters is now done here, rather than in NCP.MakeDocument. ")

    (* ;; "rht 8/5/88: Added RegionOrPosition arg and passed to super fn.")

    (NCP.WithLockedCards (PROG (RootCard RootTitle DocWindow DocCard DocWindowOrCard DocStream 
                                      ParamProps CurParams HeadingsFromFileboxes TitlesFromNoteCards
                                      BuildBackLinks CopyEmbeddedLinks ExpandEmbeddedLinks InspectWin
                                      RootSubstanceType)
                               (OR NoDisplayFlg (SPAWN.MOUSE))
                               (SETQ DocWindowOrCard (NC.ApplySupersFn MakeFn Card "Document" 
                                                            NoDisplayFlg NIL InterestedWindow 
                                                            RegionOrPosition))
                               (if NoDisplayFlg
                                   then (SETQ DocWindow InterestedWindow)
                                        (SETQ DocCard DocWindowOrCard)
                                 else (SETQ DocWindow DocWindowOrCard)
                                      (SETQ DocCard (NC.CoerceToCard DocWindow)))
                                                             (* ; 
                      "NC.MakeNoteCard either returned a Card or a window depending on NoDisplayFlg.")
                               (SETQ RootCard (OR (NC.CoerceToCard (CAR TypeSpecificArgs))
                                                  (NC.SelectNoteCards T NIL NC.SelectingCardMenu 
                                                         DocWindow 
                      "Please shift-select the Note Card or File Box the document should start from."
                                                         )))
                               (if (NOT RootCard)
                                   then (NC.DeleteNoteCard Card NIL T)
                                        (RETURN NIL))
                               (SETQ RootTitle (NC.RetrieveTitle RootCard))
                               (NC.SetTitle DocCard (CONCAT "Document from %"" RootTitle "%""))
                               (AND DocWindow (WINDOWPROP DocWindow 'TITLE (NC.RetrieveTitle DocCard)
                                                     ))
                               (SETQ DocStream (NC.FetchSubstance DocCard))

(* ;;; "Get MakeDocument parameters from user via inspector window if none were passed in.")

                               (if (SETQ ParamProps (CADR TypeSpecificArgs))
                                   then (SETQ CurParams (NCP.DocumentParameters ParamProps))
                                 else (SETQ InspectWin (NC.BuildMakeDocInspector DocWindow))
                                      (TOTOPW InspectWin)
                                      (for while (OPENWP InspectWin) do (BLOCK)))
                               (if (EQ (GETPROP 'NC.MakeDocParameters '--DONE--)
                                       'QUIT)
                                   then (PUTPROP 'NC.MakeDocParameters '--DONE-- '--CANCEL--)
                                        (NC.DeleteNoteCard Card NIL T)
                                        (if ParamProps
                                            then (SETPROPLIST 'NC.MakeDocParameters CurParams))
                                        (RETURN NIL))
                               (SETQ HeadingsFromFileboxes (GETPROP 'NC.MakeDocParameters
                                                                  'HeadingsFromFileboxes))
                               (SETQ TitlesFromNoteCards (GETPROP 'NC.MakeDocParameters '
                                                                TitlesFromNoteCards))
                               (SETQ BuildBackLinks (GETPROP 'NC.MakeDocParameters 'BuildBackLinks))
                               (SETQ CopyEmbeddedLinks (GETPROP 'NC.MakeDocParameters '
                                                              CopyEmbeddedLinks))
                               (SETQ ExpandEmbeddedLinks (GETPROP 'NC.MakeDocParameters '
                                                                ExpandEmbeddedLinks))

(* ;;; "Call recursive routine to dump filebox.")

                               (RESETLST
                                   (RESETSAVE (CURSOR WAITINGCURSOR))
                                   (NC.PrintMsg DocWindow NIL 
                                          "Collecting text from descendant cards ... ")

(* ;;; "Clean up the SeenBefore markers placed on the cards and boxes just copied.")

                                   [RESETSAVE NIL '(PROGN (for Card in (NC.FetchUserDataProp
                                                                        DocCard
                                                                        'SeenCards)
                                                             do (NC.SetUserDataProp Card 'SeenBefore
                                                                       NIL))
                                                          (NC.SetUserDataProp DocCard 'SeenCards NIL]
                                                             (* ; 
                                       "Clean up the CrossFileLinkModePropList hung off the Doccard.")
                                   [RESETSAVE NIL '(PROGN (NC.SetUserDataProp DocCard '
                                                                 CrossFileLinkModePropList NIL]

(* ;;; "Unbelievably kludgy hack to get around Intermezzo TEdit bug.  Just insert and delete a CR.")

                                   (TEDIT.INSERT DocStream NC.CRString 1)
                                   (TEDIT.DELETE DocStream 1 1)
                                   (NC.SetUserDataProp DocCard 'CrossFileLinkModePropList
                                          (LIST (fetch (Card NoteFile) of DocCard)
                                                NIL))
                                   (NC.DumpCardToDoc RootCard DocCard DocStream 0 0 
                                          HeadingsFromFileboxes TitlesFromNoteCards BuildBackLinks 
                                          CopyEmbeddedLinks ExpandEmbeddedLinks)
                                   (NC.PrintMsg DocWindow NIL "Done!"))
                               (COND
                                  ((NOT NoDisplayFlg)
                                   (BLOCK 250)
                                   (NC.ClearMsg DocWindow T)))

                          (* ;; 
                 "Return NC.MakeDocParameters to its original setting, if new params were passed in.")

                               (if ParamProps
                                   then (SETPROPLIST 'NC.MakeDocParameters CurParams))
                               (RETURN DocWindowOrCard])
)



(* ;; "Change to NCIDEASKETCHCARD")

(DEFINEQ

(NCIDEASKETCH.MakeIdeaSketchCard
  [LAMBDA (Card Title NoDisplayFlg ParamList InterestedWindow RegionOrPosition)
                                                             (* ; "Edited  5-Aug-88 15:41 by Trigg")

(* ;;; "Create an idea sketch card.  This is almost a copy of NC.MakeSketchCard.")

    (* ;; "kirk 10Aug86 Converted to 1.3k")

    (* ;; "rht 8/5/88: Added RegionOrPosition arg and passed to NC.DetermineDisplayRegion.  Also added ParamList and InterestedWindow args.")

    (if NoDisplayFlg
        then (NC.SetSubstance Card (SKETCH.ADD.ELEMENT NIL NIL))
             Card
      else (LET (Window CardType)
                (SETQ CardType (NC.RetrieveType Card))
                [SETQ Window (WRITEW.CREATE NIL NIL (NC.DetermineDisplayRegion Card RegionOrPosition)
                                    (OR Title "Untitled")
                                    NIL
                                    (SKETCH.COMMANDMENU (NC.GetCardTypeField MiddleButtonMenuItems 
                                                               CardType]
                (WINDOWPROP Window 'DONTQUERYCHANGES T)
                (WINDOWPROP Window 'COPYBUTTONEVENTFN (FUNCTION NC.SK.COPY.BUTTONEVENTFN))
                (WINDOWPROP Window 'SHRINKFN (FUNCTION NC.SketchCardShrinkFn))
                (NC.InstallTitleBarButtonEventFn Window (FUNCTION NC.SketchTitleBarButtonEventFn))
                (NC.InstallTitleBarLeftMenu Window CardType)
                (NC.SetSubstance Card (INSURE.SKETCH Window))
                Window])
)



(* ;; "Change to NCFILECARD")

(DEFINEQ

(NC.MakeFileCard
  [LAMBDA (Card Title NoDisplayFlg ParamList InterestedWindow RegionOrPosition)
                                                             (* ; "Edited  5-Aug-88 15:47 by Trigg")

(* ;;; "Make a new card of type File -- ERSETQ around Core procedure here!")

    (* ;; "rht 8/5/88: Added RegionOrPosition arg and passed to NC.MakeFileCardCore.  Also added ParamList and InterestedWindow args.")

    (LET (ReturnValue)
         (COND
            ((AND (ERSETQ (SETQ ReturnValue (NC.MakeFileCardCore Card Title NoDisplayFlg ParamList 
                                                   InterestedWindow RegionOrPosition)))
                  ReturnValue))
            (T (AND (OPENWP (NC.FetchWindow Card))
                    (CLOSEW (NC.FetchWindow Card)))
               NIL])

(NC.MakeFileCardCore
  [LAMBDA (Card Title NoDisplayFlg ParamList InterestedWindow RegionOrPosition)
                                                             (* ; "Edited  5-Aug-88 15:48 by Trigg")

(* ;;; "Make a new card of type File -- Core procedure")

    (* ;; "fgh 12/17/85 Updated for 1.3 multiple open NF changes")

    (* ;; "fgh 6/1/86 Updated with new title bar menu scheme")

    (* ;; "rht 3/25/87: Cleaned up lots of outdated cruftiness.")

    (* ;; "rht 4/29/87: Changed to match NC.MakeTEditCard.")

    (* ;; "rht 8/5/88: Added RegionOrPosition arg and passed to NC.MakeNewCardWindow.  Also added ParamList and InterestedWindow args.")

    (LET (FileName TextStream)
         (if (NOT NoDisplayFlg)
             then (LET ((Window (NC.MakeNewCardWindow Card (OR Title "Creating File card ...")
                                       NIL T RegionOrPosition))
                        (Type (NC.RetrieveType Card)))       (* ; 
                                             "Make a prompt window 'invisibly' so it gets hooked in.")
                       (NC.AttachPromptWindowOffScreen Window)
                       (NC.InstallTitleBarLeftMenu Window Type)
                       (NC.InstallTextTitleBarMiddleMenu Window Type)
                       (WINDOWADDPROP Window 'SHRINKFN (FUNCTION NC.FileCardShrinkFn))
                       (TEDIT NIL Window NIL (NC.MakeTEditPropsList Window T (fetch (Card NoteFile)
                                                                                of Card)))
                       (until [SETQ TextStream (NC.SetTextStream Card (WINDOWPROP Window 'TEXTSTREAM]
                          do (BLOCK))
                       (STREAMPROP TextStream 'NoteCardObject Card)
                       (if (SETQ FileName (NC.GetFileFromUser Window))
                           then (TEDIT.INCLUDE (TEXTOBJ TextStream)
                                       FileName)
                                (NC.SetSubstance Card FileName)
                                (WINDOWPROP Window 'TITLE (NC.SetTitle Card (NC.FileCardTitle Card)))
                                (NC.PutProp Card 'FileName FileName)
                                (NC.PutProp Card 'FileVersion (NC.FileCardFileVersionNumber Card))
                                (GIVE.TTY.PROCESS Window)
                                Window
                         else (NC.DeleteNoteCard Card NIL T)
                              NIL))
           else (SETQ FileName (NC.GetFileFromUser))
                (NC.SetSubstance Card FileName)
                (NC.SetTitle Card (NC.FileCardTitle Card))
                Card])
)
(PUTPROPS RHTPATCH332 COPYRIGHT ("Xerox Corporation" 1988))
(DECLARE%: DONTCOPY
  (FILEMAP (NIL (4086 4553 (NC.FetchNewCardPos 4096 . 4551)) (4589 14563 (NC.DetermineDisplayRegion 4599
 . 10118) (NC.MakeNoteCard 10120 . 14561)) (14601 27062 (NCP.CreateCard 14611 . 17516) (
NCP.CreateTextCard 17518 . 18215) (NCP.CreateFileBox 18217 . 19026) (NCP.CreateBrowserCard 19028 . 
22010) (NCP.CreateSketchCard 22012 . 22662) (NCP.CreateGraphCard 22664 . 23307) (NCP.MakeDocument 
23309 . 25271) (NCP.MakeLinkIndex 25273 . 27060)) (27101 30496 (NC.MakeTEditCard 27111 . 30494)) (
30538 33470 (NC.MakeFileBox 30548 . 33468)) (33510 36183 (NC.MakeGraphCard 33520 . 36181)) (36225 
47458 (NC.MakeBrowserCard 36235 . 47456)) (47499 49472 (NC.MakeSketchCard 47509 . 49470)) (49513 52559
 (NC.MakeSearchCard 49523 . 52557)) (52603 55068 (NC.MakeLinkIndex 52613 . 55066)) (55111 64282 (
NC.MakeDocument 55121 . 64280)) (64327 65904 (NCIDEASKETCH.MakeIdeaSketchCard 64337 . 65902)) (65943 
69493 (NC.MakeFileCard 65953 . 66772) (NC.MakeFileCardCore 66774 . 69491)))))
STOP