DIRECTORY IO USING [STREAM], List USING [AList], Rope USING [ROPE]; Commander: CEDAR DEFINITIONS = BEGIN OPEN IO, List, Rope; CommandProc: TYPE = PROC [cmd: Handle] RETURNS [result: REF ¬ NIL, msg: ROPE ¬ NIL]; Register: PROC [key: ROPE, proc: CommandProc ¬ NIL, doc: ROPE ¬ NIL, clientData: REF ¬ NIL, interpreted: BOOL ¬ TRUE]; Handle: TYPE = REF CommandObject; CommandObject: TYPE = RECORD [ in, out, err: STREAM ¬ NIL, command: ROPE ¬ NIL, commandLine: ROPE ¬ NIL, procData: CommandProcHandle ¬ NIL, propertyList: AList ¬ NIL ]; CommandProcHandle: TYPE = REF CommandProcObject; CommandProcObject: TYPE = RECORD [ proc: CommandProc ¬ NIL, doc: ROPE ¬ NIL, clientData: REF ANY ¬ NIL, interpreted: BOOL ¬ TRUE ]; Enumerate: PROC [EnumerateAction] RETURNS [key: ROPE, procData: CommandProcHandle]; EnumerateAction: TYPE = PROC [key: ROPE, procData: CommandProcHandle] RETURNS [stop: BOOL ¬ FALSE]; Lookup: PROC [key: ROPE] RETURNS [procData: CommandProcHandle]; END. 0 Commander.mesa Copyright Ó 1985, 1986, 1991 by Xerox Corporation. All rights reserved. McGregor, 7-Dec-81 10:53:03 Paul Rovner, March 22, 1983 12:25 pm Stewart, September 9, 1983 11:40 am Russ Atkinson (RRA) February 28, 1985 1:34:11 pm PST Michael Plass, August 19, 1991 11:04 am PDT Basic command registration; refer to CommanderOps for more support for implementing command procedures. A CommandProc represents a function which a user can invoke from a CommandTool. The result will be stored in the CommandTool property list under the key $Result for the possible use by the suceeding command. Any result other than the ATOM $Failure is deemed to indicate some sort of success. A command may be unregistered by registering proc: NIL with the appropriate key. Case is ignored for keys. If the key has no directory part, the current working directory will be prepended. in and out may be redirected. err is a bidirectional stream which always allows communication with the user. UserAbort is indicated only by in.UserAborted[]. The first token on the command line, used as a key to select this CommandProc. This rope will be the key under which the command was registered, rather than the (possibly) prefix of that string by which the command was invoked. commandLine is the command line with the first token (the command) removed; commandLine ends with end-of-line character. This field contains the information registered with the CommandProc, doc and clientData may be useful to the authors of commands. Name value pairs. The key $Result will be associated with the result of the previous command. The command line unprocessed by the CommandTool will be found under $OriginalCommandLine. A CommandProc may alter the property list either by appending to it, in which case the changes are permanent (seen by later commands), or by prepending, in which case the changes will be discarded when the CommandProc returns. Changes made to the value fields of existing properties are always permanent. ... is the procedure to invoke in order to perform the command. ... is a short blurb about what the command does. ... is passed to the command when it is invoked. ... controls how the command line is to be interpreted. FALSE means to do no processing, since the command itself has funny syntax. TRUE means to do I/O redirection, use semicolon separators and other processing. ... calls the EnumerateAction with the key and registered procedure data for all registered commands. It will stop early if the EnumerateAction returns TRUE. Commands are not enumerated in any particular order. ... will look up the command and return the associated CommandProcHandle (NIL if no such command is registered). Case of keys does not matter. As in Register, if no directory part is mentioned, the current working directory will be prepended to the key. ÊÖ(cedarcode) style•NewlineDelimiter ™codešœ™Kšœ Ïeœ=™HKšœ™Kšœ$™$Kšœ#™#K™4K™+K˜K™gK˜—šÏk ˜ Kšžœžœžœ˜Kšœžœ ˜Kšœžœžœ˜—K˜šÏn œžœž œž˜$šžœžœ ˜K˜—šŸ œžœžœžœ žœžœžœžœ˜T™OK™Ô—K™—šŸœžœžœžœžœžœžœžœžœžœ˜vK™¿K˜—šœžœžœ˜!K˜—šœžœžœ˜šœžœžœ˜K™Ÿ—šœ žœžœ˜Kšœä™ä—šœ žœžœ˜Kšœx™x—šœžœ˜"K™—šœž˜K™ì—Kšœ˜K˜—šœžœžœ˜0K˜—šœžœžœ˜"šœžœ˜K™?—šœžœžœ˜K™1—šœ žœžœžœ˜Kšœ0™0—šœ žœž˜KšœÖ™Ö—Kšœ˜K˜—šŸ œžœžœžœ˜SKšŸœžœžœžœžœžœžœ˜cKšœ™žœ7™ÔK˜—šŸœžœžœžœ˜?Kšœÿ™ÿK™——Kšžœ˜—…—ÒÅ