WalnutWindow.Mesa
Copyright Ó 1985, 1987, 1988, 1992 by Xerox Corporation. All rights reserved.
Willie-Sue, July 18, 1988 7:37:28 pm PDT
Donahue, May 22, 1985 10:41:18 am PDT
BEGIN
Viewer: TYPE = ViewerClasses.Viewer;
ROPE: TYPE = Rope.ROPE;
OutCome: TYPE = {ok, flushed, notRunning};
WalnutHandle: TYPE = REF WalnutHandleRec;
WalnutHandleRec: TYPE;
Dealing with multiple Walnut Control Windows
GetHandleForRootFile:
PROC[rootFile:
ROPE]
RETURNS[wH: WalnutHandle];
wH will be NIL if that rootFile is not an active walnut
GetHandleForMail:
PROC
RETURNS[wH: WalnutHandle];
get wH for the one database allowed to get new Mail - may return NIL
GetHandleList:
PROC
RETURNS[
LIST
OF WalnutHandle];
returns a list of all the known WalnutHandle's
GetRootFileForHandle:
PROC[wH: WalnutHandle]
RETURNS[rootFile:
ROPE];
returns NIL if the handle is no longer valid
GetSegmentForHandle:
PROC[wH: WalnutHandle]
RETURNS[segment:
ATOM];
returns NIL if the handle is no longer valid
GetHandleForSegment:
PROC[segment:
ATOM]
RETURNS[wH: WalnutHandle];
returns NIL if no handle for that segment
Msg and MsgSet viewer procedures
GetMsgName:
PROC[v: Viewer]
RETURNS[mName:
ROPE, rootFile:
ROPE];
If v is a Viewer for a Walnut Msg, then return its name else NIL
GetMsgSetName:
PROC[v: Viewer]
RETURNS[msName:
ROPE, rootFile:
ROPE];
If v is a Viewer for a Walnut MsgSet, then return its name else NIL
CurrentVersion:
PROC[wH: WalnutHandle, msName:
ROPE]
RETURNS[version:
INT];
Give the current "expected version" of the message set (-1 means "don't care"). This version may not agree with the database; it is simply the current version that WalnutWindow believes!
AddToMsgMenu:
PROC[wH: WalnutHandle, label:
ROPE, proc: Menus.MenuProc, clientData:
REF
ANY ¬
NIL, onQueue:
BOOL ¬
FALSE, doReset:
BOOL ¬
TRUE];
adds menu button, synchronised using walnutQueue if onQueue is TRUE; if doReset then after the call to the client proc, walnut's display will be checked and updated if necessary.
Errors from WalnutOps will cause WalnutDefs.Error to be raised.
IF WalnutHandle is NIL, then will get added for all current running Walnut's, but then the client has no way of finding out which Walnut it is running in.
ReplaceInMsgMenu:
PROC[wH: WalnutHandle, label:
ROPE, proc: Menus.MenuProc, clientData:
REF
ANY ¬
NIL, onQueue:
BOOL ¬
FALSE, doReset:
BOOL ¬
TRUE]
RETURNS[oldFound: BOOL];
replaces menu button lable if found (else adds it), synchronised using walnutQueue if onQueue is TRUE; if doReset then after the call to the client proc, walnut's display will be checked and updated if necessary.
Errors from WalnutOps will cause WalnutDefs.Error to be raised.
If WalnutHandle is NIL, then will get added for all current running Walnut's, but then the client has no way of finding out which Walnut it is running in.
RemoveFromMsgMenu:
PROC[wH: WalnutHandle, name:
ROPE];
removes the named button from the msg displayer menu, if such a button exists; no errors
Displaying Msgs and MsgSets
DisplayMsg:
PROC[wH: WalnutHandle, msg:
ROPE, oldV: Viewer ¬
NIL, shift:
BOOL ¬
FALSE, paint:
BOOL ¬
TRUE]
RETURNS[v: Viewer];
displays Msg name (if it exists) in Viewer oldV; if oldV is NIL it creates a viewer
DisplayMsgSet:
PROC[wH: WalnutHandle, msgSet:
ROPE, shift:
BOOL ¬
FALSE, repaint:
BOOL ¬
TRUE]
RETURNS[v: Viewer];
returns NIL if msgSet is not a MsgSet in wH. This operation also inserts the viewer into the state recorded by the Walnut control window, so that operations on the messages in the message set are guaranteed to use a consistent version of the set. If the message set is already displayed, then it will be repainted if repaint is TRUE
Other useful operations
StartUp:
PROC[rootFile:
ROPE, dontDoMail:
BOOL ¬
FALSE]
RETURNS[wH: WalnutHandle];
Open up a WalnutWindow on the database named in the root file
Shutdown:
PROC[wH: WalnutHandle];
Close down the WalnutWindow
QueueCall:
PROC[wH: WalnutHandle, proc:
PROC[WalnutHandle]
RETURNS[doReset:
BOOL]]
RETURNS[outCome: OutCome];
places proc on Walnut's TBQueue; Walnut will do a Reset after the call completes, in case proc has changed the displayed state of Walnut. outCome lets the caller know what happened with the call.
Errors from WalnutOps will cause WalnutDefs.Error to be raised. If proc changed the database then proc should return TRUE, to get Walnut to update the display
GetNewMail:
PROC[wH: WalnutHandle];
checks if user has changes, then calls DoNewMail
Expunge: PROC[wH: WalnutHandle];
Scavenge: PROC[rootFile: ROPE, dontDoMail: BOOL ¬ FALSE] RETURNS[wH: WalnutHandle];
WriteArchiveFile:
PROC[wH: WalnutHandle, fileName:
ROPE, msgSetList:
LIST
OF
ROPE];
If the message set list is NIL, then the entire database is dumped
ReadArchiveFile:
PROC[wH: WalnutHandle, fileName, msgSet:
ROPE, useCategoriesInFile:
BOOL ¬
FALSE];
IF msgSet is NIL and useCategoriesInFile is FALSE, then messages go into Active; IF msgSet is NIL and useCategoriesInFile is TRUE, then use the ones specified in the file
IF msgSet is non-NIL THEN put all messages into it
SelectMsgSetsFromMSNames:
PROC [wH: WalnutHandle, msNames:
LIST
OF
ROPE]
RETURNS[notFound: LIST OF ROPE];
Selects the message set buttons in the Walnut Control viewer which corresponds to the list of msNames given. Returns a list of any not found
GetWalnutViewers:
PROC[wH: WalnutHandle]
RETURNS [msgSetList, msgList, wallabyList: LIST OF Viewer];
Reporting Operations
Report:
PROC[wH: WalnutHandle, msg1, msg2, msg3:
ROPE ¬
NIL];
Prints non-omitted arguments in the Walnut window followed by CR.
ReportRope:
PROC[wH: WalnutHandle, msg1, msg2, msg3:
ROPE ¬
NIL];
Similar to above, but doesn't print CR at end.
ReportFormat:
PROC[wH: WalnutHandle, format:
ROPE ¬
NIL, v1, v2, v3, v4, v5:
IO.Value ¬ [null[]] ];