• No results found

3.5 Editor windows

3.5.2 Editing features

The Editor offers a complete range of text-viewing, text-editing and print features for editing text and source code, including:

Syntax highlightingAuto-completionParameter informationIndentationBrace matching

Text selection and clipboard operationsFind features

Note: To edit source files during a debugging session, ensure that the Read-only source files feature has been disabled. To do this, select Tools>Options and click on the Edit/Debug tab, then uncheck the Read-only source files option. Then click on Apply and OK. Note that while this allows you to modify the application source files, you must recompile the executable file so that your changes are taken into account when running the application.

Syntax highlighting

STVD offers configurable syntax highlighting to improve the readability of your C and Assembly source files. This feature allows you to define the source code display conditions (text color, background color, character style) for a syntactic group. In addition to highlighting for commands, variables and comments, the Editor recognizes language-specific keywords for C and Assembler source files.

Note: Language-specific highlighting is established at the file level, therefore no language-specific highlighting is applied to Assembler code in C language files (*.c, *.h or *.ssp).

A basic highlighting configuration is set by default, which you can modify to meet your specific needs or preferences by using the Styles/Languages tab of the Options window (Tools>Options). For more information about modifying the syntax highlighting

configuration, refer to Section 3.7.1: Customizing editor features on page 61.

Auto-completion

While typing your code, use the auto-completion feature to see a list of language-specific keywords that match what you have started typing. For example, when typing a command in a C source file, type the first letters followed by CTRL+Space, or select Edit>Complete

Word. A pop-up window opens with the alphabetical listing of C language keywords, at the

section of the list that matches what you have started typing. Highlight the keyword you want and press enter (see Figure 25).

Figure 25. Auto completion pop-up list

If you have just created a new C or Assembler source file, the auto-completion feature is not available until you have saved the file with the file extension that is appropriate to the language (for C: *.c, *.h, or for Assembly: *.asm, *.s, *.S or *.inc).

Parameter information

While typing your code in Assembly, the parameter information tips prompt you with the syntax for the instruction that you are typing. Syntax information is provided for the ST ASM instruction set.

For example, when typing an instruction in an Assembler source file, type the instruction then press CTRL+Shift+Space, or select Edit>Parameter Info. A tip window appears with the syntax of the instruction that you have named (see Figure 26).

If you have just created a new Assembler source file, the parameter information feature is not available until you have saved the file with the appropriate file extension: *.asm, *.s, *.S or *.inc.

Figure 26. Parameter information tip

Indentation

During text entry, auto-indent returns the cursor to the column in which the previous line of text starts, so that the indent of the base line is preserved in subsequent lines. In addition, whenever you type the opening brace { for a function, the subsequent line is automatically indented. When you type the closing brace } for your function, the line with the closing brace and subsequent lines are un-indented by one level.

Figure 27. Auto indentation

When enabled, the editor also provides indentation guides to help you see code lines that have the same indent level. For more information about configuring these options, refer to

Section 3.7: Customizing your work environment on page 60.

You can also manually indent lines by selecting a line or placing the cursor at the beginning of the line and pressing the Tab key. Block indent allows any block of text highlighted with the text cursor to be indented with the Tab key in the same way that you would indent a single line. Pressing SHIFT+Tab un-indents the selected text block or line, moving it to the left.

Brace matching

When viewing and navigating in source code, brace matching highlights matching opening and closing braces – {}, (), [], <>. If you highlight a brace with the cursor, then the matching brace is highlighted in the same color. If you press CTRL+E, or select Edit>Match Brace, then the cursor moves to the corresponding brace.

Figure 28. Brace matching

Text selection and clipboard operations

The editor offers the same clipboard features (Cut, Copy and Paste) used by standard Windows-based text editors using the same keystroke combinations. You can select text with the mouse, using the left mouse button alone or using <Alt + left mouse button> to define any rectangle in the text area and select the text it contains.

Drag and drop

Any selected block of text (highlighted using the text cursor) can also be dragged while holding down the left mouse button and moved to another window in STVD, another application, or to a new location inside the Editor window. When dragged, a cross-hatch square symbol accompanies the mouse cursor to indicate the transfer of text.

The same action (drag with left mouse button) with the Control key depressed, copies the highlighted text to the new location. In this case, a square symbol containing a plus sign accompanies the mouse cursor.

Find features

The Editor window provides standard find and replace commands to help you locate and update specific strings. The Find, Find next, Replace and Find in files functions are available from the Edit menu. The Find command is also available in the contextual menu.

In addition to searches for strings or variables, the Editor allows you to search for patterns of characters by using Regular expressions.

Find

You can select the string for a search by placing the cursoranywhere in the string, highlighting it or typing it directly in the search window.

If you place the cursor to select the string, the string for the search is delimited by white space or any other non-alphabetic and non-numeric characters. On the other hand, when you select by highlighting a string, the full string of characters regardless of the type of characters appears in the Find window.

Figure 29. Find dialog box

In addition to common find options (Match whole word, Match case), the Find dialog box allows you to search for patterns of characters using Regular expressions.

Find pull-down list

The Edit toolbar in the active window contains a text entry box for quick string searches (see

Figure 30). Type the string you want to search for in the field, or select a string that you have already searched for from the pull-down list.

Figure 30. Quick find for strings or variables in a source file

Replace

In the active Editor window, a string at the cursor position (delimited by white space and/or other usual separators) or any highlighted string, can be sought in the whole of the text. Pull down the Edit menu from the main menu bar, and select the Replace command to open the Replace window.

Figure 31. Find/replace window

In addition to common find options (Match whole word, Match case), the Replace dialog box allows you to search for patterns of characters using Regular expressions.

Find in files

The Find in Files command allows you to search for any string in any number of file types within a given source directory. In addition to common find features and directory search options, the Find in Files dialog box allows you to search for patterns of characters using

Regular expressions.

For example, Figure 32 shows the search for the variable “alpha” in files with a variety of extensions.

Figure 32. Find in Files dialog box

If you put a checkmark beside the Look in additional folders option, a dialog box like the one shown in Figure 33 is displayed. You can add additional folders to search.

The results of your search are displayed in the Output window, by default in the Find in Files 1 tab, or in the Find in Files 2 tab if you select the option Output to pane 2.

Figure 34. Find in Files tabs

Go to

This command opens the Go To window, permitting a line in a source file to be defined as the target for the Go To action.

Figure 35. Go To window

Regular expressions

Regular expressions make it possible to search ASCII text for patterns of characters instead of literal strings of characters. For example, they allow you to search for all expressions consisting of a character followed by any character in a defined set, or to search only for occurrences of a string of characters at the end of a line.

Checking the Regular Expressions checkbox in the Find, Replace or Find in files windows enables the use of meta characters for regular expressions such as those listed in Table 16.

Table 16. Regular expressions

Meta

character Use Example

[ ] Find any characters in the defined set. X[A-B] finds any occurrences of XA or XB

[^ ] Find characters except those in the defined set

X[^C-Z] finds any occurrences of XA or XB and excludes combinations with any other letters (XC, XD, ... XZ)

. Any character

X..[A-B] finds any occurrences of X followed by any two characters and then an A or B (X--A, or X--B where - is equal to any ASCII character)

+ Matches one or more occurrences of the specified characters

X[A-B]+ finds any occurrences of X followed by one or more occurrences of the defined set (XA, XB, XAA, XAB, XBB, XAAA, XAAB, ...)

These are just a few of the regular expressions that you might use to search your files. For more information, you can refer to any reference about Unix regular expressions.

Note: When regular expressions are enabled in the Replace dialog box, they are used in the Find what field. A regular expression in the Replace with field is treated as a string of ASCII characters, not as a regular expression.