Using Sun WorkShop

Pattern Search Mode

With pattern searching, you can search for regular expressions and simple text strings using the Browsing window.

Pattern searching searches all of the directories listed in the sb_init file (see "Importing Databases").

Browsing Window in Pattern Search Mode

Figure 3-2 shows the Browsing window in Pattern Search mode (see Figure 3-1 to identify the other components of the window).

Figure 3-2 Browsing Window in Pattern Search Mode

Graphic

Pattern text box 

Allows you to enter a regular expression to be matched 

Files text box 

Allows you to specify a file filter for the search 

Searching for a Pattern

To search for a pattern:

  1. In the Sun WorkShop main window, choose Browse > Pattern Search or click the Browsing button; then click the Pattern Search radio button in the Browsing window.

  2. Look in the Browsing window title bar to be sure you are in the correct browsing directory.

    If not, choose Browse > Change Browsing Directory and select the correct directory in the Pattern Search Directory dialog box.

  3. Type the pattern for which you want to search in the Pattern text box.

    If you cannot remember the exact symbol for which you want to search, you can use wildcard characters (., *. ^, and $) in your pattern (see "Special Characters in Patterns").

  4. Type a filter in the Files text box.

    The default filter searches the current directory for all files ending in .h, .c, .cc, or .f. Sun WorkShop saves the filter in your WorkSet whenever you save the WorkSet.

    Pattern searching uses the sb_init file to search multiple directories. It applies the Files filter to each directory.

  5. Press Return, choose Query > Find Matches, or click the Find Matches button.

  6. Move through the Match pane using the mouse, the Next Match and Previous Match buttons or menu items, or by pressing F5 and Shift+F5.

  7. Click a match to view the source in the editor window.


    Note -

    If you are overwhelmed by the number of matches found, restrict the types of files searched by changing the file types in the Files text box, and repeat the search.


You can search text displayed in the editor window. Double-click the text in the editor window to copy it, and paste it in the Browsing window's text box. If you are using vi or XEmacs as your text editor, you can also select text in the editor window and click the Find Refs button in the tool bar.

Special Characters in Patterns

Although you can enter a pattern exactly as it appears in the code, you can also use special characters to specify a set of patterns. You can use the special characters in Table 3-1 in patterns.

Table 3-1 Special Characters in Patterns

Character 

 Meaning Example

Period (.) 

Matches any character 

l.nes matches all occurrences of lanes or lines.

Asterisk (*) 

Matches any number of characters, including zero or more consecutive occurrences of the character that precedes it, except when it is the first character in the pattern

file.*() matches any string that fcontains file followed by zero or more characters and (), such as traffic_file_close() and file_save_popup. *file. matches only strings that begin with file.

Circumflex (^) 

Constrains the search to match the beginning of a line 

^tr* finds all lines that begin with traffic, truck, or any other string beginning with tr.

Dollar sign ($) 

Constrains the search to match the end of a line 

lanes$ finds all the lines that end with the string lanes.

For example, suppose you want to search for window_popup in the code, but only those instances that begin a line. You would type the following query:

^window_popup*

The circumflex (^) tells the browser to look only at those matches that start a line of code, while the asterisk (*) asks for all matches with window_popup, including window_popup_name_objects and window_popup1_objects.


Note -

Surrounding an expression with a circumflex and a dollar sign constrains the search to match the entire line.