If you have to deal with a significant number of diagrams, powerful editing capabilities get essential. You may want to search for diagrams and elements containing certain substrings and to perform consistent changes (e.g. variable renaming) even throughout several diagrams.
The Find & Replace dialog offers a variety of helpful selection and modification opportunities in various combinations:
Activation
There are several ways to open the File & Replace dialog:
- by pressing the speed button in the toolbar;
- by entering the accelerator key combination <Ctrl><F>;
- via the Edit menu:
Find and Replace Patterns
At the window top you enter your textual search pattern, either interpreted as plain substring or as regular expression (depending on whether or not checkbox "Regular expressions" is selected).
Beneath the search pattern you may enter a replacing string or pattern if you intend to substitute one or more of the found substrings. If the Regular expressions checkbox is selected then the replacement may contain placeholders like $1, $2 etc. which refer to the content of the first, second and so on group of the regular expression match. (A group in a regular expression is a sub-pattern in parentheses, like ([0-9][0-9]) in the screenshot above, which would mean $1 to be 00, 02, 04, respectively, for the first, the second, and the third match).
The Find & Replace dialog keeps a history of depth 10 for each of the two pattern fields, which is available via the respective pulldown button.
Mode settings (left-hand side)
Here you may specify the search direction and how the patterns are to be interpreted.
Direction "down" means to traverse the search results from top to bottom and the matches within a single text in forward direction. Direction "up" is the opposite (bottom to top, from right to left).
The checkbox "Regular expressions" specifies — if selected — that the patterns be interpreted as regular expressions with exactly the syntax accepted by Java class java.util.regex.Pattern. Since a complete description would exceed the scope of this user guide, just some examples:
Pattern | Matches | Examples |
b.y |
All three-character substrings starting with b and ending with y |
bay, boy, buy |
b.?y |
Substrings with at most one character between b and y |
by, buy, b2y |
b[a-z]*y |
Substrings with any number of lower-case letters between b and y |
by, bay, buoy, baby, belly, balcony |
b[a-z]*?y |
Substrings with minimum number of lower-case letters between b and y |
the ones before except baby (where by is the smaller match) |
The checkboxes "Case-sensitive" and "Whole word" are only selectible if "Regular expressions" is unchecked. Regular expressions may specify themselves whether case matters or how a substring be surrounded in order to match, though with some effort — in order to match the word "result" case-independently and as isolated word, you might write the following regular expression:
(^|\W)[Rr][Ee][Ss][Uu][Ll][Tt](\W|$)
In plain-string mode, case does not matter by default, and the pattern may be any substring, such that a search string BY would be found within Babylon. By selecting any of the checkboxes "Case-sensitive" and "Whole word", however, the above word would no longer be a match.
Scope settings (left-hand side)
You may choose the search scope among
- Opened diagrams = all diagrams currently held in Structorizer and Arranger,
- Current diagram = just the current diagram in Structorizer (Arranger not searched), and
- Current selection = just the currently selected sequence of elements in the current diagram, including substructure.
If you opt for all opened diagrams then you may restrict the search to certain diagram types (i.e. any subset of them).
Further on, you may specify whether the element texts and/or the element comments are to be involved in the search. (To exclude both doesn't make sense, of course.)
Element types (right-hand side)
You may limit the search to any subset of element types, e.g. to exclude Call elements from search. The All and None button are to facilitate selecting or unchecking all element types at once.
Independently of the element type choice, you may or may not include disabled elements.
Result view (central)
When you have specified all search criteria according to the opportunities explained above, pressing the "Find" button will start the search.
The central view will show the tree (or "forest") of all found elements in the diagrams according to the scope setting. The diagrams containing elements with matches form the forest roots, the found elements are the subnodes (leaves) of their respective parent diagram. All elements with matches in texts or comments appear at the same level, no matter how deep they were structurally nested. If you don't see elements below a diagram root then just click on the respective root in order to expand the subtree. If the diagram header element itself holds a match then it will also be shown at the element level. In forward mode, the first matching element (in the first presented root) will already be selected and its text and comment appear in the contents text areas at the dialog bottom. If there are several matches within the enabled text areas then all but one are highlighted in yellow, the very current match within the text has orange background (see figure above).
The further navigation depends on whether checkbox "Element-wise" (in the lower left corner next to the buttons) is selected or not: If not then the next click on "Find" will move the orange spot to the next match within the text of the same element, if checked, however, the presentation skips to the next element from the result list ("fast" mode).
You may change navigation direction by switching the radio buttons "Down" and "Up", thus going back to previous matches.
While you traverse through the elements, Structorizer will simultaneously scroll through the current diagram and highlight the current element if the element belongs to the diagram in the work area. While you traverse elements of other diagrams in the result tree, Arranger will scroll to the respective diagram in its arrangement.
Buttons
The Find button starts search (if result view was empty or exhausted) or moves the spot to the next/previous match within the text of the current element ("Element-wise" off) or to the next node of the search result ("Element-wise" on).
Button Replace/Find will replace the currently focussed match and then move to the next match the way the Find button would do. Be aware that doing the replace action with empty replace pattern field will delete the matching substring.
Button Replace just replaces the spotted match without moving the spot afterwards.
Button Replace All will blindly replace all remaining matches from the currently selected match on towards the end of the search result set in the specified navigation direction (down/up). So it doesn't always really mean "all".
Every single replacement is undoable (and redoable) in reverse order, but only from the respective diagram, which must be summoned to the Structorizer window. The undo / redo action or any other editing in the diagram will wipe the result tree in the Find & Replace window. So does any diagram addition or removal in the Arranger if scope "Opened diagrams" is selected.
The Close button will simply hide the Find & Replace dialog, all settings will be maintained and will still be present on reopening the dialog. Most criteria and the pattern histories will even be saved in the structorizer.ini file on ending the session such that they will be restored in the next Structorizer session.
Mnemonics
The four main buttons and several other mode-relevant controls are associated with mnemonic keys, such that pressing <Alt>+mnemonic has the same effect as clicking the respective control. Version 3.29-11, however, modified some of the mnemonics (particularly that of the "Down" radio button) and equipped more controls with mnemonics. The underscores (becoming visible on holding the <Alt> key down, with some Look & Feels they are constantly shown) in the screenshot below demonstrate which mnemonics are configured for the English locale (may differ slightly in other locales, cf. screenshot with German locale above) since version 3.29-11:
Known problems
In rare cases, particularly with regular expression mode and large multi-line texts or comments in some elements, the regular expression mechanism may apparently run into a Java-internal endless recursion crash, which results in an awkward dialog state, often noticeable via rendering defects on icons and text font in the result area (as if the dialog elements were disabled), e.g.:
Usually, the dialog will still react and return to full function with the next (different) search. |