Textual Re-editingTo 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.
Move the insertion cursor between the 1 and the ; and
type 0. Then strike RETURN.
Now we turn the statement A:=10; into A:=100; by inserting a 0, but this time in slow motion with explanations.
Move the insertion cursor between the 0 and the ; in the
statement A:=10; but do not make any changes yet.
Note that the structural selection (the underlining) is 10, the expression on the right side of the assignment statement.
Type 0 but do not strike RETURN yet.
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.
Strike RETURN.
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.
Move the insertion cursor between Z and the ; in the
statement F := (X + Y) * Z; and type +1. Do not strike
RETURN yet.
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.
Strike RETURN and note that the parentheses are inserted
automatically.
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.
Click the mouse between the ) and the ; to move the
insertion cursor to the right end of the expression. Repeatedly strike
Backspace until the expression (X + Y) * (Z + 1) has been
erased. Be sure to stop before erasing the :=. Note how the text
buffer widens as characters are rubbed out to its left.
Now reenter the original expression (x+y)*z and strike
RETURN.
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.
Now position the insertion cursor between z and ; again.
Strike Alt+T twice and note that the text buffer is the entire
expression (X + Y) * Z. Now type +1 and strike
RETURN.