8.4   Customizing the Tools Menu

You can add entries to the Tools menu to allow easy access to additional tools. Before you add any commands in this part of the menu, Tornado displays the placeholder No Custom Tools as a disabled menu entry. The Customize command in the Tools menu allows you to add (or remove) entries at the end of the Tools menu.

8.4.1   The Customize Tools Dialog Box

Click Tools>Customize to open the Customize Tools dialog box (Figure 8-4).

The Menu Contents list box in the Customize Tools dialog box shows all custom commands currently in the Tools menu. When you select any item in this list, you can edit its attributes in the three text boxes near the bottom of the dialog box.

The Customize Tools dialog box has the following buttons:

Add
Activates the list and check boxes at the bottom of the Customize Tools dialog box and enters New Tool in the Menu Text list box. Replace New Tool with the command description; when you click OK, the new menu item appears in the Tools menu.

Remove
Deletes the selected menu item from the Tools menu.

Move Up
Moves the selected menu item up one line in the Menu Contents list box and changes the displayed order on the Tools menu.

Move Down
Moves the selected menu item down one line in the Menu Contents list box and changes the displayed order on the Tools menu.

OK
Applies your changes to the Tools menu.

Cancel
Discards your changes without modifying the Tools menu.

The three text boxes near the bottom of the Customize Tools dialog box allow you to specify or change the attributes of a custom command.

Menu Text
Contains the name of the custom command, as it appears in the Tools menu.

Tool Command
Specifies the instructions to execute your command. You can place anything here that you could execute at the command prompt or in a batch file. Click the button at the right of the box to see a pop-up menu including a browse option and a list of macros which allow you to capture Tornado context in your commands. See Macros for Customized Menu Commands for explanations of these macros.

Working Directory
Use this field to specify where (in what directory) to run the custom command. You can edit the directory name in place, or click the button at the right of this field to bring up a menu similar to the Tool Command menu. It includes a directory browser where you can search for the right directory and the same list of macros. To use the Tornado working directory, leave this field blank.

At the bottom of the Customize Tools dialog box are the following check boxes:

Prompt for Arguments
When this box is checked, Tornado prompts for command arguments using a dialog box, when you click the new command. The command line is displayed in a window where you can add additional information. (See Figure 8-5.)

Redirect to Child Window
When this box is checked, Tornado redirects the output of your command to a child window--a window contained within the Tornado application window. Otherwise, the command runs independently, either as a console application or a Windows application.

Close Window On Exit
When this box is checked, Tornado closes the window associated with your tool when the command is done. This only applies when you also check the Redirect to Child Window box to redirect command output to a child window.

Macros for Customized Menu Commands

The pop-up menu opened by the buttons to the right of the text boxes provides several macros for your use in custom menu commands. These macros allow you to write custom commands that are sensitive to the context in the editor, or to the global Tornado context. For example, there are macros for the full path of the file in the active editor window, and for useful fragments of that file's name. Table 8-2 lists macros for editor context; in this table, the phrase active file refers to the file that is currently selected in the project facility.

Table 8-2:  Menu-Customization Macros for Editor Context


Menu Entry
 
Macro
 
Description
 
Example
 

File path
 
$filepath
 
Full path to the active file.
 
/usr/xeno/zap.c
 
Dir name
 
$filedir
 
Directory containing the active file.
 
/usr/xeno
 
File name
 
$filename
 
Name of the active file, without path information.
 
zap.c
 
Base name
 
$basename
 
Name of the active file, without the file extension.
 
zap
 

Table 8-3 lists macros for the project facility context.

Table 8-3:  Menu-Customization Macros for Project Context


Menu Entry
 
Macro
 
Description
 
Example
 

Project dir
 
$projdir
 
The name of the directory of the current project.
 
/usr/xeno/proj/widget
 
Project build dir
 
$builddir
 
The name of the directory for the current build of the current project.
 
/usr/xeno/proj/widget/default
 
Derived object
 
$derivedobj
 
The name of the derived object of the currently selected source file in the current project.
 
/usr/xeno/proj/widget/default/zap.o
 

Table 8-4 lists macros for the global Tornado context.

Table 8-4:  Menu-Customization Macros for Global Context


Menu Entry
 
Macro
 
Description
 
Example
 

Target name
 
$targetName
 
The full name of the target server selected in the Tornado Launch toolbar.
 
vxsim@ontario
 
Target
 
$target
 
The name of the target selected in the Tornado Launch toolbar.
 
vxsim
 
Tornado inst. dir
 
$wind_base
 
Installation directory recorded in the environment variable WIND_BASE.
 
/usr/wind
 
Tornado host type
 
$wind_host_type
 
Host type recorded in the environment variable WIND_HOST_TYPE.
 
sun4-solaris2
 
Tornado registry
 
$wind_registry
 
Registry recorded in the environment variable WIND_REGISTRY
 
mars
 

8.4.2   Examples of Tools Menu Customization

When creating a menu command be sure to check Redirect to Child Window for all applications that do not automatically open their own shell or window. Otherwise the command will attempt to run in the window that launched Tornado, if that window is still open. Thus an editor or version control command should be redirected, but a call to a browser need not be.

Version Control

This example illustrates how to use the Customize Tools dialog box to add an Uncheckout command to the Tools menu: the command cancels the checkout of whatever file is currently open in Tornado (that is, the file visible in the current editor window). Figure 8-6 illustrates the specification for a ClearCase command to uncheckout a module.

The Menu Text entry indicates that the command unchecks out a file, but is not specific to any particular file. The Tool Command field uses the $filepath macro (Macros for Customized Menu Commands) to expand the current file to its full path name.

In this example, the Prompt for Arguments and Redirect to Child Window boxes are checked. When the new Uncheckout command in the Tools menu is executed, the predefined argument list appears as a default in a dialog box (shown in Figure 8-7), to permit specifying other arguments if necessary.

Alternate Editor

Figure 8-8 illustrates the specification for a command to run the UNIX vi editor on the file that is currently open in Tornado. The Menu Text contains a useful name, while the Tool Command field uses the actual execution command and $filepath to identify the current file. In this case, Prompt for Arguments is not checked; thus the editor runs immediately. Again, Redirect to Child Window is checked so that the editor will open in a new window.

Binary Utilities

Tornado includes a suite of software-development utilities described in the GNU ToolKit User's Guide: The GNU Binary Utilities. If you execute any of these utilities frequently, it may be convenient to define commands in the Tools menu for that purpose.

Figure 8-9 illustrates the specification for a command to run the sizearch utility, which lists the size of each section of an object module for target architecture arch. In this example, the Tool Command field constructs the path and name of the object file generated from the current source file using $filedir/SIMSPARCSOLARISgnu/$basename. The Working Directory field is filled in using the browse option to locate the appropriate version of sizearch in the correct directory.

World Wide Web

You can add a Tools command to link your Web browser directly to announcements from Wind River Systems (and to related Internet resources). Figure 8-10 shows the specification for a Wind River Web Page command. (For a description of the information available on the WRS home page, see 9.3 WRS Broadcasts on the World Wide Web.

Tornado itself does not include a Web browser. If you do not have a Web browser, or your system does not have direct Internet access, ignore this example; it provides convenient access to information, but no essential functionality.