CommandToolExtras.mesa
This interface is temporary. It will be folded into CommandTool next time interfaces change.
Last Edited by: Stewart.pa, January 16, 1984 3:11 pm
DIRECTORY
Commander USING [Handle],
ReadEvalPrint USING [Handle],
Rope USING [ROPE],
ViewerClasses USING [Viewer];
CommandToolExtras: CEDAR DEFINITIONS =
BEGIN
Useful procedures for writing commands.
These procedures relieve one from the tedium of using CommandTool.Parse or ParseToList. These commands actually call CommandTool.Parse and save the result on the property list.
NumArgs: PROC [cmd: Commander.Handle] RETURNS [INT];
Returns number of argument tokens that would be produced by CommandTool.Parse (including the name of the command itself). This is ArgumentVector.argc.
NextArgument: PROC [cmd: Commander.Handle] RETURNS [Rope.ROPE];
Returns the next command line token. ArgN sets the "pointer". The initial value of the pointer is the first token after the name of the command. Returns NIL after returning the last real argument.
ArgN: PROC [cmd: Commander.Handle, n: INT] RETURNS [Rope.ROPE];
Returns the nth command line argument. ArgN[cmd, 0] is the name of the command. After any given ArgN, NextArgument will return the (n+1)st argument. Returns NIL if there is no nth argument.
RegistrationDirectory: PROC [cmd: Commander.Handle] RETURNS [Rope.ROPE];
Returns the name of the directory in which the present command was registered. Typically, this will be the directory in which the .load file was found. This directory is the appropriate place to look for TIP tables etc.
For Cedar 5.1, this command returns FileNames.GetDirectory[cmd.command]. In a later release, it will return the directory information stored explicitly in the Commander registry. Note: If Commander.Register is called with a short name, the command name is prepended with the name of the current working directory. If a .load file is running, then the current working directory will be the directory in which the .load file was found, so this scheme will work.
Procedures for manipulating a command tool.
These procedures relieve one from the tedium of using CommandTool.Parse or ParseToList. These commands actually call CommandTool.Parse and save the result on the property list.
GetViewer: PROC [cmd: Commander.Handle] RETURNS [ViewerClasses.Viewer];
Returns the viewer associated with the top level CommandTool, if there is one. If this procedure is called from a command run by a nested instance of the CommandTool, it will chase up the stack of CommandTool instances until it finds the top level.
GetReadEvalPrint: PROC [cmd: Commander.Handle, topLevel: BOOLFALSE] RETURNS [ReadEvalPrint.Handle];
Returns the ReadEvalPrint.Handle associated with the top level CommandTool. If this procedure is called from a command run by a nested instance of the CommandTool, it will chase up the stack of CommandTool instances until it finds the top level.
END.