One of the more obvious features of the Borland C++ 3.1 Integrated Development Environment (IDE) is its ability to display the different elements of a source file in special styles or colors (syntax highlighting). By displaying the source code this way, the editor can help you understand the structure of your program by making the structure more obvious and can help you recognize errors as you edit the code.
In the Windows version of the IDE, you can change the type style or color of specific elements of a source file. To do so, you select the Highlight... menu item from the Environment submenu of the Options menu. When you do, the IDE displays the Highlighting dialog box shown in Figure A. Since you run the IDE from Windows, the IDE can display text in many waysboldface, italic, underlined, and so on. If you don't like the default settings, you can create your own color schemes.
Figure A - From the Windows IDE, you use the Highlighting dialog box to customize the syntax highlighting options.
Unfortunately, the DOS version of the IDE can only display text
in a single type style. In addition, the DOS IDE doesn't
have the same Highlight... option available from the
Environment submenu of its Options menu. In this article, we'll
show you how to use the Colors dialog box to modify the colors
the DOS IDE uses to display different elements of a C or C++ source
file.
A Windows application will display most user-interface items in a standard way. For example, buttons in a dialog box are usually gray. Few, if any, applications violate the accepted standards or allow the user to modify the appearance of standard items from inside the application.
However, DOS applications like the DOS IDE don't have a widely accepted user-interface standard. Because of this, Borland allows you to customize the colors of various user interface itemsincluding the source code in an edit windowthat appear in the DOS IDE.
To change the display color of a specific type of source file element, you'll use the same Colors dialog box you use to customize the appearance of the user-interface items. The Item list box in the Colors dialog box lists the parts of a particular IDE component that can use custom foreground and background colors.
You can change the colors of many parts of an edit window (Active/Inactive Title or Border, Scroll Bar, and so on) just as you can change those same parts in other types of IDE windows. However, the Item list box also lists the elements of a source file by syntax (comments, reserved words, or numerical constants).
After you change the foreground or background color for a given
item, you'll be able to see the change immediately in any
open edit window for a source file. However, since this setting
isn't part of a project file (it's part of the IDE
configuration), any source file in any project will now use this
setting. Now, let's apply this technique to change the
color of comments in C++ source files.
To begin, launch the Borland C++ 3.1 IDE for DOS. When the IDE's menu and desktop appear, choose Environment from the Options menu and then choose Colors... from the Environment submenu to display the Colors dialog box.
When the Colors dialog box appears, select Edit Window in the Group list box. When you do this, the parts of an edit window you can modify will appear in the Item list box, as shown in Figure B.
Figure B - You can use the Colors dialog box to customize the syntax highlighting of source files in the DOS IDE.
To change the color for comments, select Comment from the Item list box. Now, you'll see the current foreground and background color settings for this item in the Item Color group and in the Foreground and Background groups.
The Item Color group displays the color settings as they will appear in the edit window. In contrast, the Foreground and Background groups show the current choice from a display of the possible color selections by marking the current color with a special symbol (ï|ï|ï).
Unless you've already changed the comment colors on your system, you should see the default color combination for comments as red text on a blue background. Unfortunately, this combination can be difficult to read, especially for people with any form of red-green color blindness.
To change the color of comment text without changing the background color, select the aqua region of the Foreground group. Many people find this color combination easier to read, and the comment color is less obtrusive when you're scanning a source file for code and trying to ignore any comments. To save this color setting, click OK.
Finally, let's open a source file to see how the new comment color appears onscreen. To do this, choose Open... from the File menu.
In the Open A File dialog box, enter
\borlandc\include\iostream.h
in the Name entry field. Click Open to view this file. When the edit window for the IOSTREAM.H file appears, you should see the comments as aqua text on a blue background.
To close the IOSTREAM.H edit window, choose Close from the Window
menu. To quit the IDE, choose Quit from the File menu.
The DOS IDE doesn't benefit from the flexible syntax display
options of the IDE that runs under Windows. However, by using
the Colors dialog box, you can still customize the appearance
of different parts of a C or C++ source file.
Copyright (c) 1996 The Cobb Group, a division of Ziff-Davis Publishing Company. All rights reserved. Reproduction in whole or in part in any form or medium without express written permission of Ziff-Davis Publishing Company is prohibited. The Cobb Group and The Cobb Group logo are trademarks of Ziff-Davis Publishing Company.