8.7 Positioning the Text Displayed in a Text Subwindow
Usually, more text is managed by the text subwindow than can be displayed all at once. As a
result, it is often necessary to determine the indices of the characters that are being displayed
and to control exactly which portion of the text is visible.
8.7.1 Screen Lines and File Lines
When there are long lines in the text, it is necessary to distinguish between two deﬁnitions of
“line of text.”
A screen line reﬂects what is actually displayed on the screen. A line begins with the left-
most character in the subwindow and continues across until either a newline character or the
right edge of the subwindow is encountered. A ﬁle line, on the other hand, can only be ter-
minated by the newline character. It is deﬁned as the span of characters starting after a new-
line character (or the beginning of the ﬁle) running through the next newline character (or the
end of the ﬁle).
Whenever the right edge of the subwindow is encountered before the newline, if the follow-
ing attribute-value pair were speciﬁed:
then the next character and its successors would be displayed on the next lower screen line.
In this case, there would be two screen lines, but only one ﬁle line. From the perspective of
the display there are two lines; from the perspective of the ﬁle, only one. On the other hand,
if the following attribute-value pair were speciﬁed:
then the entire word would be displayed on the next line.
Unless otherwise speciﬁed, all text subwindow attributes and procedures use the ﬁle line deﬁ-
nition. Line indices have a zero-origin, like the character indices; that is, the ﬁrst line has
index 0, not 1.
8.7.2 Absolute Positioning
Two attributes are provided to allow you to specify which portion of the text is displayed in
the text subwindow.
Setting the attribute
TEXTSW_FIRST to a given index causes the ﬁrst character of the line
containing the index to become the ﬁrst character displayed in the text subwindow. Thus, the
following call causes the text to be positioned so that the ﬁrst displayed character is the ﬁrst
character of the line that contains index 1000:
xv_set(textsw, TEXTSW_FIRST, 1000, NULL);
Since the text subwindow is subclassed from the OPENWIN package and can be split into sev-
eral views, the previous code fragment would only cause the positioning of one view. To
226 XView Programming Manual