Retired Document
Important: This sample code may not represent best practices for current development. The project may use deprecated symbols and illustrate technologies and techniques that are no longer recommended.
Sources/MSAETextUtils.h
// MSAETextUtils.h |
// |
// Original version by Jon Lansdell and Nigel Humphreys. |
// 4.0 and 3.1 updates by Greg Sutton. |
// ©Apple Computer Inc 1996, all rights reserved. |
#ifndef __MSAETEXTUTILS__ |
#define __MSAETEXTUTILS__ |
#include "MSToken.h" |
#include <TextEdit.h> |
OSErr PutStyledTextFromDescIntoTEHandle(const AEDesc *sourceTextDesc, TEHandle theHTE); |
TEHandle TEHandleFromWindow(WindowPtr theWindow); |
TEHandle TEHandleFromTextToken(TextToken* aToken); |
OSErr GetInsertDescFromInsertHere(AEDesc* insertHereDesc, |
AEDesc* insertDesc, DescType* insertType); |
enum TokenWithinType |
{ |
kTokenBefore = 1, kTokenPartialBefore, kTokenWithin, |
kTokenPartialAfter, kTokenAfter |
}; |
typedef enum TokenWithinType TokenWithinType; |
TokenWithinType TokenWithinToken(TextToken* container, TextToken* token, short* numPartial); |
// Text from window routines |
OSErr TextTokenFromDocumentToken(WindowToken* theWindowToken, TextToken* theTextToken); |
OSErr TextTokenFromDocumentDesc(AEDesc* windowDesc, TextToken* aToken); |
OSErr TextDescFromDocumentToken(WindowToken* theWindowToken, AEDesc* textDesc); |
OSErr TextDescFromDocumentDesc(AEDesc* windowDesc, AEDesc* textDesc); |
typedef char chars[32001]; |
typedef chars **charsHandle; |
// Routines to count and get desccriptors of text |
void MoveToNonSpace(short *start, short limit, charsHandle myChars); |
void MoveToSpace(short *start, short limit, charsHandle myChars); |
void MoveToEndOfParagraph(short *start, short limit, charsHandle myChars); |
OSErr CountTextElements(TEHandle inTextHandle, short startAt, |
short forHowManyChars, DescType elementType, short* result); |
OSErr GetDescOfNthTextElement(short index, DescType elementType, |
TextToken* containerToken, AEDesc* result); |
// Routines to determine text token type |
char GetTEHChar(TEHandle aTEH, short offset); |
Boolean IsAtStart(TextToken* theToken); |
Boolean IsAtEnd(TextToken* theToken); |
Boolean IsWhiteSpace(short aChar); |
Boolean IsParagraphDelimiter(short aChar); |
Boolean IsContentsToken(TextToken* theToken); |
Boolean IsParagraphToken(TextToken* theToken, short* start, short* end); |
Boolean IsWordToken(TextToken* theToken, short* start, short* end); |
DescType GetTextTokenType(TextToken* theToken, short* start, short* end); |
OSErr MakeContentsSpecifier(TextToken* theToken, AEDesc* result); |
OSErr MakeAbsoluteTextSpecifier(WindowPtr theWindow, DescType textType, long index, AEDesc* result); |
OSErr MakeInsertionPointSpecifier(TextToken* theToken, AEDesc* result); |
OSErr GetIndexSpecifier(TextToken* theToken, DescType textType, long index, AEDesc* result); |
// Call following routine to get a specifier for any given text token |
OSErr GetTextTokenObjectSpecifier(TextToken* theToken, AEDesc* result); |
enum |
{ |
ETX = 0x03, // Enter key on keyboard or keypad |
BS = 0x08, // Backspace key on keyboard |
HT = 0x09, // Tab key on keyboard |
LF = 0x0A, // Line feed character |
CR = 0x0D, // Return key on keyboard |
ESC = 0x1B, // Clear key on keypad |
FS = 0x1C, // Left arrow key on keypad |
GS = 0x1D, // Right arrow key on keypad |
RS = 0x1E, // Up arrow key on keypad |
US = 0x1F // Down arrow key on keypad |
}; |
#endif |
Copyright © 2003 Apple Computer, Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2003-01-14