wordBreak
#include <TextEdit.h>
typedef struct TERec { Size Offset Description Rect destRect; 8 0 Rectangle in which text is drawn Rect viewRect; 8 8 Rectangle in which text is visible Rect selRect; 8 16 Selection rectangle ( undocumented) short lineHeight; 2 24 Distance between lines (see " style
notes)
short fontAscent; 2 26 Max distance above baseline for
txFont
Point selPoint; 4 28 Point selected with mouse, in local coordinates
short selStart; 2 32 Offset in hText of char at start of
selection
short selEnd; 2 34 Offset in hText of character at end of
selection
short active; 2 36 (used internally)
ProcPtr wordBreak; 4 38 Routine handles word breaks (0= standard)
ProcPtr clikLoop; 4 42 Rtn gets control while mouse down (0=std)
long clickTime; 4 46 (used internally)
short clickLoc; 2 50 (used internally)
long caretTime; 4 52 (used internally)
short caretState; 2 56 (used internally)
short just; 2 58 0=justify left, 1=center,
-1=justify right
short teLength; 2 60 Number of characters in hText
Handle hText; 4 62 Leads to characters to be edited short recalBack; 2 66 (used internally)
short recalLines; 2 68 (used internally)
short clikStuff; 2 70 (used internally)
short crOnly; 2 72 >0 for word wrap, <0 for newline
only at CR
short txFont; 2 74 Font to be used (See Notes on
style-awareness)
Style txFace; 1 76 Text Style to be used; eg, bold, italic, ... (")
char filler; 1 77 ( unused)
short txMode; 2 78 Transfer Mode; eg, srcCopy, srcOr,
...
short txSize; 2 80 Size, in points, to use (<0 means
style-aware)
displayed/edited
ProcPtr highHook; 4 86 Routine to perform highlighting (0= standard)
ProcPtr caretHook; 4 90 Routine to display caret (0= standard)
short nLines; 2 94 Number of lines of text in hText
short lineStarts[16001]; n 96 Array of offsets to start of each line
} TERec ; 96+n (n is nLines * 2) typedef TERec *TEPtr;
typedef TERec **TEHandle;
typedef char Chars[32001]; array of 0 to 32000 signed bytes
typedef Chars *CharsPtr;
typedef Chars **CharsHandle;
Notes: A TEHandle (leading to a TERec) is used in nearly every TextEdit call. This data structure is often called an "edit record". Use TENew or memory associated with one.
GetDItem and iType returns as editText, then the iHandle value is the hText field of that TERec . Un characteristic of the Mac ROMs, TextEdit provides few functions
dedicated to modifying fields of this record. Thus, you may need to twiddle
this structure more than say, a WindowRecord. Note that if you change any field values, such as txSize or txFont, be sure to call InvalRect so the change is displayed; eg:
and, of course, call TEUpdate when you get an update message for the window.
Style-Aware Edit Records
Starting with Sytem 4.1, and included in the 256K ROMs, TextEdit supports a flexible system for applying " styles" (i.e., formatting
characteristics such as font, size, face, and color) to the text of an edit
Style-aware edit records are created via TEStylNew and are backward compatible with the older-style edit records. The only differences are:
The txSize field is used to indicate a "new- style" edit record. If it is
a negative value, then this is style-aware edit record. If positive or
0, this is the old, familiar record.
The txFont and txFace fields are combined into a 4-byte field which
is used as a TEStyleHandle leading to all kinds of style-relevant
information.
The lineHeight and fontAscent fields identify whether the text is
displayed at a fixed height or is calculated on a line-by-line basis,
based upon the tallest style in a line. A value of -1 in either field
specifies the variable-height line scheme. See LHTable.
fontAscent to -1, and allocates and intializes the TEStyleRec and related structures and places a TEStyleHandle into the four bytes starting at txFont.