TOC PREV NEXT INDEX DOC LIST MASTER INDEX



The C/C++ Editor

The C/C++ editor is a text editor with special features for editing C/C++ source files. Note that this version of the C/C++ editor is the Apex text editor. This editor is only available with Rational Apex C/C++ and Rational Apex Duo.

About This Chapter

This chapter describes the C/C++ editor and shows how to use it. Specifically, this chapter covers the following topics:

This chapter describes the commands available from the Apex C/C++ editor's File, Edit, View, Navigate, and Compile menus. The Control menu is examined in Using and Customizing Summit/CM and the Debug menu is described in Using the Apex Debugger.


The C/C++ Editor Window

The C/C++ editor window is similar to the text-editor window described in The Apex Text Editor.

The C/C++ editor is used to create, view, and edit C/C++ source code.

Note: The C++ editor was designed using the standard Motif text widget, so its basic editing commands are similar to those of many other Motif clients (and emacs, too). Some keystroke combinations recognized by the Apex editor are actually accelerators for the commands on the Edit menu.


Starting the C/C++ Editor

There are several ways to start the C/C++ editor. You can:


Editing Source Code

The editing commands recognized by the C/C++ editor are the same as those recognized by the Apex text editor described in The Apex Text Editor. By choosing commands from the Edit menu, you can:

There are two ways to execute editing commands: by choosing commands from the Edit menu and by typing keyboard shortcuts. For details, see Using the Text Editor.

Editor Modes

The C/C++ editor, like the text editor, is always in one of two modes: edit mode or the default read-only mode. When the editor is in edit mode, you can modify files. When the editor is in read-only mode commands that modify files are inactive or grayed. To toggle between edit and read-only mode, select File > Edit or click the Edit button.

Searching for Text and Replacing Text

To search for text that matches a specified string in a source file, choose Search from the Edit menu or type keyboard shortcuts. You can also search for text and replace it with a different string. For details, see Selecting Text and Replacing Text.

Cutting and Pasting Text

To cut selected text from the C/C++ editor window and transfer it to an internal clipboard, choose the Cut command from the Edit menu. When text has been transferred from an Apex window to the clipboard, you can paste the text into windows displayed by other applications running under the Motif window manager. For more information on cutting and pasting text, see Editing Text.

To delete selected text from the edit window, choose Delete from the Edit menu or execute one of the keyboard shortcuts listed in Deleting Text from a Document.


C/C++-Specific Editing

In addition to its standard text-editing features, the Apex C/C++ editor offers many C/C++-specific editing features. You choose commands from the editor's Compile and Navigate menus to use these features.

C/C++ files are made up of objects such as keywords, identifiers, statements, and declarations. These objects are arranged in a hierarchical structure and are related to each other in various ways. The Apex C/C++ editor is designed to recognize the structure of C/C++ objects and the relationships that C/C++ objects have with each other, and to offer special browsing and selecting commands for C/C++ files.

Browsing

With the C/C++ editor, you can browse through interdependent C/C++ files in the same way you might browse through a printed cross-reference listing. However, with Apex, no listing is required; browsing is interactive and automatic. Browsing uses the dependency information and is useful, for example, when you are:

Traversing

To traverse C/C++ variables, classes, and functions, place the cursor on an object and select one of the following Visit or Visit In Place commands (for more information on the Visit or Visit In Place commands, see Using and Customizing the GUI).

For example, to traverse to the defining occurrence of a program object such as a function, variable, or type:

1 . Place the cursor on any occurrence of the object.

2 . Choose the Navigate > Visit command. (Visit is also available on the button bar and pop-up menu.)

Note that browsing operations depend on semantic information about your C/C++ files that is collected during semantic analysis. If you have difficulty browsing because you have made changes since the last time you analyzed a file, select Compile > Analyze and then try browsing again.

Viewing the Usage of C/C++ Objects

When you execute commands available from the Compile menu, you can find:

The commands for viewing the usage of C/C++ objects are:

By default, all three of the commands listed above display dialog boxes that let you specify C/C++ items. Alternatively, you can execute each of these three commands as a "just-do-it" menu command by holding down the Shift key while you choose the command you want to execute. (For more information on "just-do-it" menu items, see Using and Customizing the GUI.)

Table 15 lists the effects of executing the Show Usage, Local Usage, and Show Unused commands.

Table 15 Show Usage, Local Usage, and Show Unused Commands
Command
Default behavior
Optional behavior
Show Usage...
Displays a dialog box that lets you specify a C/C++ item, with the scope being the current view. Apex then highlights each usage of the specified item in the desired scope.
Displays the usage of the selected item in the scope of the current view.
Local Usage
By default, this is a "just-do-it" command that displays the usage of the selected item in the scope of the current file and its body and subfiles
Displays a dialog box that lets you specify a C/C++ item, with the scope of the item being the current file, body, and subfile. Apex then highlights each usage of the specified item in the desired scope.
Show Unused...
Displays a dialog box that lets you specify a C/C++ file, with the scope being the current view. Apex then highlights each unused declaration in that file in the desired scope.
As a "just-do-it" command, displays unused declarations in the current file in the scope of the current view.

When you execute one of the commands listed in the above table, Apex highlights each occurrence it finds. You can then traverse from one occurrence to another by clicking the Message -> button or the Message <- button in the Apex editor's button bar.

If many files reference an object, Apex displays a window listing all such files. You can then visit each file in turn and click Message -> or Message <- to traverse between references.

C/C++-Specific Edit Commands

Several commands make the formatting and maintenance of C/C++ files easier and more convenient:

Error Checking

When you write C/C++ source code using the Apex C/C++ editor, you can check your C/C++ files for errors as you edit them. The Compile > Code menu command performs error checking.

When you execute the Code command, Apex displays any errors found in the Output window and in a Summary window. You can traverse from an error in the Summary window by double-clicking on the error message. In addition, you can select an error in the C/C++ editor that is highlighted and execute the Help > Explain command to display the corresponding error message.


Rational Software Corporation 
http://www.rational.com
support@rational.com
techpubs@rational.com
Copyright © 1993-2002, Rational Software Corporation. All rights reserved.
TOC PREV NEXT INDEX DOC LIST MASTER INDEX TECHNOTES APEX TIPS