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
Routines / Customizing TextEdit


TESetWordBreak

The TESetWordBreak procedure installs the address of a customized word-selection break routine in the wordBreak field of the specified edit record.

PROCEDURE TESetWordBreak (wBrkProc: ProcPtr; hTE: TEHandle);
wBrkProc
A pointer to the customized word-selection break routine.
hTE
A handle to the edit record containing the wordBreak field to
be modified.
DESCRIPTION
A word break routine determines which word is highlighted when the user double-clicks in the text. It also determines where TextEdit breaks the text at the end of a line. You can use TESetWordBreak to replace the default routine in the wordBreak field that is used for word selection and line breaking under certain circumstances. Whether or not TextEdit uses the word-selection break routine referenced by this field is determined by the algorithm implemented in the default TEFindWord routine. For a description of this algorithm, see "Customizing Word Selection" on page 2-56; this section also describes what to consider if you replace the TEFindWord hook routine.

When you replace the wordBreak field hook routine, your customized word break routine is used instead of the default one. The default routine breaks words at any character with an ASCII value of $20 or less (the space character or nonprinting control characters). Your routine can use a different value.

Before non-Roman script systems were supported, TextEdit used the word break hook routine installed in the wordBreak field for all word selection and line breaking. However, in order to support both Roman and non-Roman script systems, TextEdit now uses the routine installed in the low-memory global variable TEFindWord. The default TEFindWord hook routine determines which hook TextEdit should use for word selection and line breaking--the wordBreak hook or the Text Utilities FindWordBreaks procedure--based on what script systems are installed and some other factors. You can replace the TEFindWord hook routine with a customized version.

ASSEMBLY-LANGUAGE INFORMATION
You must directly set the wordBreak field to point to your own word break routine; do not use the TESetWordBreak procedure.The registers for the word break routine must contain the following values.
Registers on entry
A0Pointer to text
D0Character position (word)
Register on exit
Z bit (zero flag)Condition code:
status register0 to break at specified character

1 not to break there

If you replace TEFindWord, be careful to set the correct values in the appropriate registers. For TEFindWord, the registers are set on entry as specified below, and TextEdit depends on the registers being set at exit as specified below.
Registers on entry
D0Current position (the value of selStart field in edit record) (word)
D2Identifier of routine that called FindWordBreaks (word)
 IdentifierValueExplanation
 teWordSelect4called for word selection
 teWordDrag8called for extending word selection
 teFromFind12called for determining new line breaks
 teFromRecal16called for word breaking in line recalculation
A3Pointer to the edit record
A4Locked handle to the edit record
Registers on exit
D0Word start (word)
D1Word end (word)

SEE ALSO
For more information about the FindWordBreaks procedure, see the chapter "Text Utilities" in this book.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996