The code fragment below can be used to find delimited text. Notice that the field_flag
value is TEXTSW_DELIMITER_FORWARD.
Textsw_index first, last_plus_one, pos;
first = (Textsw_index) xv_get(textsw, TEXTSW_INSERTION_POINT);
pos = textsw_match_bytes(textsw, &first, &last_plus_one,
"/*", 2,
"*/", 2, TEXTSW_DELIMITER_FORWARD);
if (pos > 0) {
textsw_set_selection(textsw, first, last_plus_one, 1);
xv_set(textsw, TEXTSW_INSERTION_POINT, last_plus_one, NULL);
} else
(void) window_bell(textsw);
This code searches forward from first until it finds the starting /* and matches it forward
with the next */. If no match is found, a bell will ring in the text subwindow.
8.9 Marking Positions
Often a client wants to keep track of a particular character or group of characters that are in
the text subwindow. Given that arbitrary editing can occur in a text subwindow and that it is
very tedious to intercept and track all of the editing operations applied to a text subwindow, it
is often easier to simply place one or more marks at various positions in the text subwindow.
These marks are automatically updated by the text subwindow to account for user and client
edits. There is no limit to the number of marks you can add.
A new mark is created by calling:
Textsw_mark
textsw_add_mark(textsw, position, flags)
Textsw textsw;
Textsw_index position;
unsigned flags;
The flags argument is either TEXTSW_MARK_DEFAULTS or TEXTSW_MARK_
MOVE_AT_INSERT
. The latter causes an insertion at the marked position to move the mark to
the end of