(FILECREATED " 8-Jun-87 23:38:18" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH275.;5 52419
changes to: (FNS NCP.CopyCards NCP.GetCrossFileLinkDestCard NC.FixUpLinksInCardCopy
NC.CopyCards NC.SelectNoteCards NC.SelectNoteCardsCopyInsertFn
NC.GetCrossFileLinkDestCard NC.PromptWindowOpenP
NC.OpenCrossFileLinkDestNoteFile NCP.CollectCards NCP.CardNeighbors
NC.ComputeCrossFileLinkMode)
(VARS RHTPATCH275COMS)
previous date: " 6-Jun-87 16:21:17" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH275.;1)
(* Copyright (c) 1987 by Xerox Corporation. All rights reserved.)
(PRETTYCOMPRINT RHTPATCH275COMS)
(RPAQQ RHTPATCH275COMS ((* * Enables copying of "external" links in NC.CopyCards. Also small fix to
NC.ComputeCrossFileLinkMode.)
(* * Changes to NCDATABASE)
(FNS NC.FixUpLinksInCardCopy NC.CopyCards)
(* * Change to NCCROSSFILELINKS)
(FNS NC.ComputeCrossFileLinkMode NC.GetCrossFileLinkDestCard
NC.OpenCrossFileLinkDestNoteFile)
(* * Changes to NCPROGINT)
(FNS NCP.CollectCards NCP.CardNeighbors)
(* * New function for NCPROGINT)
(FNS NCP.GetCrossFileLinkDestCard)
(* * Change to NCINTERFACE)
(FNS NC.SelectNoteCards NC.SelectNoteCardsCopyInsertFn)
(* * New function for NCINTERFACE)
(FNS NC.PromptWindowOpenP)))
(* * Enables copying of "external" links in NC.CopyCards. Also small fix to
NC.ComputeCrossFileLinkMode.)
(* * Changes to NCDATABASE)
(DEFINEQ
(NC.FixUpLinksInCardCopy
(LAMBDA (CardCopy CardHashArray LinksHashArray CurrentLinkLabels NewLinkLabels InterestedWindow
CopyExternalToLinksFlg CrossFileLinkModePropList)
(* rht: " 8-Jun-87 14:07")
(* * For all the links from or to CardCopy, change other endpoint's card according to mapping table in
CardHashArray. If other endpoint is a card not found in the hash array, then drop that link altogether.
The mapping from old link UIDs to new ones is in LinksHashArray. Any new link labels not in CurrentLinkLabels get
TCONC'ed onto NewLinkLabels.)
(* * rht 2/17/86: Now uses NC.ApplyFn instead of APPLY* for deleting and collecting references.)
(* * rht 11/1/86: Added missing var bindings and a BLOCK)
(* * rht 6/6/87: Added new args InterestedWindow, CopyExternalToLinksFlg, and CrossFileLinkModePropList to handle
optional copying of external links.)
(LET ((CardCopyType (NC.FetchType CardCopy)))
(* * Fix all the From links.)
(NC.SetFromLinks CardCopy (for Link in (NC.FetchFromLinks CardCopy) eachtime
(BLOCK)
bind SourceCard OldLinkUID LinkLabel
when (SETQ SourceCard (GETHASH (fetch (Link
SourceCard)
of Link)
CardHashArray))
collect (replace (Link DestinationCard) of Link
with CardCopy)
(replace (Link SourceCard) of Link
with SourceCard)
(replace (Link UID) of Link
with (OR (GETHASH (SETQ OldLinkUID
(fetch (Link UID)
of Link))
LinksHashArray)
(PUTHASH OldLinkUID (NC.MakeUID)
LinksHashArray)))
(* Keep track of link labels in case any are new.)
(OR (FMEMB (SETQ LinkLabel
(fetch (Link Label)
of Link))
CurrentLinkLabels)
(NC.SystemLinkLabelP LinkLabel)
(FMEMB LinkLabel (CAR NewLinkLabels))
(TCONC NewLinkLabels LinkLabel))
Link))
(* * Do it all again for the To links.)
(NC.SetToLinks CardCopy (for Link in (NC.FetchToLinks CardCopy) eachtime (BLOCK)
bind DestCard OldLinkUID LinkLabel
when (SETQ DestCard (GETHASH (fetch (Link
DestinationCard)
of Link)
CardHashArray))
collect (replace (Link SourceCard) of Link with
CardCopy)
(replace (Link DestinationCard) of Link
with DestCard)
(replace (Link UID) of Link
with (OR (GETHASH (SETQ OldLinkUID
(fetch (Link UID)
of Link))
LinksHashArray)
(PUTHASH OldLinkUID (NC.MakeUID)
LinksHashArray)))
(* Keep track of link labels in case any are new.)
(OR (FMEMB (SETQ LinkLabel (fetch
(Link Label) of Link))
CurrentLinkLabels)
(NC.SystemLinkLabelP LinkLabel)
(FMEMB LinkLabel (CAR NewLinkLabels))
(TCONC NewLinkLabels LinkLabel))
Link))
(* * Now fix the links inside imageobj's in the card's substance.)
(AND (fetch (Card LinkAnchorModesSupported) of CardCopy)
(for Link in (CAR (NC.ApplyFn CollectLinksFn CardCopy)) eachtime (BLOCK)
bind PreviousLink do (LET ((DestCard (fetch (Link DestinationCard)
of Link))
(LinkLabel (fetch (Link Label) of Link))
OldLinkUID DestCardCopy NewLink)
(COND
((SETQ DestCardCopy (GETHASH DestCard
CardHashArray))
(replace (Link SourceCard) of Link
with CardCopy)
(replace (Link DestinationCard) of Link
with DestCardCopy)
(replace (Link UID) of Link
with (OR (GETHASH
(SETQ OldLinkUID
(fetch (Link UID)
of Link))
LinksHashArray)
(PUTHASH OldLinkUID (
NC.MakeUID)
LinksHashArray)))
(* Keep track of link labels in case any are new.)
(OR (FMEMB LinkLabel CurrentLinkLabels)
(NC.SystemLinkLabelP LinkLabel)
(FMEMB LinkLabel (CAR NewLinkLabels))
(TCONC NewLinkLabels LinkLabel))
(SETQ PreviousLink Link))
((AND CopyExternalToLinksFlg
(if (NC.CrossFileLinkCardP DestCard)
then (SETQ DestCard
(NC.GetCrossFileLinkDestCard
DestCard InterestedWindow))
else DestCard)
(SETQ NewLink
(NC.MakeLink NIL LinkLabel DestCard
CardCopy
(fetch (Link
DisplayMode)
of Link)
(fetch (Link AnchorMode)
of Link)
NIL NIL PreviousLink
(
NC.ComputeCrossFileLinkMode
DestCard
CrossFileLinkModePropList
InterestedWindow))))
(* It's an external link. Try to make a copy, possibly
resulting in a cross-file link.)
(* Smash the imageobj's link with contents of new one
we just made.)
(for FieldName in (RECORDFIELDNAMES
(QUOTE Link))
do (RECORDACCESS
FieldName Link (RECLOOK
(QUOTE Link))
(QUOTE REPLACE)
(RECORDACCESS FieldName NewLink
(RECLOOK
(QUOTE Link))
(QUOTE FETCH))))
(SETQ PreviousLink Link))
(T (NC.ApplyFn DeleteLinksFn CardCopy Link)))))))))
(NC.CopyCards
(LAMBDA (Cards DestNoteFileOrFileBox RootCards QuietFlg InterestedWindow CopyExternalToLinksMode)
(* rht: " 6-Jun-87 16:47")
(* * Create copies of cards in Cards. If DestNoteFileOrFileBox is a notefile, then destination will be the contents
box in that notefile, else the FileBox's notefile. RootCards should be NIL or a subset of Cards.
If NIL, then file all Cards in the dest filebox. Otherwise, just file RootCards in that filebox and assume others
are linked somehow to the RootCards. Links between cards in Cards are copied, but links from or to outside cards
aren't.)
(* * Currently all Cards must be in same notefile, but this perhaps could be relaxed if could prevent possibility
of two cards in different notefiles having the same UID.)
(* * kirk 24Apr86 Added calls to select cards if none provided)
(* * rht 9/2/86: Added InterestedWindow arg.)
(* * pmi 12/12/86: Removed obsolete ReturnLinksFlg argument in call to NC.SelectNoteCards.)
(* * rg 3/18/87 added NC.CardSelectionOperation wrapper)
(* * rg 4/2/87 changed NC.CardSelectionOperation to NCP.WithLockedCards ; added NC.IfAllCardsFree wrapper)
(* * rht&rg&pmi 4/22/87: No longer calls ERROR!)
(* * rg 6/2/87 was checking for CANCELLED instead of DON'T)
(* * rg 6/5/87 deletes new cards if we cancel out halfway through)
(* * rht 6/6/87: Now optionally copies "external" links. Passes extra new args to NC.FixUpLinksInCardCopy.)
(NCP.WithLockedCards (NC.IfAllCardsFree
(NC.LockListOfCards Cards "Copy Cards")
(PROG (NumCards SourceNoteFile DestNoteFile BoxToFileIn TempStream
CardHashArray LinksHashArray CurrentLinkLabels
NewLinkLabels NewCardsAndLocsOnStream
CopyExternalToLinksFlg)
(* * Make sure the arguments are valid.)
(if (NULL Cards)
then (if (NULL (SETQ Cards
(NC.SelectNoteCards NIL NIL
NC.SelectingCardsMenu NIL
"Shift-select from the same NoteFile cards to copy:"
NIL)))
then (RETURN NIL)))
(SETQ Cards (MKLIST Cards))
(SETQ NumCards (LENGTH Cards))
(* All Cards to copy must live in same notefile.)
(SETQ SourceNoteFile (fetch (Card NoteFile)
of (CAR Cards)))
(if (NOT (AND (type? NoteFile SourceNoteFile)
(OPENP (fetch (NoteFile Stream)
of SourceNoteFile))))
then (NC.ReportError "NC.CopyCards"
(CONCAT (fetch (NoteFile
FullFileName)
of SourceNoteFile)
" not an open notefile.")))
(if (NOT (for Card in Cards
always (NC.SameNoteFileP (fetch
(Card NoteFile)
of Card)
SourceNoteFile)))
then (NC.ReportError "NC.CopyCards"
"All cards in Cards arg don't live in the same notefile."))
(* Compute dest notefile and dest filebox.)
(if (NOT DestNoteFileOrFileBox)
then (if (EQ (QUOTE DON'T)
(SETQ DestNoteFileOrFileBox
(NC.SelectNoteCards T NIL
NC.SelectingCardMenu NIL
"Shift-select the FileBox to contain these cards."
T)))
then (RETURN NIL)))
(if (type? NoteFile DestNoteFileOrFileBox)
then (SETQ DestNoteFile DestNoteFileOrFileBox)
(SETQ BoxToFileIn (fetch (NoteFile
TableOfContentsCard)
of DestNoteFile))
elseif (NCP.FileBoxP DestNoteFileOrFileBox)
then (SETQ BoxToFileIn DestNoteFileOrFileBox)
(SETQ DestNoteFile (fetch (Card NoteFile)
of BoxToFileIn))
else (NC.ReportError "NC.CopyCards" (CONCAT
"Arg not notefile or filebox: "
DestNoteFileOrFileBox)))
(if (NOT (AND (type? NoteFile DestNoteFile)
(OPENP (fetch (NoteFile Stream)
of DestNoteFile))))
then (NC.ReportError "NC.CopyCards"
(CONCAT (fetch (NoteFile
FullFileName)
of DestNoteFile)
" not an open notefile.")))
(if (LDIFFERENCE (SETQ RootCards (MKLIST RootCards))
Cards)
then (NC.ReportError "NC.CopyCards"
"RootCards argument not subset of Cards argument."))
(if (NULL RootCards)
then (SETQ RootCards Cards))
(* * Figure out whether to copy "external" links.)
(SETQ CopyExternalToLinksFlg
(SELECTQ CopyExternalToLinksMode
(COPY T)
(DON'TCOPY NIL)
(SELECTQ (NC.AskUserWithMenu (QUOTE
(Yes No Cancel))
(CONCAT
"You've asked to copy "
(LENGTH Cards)
" cards."
(CHARACTER
13)
"Links among these cards will be automatically copied."
(CHARACTER
13)
"Do you also want to copy links pointing from these cards to elsewhere? ")
InterestedWindow)
(Yes T)
(No NIL)
(RETURN NIL))))
(* * Now get to work.)
(SETQ TempStream (OPENSTREAM (QUOTE {NODIRCORE})
(QUOTE BOTH)))
(SETQ CurrentLinkLabels (NC.RetrieveLinkLabels DestNoteFile))
(SETQ NewLinkLabels (TCONC NIL))
(SETQ LinksHashArray (HASHARRAY NC.CopyCardsLinksHashArraySize
NIL (FUNCTION NC.MakeHashKey)
(FUNCTION NC.SameUIDP)))
(SETQ CardHashArray (HASHARRAY NumCards NIL
(FUNCTION
NC.MakeHashKeyFromCard)
(FUNCTION NC.SameCardP)))
(* * Create new cards in DestNoteFile for each card. Make these cards by copying original cards to a temp stream.
Keep track of UID mappings between original cards and card copies using CardHashArray.)
(OR QuietFlg (NC.PrintMsg InterestedWindow T
"Copying cards: creating empty copies."
(CHARACTER 13)
"Processing item " 1 " out of "
NumCards "..." (CHARACTER 13)))
(SETQ NewCardsAndLocsOnStream NIL)
(RESETLST
(RESETSAVE NIL
(QUOTE (PROGN
(if RESETSTATE
then (for CardAndLoc
in
NewCardsAndLocsOnStream
do (
NC.DeleteNoteCardInternal
(CAR CardAndLoc)
T InterestedWindow))
(NC.ClearMsg
InterestedWindow T)))
))
(for Card in Cards as i from 1
bind NewCard WasActiveFlg HadStatusNILFlg IndexLocs
eachtime (BLOCK) unless (NC.CrossFileLinkCardP Card)
do (OR QuietFlg (if (ZEROP (REMAINDER i 100))
then (NC.PrintMsg
InterestedWindow T
"Copying cards: creating empty copies."
(CHARACTER
13)
"Processing item "
i " out of "
NumCards "..."
(CHARACTER
13))))
(if (NOT (SETQ WasActiveFlg (NC.ActiveCardP
Card)))
then (NC.GetNoteCard Card))
(if (SETQ HadStatusNILFlg
(NULL (fetch (Card Status) of Card)))
then (* Have to have Status slot ACTIVE in order that Put
to stream won't break.)
(replace (Card Status) of Card
with (QUOTE ACTIVE)))
(SETQ IndexLocs (NC.PutNoteCardToStream Card NIL T
TempStream))
(if HadStatusNILFlg
then (replace (Card Status) of Card
with NIL))
(if (NOT WasActiveFlg)
then (NC.DeactivateCard Card))
(* Make new empty card for copy.)
(SETQ NewCard (NC.GetNewCard DestNoteFile))
(* Map old cards to card copies.)
(PUTHASH Card NewCard CardHashArray)
(push NewCardsAndLocsOnStream (CONS NewCard
IndexLocs))))
(* * For each card, get it off the temp stream, fix its links, fix browser info if necessary, and write it down to
the dest notefile.)
(SETFILEPTR TempStream 0)
(OR QuietFlg (NC.PrintMsg InterestedWindow T
"Copying cards: fixing links and browser cards."
(CHARACTER 13)
"Processing item " 1 " out of "
NumCards "..." (CHARACTER 13)))
(for NewCardAndLocsOnStream in NewCardsAndLocsOnStream
as i from 1 eachtime (BLOCK)
bind (CrossFileLinkModePropList ←(LIST DestNoteFile NIL))
do (OR QuietFlg (if (ZEROP (REMAINDER i 100))
then (NC.PrintMsg InterestedWindow
T
"Copying cards: fixing links and browser cards."
(CHARACTER
13)
"Processing item "
i " out of "
NumCards "..."
(CHARACTER
13))))
(LET ((NewCard (CAR NewCardAndLocsOnStream))
(IndexLocs (CDR NewCardAndLocsOnStream)))
(* Have to make status active for Get fns to work.)
(NC.SetStatus NewCard (QUOTE ACTIVE))
(NC.GetNoteCardFromStream NewCard TempStream
IndexLocs)
(NC.FixUpLinksInCardCopy NewCard CardHashArray
LinksHashArray
CurrentLinkLabels
NewLinkLabels
InterestedWindow
CopyExternalToLinksFlg
CrossFileLinkModePropList)
(if (NC.IsSubTypeOfP (NC.FetchType NewCard)
(QUOTE Browser))
then (NC.FixUpBrowserCardCopy NewCard
CardHashArray))
(NC.PutNoteCard NewCard)))
(* * Link RootCards under filebox in DestNotefile.)
(OR QuietFlg (NC.PrintMsg InterestedWindow T
"Copying cards: filing "
(LENGTH RootCards)
" new cards in "
(NC.FetchTitle BoxToFileIn)
"..."
(CHARACTER 13)))
(NC.FileBoxCollectChildren NIL BoxToFileIn
(for RootCard in RootCards
eachtime (BLOCK)
collect (GETHASH RootCard
CardHashArray))
T)
(* * Put out any new link labels to the dest notefile.)
(AND (SETQ NewLinkLabels (CDAR NewLinkLabels))
(NC.StoreLinkLabels DestNoteFile (APPEND NewLinkLabels
CurrentLinkLabels)))
(OR QuietFlg (NC.ClearMsg InterestedWindow T))
Cards)))))
)
(* * Change to NCCROSSFILELINKS)
(DEFINEQ
(NC.ComputeCrossFileLinkMode
(LAMBDA (RemoteCard CrossFileLinkModePropList InterestedWindow)
(* rht: " 6-Jun-87 16:19")
(* * If we've already made cross file links to RemoteCard's notefile, then it'll be registered on
CrossFileLinkModePropList. Otherwise, consult global var, possibly ask user, and register her answer on
CrossFileLinkModePropList.)
(* * rht 6/6/87: Changed so that check of globalvar happens before check of CrossFileLinkModePropList.)
(DECLARE (GLOBALVARS NC.NewCrossFileLinksMode))
(LET ((NoteFile (fetch (Card NoteFile) of RemoteCard))
Mode)
(COND
((FMEMB NC.NewCrossFileLinksMode (QUOTE (TWOWAY ONEWAY)))
NC.NewCrossFileLinksMode)
((FMEMB NoteFile CrossFileLinkModePropList)
(LISTGET CrossFileLinkModePropList NoteFile))
(T (SETQ Mode (if (NC.AskCrossFileLinkMode RemoteCard InterestedWindow)
then (QUOTE TWOWAY)
else (QUOTE ONEWAY)))
(LISTPUT CrossFileLinkModePropList NoteFile Mode)
Mode)))))
(NC.GetCrossFileLinkDestCard
(LAMBDA (CrossFileLinkCard InterestedWindow Don'tOpenDestNoteFileFlg)
(* rht: " 8-Jun-87 11:39")
(* * Find the notefile corresponding to this crossfilelink and try to open it if not already open.
Then look for the card in there having the given UID. Return NIL if failed for any reason.)
(* * rht 11/10/86: Make sure CrossFileLinkCard is cached before fetching substance.)
(* * rht 11/19/86: Now rips off version number from destination notefile hint.)
(* * rht 12/11/86: Now checks that destination card is not deleted.)
(* * rht 12/16/86: Now takes InterestedWindow argument.)
(* * rht 3/25/87: Now calls NC.CoerceToInterestedWindow.)
(* * rht 3/27/87: Now calls NC.OpenCrossFileLinkDestNoteFile.)
(* * rht 5/27/87: New arg Don'tOpenDestNoteFileFlg. If non-nil, then destination notefile has to be already open.)
(* * rht 6/4/87: Now passes CrossFileLinkCard to NC.OpenCrossFileLinkDestNoteFile.)
(* * rht 6/8/87: Now computes WasOpenPromptWindowFlg)
(LET ((Title (NC.FetchTitle CrossFileLinkCard))
(SourceNoteFile (fetch (Card NoteFile) of CrossFileLinkCard))
Substance DestNoteFileUID DestFileHint DestCardUID DestNoteFile DestFileName Card
WasOpenPromptWindowFlg)
(OR InterestedWindow (SETQ InterestedWindow (NC.CoerceToInterestedWindow
SourceNoteFile)))
(SETQ WasOpenPromptWindowFlg (NC.PromptWindowOpenP InterestedWindow))
(if (NOT (NC.ActiveCardP CrossFileLinkCard))
then (NC.GetNoteCard CrossFileLinkCard))
(SETQ Substance (NC.FetchSubstance CrossFileLinkCard))
(SETQ DestCardUID (fetch (CrossFileLinkSubstance CrossFileLinkDestCardUID) of
Substance))
(SETQ DestNoteFileUID (fetch (CrossFileLinkSubstance CrossFileLinkDestNoteFileUID)
of Substance))
(SETQ DestFileHint (fetch (CrossFileLinkSubstance CrossFileLinkDestFileHint)
of Substance))
(SETQ DestNoteFile (NC.NoteFileFromNoteFileUID DestNoteFileUID))
(SETQ DestFileName (OR (AND (type? NoteFile DestNoteFile)
(fetch (NoteFile FullFileName) of DestNoteFile))
DestFileHint))
(for while (if Don'tOpenDestNoteFileFlg
then (NCP.OpenNoteFileP DestNoteFile)
else (SETQ DestNoteFile (NC.OpenCrossFileLinkDestNoteFile
DestNoteFile
DestFileName
InterestedWindow
CrossFileLinkCard)))
bind NewFileName
do (if (NC.ValidCardP (SETQ Card (NC.CardFromUID DestCardUID DestNoteFile)))
then (if (NOT (EQUAL (SETQ NewFileName (fetch (NoteFile FullFileName)
of DestNoteFile))
(FULLNAME (fetch (CrossFileLinkSubstance
CrossFileLinkDestFileHint)
of Substance))))
then (replace (CrossFileLinkSubstance CrossFileLinkDestFileHint)
of Substance with (PACKFILENAME (QUOTE VERSION)
NIL
(QUOTE BODY)
NewFileName))
(NC.MarkCardDirty CrossFileLinkCard))
(RETURN Card)
else (if Don'tOpenDestNoteFileFlg
then (RETURN NIL)
else (NC.PrintMsg InterestedWindow T
"Couldn't find destination card in "
DestFileName "." (CHARACTER 13))
(if (NOT (NC.AskYesOrNo
"Want to try opening a different notefile? "
" -- " "Yes" NIL InterestedWindow
WasOpenPromptWindowFlg))
then (RETURN NIL)
else (SETQ DestNoteFile (SETQ DestFileName NIL)))))))))
(NC.OpenCrossFileLinkDestNoteFile
(LAMBDA (DestNoteFile DestFileName InterestedWindow CrossFileLinkCard)
(* rht: " 8-Jun-87 11:39")
(* * If DestNoteFile is an open notefile, then fine. Otherwise get file names from user and keep trying to open
until she gives up.)
(* * rht 5/25/87: Minor change: no longer passes InterestedWindow to NC.OpenNoteFile.)
(* * rht 6/3/87: Now calls new function NC.AskUserWithMenu. Added CrossFileLinkCard argument whose title is used to
construct Message.)
(* * rht 6/8/87: Now computes WasOpenPromptWindowFlg)
(OR InterestedWindow (NC.CoerceToInterestedWindow CrossFileLinkCard))
(LET ((WasOpenPromptWindowFlg (NC.PromptWindowOpenP InterestedWindow)))
(if (NCP.OpenNoteFileP DestNoteFile)
then DestNoteFile
else (LET ((MenuItems (QUOTE (Read/Write Read-Only Don't% Open))))
(for while (OR DestFileName (SETQ DestFileName
(NC.AskUser "File name to try opening: " NIL NIL T
InterestedWindow WasOpenPromptWindowFlg)))
do (LET ((Message (if (NC.ValidCardP CrossFileLinkCard)
then (CONCAT "Open " DestFileName
" to look for '"
(NC.RetrieveTitle
CrossFileLinkCard)
"'?")
else (CONCAT "OPEN " DestFileName "?")))
ReadOnlyOpenFlg)
(if (AND (SELECTQ (NC.AskUserWithMenu MenuItems Message
InterestedWindow
WasOpenPromptWindowFlg T)
(Read/Write (SETQ ReadOnlyOpenFlg NIL)
T)
(Read-Only (SETQ ReadOnlyOpenFlg T))
(Don't% Open (RETURN NIL))
(RETURN NIL))
(NCP.OpenNoteFileP (SETQ DestNoteFile
(NC.OpenNoteFile
(OR DestNoteFile
DestFileName)
NIL NIL NIL NIL NIL NIL NIL
NIL NIL NIL NIL
ReadOnlyOpenFlg))))
then (RETURN DestNoteFile)
else (NC.PrintMsg InterestedWindow T "Couldn't open "
DestFileName "." (CHARACTER 13))
(SETQ DestFileName (SETQ DestNoteFile NIL))
(if (NOT (NC.AskYesOrNo
"Want to try opening a different notefile? "
" -- " "Yes" NIL
InterestedWindow
WasOpenPromptWindowFlg))
then (RETURN NIL))))))))))
)
(* * Changes to NCPROGINT)
(DEFINEQ
(NCP.CollectCards
(LAMBDA (RootCards LinkTypes MaxDepth FollowCrossFileLinksFlg)
(* rht: " 6-Jun-87 17:41")
(* * Starting from RootCards and following link of types in LinkTypes to a max depth of MaxDepth, collect and
return all cards encountered. LinkTypes can contain backward links.)
(* * rht 8/29/86: Now handles case of NULL MaxDepth. Also handles case when RootCards is single card instead of
list.)
(* * rht 6/6/87: Added FollowCrossFileLinksFlg; if non-nil, then try to follow cross-file links into remote
notefiles, else ignore them.)
(OR MaxDepth (SETQ MaxDepth 65535))
(if (LEQ MaxDepth 0)
then RootCards
else (for Depth from 1 to MaxDepth eachtime (BLOCK)
bind (Fringe ←(MKLIST RootCards))
(Collection ←(APPEND (MKLIST RootCards)))
do (SETQ Fringe (LDIFFERENCE (NCP.CardNeighbors Fringe LinkTypes
FollowCrossFileLinksFlg)
Collection))
(if (NULL Fringe)
then (RETURN Collection)
else (SETQ Collection (NCONC Fringe Collection)))
finally (RETURN Collection)))))
(NCP.CardNeighbors
(LAMBDA (Cards LinkTypes FollowCrossFileLinksFlg) (* rht: " 6-Jun-87 17:41")
(* * Return a list of cards one link from Card in the forward direction having some link of type in LinkTypes.
LinkTypes can contain atoms starting with "←" in which case it's a backward link. LinkTypes can contain either or
both of ANY and ←ANY, meaning to include any forward or backward links, respectively.)
(* * rht 6/6/87: Added FollowCrossFileLinksFlg; if non-nil, then try to follow cross-file links into remote
notefiles, else ignore them.)
(if (NULL LinkTypes)
then (for Link in (NCP.GetLinks Cards)
join (LET ((DestCard (fetch (Link DestinationCard) of Link)))
(MKLIST (if (NC.CrossFileLinkCardP DestCard)
then (if FollowCrossFileLinksFlg
then (NC.GetCrossFileLinkDestCard DestCard)
else NIL)
else DestCard))))
else (LET (ForwardLinkTypes BackwardLinkTypes)
(for LinkType in (MKLIST LinkTypes) do (if (EQ (NTHCHAR LinkType 1)
(QUOTE ←))
then (pushnew
BackwardLinkTypes
(SUBATOM
LinkType 2))
else (pushnew ForwardLinkTypes
LinkType)))
(UNION (AND ForwardLinkTypes (for Link
in (NCP.GetLinks
Cards NIL (if (FMEMB (QUOTE ANY)
ForwardLinkTypes)
then NIL
else ForwardLinkTypes))
join
(LET ((DestCard (fetch (Link DestinationCard)
of Link)))
(MKLIST (if (NC.CrossFileLinkCardP
DestCard)
then (if
FollowCrossFileLinksFlg
then
(
NC.GetCrossFileLinkDestCard
DestCard)
else NIL)
else DestCard)))))
(AND BackwardLinkTypes (for Link
in (NCP.GetLinks
NIL Cards (if (FMEMB (QUOTE
ANY)
BackwardLinkTypes)
then NIL
else BackwardLinkTypes))
join
(LET ((SrcCard (fetch (Link SourceCard)
of Link)))
(MKLIST (if (NC.CrossFileLinkCardP
SrcCard)
then
(if
FollowCrossFileLinksFlg
then (
NC.GetCrossFileLinkDestCard
SrcCard)
else NIL)
else SrcCard))))))))))
)
(* * New function for NCPROGINT)
(DEFINEQ
(NCP.GetCrossFileLinkDestCard
(LAMBDA (CrossFileLinkCard InterestedWindow Don'tOpenDestNoteFileFlg)
(* rht: " 8-Jun-87 23:24")
(* * Try to get the remote card corresponding to the given cross-file link card.)
(AND (NCP.ValidCardP CrossFileLinkCard)
(EQ (NCP.CardType CrossFileLinkCard)
(QUOTE CrossFileLink))
(NC.GetCrossFileLinkDestCard CrossFileLinkCard InterestedWindow Don'tOpenDestNoteFileFlg)
)))
)
(* * Change to NCINTERFACE)
(DEFINEQ
(NC.SelectNoteCards
(LAMBDA (SingleCardFlg SelectionPredicate Menu InstigatingCardOrWindow Msg CheckForCancelFlg
FileLevelLockFlg) (* rht: " 8-Jun-87 14:11")
(* Select a set of note cards or a single note card, depending on SingleCardFlg. Works by interpreting all mouse
presses until a card has been chosen (if SingleCardFlg is T) or until the Done button has been pressed
(if SingleCardFlg is NIL). If the mouse press occus within a Title bar of a notecard, add that note card to the
selected list. Otherwise, if you are pointing into a note card, call the BUTTONEVENTFN for that note card.
The Selection in Progress flag has been set, so all note card BUTTONEVENTFNs should know to ignore all presses
except those that occur on link icons. Link icon presses should simply add the desination of that link to the
selected note cards list. This function should always be called from inside of an NC.CardSelectionOperation
wrapper.)
(* * rht 8/1/84: Changed second RESETSAVE call to give NC.ClearMsg a NIL argument.)
(* * rht 1/9/85: Fixed so now prints name of selected item even it's a link.)
(* * rht 2/15/85: Now can backspace over last selection chosen. Added new arg Msg so that when we reprint the list,
we can reprint the message as well.)
(* * rht 3/23/85: Added the CheckForCancelFlg arg, which if non-nil causes Cancel to be handled differently then
Done after no selections. Namely, Cancel will return the atom CANCELLED whereas Done with no selections returns
NIL. If CheckForCancelFlg is NIL then NIL is returned in both cases.)
(* * fgh 11/14/85 Updated to handle Card and NoteFile objects.)
(* * rht 11/18/85: Fixed so able to select when InstigatingNoteFile is NIL.)
(* * fgh 12/20/85 Totally rewritten for 1.3 selection mechanism. Based on COPYINSERT now rather than on takingf
over the mouse process.)
(* * fgh 1/15/86 Added call to SPAWN.MOUSE in case this is called under the mouse process)
(* * kirk 25Apr86 Changed to use SessionIcon (NC.NoteCardsIconWindow) rather than PROMPTWINDOW if no Instigating
window is supplied.)
(* * fgh 7/5/86 Added code to put CRs into printout of selected cards in order to keep prompt window from getting
infinitely wide to accomdate the printout.)
(* * rht 10/5/86: Now allows choice of cards from remote notefile.)
(* * rht 10/18/86: Give TTY process to process that originally had it if possible.)
(* * rht & pmi 11/14/86: Now checks for valid card before testing SelectionPredicate.)
(* * pmi 12/5/86 Modified prompt messages to mention SHIFT-selection.)
(* * pmi 12/12/86: Removed obsolete ReturnLinksFlg argument.)
(* * rg 3/18/87 reworked for NC.CardSelectionOperation: added NAMED-RESETSAVE forms for Card locking.)
(* * 3/23/87: Changed to call REMOVEWINDOW instead of DETACHWINDOW before deleting the attached menu.
Also changed so that menu is attached to InstigatingWindow rather than to PromptWindow. This makes it possible for
windows to "slide down" when selection ends.)
(* * rht 3/24/87: Now calls NC.CoerceToInterestedWindow)
(* * RG 4/1/87 changed CANCELLED to DON'T)
(* * rg 4/22/87 changed some names,)
(* * rht&rg&pmi 4/22/87: Moved location of ALLOW.BUTTON.EVENTS.)
(* * rg 6/2/87 added FileLevelLockFlg)
(* * rht 6/6/87: If user selects a cross-file link card, then try to follow it.)
(DECLARE (USEDFREE CardListResetVar))
(* * if we are running under the mouse process, start up a new mouse process)
(ALLOW.BUTTON.EVENTS)
(LET (Window Card ButtonEventFn InstigatingWindow InstigatingCard InstigatingNoteFile MenuWindow
PromptWindow CopyInsertEvent CardProcessedEvent SelectedCards BinLoopProcess
OldTTYProcess OpInProgress ResetItems TTYResetVar InternalResetVar)
(NAMED-RESETLST
InternalResetVar
(OR SelectionPredicate (SETQ SelectionPredicate (FUNCTION TRUE)))
(SETQ PromptWindow (OR (NC.AttachPromptWindow (SETQ InstigatingWindow
(NC.CoerceToInterestedWindow
InstigatingCardOrWindow)))
PROMPTWINDOW))
(SETQ InstigatingCard (NC.CoerceToCard InstigatingCardOrWindow))
(SETQ InstigatingNoteFile (AND InstigatingCard (fetch (Card NoteFile) of
InstigatingCard)))
(NC.PrintMsg InstigatingWindow T (COND
(Msg (CONCAT Msg (CHARACTER 13)))
(T ""))
"Items shift-selected: ")
(SETQ OldTTYProcess (TTY.PROCESS))
(* * Set up the prompt window for proper use by the CopyInsertFn)
(NAMED-RESETSAVE InternalResetVar (WINDOWPROP PromptWindow (QUOTE SelectCardsMonitor)
(CREATE.MONITORLOCK (QUOTE
SelectCards)))
(BQUOTE (WINDOWPROP , PromptWindow SelectCardsMonitor NIL)))
(WINDOWPROP PromptWindow (QUOTE CopyInsertEvent)
(SETQ CopyInsertEvent (CREATE.EVENT (QUOTE CopyInsertEvent))))
(WINDOWPROP PromptWindow (QUOTE NewCardsProcessed)
T)
(WINDOWPROP PromptWindow (QUOTE CardProcessedEvent)
(SETQ CardProcessedEvent (CREATE.EVENT (QUOTE CardProcessedEvent))))
(WINDOWPROP PromptWindow (QUOTE SelectNoteCardsProcess)
(THIS.PROCESS))
(WINDOWPROP PromptWindow (QUOTE COPYINSERTFN)
(FUNCTION NC.SelectNoteCardsCopyInsertFn))
(NAMED-RESETSAVE InternalResetVar (WINDOWPROP PromptWindow (QUOTE SelectedCards)
NIL)
(BQUOTE (WINDOWPROP , PromptWindow (QUOTE SelectedCards)
NIL)))
(NAMED-RESETSAVE InternalResetVar (WINDOWPROP PromptWindow (QUOTE SelectingCards)
T)
(BQUOTE (WINDOWPROP , PromptWindow SelectingCards NIL)))
(* * Make the process behind the prompt window includiong control for a blibnking cursor)
(WINDOWPROP PromptWindow (QUOTE PROCESS)
(SETQ BinLoopProcess (ADD.PROCESS
(QUOTE (PROG NIL (BLOCK)
(TTYDISPLAYSTREAM (PROCESSPROP (THIS.PROCESS)
(QUOTE WINDOW)))
XXXX
(BIN)
(BLOCK)
(GO XXXX)))
(QUOTE WINDOW)
PromptWindow
(QUOTE NAME)
(QUOTE BinLoopProcess)
(QUOTE TTYENTRYFN)
(FUNCTION (LAMBDA (Process)
(PROCESSPROP Process (QUOTE OldCaret)
(CARET CROSSHAIRS))
(ECHOMODE)))
(QUOTE TTYEXITFN)
(FUNCTION (LAMBDA (Process)
(CARET (PROCESSPROP Process (QUOTE OldCaret)))
(ECHOMODE T))))))
(NAMED-RESETSAVE InternalResetVar NIL (BQUOTE (DEL.PROCESS , BinLoopProcess)))
(* * Insure the prompt window is cleared on the way out)
(NAMED-RESETSAVE InternalResetVar NIL
(BQUOTE (PROGN (AND (HASTTYWINDOWP , BinLoopProcess)
(TTY.PROCESS (if (AND (PROCESSP
, OldTTYProcess)
(HASTTYWINDOWP
, OldTTYProcess)
)
then , OldTTYProcess
else T)))
(NC.ClearMsg , InstigatingWindow T))))
(* * Set up the menu above the prompt window)
(* fix in case MENUPOSITION is set incorrectly in menu
passed down)
(replace (MENU MENUPOSITION) of Menu
with (CONSTANT (create POSITION
XCOORD ← 0
YCOORD ← 0)))
(NAMED-RESETSAVE InternalResetVar (PROGN (ATTACHMENU
Menu
(OR InstigatingWindow PROMPTWINDOW)
(if InstigatingWindow
then (QUOTE TOP)
else (QUOTE BOTTOM))
(if (AND (WINDOWP InstigatingWindow)
(WINDOWP PromptWindow))
then (CDR (WINDOWPROP
PromptWindow
(QUOTE WHEREATTACHED))
)
else (QUOTE LEFT)))
(WINDOWPROP (WFROMMENU Menu)
(QUOTE SelectionPromptWindow)
PromptWindow))
(BQUOTE (PROGN (REMOVEWINDOW (WFROMMENU , Menu)))))
(* * If there is an instigating window, make sure it and all its attachments are visible on the screen.)
(if InstigatingWindow
then (NC.MoveWindowOntoScreen InstigatingWindow))
(* * Give the prompt window the tty process)
(TTY.PROCESS (WINDOWPROP PromptWindow (QUOTE PROCESS)))
(* * Loop as long as necessary)
(WITH.MONITOR
(WINDOWPROP PromptWindow (QUOTE SelectCardsMonitor))
(until (OR (EQ SelectedCards (QUOTE DON'T))
(AND SingleCardFlg SelectedCards)
(EQ (CAR SelectedCards)
(QUOTE DONE)))
do
( (* Wait for the user to respond by copy inserting
something into the prompt window)
(until (OR (NOT (PROCESSP BinLoopProcess))
(NOT (EQ SelectedCards (WINDOWPROP PromptWindow (QUOTE
SelectedCards)))))
do (MONITOR.AWAIT.EVENT (WINDOWPROP PromptWindow (QUOTE
SelectCardsMonitor))
CopyInsertEvent 1000))
(* Get the latest selection list)
(SETQ SelectedCards (WINDOWPROP PromptWindow (QUOTE SelectedCards)))
(WINDOWPROP PromptWindow (QUOTE NewCardsProcessed)
T)
(NOTIFY.EVENT CardProcessedEvent T)
(OR (PROCESSP BinLoopProcess)
(SETQ SelectedCards (QUOTE DON'T)))
(NAMED-RESETLST
TTYResetVar (* Turn off the caret)
(NAMED-RESETSAVE TTYResetVar (TTY.PROCESS (THIS.PROCESS)))
(* If the last thing wasn't a done or cancel, process
the new selection)
(SETQ Card (CAR SelectedCards))
(WITH.MONITOR
NC.LockLock
(COND
((AND (NEQ Card (QUOTE DONE))
(NEQ SelectedCards (QUOTE DON'T))
(NEQ Card (QUOTE *New% Card*)))
(* Try to follow cross-file links.)
(if (AND (NC.ValidCardP Card)
(NC.CrossFileLinkCardP Card))
then (SETQ Card (NC.GetCrossFileLinkDestCard Card
InstigatingWindow))
(WINDOWPROP PromptWindow (QUOTE SelectedCards)
(SETQ SelectedCards (CONS Card (CDR
SelectedCards)))))
(* Check to make sure that the selection is valid)
(COND
((EQ Card (QUOTE *Undo% Selection*))
(* Chop off two elements from the list -
the indicator and the previous item.)
(SETQ Card (CADR SelectedCards))
(WINDOWPROP PromptWindow (QUOTE SelectedCards)
(SETQ SelectedCards (CDDR SelectedCards)))
(* now get our hands off of all the locks we've
acquired for this card)
(if Card
then (NAMED-RESETUNSAVE CardListResetVar (NC.FetchUserDataProp
Card
(QUOTE ResetItems)))
(NC.SetUserDataProp Card (QUOTE ResetItems)
NIL))
(NC.ClearMsg InstigatingWindow NIL))
((OR (NOT (NC.ValidCardP Card))
(NULL (APPLY* SelectionPredicate Card)))
(* Does this card match the slection predicate)
(NC.PrintMsg InstigatingWindow T "*** Invalid selection. ***"
(CHARACTER 13))
(WINDOWPROP PromptWindow (QUOTE SelectedCards)
(SETQ SelectedCards (CDR SelectedCards))))
((AND (SETQ OpInProgress (if FileLevelLockFlg
then (NC.NoteFileCheckOpInProgress
(fetch (Card NoteFile)
of Card))
else (NC.CardCheckOpInProgress Card)))
(NEQ OpInProgress (QUOTE US)))
(NC.PrintOperationInProgressMsg InstigatingWindow "Select Card"
OpInProgress)
(DISMISS 1000)
(WINDOWPROP PromptWindow (QUOTE SelectedCards)
(SETQ SelectedCards (CDR SelectedCards)))
(NC.ClearMsg InstigatingWindow NIL))
(T (* A valid selection.)
(NC.ClearMsg InstigatingWindow NIL)
(if FileLevelLockFlg
then (SETQ ResetItems
(LIST (NAMED-RESETSAVE
CardListResetVar
(NC.NoteFileProp (fetch (Card NoteFile)
of Card)
(QUOTE OperationInProgress)
"Select Card")
(BQUOTE (NC.NoteFileProp
,
(fetch (Card NoteFile)
of Card)
OperationInProgress NIL)))
(NAMED-RESETSAVE
CardListResetVar
(NC.NoteFileProp (fetch (Card NoteFile)
of Card)
(QUOTE ProcessInProgress)
(THIS.PROCESS))
(BQUOTE (NC.NoteFileProp
,
(fetch (Card NoteFile)
of Card)
ProcessInProgress NIL)))
(NAMED-RESETSAVE CardListResetVar
(SETQ NC.NoteFileBusyList
(CONS (THIS.PROCESS)
NC.NoteFileBusyList))
(QUOTE (SETQ
NC.NoteFileBusyList
(DREMOVE
(THIS.PROCESS)
NC.NoteFileBusyList)))))
)
else (SETQ ResetItems
(LIST (NAMED-RESETSAVE CardListResetVar
(SETQ NC.CardBusyList
(CONS (THIS.PROCESS)
NC.CardBusyList))
(QUOTE (SETQ
NC.CardBusyList
(DREMOVE (
THIS.PROCESS)
NC.CardBusyList))))
(NAMED-RESETSAVE
CardListResetVar
(NC.NoteFileProp
(fetch (Card NoteFile) of Card)
(QUOTE CardProcessInProgressList)
(CONS (THIS.PROCESS)
(NC.NoteFileProp (fetch
(Card NoteFile)
of Card)
(QUOTE
CardProcessInProgressList))))
(BQUOTE (NC.ResetCardProcessInProgress
,
(fetch (Card NoteFile)
of Card))))
(NAMED-RESETSAVE CardListResetVar
(NC.SetUserDataProp
Card
(QUOTE OperationInProgress)
"Select Card")
(BQUOTE (NC.SetUserDataProp
, Card
OperationInProgress NIL)
))
(NAMED-RESETSAVE CardListResetVar
(NC.SetUserDataProp
Card
(QUOTE ProcessInProgress)
(THIS.PROCESS))
(BQUOTE (NC.SetUserDataProp
, Card
ProcessInProgress NIL)
)))))
(NAMED-RESETSAVE InternalResetVar (NC.SetUserDataProp
Card
(QUOTE ResetItems)
ResetItems)
(BQUOTE (NC.SetUserDataProp , Card ResetItems
NIL)))))
(* * Print the results in the prompt window)
(NC.PrintMsg InstigatingWindow NIL (COND
(Msg (CONCAT Msg (CHARACTER 13)))
(T ""))
"Items selected: ")
(for ThisCard in (REVERSE SelectedCards)
do (NC.PrintMsg InstigatingWindow NIL (NC.RetrieveTitle ThisCard)
", ")
(if (AND InstigatingWindow (GREATERP
(DSPXPOSITION NIL PromptWindow)
(TIMES 1.25 (WINDOWPROP InstigatingWindow
(QUOTE WIDTH)))))
then (NC.PrintMsg InstigatingWindow NIL (CHARACTER 13)))))
))))))
(* * Return the result)
(PROG1 (COND
((EQ SelectedCards (QUOTE DON'T))
(COND
(CheckForCancelFlg (QUOTE DON'T))
(T NIL)))
(SingleCardFlg (if (EQ (CAR SelectedCards)
(QUOTE DONE))
then NIL
else (CAR SelectedCards)))
(T (if (EQ (CAR SelectedCards)
(QUOTE DONE))
then (DREVERSE (CDR SelectedCards))
else (DREVERSE SelectedCards))))
(WINDOWPROP PromptWindow (QUOTE SelectedCards)
NIL))))))
(NC.SelectNoteCardsCopyInsertFn
(LAMBDA (ImageObj Window) (* rht: " 8-Jun-87 11:15")
(* * Copy insert fn for promptwindow during SelectNoteCards operation)
(LET ((CardProcessedEvent (WINDOWPROP Window (QUOTE CardProcessedEvent)))
(SelectCardsMonitor (WINDOWPROP Window (QUOTE SelectCardsMonitor))))
(WITH.MONITOR SelectCardsMonitor (until (OR (NOT (PROCESSP (WINDOWPROP
Window
(QUOTE
SelectNoteCardsProcess))))
(WINDOWPROP Window (QUOTE
NewCardsProcessed)))
do (MONITOR.AWAIT.EVENT SelectCardsMonitor
CardProcessedEvent 1000))
(LET ((Card (COND
((NC.LinkIconImageObjP ImageObj)
(fetch (Link DestinationCard) of (
NC.FetchLinkFromLinkIcon
ImageObj)))
((NC.CardImageObjP ImageObj)
(IMAGEOBJPROP ImageObj (QUOTE OBJECTDATUM)))))
(SelectedCards (WINDOWPROP Window (QUOTE SelectedCards)))
(CopyInsertEvent (WINDOWPROP Window (QUOTE CopyInsertEvent))))
(* * Add the selected acrd to the selected cards list)
(if (AND Card (for SelectedCard in SelectedCards
never (NC.SameCardP Card SelectedCard)))
then (WINDOWPROP Window (QUOTE SelectedCards)
(CONS Card SelectedCards))
(WINDOWPROP Window (QUOTE NewCardsProcessed)
NIL))
(* * Wake up the main process)
(NOTIFY.EVENT CopyInsertEvent T))))))
)
(* * New function for NCINTERFACE)
(DEFINEQ
(NC.PromptWindowOpenP
(LAMBDA (MainWindow) (* rht: " 8-Jun-87 11:43")
(* * Return non-nil if MainWindow has an open prompt window.)
(OR (OPENWP (CAR (WINDOWPROP MainWindow (QUOTE PROMPTWINDOW))))
(for PromptWinPair in (WINDOWPROP MainWindow (QUOTE OtherPromptWindows))
thereis (OPENWP (CAR PromptWinPair))))))
)
(PUTPROPS RHTPATCH275 COPYRIGHT ("Xerox Corporation" 1987))
(DECLARE: DONTCOPY
(FILEMAP (NIL (1464 19976 (NC.FixUpLinksInCardCopy 1474 . 7956) (NC.CopyCards 7958 . 19974)) (20016
27777 (NC.ComputeCrossFileLinkMode 20026 . 21207) (NC.GetCrossFileLinkDestCard 21209 . 25208) (
NC.OpenCrossFileLinkDestNoteFile 25210 . 27775)) (27811 31917 (NCP.CollectCards 27821 . 29119) (
NCP.CardNeighbors 29121 . 31915)) (31957 32502 (NCP.GetCrossFileLinkDestCard 31967 . 32500)) (32537
51848 (NC.SelectNoteCards 32547 . 50159) (NC.SelectNoteCardsCopyInsertFn 50161 . 51846)) (51890 52337
(NC.PromptWindowOpenP 51900 . 52335)))))
STOP