(FILECREATED " 3-Jun-87 15:22:13" {QV}<NOTECARDS>1.3K>NEXT>RGPATCH044.;4 47865
changes to: (VARS RGPATCH044COMS)
(FNS NC.CopyCards NC.CheckForExpandIndex NC.CopyStructure NC.MoveStructure
NC.LockListOfCards NC.SelectNoteCards NC.MoveCards
NC.NoteFileCheckOpInProgress NC.SessionCheckOpInProgress)
previous date: " 2-Jun-87 19:27:45" {QV}<NOTECARDS>1.3K>NEXT>RGPATCH044.;1)
(* Copyright (c) 1987 by Xerox Corporation. All rights reserved.)
(PRETTYCOMPRINT RGPATCH044COMS)
(RPAQQ RGPATCH044COMS ((* * rg 6/2/87 operations that might have to expand index now lock entire
notefile)
(* * changes to NCDATABASE)
(FNS NC.CopyCards NC.LockListOfCards NC.MoveCards
NC.NoteFileCheckOpInProgress NC.SessionCheckOpInProgress
NC.CheckForExpandIndex)
(* * changes to NCINTERFACE)
(FNS NC.SelectNoteCards NC.CopyStructure NC.MoveStructure)))
(* * rg 6/2/87 operations that might have to expand index now lock entire notefile)
(* * changes to NCDATABASE)
(DEFINEQ
(NC.CopyCards
[LAMBDA (Cards DestNoteFileOrFileBox RootCards QuietFlg InterestedWindow)
(* Randy.Gobbel " 3-Jun-87 10:16")
(* * 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)
(NCP.WithLockedCards (NC.IfAllCardsFree (NC.LockListOfCards Cards "Copy Cards")
(PROG (NumCards SourceNoteFile DestNoteFile BoxToFileIn
TempStream CardHashArray LinksHashArray
CurrentLinkLabels NewLinkLabels
NewCardsAndLocsOnStream)
(* * 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))
(* * 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
(for Card in Cards as i from 1
bind NewCard WasActiveFlg HadStatusNILFlg
IndexLocs
eachtime (BLOCK)
collect
[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)
(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)
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)
(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])
(NC.LockListOfCards
[LAMBDA (CardIdentifiers Operation FileLevelFlg) (* Randy.Gobbel " 2-Jun-87 19:31")
(* * set locks on cards passed in, return a list of the lock statuses. Status = NIL means lock was free, =
(QUOTE US) means we already had it, = <string> means operation described by the string was already in progress on
that card)
(* * RG 4/2/87 created)
(* * rg 6/2/87 added FileLevelFlg)
(DECLARE (USEDFREE CardListResetVar))
(WITH.MONITOR NC.LockLock (LET* [(Cards (for CardIdentifier in CardIdentifiers
collect (NC.CoerceToCard CardIdentifier)))
(LockStatusList (for Card in Cards
collect (if FileLevelFlg
then
(NC.NoteFileCheckOpInProgress
(fetch (Card NoteFile)
of Card))
else (NC.CardCheckOpInProgress
Card]
[for Card in Cards as Status in LockStatusList
when (NULL Status)
do (if FileLevelFlg
then
[NAMED-RESETSAVE
CardListResetVar
(NC.NoteFileProp (fetch (Card NoteFile)
of Card)
(QUOTE OperationInProgress)
Operation)
(BQUOTE (NC.NoteFileProp ,
(fetch
(Card NoteFile)
of Card)
OperationInProgress ,
(NC.NoteFileProp
NoteFile
(QUOTE
OperationInProgress]
[NAMED-RESETSAVE
CardListResetVar
(NC.NoteFileProp (fetch (Card NoteFile)
of Card)
(QUOTE ProcessInProgress)
(THIS.PROCESS))
(BQUOTE (NC.NoteFileProp
,
(fetch (Card NoteFile) of Card)
ProcessInProgress ,
(NC.NoteFileProp
(fetch (Card NoteFile)
of Card)
(QUOTE ProcessInProgress]
[NAMED-RESETSAVE CardListResetVar
(SETQ NC.NoteFileBusyList
(CONS (THIS.PROCESS)
NC.NoteFileBusyList))
(QUOTE (SETQ
NC.NoteFileBusyList
(DREMOVE
(THIS.PROCESS
)
NC.NoteFileBusyList]
else [NAMED-RESETSAVE
CardListResetVar
(NC.SetUserDataProp Card (QUOTE
ProcessInProgress)
(THIS.PROCESS))
(BQUOTE (NC.SetUserDataProp
, Card ProcessInProgress ,
(NC.FetchUserDataProp
Card
(QUOTE ProcessInProgress]
[NAMED-RESETSAVE
CardListResetVar
(NC.SetUserDataProp Card (QUOTE
OperationInProgress)
Operation)
(BQUOTE (NC.SetUserDataProp
, Card OperationInProgress ,
(NC.FetchUserDataProp
Card
(QUOTE OperationInProgress]
[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
(SETQ NC.CardBusyList
(CONS (THIS.PROCESS)
NC.CardBusyList))
(QUOTE (SETQ
NC.CardBusyList
(DREMOVE
(THIS.PROCESS)
NC.CardBusyList]
LockStatusList])
(NC.MoveCards
[LAMBDA (Cards DestNoteFileOrFileBox RootCards QuietFlg InterestedWindow)
(* Randy.Gobbel " 2-Jun-87 19:27")
(* * Move cards into a filebox by copying and deleting.)
(* * rht&rg&pmi 4/22/87: Took out ERROR!)
(* * rg 6/2/87 added NCP.WithLockedCards wrapper)
(DECLARE (GLOBALVARS NC.SelectingCardsMenu))
(NCP.WithLockedCards (NC.IfAllCardsFree (NC.LockListOfCards Cards "Move Cards")
(OR Cards (SETQ Cards
(NC.SelectNoteCards NIL NIL
NC.SelectingCardsMenu NIL
"Shift-select from the same NoteFile cards to move:")))
(if Cards
then (SETQ Cards (MKLIST Cards))
(NC.CopyCards Cards DestNoteFileOrFileBox
RootCards QuietFlg
InterestedWindow)
(NC.DeleteNoteCards Cards T NIL
InterestedWindow
QuietFlg NIL])
(NC.NoteFileCheckOpInProgress
[LAMBDA (NoteFile) (* Randy.Gobbel " 2-Jun-87 19:26")
(* * NoteFile level check for operation in progress. Checks session level, then NoteFile level, then Card level.
Returns NIL if there is no conflict at any level, otherwise a string describing the conflicting operation.
THIS PROCEDURE IS INTERNAL TO THE NOTECARDS GLOBAL MONITOR!)
(* * rg 3/3/87 created)
(* * rg 6/2/87 changed to allow enlarging lock scope if it's all in the same process)
(LET (ProcInProgress CardProcessInProgressList)
(COND
((PROCESSP NC.SessionProcessInProgress) (* someone doing a session op, check to see if it's
us)
(COND
((NEQ NC.SessionProcessInProgress (THIS.PROCESS))
(* if someone else has the session lock, return that
op)
NC.SessionOperationInProgress)
(T (* we have the session lock, just return NIL)
NIL)))
([PROCESSP (SETQ ProcInProgress (NC.NoteFileProp NoteFile (QUOTE ProcessInProgress]
(* someone doing a NF op, check to see if it's us)
(COND
((NEQ ProcInProgress (THIS.PROCESS)) (* if someone else has the NF lock, return that op)
(NC.NoteFileProp NoteFile (QUOTE OperationInProgress)))
(T (* we have the NF lock, do nothing)
NIL)))
((AND [EQ (THIS.PROCESS)
(CAR (SETQ CardProcessInProgressList (NC.NoteFileProp NoteFile
(QUOTE
CardProcessInProgressList]
(EQ (LENGTH CardProcessInProgressList)
1)) (* card ops in progress by our own process)
NIL)
(CardProcessInProgressList (* some card ops in progress, we lose)
"Card Operations")
(T (* all relevant locks are free)
NIL])
(NC.SessionCheckOpInProgress
[LAMBDA NIL (* Randy.Gobbel " 2-Jun-87 19:26")
(* * Session level check for operation in progress. Checks session level, then NoteFile level, then Card level.
Returns NIL if there is no conflict at any level, otherwise a string describing the conflicting operation.
THIS PROCEDURE IS INTERNAL TO THE NOTECARDS GLOBAL MONITOR!)
(* * rg 3/3/87 created)
(* * rg 6/2/87 changed to allow enlarging lock scope if it's all in the same process)
(LET (BusyList)
(COND
[(PROCESSP NC.SessionProcessInProgress) (* someone doing a session op, check to see if it's
us)
(COND
((NEQ NC.SessionProcessInProgress (THIS.PROCESS))
(* if someone else has the session lock, return that
op)
NC.SessionOperationInProgress)
(T (* we have the session lock)
(QUOTE US]
((AND (EQ (THIS.PROCESS)
(CAR (SETQ BusyList NC.NoteFileBusyList)))
(EQ (LENGTH BusyList)
1)) (* notefile ops in progress by our own process, assume
we know what we're doing)
NIL)
(BusyList (* NF ops are active, we lose)
"NoteFile Operations")
((AND (EQ (THIS.PROCESS)
(CAR (SETQ BusyList NC.CardBusyList)))
(EQ (LENGTH BusyList)
1)) (* card ops in progress, but it's our own process)
NIL)
(BusyList (* some card ops are active, we lose)
"Card Operations")
(T (* all relevant locks are free)
NIL])
(NC.CheckForExpandIndex
[LAMBDA (NoteFile QuietFlg InterestedWindow) (* Randy.Gobbel " 3-Jun-87 10:31")
(* * If index is nearly full, then confirm with user whether it's okay to expand in place. Offer user ability to
change the amount to expand by. Return nil if no expand, return new index size otherwise. If index is full, then we
MUST expand otherwise error out.)
(* * rht 5/24/87: Now passes QuietFlg to NC.ExpandIndexInPlace.)
(* * rg 6/3/87 call to Checkpoint wasn't checking for DON'T)
(DECLARE (GLOBALVARS NC.IndexPercentUsedThreshold NC.IndexFractionToExpandBy NC.MenuFont))
(OR InterestedWindow (SETQ InterestedWindow (NC.CoerceToInterestedWindow NoteFile)))
(LET ((NextIndexNum (fetch (NoteFile NextIndexNum) of NoteFile))
(IndexSize (fetch (NoteFile HashArraySize) of NoteFile))
(IndexNumsFreeList (fetch (NoteFile IndexNumsFreeList) of NoteFile))
PercentUsed NumUsed)
(if (GREATERP [SETQ PercentUsed (FIX (TIMES 100
(FQUOTIENT
[SETQ NumUsed
(SUB1 (DIFFERENCE
NextIndexNum
(LENGTH
IndexNumsFreeList]
IndexSize]
NC.IndexPercentUsedThreshold)
then (LET ([Menu (create MENU
ITEMS ← NIL
TITLE ← " Expand notefile index? "
CENTERFLG ← T
MENUBORDERSIZE ← 1
MENUOUTLINESIZE ← 1
MENUROWS ← 1
MENUFONT ← NC.MenuFont
ITEMHEIGHT ← (IPLUS 10 (FONTPROP NC.MenuFont
(QUOTE HEIGHT)))
MENUTITLEFONT ← (FONTCREATE (QUOTE HELVETICA)
10
(QUOTE BOLD]
(PromptWindow (OR (NC.AttachPromptWindow InterestedWindow)
PROMPTWINDOW))
IndexNum PercentFullMessage NewIndexSize NumNewSlots NewNum
ActualNumNewSlots IndexFullFlg)
[SETQ NewIndexSize (PLUS IndexSize (SETQ NumNewSlots
(FIX (FTIMES IndexSize
NC.IndexFractionToExpandBy]
(* * Fix menu and message depending on whether index is full or not.)
[if (SETQ IndexFullFlg (GEQ NumUsed IndexSize))
then (SETQ PercentFullMessage (CONCAT (fetch (NoteFile
FullFileName)
of NoteFile)
" is full (" NumUsed
" out of "
IndexSize " cards used)."
(CHARACTER 13)))
[replace (MENU ITEMS) of Menu
with (QUOTE ((Yes (QUOTE Yes)
"Go ahead and expand index to make room for new cards.")
(Cancel (QUOTE Cancel)
"Cancel creation of new card.")
(Change% Num (QUOTE Change% Num)
"Change the number of new cards to expand index by."]
else (SETQ PercentFullMessage (CONCAT (fetch (NoteFile
FullFileName)
of NoteFile)
" is " PercentUsed "%% full ("
NumUsed " out of " IndexSize
" cards used)."
(CHARACTER 13)))
(replace (MENU ITEMS) of Menu
with (QUOTE ((Yes (QUOTE Yes)
"Go ahead and expand index to make room for new cards.")
(No (QUOTE No)
"Continue without expanding index.")
(Change% Num (QUOTE Change% Num)
"Change the number of new cards to expand index by."]
(for
do (NC.PrintMsg InterestedWindow T PercentFullMessage)
(NC.PrintMsg InterestedWindow NIL (CONCAT
"Okay to checkpoint notefile and make room for "
NumNewSlots
" new cards?"
(CHARACTER 13)))
(SELECTQ [MENU Menu (CREATEPOSITION (fetch (REGION LEFT)
of (WINDOWREGION
PromptWindow))
(fetch (REGION TOP)
of (WINDOWREGION
PromptWindow]
(Yes (* Go ahead and expand index after checkpointing
notefile.)
(if (EQ (NC.CheckpointNoteFile
NoteFile NIL NIL InterestedWindow
(CONCAT "Expanding notefile index"
(CHARACTER 13)))
(QUOTE DON'T))
then (ERROR!))
(SETQ ActualNumNewSlots
(NC.ExpandIndexInPlace NoteFile NewIndexSize NIL
InterestedWindow NIL
QuietFlg))
(COND
((NULL ActualNumNewSlots)
(* Looks like NC.ExpandIndexInPlace bombed for some
reason.)
(FLASHW PROMPTWINDOW)
(if IndexFullFlg
then
(* If index is full, we have to bail out of card
creation.)
(NC.PrintMsg NIL T
"Couldn't expand index. Card creation operation canceled.")
(ERROR!)
else (NC.PrintMsg NIL T
"Couldn't expand index.")))
((LESSP ActualNumNewSlots NumNewSlots)
(* NC.ExpandIndexInPlace probably bombed but we at
least got some of what we asked for.)
(FLASHW PROMPTWINDOW)
(NC.PrintMsg NIL T
"Only able to make room for "
ActualNumNewSlots
" new cards out of "
NumNewSlots " requested." NIL)))
(NC.ClearMsg InterestedWindow T)
(RETURN NewIndexSize))
(No (* Don't expand index, just return.)
(NC.ClearMsg InterestedWindow T)
(RETURN NIL))
(Cancel (* Bad news. We have to bail out because index is
full.)
(NC.ClearMsg InterestedWindow T)
(ERROR!))
[Change% Num (* Let user change number of new slots to make room
for.)
(SETQ NewNum
(RNUMBER "Number of new cards to add"
NIL NIL NIL T))
(if (AND (NUMBERP NewNum)
(GREATERP NewNum 0))
then (SETQ NewIndexSize
(PLUS IndexSize (SETQ
NumNewSlots NewNum]
NIL])
)
(* * changes to NCINTERFACE)
(DEFINEQ
(NC.SelectNoteCards
[LAMBDA (SingleCardFlg SelectionPredicate Menu InstigatingCardOrWindow Msg CheckForCancelFlg
FileLevelLockFlg) (* Randy.Gobbel " 2-Jun-87 15:34")
(* 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)
(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 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)
(WINDOWPROP PromptWindow (QUOTE COPYINSERTFN)
(FUNCTION NC.SelectNoteCardsCopyInsertFn))
[WINDOWPROP PromptWindow (QUOTE CopyInsertEvent)
(SETQ CopyInsertEvent (CREATE.EVENT (QUOTE CopyInsertEvent]
(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)))
(NAMED-RESETSAVE InternalResetVar (WINDOWPROP PromptWindow (QUOTE SelectCardsMonitor)
(CREATE.MONITORLOCK (QUOTE
SelectCards)))
(BQUOTE (WINDOWPROP , PromptWindow SelectCardsMonitor 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 [NOT (EQ SelectedCards (WINDOWPROP PromptWindow (QUOTE
SelectedCards]
do (MONITOR.AWAIT.EVENT (WINDOWPROP PromptWindow (QUOTE
SelectCardsMonitor))
CopyInsertEvent))
(* * Get the latest selection list)
(SETQ SelectedCards (WINDOWPROP PromptWindow (QUOTE SelectedCards)))
(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*)))
(* * 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)
(NAMED-RESETUNSAVE NC.SelectNoteCardsResetVar (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)
))
ResetItems)))
(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.CopyStructure
[LAMBDA (RootCards DestinationFileBox TraversalSpecs InterestedWindow QuietFlg)
(* Randy.Gobbel " 3-Jun-87 10:15")
(* * Copy a NoteCard structure into a filebox)
(* * kirk 13/7/86: Placed TraversalSpecs after RootCards selection and changed prompt message)
(* * rht 9/2/86: Threw away CheckFlg arg. Wasn't being used. Changed to call NCP.CollectCards instead of outdated
NC.CollectCards. Changed arg named ToPosition to DestinationFileBox. Also changed FromCard to RootCard.
Passes two link types to NC.AskTraversalSpecs.)
(* * pmi 12/12/86: Removed obsolete ReturnLinksFlg argument in call to NC.SelectNoteCards.)
(* * rht 3/9/87: Now accepts multiple root cards.)
(* * rg 3/9/87 added NC.ProtectedSessionOperation wrapper)
(* * RG 3/18/87 changed NC.ProtectedSessionOperation to NCP.WithLockedCards ; added NC.IfAllCardsFree wrapper)
(* * rht&rg&pmi 4/22/87: Removed calls to ERROR!)
(* * rg 6/2/87 added check for DON'T to selection of dest filebox)
(DECLARE (GLOBALVARS NC.SelectingCardsMenu NC.SelectingCardMenu))
(NCP.WithLockedCards (SETQ RootCards (MKLIST RootCards))
(NC.IfAllCardsFree
(NC.LockListOfCards RootCards "Copy Structure")
(if [AND (OR RootCards (SETQ RootCards
(NC.SelectNoteCards NIL NIL NC.SelectingCardsMenu
NIL
"Shift-select the root cards of the structure")))
[OR TraversalSpecs (SETQ TraversalSpecs
(NC.AskTraversalSpecs (fetch (Card NoteFile)
of (CAR RootCards))
(QUOTE (SubBox FiledCard]
(OR DestinationFileBox
(NEQ (SETQ DestinationFileBox
(NC.SelectNoteCards T
(FUNCTION [LAMBDA (
Card)
(NC.FileBoxP
Card T])
NC.SelectingCardMenu NIL
"Shift-select the FileBox to contain the structure."
T))
(QUOTE DON'T]
then (NC.CopyCards (NCP.CollectCards RootCards
(fetch (TRAVERSALSPECS
LinkTypes)
of TraversalSpecs)
(fetch (TRAVERSALSPECS
Depth)
of TraversalSpecs))
DestinationFileBox RootCards QuietFlg
InterestedWindow])
(NC.MoveStructure
[LAMBDA (RootCards DestinationFileBox TraversalSpecs InterestedWindow QuietFlg
Don'tPutToBeDeletedCardsFlg) (* Randy.Gobbel " 2-Jun-87 19:44")
(* * Copy a NoteCard structure into a filebox)
(* * rht 9/2/86: Added QuietFlg and Don'tPutToBeDeletedCardsFlg args. Changed names of a few args and removed
Don'tClearFlg arg. Took out REVERSE to save time and space.)
(* * rht 3/9/87: Now accepts multiple root cards.)
(* * rht&rg&pmi 4/22/87: Now checks that NC.CopyStructure returns valid stuff before deleting.)
(* * rg 6/2/87 added NCP.WithLockedCards wrapper)
(NCP.WithLockedCards (MKLIST RootCards)
(NC.IfAllCardsFree (NC.LockListOfCards RootCards "Move Structure")
(LET ((Structure (NC.CopyStructure (MKLIST RootCards)
DestinationFileBox
TraversalSpecs
InterestedWindow
QuietFlg)))
(AND Structure
(NC.DeleteNoteCards Structure T NIL
InterestedWindow
QuietFlg NIL
Don'tPutToBeDeletedCardsFlg])
)
(PUTPROPS RGPATCH044 COPYRIGHT ("Xerox Corporation" 1987))
(DECLARE: DONTCOPY
(FILEMAP (NIL (1039 27790 (NC.CopyCards 1049 . 11902) (NC.LockListOfCards 11904 . 15953) (NC.MoveCards
15955 . 16992) (NC.NoteFileCheckOpInProgress 16994 . 19242) (NC.SessionCheckOpInProgress 19244 .
21224) (NC.CheckForExpandIndex 21226 . 27788)) (27826 47784 (NC.SelectNoteCards 27836 . 44035) (
NC.CopyStructure 44037 . 46592) (NC.MoveStructure 46594 . 47782)))))
STOP