Matching direction, Regular expression syntax mode, Gui based objects – Crunch CRiSP File Editor 6 User Manual

Page 51

Advertising
background image

Page 51

backward matching.

The search macros - search_fwd, search_back, translate, search_string and search_list have a parameter,
labelled 're' which is used to control the minimal/maximal matching. The minimal/maximal terminology refers
to the way that the closure operators (i.e. zero or more or one or more sequences of regular expressions)
are matched. This parameter can have one of seven valid values: -3, -2, -1, 0, 1, 2, 3.

The seven case are as follows:

-3 maximal closure, backward
-2 maximal closure, same as search direction
-1 maximal closure, forward
0 forward (literal match)
1 minimal closure, forward
2 minimal closure, same as in search direction
3 minimal closure, backward

0 is used for non-regular expressions. The maximal matching modes are compatible with Unix.

Matching Direction

The difference between forward and backward matching are that the two mainly comes into effect when
performing a backward match. Consider the following line:

the cat sat on the mat
_^

with the cursor placed on the 'h' of the first word, 'the'. In forward matching, if we are searching for the word
'the', then the string 'he cat sat on the mat' will be searched, and the match will be on the word 'the' before
'mat'. In backwards matching mode, the search can start before the cursor, and will match the word 'the' at
the start of the line.

Regular Expression Syntax Mode

CRiSP allows the user to select between pure CRiSP regular expression syntax, as described above, or the
more familiar Unix syntax. This is done by calling the re_syntax() primitive or by setting the SF_UNIX flag to
the re_search()/re_translate() primitives. In CRiSP mode, regular expressions are exactly as described in
the previous sections of this chapter.

In Unix mode, the following features are enabled/disabled:

The '.' character replaces the '?' wild-card character.

The '*' character means zero or more iterations of the previous expression. This disables the CRiSP '@' zero
or more character.

The sequence \(..\) replaces the use of {..}. The { and } characters become normal characters.

GUI Based Objects

This section describes the mechanisms and primitives CRiSP provides for accessing such things as
scrollbars, dialog boxes, etc. Because different versions of CRiSP may or may not support all of these
functions, each primitive can be tested to ensure that the primitive is fully implemented, allowing macros to
run in both a pure character-mode based environment or the GUI environment, or both, as appropriate. The
macros supplied with CRiSP can operate in both ways, and many of these macros determine their look and
feel depending on how they are invoked. E.g. popup dialog boxes are normally implemented in the
underlying toolkit (e.g. XView or Motif) when accessed from the menu bar using the mouse, but as character
based items when invoked from a keystroke. This means the user can choose between the normally faster
keyboard based mechanisms or the more user friendly mechanisms when invoked via the mouse.

The primitives provided for creating graphical objects are designed to complement the macro facilities
available. The primitives provide as much functionality as is required, plus a little more. There is a fine
dividing line between the functionality available in CRiSP and the functionality available in say, for example,
a graphical user-interface tool such as X-Designer or DEVGuide. The idea of CRiSP is to provide high-level

Advertising