TutorialTextual Re-editing




Prev | Up | Next | Back | Forward | Tutorial Top

To modify text, just position the insertion cursor at the appropriate location and either type or delete characters. For example, let us turn the statement A:=1; into the statement A:=10; by inserting a 0.

Now we turn the statement A:=10; into A:=100; by inserting a 0, but this time in slow motion with explanations.

Note that the structural selection (the underlining) is 10, the expression on the right side of the assignment statement.

As a result of typing 0, the syntactic correctness of the expression is in doubt. (Although 100 is syntactically correct, the built-in parser has not yet been invoked, so its correctness is not known yet.) A region of text whose syntactic correctness is in doubt is called a text buffer. As soon as 0 was typed, the structural selection became a text buffer, as indicated by its distinctive display style.

The built-in parser is invoked whenever the structural selection is redirected away from a recently modified text buffer. In particular, as a side-effect of striking RETURN, the parser was invoked on the text 100, which successfully parsed as an expression. Accordingly, the text buffer containing the unanalyzed text 100 was replaced by syntactically assured text.

When the parser is invoked on a text buffer (e.g., 100), the text is required to be well-formed with respect to the syntactic category of the structural selection (e.g., expression). When the text buffer is syntactically analyzed, the text that surrounds it is ignored. The text buffer constitutes the focus of current attention and its surrounding context is fixed.

Consider the statement F := (X + Y) * Z; and suppose we wish to change the factor Z into Z+1.

Note the text buffer (i.e., the region of text under modification) is just the phrase Z+1. Accordingly, when RETURN is struck, Z+1 is re-parsed in its given context. As the right operand of *, the expression Z+1 must be parenthesized.

In the above example, when the insertion cursor was moved between Z and ; the structural selection (and the resulting text buffer) was set to Z, which was appropriate. If we had intended to change the entire expression into a sum of (X + Y) * Z and 1, then we should have widened the focus of attention before invoking the parser. Let us return to the original expression and so that we can illustrate how to change the entire expression into a sum of (X + Y) * Z and 1.

Command text-capture, (menu: Text/Text Capture   X: Alt+T   NT: Ctrl+T) turns the structural selection into a text buffer. Each successive execution of text-capture widens the text buffer to a larger phrase.


Forward