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.
Source/SVAETextUtils.h
/* |
File: SVAETextUtils.h |
Contains: |
Written by: Original version by Jon Lansdell and Nigel Humphreys. |
3.1 updates by Greg Sutton. |
Copyright: Copyright © 1995-1999 by Apple Computer, Inc., All Rights Reserved. |
You may incorporate this Apple sample source code into your program(s) without |
restriction. This Apple sample source code has been provided "AS IS" and the |
responsibility for its operation is yours. You are not permitted to redistribute |
this Apple sample source code as "Apple sample source code" after having made |
changes. If you're going to re-distribute the source, we require that you make |
it clear in the source that the code was descended from Apple sample source |
code, but that you've made changes. |
Change History (most recent first): |
7/20/1999 Karl Groethe Updated for Metrowerks Codewarror Pro 2.1 |
*/ |
#ifndef __SVAETEXTUTILS__ |
#define __SVAETEXTUTILS__ |
#include "SVToken.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 TextTokenFromWindowToken(WindowToken* theWindowToken, TextToken* theTextToken); |
OSErr TextTokenFromWindowDesc(AEDesc* windowDesc, TextToken* aToken); |
OSErr TextDescFromWindowToken(WindowToken* theWindowToken, AEDesc* textDesc); |
OSErr TextDescFromWindowDesc(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-07-22