Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Text /
Chapter 2 - TextEdit / TextEdit Reference
Data Structures


The Style Record

The style record stores the character attribute information for the text of a multistyled edit record. If an edit record has associated character attribute information, its txFont and txFace fields combine to hold a style handle, of type TEStyleHandle, to its style record. The text is divided into style runs, summarized in the style run table, of type StyleRun, which is part of the style record. Each entry in the style run table gives the starting character position of a run and an index into the style table, of type TEStyleTable.

The style table element pointed to by the style run index describes the character attributes for that run.

To determine the length of a run, you subtract its start position from that of the next entry in the style run table. A dummy entry at the end of the style run table delimits the length of the last run; its start position is equal to the overall number of characters in the text, plus 1. The TEStyleRec data type defines the style record.

TYPE  TEStyleRec =
      RECORD
         nRuns:      Integer;       {number of style runs}
         nStyles:    Integer;       {size of style table}
         styleTab:   STHandle;      {handle to style table}
         lhTab:      LHHandle;      {handle to line-height table}
         teRefCon:   LongInt;       {reserved for application use}
         nullStyle:  NullStHandle;  {handle to style set at }
                                    { null selection}
         runs:       ARRAY [0..8000] OF StyleRun;
      END;

TEStylePtr = ^TEStyleRec;
TEStyleHandle = ^TEStylePtr; 

StyleRun = RECORD
   startChar:  Integer;       {starting character position}
   styleIndex: Integer;       {index in style table}
END;
Field Description
nRuns
The number of style runs in the text.
nStyles
The number of distinct sets of character attributes used in the text; this forms the size of the style table.
styleTab
A handle to the style table.
lhTab
A handle to the line height table.
teRefCon
A reference constant for use by applications. The application can use this 32-bit field to suit its needs.
nullStyle
A handle to the style scrap record used to store the character attribute information for a null selection.
runs
A table of style runs that is of indefinite length.
TEStylePtr = ^TEStyleRec;
TEStyleHandle = ^TEStylePtr; 

StyleRun = RECORD
   startChar:  Integer;       {starting character position}
   styleIndex: Integer;       {index in style table}
END;

Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996