This chapter explains how to use the CodeWarrior text editor to edit your source code.
You can also change options that affect the way the editor works. See "Editor".
The CodeWarrior editor, shown in Figure 5.1, contains elements you'll find useful when viewing and editing your source files.
To see an Editor window, create a new text file using the New Text command on the File Menu.
The sections that follow describe the elements of the Editor window shown in Figure 5.1.
The Text Editing Area of the Editor window is where your text is entered in your new window.
Use the Interface pop-up menu to open interface or header files referenced by the current file, as shown in Figure 5.2. You can also use the Touch command from this pop-up.
To open a file in the list, scroll to the file you want to see and release the mouse button.
For more information on opening files, see "Opening an Existing File."
Use the Routine pop-up menu shown in Figure 5.3 to set the current location of the text insertion point in your text files.
The checked routine in the pop-up contains the current location of the text insertion point.
The Routine pop-up menu lists the routines in your source file.
Use the Options pop-up menu, shown in Figure 5.4, to choose syntax styling for the current file, and also to set the format for how to save the file.
For more information on how to use the options on this pop-up menu, see "Saving as a Be, Macintosh, or DOS text file."
For more information on the Syntax Styling option shown in this menu, see "Syntax Styling."
The Permissions pop-up menu, as shown in Figure 5.5, indicates the read/write status of the file you are currently editing. The icon indicates whether the file is locked or unlocked.
The Read Only pop-up menu, shown below in Figure 5.6, appears in the place of the Permissions pop-up menu when you open a file that cannot be modified. For example, if you open a file from a CD-ROM in the IDE, the Read Only icon will appear, since this file cannot be modified.
The line number box, as shown in Figure 5.1, displays the line number that contains the text insertion point.
You set the size or font used to display text in an Editor window in the Fonts & Tabs preference panel. For more information, see "Font."
The topics in this section are:
The CodeWarrior editor provides dynamic scrolling, which means that as you drag the Scroll Bar at the far right of the Editor window, the CodeWarrior Editor updates the contents. See Figure 5.7 to see what the Scroll Bars look like.
Table 5.1 describes how to move the insertion point around a file with function keys.
To move insertion point to
|
Press |
---|---|
Table 5.2 describes how to scroll to different locations in a file, without moving the insertion point. Note that some of the keys listed in the table may not be on your keyboard, depending on what kind of keyboard you have.
To scroll to the
|
Press this
|
---|---|
To add text to a file you've opened, click once in the Text Editing Area of the window to set the new location of the text insertion point. After you see the insertion point at the new location, you may begin typing on the keyboard to enter text.
To read about different ways to move the insertion point in an Editor window, see "Basic Editor Window Navigation."
There are several different methods for deleting text.
To delete text that you just typed, hit the Backspace key.
To delete text that is in front of the text insertion point, use the Delete key.
If you don't know how to select text, see "Selecting Text."
There are several different ways to select text in the Editor window.
To select a word, double-click on the word.
To select a line, triple click anywhere in the line.
You can also select text by holding down the Shift key while pressing any of the shortcuts listed in Table 5.1.
To list and display an entire routine in the Editor window, press the Shift key while selecting a routine in the Routine Pop-up Menu. This is particularly useful for copy and paste operations in your file.
For more information about these commands, refer to "Edit Menu."
To use Drag & Drop Editing, select text in a source file using the techniques described in "Selecting Text", then placing the cursor over the selected text, press the left-mouse button to grab the selected text. While holding the right-mouse button down, drag the text outline until the insertion cursor is precisely where the text should be moved, then release the mouse button.
CodeWarrior provides several checks that help you balance these elements correctly.
To check for balanced parentheses, brackets, or braces, place the insertion point in the text you want to test. Then, choose Balance from the Edit Menu.
You can have the CodeWarrior Editor check for balanced punctuation automatically. If you would like to learn more about checking the balance of code automatically as you type, refer to "Balance While Typing."
Use the Shift Left and Shift Right commands on the Edit Menu to shift a block of text to the left or right.
To shift blocks of text, select a block of text. If you don't know how to do this, see "Selecting Text." Then, choose Shift Right or Shift Left from the Edit Menu.
To learn more about controlling the number of spaces the text is indented, refer to "Font."
The CodeWarrior editor supplies ways to Undo mistakes as you edit a file.
The Undo command reverses the effect of your last action. The name of the Undo command on the Edit Menu varies depending on what you last did. For example, if you just typed in some text, the command changes to Undo Typing.
The Revert command on the Edit Menu returns a file to its last saved version. For more information about this command, refer to "Revert."
You can use color to highlight many elements in your source code, such as comments, keywords, and quoted character strings. Highlighting these elements helps you identify them in the text, so you can check your spelling and syntax as you type by recognizing color patterns. For information on configuring color syntax options, see "Syntax Styling."
The CodeWarrior Editor provides several methods for navigating in a file that you are editing.
This section covers these methods:
Click the Routine icon to display the Routine pop-up menu, discussed in"The Routine pop-up menu," then select the routine you want to go to.
Use the Interface Pop-up Menu shown in Figure 5.2 to open interface or header files referenced by the current file.
To open a file in the list, scroll to the file you'd like to see and release the mouse button.
There is another method for opening an interface or header file that your source code file uses. To open the related file, you type a special key combination after selecting the file name in the active window. To learn more about this method for opening files, refer to "Opening an Existing File."
Choose Go To Line from the Search Menu to display the Go To Line dialog box in Figure 5.8. Then enter the number of the line you want to go to and select OK.