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 Edit Record

The edit record contains display, storage, styling, and other information related to editing that TextEdit requires. Although some fields are used differently for multistyled edit records and monostyled edit records, the structure of an edit record is the same whether the text is multistyled or monostyled.

TYPE  TERec = 
      RECORD         
         destRect:   Rect;    {destination rectangle}
         viewRect:   Rect;    {view rectangle}
         selRect:    Rect;    {the selection rectangle}
         lineHeight: Integer; {used for vertical spacing of lines}
         fontAscent: Integer; {used for caret/highlighting }
                              { position}
         selPoint:   Point;   {point selected with the mouse}
         selStart:   Integer; {start of selection range}
         selEnd:     Integer; {end of selection range}
         active:     Integer; {set when record is activated or }
                              { deactivated}
         wordBreak:  ProcPtr; {word break hook}
         clikLoop:   ProcPtr; {click loop hook}
         clickTime:  LongInt; {used internally}
         clickLoc:   Integer; {used internally}
         caretTime:  LongInt; {used internally}
         caretState: Integer; {used internally}
         just:       Integer; {alignment of text}
         teLength:   Integer; {length of text}
         hText:      Handle;  {handle to text to be edited}
         hDispatchRec: Handle;{handle to TextEdit dispatch record}
         clikStuff:  Integer; {used internally}
         crOnly:     Integer; {if <0, new line at Return only}
         txFont:     Integer; {text font.Otherwise, if txSize is }
                              { -1, combines with txFace to hold }
                              { a handle to the style record.}
         txFace:     Style;   {character style; unpacked byte. }
                              { Otherwise, if txSize is -1, } 
                              { combines with txFont to hold a }
                              { handle to the style record}
         txMode:     Integer; {pen mode}
         txSize:     Integer; {tells if multistyled }
                              { edit record; if not, font size}
         inPort:     GrafPtr; {a pointer to the graphics port }
                              { for this TERec}
         highHook:   ProcPtr; {used for text highlighting}
         caretHook:  ProcPtr; {used for caret appearance}
         nLines:     Integer; {number of lines}
         lineStarts: ARRAY[0..16000] OF Integer;
                              {positions of line starts}
   END;
TYPE  TEPtr    = ^TERec;
      TEHandle = ^TEPtr
Field Description
destRect
The destination rectangle, in local coordinates.
viewRect
The view rectangle, in local coordinates.
selRect
The selection rectangle, whose boundaries are defined in
local coordinates. This value is the current selection range or insertion point.
lineHeight
The vertical spacing of lines of text. Vertical spacing may be fixed or it may vary from line to line, depending upon specific text attributes. If the value of lineHeight is greater than 0, this field specifies the fixed vertical distance from the ascent line of one line of text down to the ascent line of the next.
If the value of lineHeight is less than 1, then this field specifies the vertical distance from the ascent line of one line of text down to the ascent line of the next calculated independently for each line, based on the maximum value for any individual character attribute on that line.
fontAscent
The font ascent line. If the value of fontAscent is greater than 0, this field specifies how far above the base line the pen is positioned to begin drawing the caret or highlighting.
For single-spaced text, this is the height of the text in pixels (the height of the tallest characters in the font from the base line). If the value of fontAscent is less than 1, this field specifies the font ascent calculated independently for each line, based on maximum value for any individual character attribute on that line.
selPoint
The point selected with the mouse, in the local coordinates of the current graphics port. The assembly-language offset for this field is named teSelPoint.
selStart
The byte offset of the beginning of a selection range. Note that byte offset 0 refers to the first byte in the text buffer.
selEnd
The byte offset of the end of a selection range. To include that byte, this value must be 1 greater than the position of the last byte offset of the text.
active
This field is used internally by TextEdit. It is set when an edit record is activated through TEActivate and then reset when the edit record is rendered inactive through TEDeactivate. To ensure future compatibility, use TEActivate or TEDeactivate to access this field.
wordBreak
The record's word selection break routine. This routine determines the word that is highlighted when the user double-clicks in the text and the position at which text is wrapped at the end of a line.
clikLoop
The pointer to the click loop routine.The specified click loop routine is called repeatedly by the TEClick procedure as long as the mouse button is held down within the text.
clickTime
This field is for internal use only.
clickLoc
This field is for internal use only.
caretTime
This field is for internal use only.
caretState
This field is for internal use only.
just
The type of text alignment: default (according to primary line direction), left, center, or right.
teLength
The number of bytes in the text to be edited. For two-byte systems, potentially twice the number of characters. Initially set to zero. The maximum length is 32767 bytes.
hText
A handle to the text. Initially, it points to a zero-length block of text in the heap.
hDispatchRec
The handle to the TextEdit dispatch record. This field is for internal use only; do not modify this field, or copy it to another edit record. Each edit record has its own dispatch record. Attempting to use the dispatch record of one edit record with another edit record can cause TextEdit to crash.
clikStuff
This field is for internal use only. TextEdit sets this field to reflect whether the most recent mouse-down event occurred on the leading or trailing edge of a glyph. TextEdit uses this value in determining a caret position.
crOnly
A value specifying whether or not text wraps at the right edge of the destination rectangle. If crOnly is positive, text does wrap.
If crOnly is negative, new lines are specified explicitly by Return characters only; text does not wrap at the edge of the destination rectangle. (This is useful in an application similar to a programming-language editor, where you may not want a single line of code to be split onto two lines.)
txFont
The font of all the text in the edit record if the txSize field of this edit record \xD1 0. If you change this value, the entire text of this
edit record has the new characteristic when it is redrawn; also, remember to change the lineHeight and fontAscent fields
as well.
If the txSize field is -1, this field combines with txFace to hold a handle to the associated style record.
txFace
The character attributes of all the text in an edit record if the txSize field of this edit record \xD1 0. If you change this value, the entire text of this edit record has the new characteristic when it is redrawn; also, remember to change the lineHeight and fontAscent fields as well.
If the txSize field is -1, this field combines with txFont to hold a handle to the associated style record.
txMode
The pen mode of all the text in the edit record. If you change this value, the entire text of this edit record has the new characteristic when it is redrawn; also, remember to change the lineHeight and fontAscent fields as well.
txSize
Depending on its value, txSize either contains the point size of all of the text or it acts as a flag indicating whether or not there is associated character attribute information. If txSize \xD1 0, this is a monostyled edit record, that is, all text is set in a single font, size, and face, and the value of txSize is the size of the text. If txSize is -1, the edit record contains associated character attribute information and the txFont and txFace fields combine to form a handle to the style record.
inPort
A pointer to the graphics port associated with this edit record.
highHook
A pointer to the routine that deals with text highlighting. In assembly language, the highHook field is located at the offset teHiHook. For more information, see the following section, "The High Hook and Caret Hook Fields."
caretHook
A pointer to the routine that controls the appearance of the caret. In assembly language, the caretHook field is located at the offset teCarHook. For more information, see the following section, "The High Hook and Caret Hook Fields."
nLines
The number of lines in the text.
lineStarts
An array containing the character position of the first character in each line. It is declared to have 16001 elements to comply with Pascal range checking. This is a dynamic data structure having only as many elements as needed. TextEdit calculates these values internally, so do not change the elements of the lineStarts array. Because this data structure grows and shrinks, the size of the edit record changes.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996