next up previous contents
Next: Tracker objects Up: User interface objects Previous: UIObject   Contents

Subsections


UIText

Files: UIText.h, UIText.C
Derived from: \bf UIObject
Global instance (if any): uiText
Used in optional component: Part of main VMD code

Description

The particular UIObject which is responsible for getting text commands from the user, parsing them, and executing them. Each time it is requested to do so, this object will check to see if the user has entered a line of text at the VMD prompt, and if so, this will read in the command, break it up into the individual words, and determine what action is being requested. Every action in VMD which the user can request to have performed has a corresponding Command object associated with it, and a text command representation.

Each text command consists of N separate words separated by whitespace, with the first word in the command used to distinguish between different types of commands. With each word there is an associated callback function which is called when a text command is read in and the first word is found in the list.

This object can also be directed to read commands from a file, and to echo text commands to the console.

UIText is able to use the Tcl library, if available, to parse the text commands and to provide sophisticated interpreted script capabilities such as control loops, variable substitution, if-then-else constructs, and user-defined subroutines and functions. If Tcl is not available, this object will still function, but only the basic VMD commands will be understood.

Constructors

Internal data structures

Nonvirtual member functions

Virtual member functions

Method of use

In the constructor for this object, first the code for the `TextEvent' command is registered as a command this object is interested in, and then all the words this object can understand (with their callback functions) are added to the object's internal list. Each time a new word is added to the VMD vocabulary, a new line must be added in this section to add the callback function (see the discussion of Command, section 27.1). The callback functions themselves should be declared in the Cmd*.h files, and defined in the Cmd*.C files.

When a text command is actually to be executed, is it broken into an argc, argv tokenized format, and given to the process_command routine. This searches for the first word in the internal list of known words, and calls the callback function with the argc, argv pair, and also the CommandQueue object to use for queuing new commands as well as the ID of this UIObject.

In the case where Tcl is being used, there is a slightly different order to these events. After a string is read, it is given to the Tcl evaluation routine, which checks it for special Tcl commands or for VMD commands. When VMD commands are seen, Tcl will tokenize the command itself and call a particular Tcl-tailored callback function. This callback function is registered with Tcl for every word in the VMD vocabulary. In this Tcl callback function, the first word is checked, and the regular text callback function is called.

Suggestions for future changes/additions

The reading of commands from files should be converted from the stdio style I/O to the use of the streams library.


next up previous contents
Next: Tracker objects Up: User interface objects Previous: UIObject   Contents
vmd@ks.uiuc.edu