TextEdit Data Structures
TextEdit Data Structures
This section supplies a brief overview of the contents of the various
TextEdit data structures and their relationships. The figure below shows
how the TextEdit data structures create an environment for the editing of
unstyled or styled text through the use of an edit record and a style record. It
also portrays a number of supporting data structures, including a
style run table, a line-height table, a null style record, a
style scrap record, and a TextEdit dispatch record.
Note: Use the information in this diagram and in the explanations that
follow only for debugging so you understand the organization of the
TextEdit data structures. For reading or writing of these data structures,
use the TextEdit routines. This practice will ensure future compatibility.
Here is a list of the functions and relationships of the TextEdit data
structures:
The edit record, defined by the TERec data type, stores the display and
editing information for TextEdit.
The style record, defined by the TEStyleRec data type, stores the style
information for the text of the edit record. If an edit record has
associated style information, its txFont and txFace fields combine to
hold a style handle, TEStyleHandle, to its style record.
The style run table, defined by the StyleRun data type, is an array that
contains the boundaries of each style run and an index to its style
information in the style element array.
The style element array, defined by the TEStyleTable data type,
contains one entry for each distinct style used in the text of the
edit record. Each style entry is defined by the STElement data type.
The styleTab field of the style record contains a handle, STHandle, to
this style element array. The styleIndex field in the style run array is
an index into this data structure.
The line-height table, defined by the LHTable data type, provides an
array of line heights to hold the vertical spacing information for a
given edit record. It also contains line ascent information. TextEdit
uses this table only if the lineHeight field in the edit record is negative.
The lhTab field of the style record contains a handle to this line-height
table. A line number is a direct index into this array.
The null style record, defined by the NullStRec data type, contains the
style information for a null selection. The nullStyle field of the
style record contains a handle to this null style record.
The style scrap record, defined by the StScrpRec data type, is a place
to store style information in the desk scrap. The scrap style table
array within this record, defined by the ScrpStyleTab data type,
contains a separate data structure for style records in the scrap. The
nullScrap field of the null style record contains a handle,
STScrpHandle, to the scrap style table.
The scrap style table, defined by the ScrpStyleTab data type, is
contained in the style scrap record. The elements of this table are
style records defined by the scrap style element record.
The scrap style element record, defined by the ScrpSTElement data
type, contains the style information for an element in the
scrap style table and is similar to the style element array. One
scrap style element record exists for each sequential style change in
the scrap style table.
The TextEdit dispatch record, defined by the TEDispatchRec data type,
contains the internal addresses of the TextEdit routines for EOLHook,
DRAWHook, WIDTHHook, HITTESTHook, nWIDTHHook, and
TextWidthHook unless you replace them with the addresses of your
own customized versions of these routines. TextEdit combines the
recalBack and recalLines fields of the edit record to store a handle to
the TextEdit dispatch record.
The text style record, defined by the TextStyle data type, furnishes a
record of text styles for communicating information between your
application and the TextEdit routines.
Warning: The space beyond the hooks in the TextEdit dispatch record is
reserved for internal use. If you attempt to use this private area, you will
corrupt TextEdit data.