wordBreak hook
The wordBreak hook (the wordBreak field in the edit record) exists to replace
TextEdit's word breaking routine. However, unless you include explicit tests for scripts, the algorithms you provide may be incorrect for non-Roman
scripts. To provide better compatibility for your application, TextEdit. • disregards the wordBreak hook on non-Roman script systems
• supplies a higher-level hook, TEFindWord, which allows you to
The TEFindWord hook is at a higher level than the wordBreak hook and replaces TextEdit's word breaking routine. This gives your application more control over the breaking process and allows you to write more efficient
routines. However, unless your routine correctly determines breaks for all
scripts, you must be sure to check for non-Roman scripts before replacing
procedure.
Here's how the default TEFindWord routine works:
• TextEdit initially determines whether a non-Roman script system is installed. If one is installed, TextEdit always uses the selection.
• If TextEdit determines that only the Roman Script System is installed and TEFindWord is being called for line breaking, it calls
the wordBreak hook.
• If TEFindWord is called for word selection for system software with
only the Roman Script System installed, TextEdit checks to see if your application has placed the address of a different word breaking
routine in the wordBreak field of the edit record. If so, TextEdit calls your word breaking routine. Otherwise, if the wordBreak field contains
breaks.
The hook TEFindWord is global and supersedes this default behavior. If you
prefer to customize TextEdit, remember to check for non-Roman scripts if you desire to replace the word breaking code only on the Roman Script System
with no other scripts installed. To check if non-Roman scripts are enabled, use
the GetEnvirons function with the smEnabled verb. See the Worldwide Software Overview for details on GetEnvirons. If you replace TEFindWord, be careful to set the correct values in the
appropriate registers on exit.
information in the edit record to provide the necessary parameters. TextEdit determines the current script boundaries for the
determines the length of the script run and the offset within the script run
from which to begin searching for a word boundary. TextEdit uses the value in the clikStuff field of the edit record to determine the leadingEdge flag for the
to replace TEFindWord correctly for non-Roman scripts. For more
information, see the Worldwide Software Overview and Macintosh Worldwide Development: Guide to System Software.