#include <HIToolbox/HIToolbox.h>

/*Initializing TextEdit, Creating an Edit Record, and Disposing of an Edit Record
pascal void TEInit             (void);
pascal TEHandle TEStyleNew     (const Rect *destRect,const Rect *viewRect);
pascal TEHandle TENew          (const Rect *destRect, const Rect *viewRect);
pascal void TEDispose          (TEHandle hTE);*/
pascal void TEInit             (void){
printf ("TEInit");
};

/*TEToScrap

Copies the contents of the TextEdit private scrap to the desk scrap. (Deprecated in Mac OS X v10.4. Use Multilingual Text Engine instead; see Handling Unicode Text Editing With MLTE.)

OSErr TEToScrap ();
Return Value

A result code. See “TextEdit Result Codes”.
Discussion

You use the TEToScrap function to move monostyled text across applications or between an application and a desk accessory. Call the Scrap Manager function ZeroScrap to initialize the desk scrap or clear its contents before calling TEToScrap. 
Availability
Available in Mac OS X v10.0 and later.
Deprecated in Mac OS X v10.4.
Declared In
TextEdit.h*/
OSErr TEToScrap (){
printf ("TEToScrap");
};


/*TECut

Removes the current selection range from the text of the designated edit structure, redrawing the text as necessary. (Deprecated in Mac OS X v10.4. Use Multilingual Text Engine instead; see Handling Unicode Text Editing With MLTE.)

void TECut (
   TEHandle hTE
);
Parameters
hTE

A handle to the edit structure containing the text to be cut. 
Discussion

For monostyled text, the TECut function writes the cut text to the private scrap.

For multistyled text, TECut writes the cut text to the private scrap and its character attributes to the style scrap it also writes both to the Scrap Manager’s desk scrap. For multistyled text, the TECut function removes the character attributes from the style structure’s style table when the text is cut.

For both monostyled and multistyled text, if the selection range is an insertion point, TextEdit deletes everything from the private scrap. When the selection range is an insertion point and the text is multistyled, TECut has no effect on the style scrap or the Scrap Manager’s desk scrap. 
Availability
Available in Mac OS X v10.0 and later.
Deprecated in Mac OS X v10.4.
Declared In
TextEdit.h*/
void TECut (
   TEHandle hTE
){
printf ("TECut",hTE);
};


/*TEUpdate

Draws the specified text within a given update rectangle. (Deprecated in Mac OS X v10.4. Use Multilingual Text Engine instead; see Handling Unicode Text Editing With MLTE.)

void TEUpdate (
   const Rect * rUpdate,
   TEHandle hTE
);
Parameters
rUpdate

The update rectangle, given in the coordinates of the current graphics port, where the specified text is to be drawn. 
hTE

A handle to the edit structure containing the text to be drawn. 
Discussion

Call TEUpdate every time the Event Manager function WaitNextEvent reports an update event for a text editing window—after you call the Window Manager function BeginUpdate , and before you call the EndUpdate function. You also need to erase the update region with the EraseRect function. If you don’t, the caret can sometimes remain visible when the window is deactivated. 
Availability
Available in Mac OS X v10.0 and later.
Deprecated in Mac OS X v10.4.
Declared In
TextEdit.h*/

void TEUpdate (
   const Rect * rUpdate,
   TEHandle hTE
){
printf ("TEUpdate",*rUpdate,hTE);
};

/*TEIdle

When called repeatedly, displays a blinking caret at the insertion point, if any exists, in the text of the specified edit structure of an active window. (Deprecated in Mac OS X v10.4. Use Multilingual Text Engine instead; see Handling Unicode Text Editing With MLTE.)

void TEIdle (
   TEHandle hTE
);
Parameters
hTE

A handle to the edit structure. 
Discussion

You need to call TEIdle only when the window containing the text is active; the caret is blinked only then. TextEdit observes a minimum blink interval, initially set to 32 ticks. No matter how often you call TEIdle, the time between blinks is never less than the minimum interval. (The user can adjust the minimum interval setting with the General Controls control panel.)

To maintain a constant frequency of blinking, you need to call TEIdle at least once each time through your main event loop. Call it more than once if your application does an unusually large amount of processing each time through the loop.

Call the Event Manager’s GetCaretTime function to get the blink rate. 
Availability
Available in Mac OS X v10.0 and later.
Deprecated in Mac OS X v10.4.
Declared In
TextEdit.h*/
void TEIdle (
   TEHandle hTE
){
printf ("TEIdle",hTE);
};



/*TEActivate

Activates the specified edit structure. (Deprecated in Mac OS X v10.4. Use Multilingual Text Engine instead; see Handling Unicode Text Editing With MLTE.)

void TEActivate (
   TEHandle hTE
);
Parameters
hTE

A handle to the specified edit structure. 
Discussion

When your application receives notification of an activate event, it can call the TEActivate function, which activates an edit structure and highlights the selection range. If the selection range is an insertion point, TEActivate simply displays a caret there. Call this function every time the Event Manager function WaitNextEvent reports that the window containing the edit structure has become active.

If you do not call TEActivate before you call TEClick, TEIdle, or TESetSelect, the selection range is not highlighted, or, if the selection range is set to an insertion point, a caret is not displayed at the insertion point. However, if you have turned on outline highlighting through the TEFeatureFlag function for the edit structure, the text of the selection range is framed or a dimmed or an unblinking caret is displayed at the insertion point. 
Availability
Available in Mac OS X v10.0 and later.
Deprecated in Mac OS X v10.4.
Declared In
TextEdit.h*/

void TEActivate (
   TEHandle hTE
){
printf ("TEActivate",hTE);
};


/*TEDeactivate

Deactivates the specified edit structure. (Deprecated in Mac OS X v10.4. Use Multilingual Text Engine instead; see Handling Unicode Text Editing With MLTE.)

void TEDeactivate (
   TEHandle hTE
);
Parameters
hTE

A handle to the specified edit structure. 
Discussion

When the activate event flag is set to deactivate the window, your application can call the TEDeactivate function, which changes an edit structure’s status from active to inactive and removes the selection range highlighting or the caret.

However, if you turned on outline highlighting through the TEFeatureFlag function for the edit structure, the text of the selection range is framed or a dimmed or an unblinking caret is displayed at the insertion point when the structure is deactivated.

Call this function every time the Event Manager function WaitNextEvent reports that the window containing the edit structure has become inactive. 
Availability
Available in Mac OS X v10.0 and later.
Deprecated in Mac OS X v10.4.
Declared In
TextEdit.h*/

void TEDeactivate (
   TEHandle hTE
){
printf ("TEDeactivate",hTE);
};


/*TEGetScrapLength

Returns the size of the TextEdit private scrap, in bytes. (Deprecated in Mac OS X v10.4. Use Multilingual Text Engine instead; see Handling Unicode Text Editing With MLTE.)

long TEGetScrapLength ();
Return Value

The size of the TextEdit private scrap, in bytes. 
Availability
Available in Mac OS X v10.0 and later.
Deprecated in Mac OS X v10.4.
Declared In
TextEdit.h*/
long TEGetScrapLength (){
printf ("TEGetScrapLength");
};

//work




/*TEClick

Controls placement and highlighting of the selection range as determined by mouse events. (Deprecated in Mac OS X v10.4. Use Multilingual Text Engine instead; see Handling Unicode Text Editing With MLTE.)

void TEClick (
   Point pt,
   Boolean fExtend,
   TEHandle h
);
Parameters
pt

The mouse location in local coordinates at the time the mouse button was pressed, obtainable from the event structure (in global coordinates). 
fExtend

A flag denoting the state of the Shift key at the time of the click as indicated by the Event Manager. If the Shift key was held down at the time of the click to extend the selection, pass a value of TRUE. 
h

A handle to the edit structure whose text is displayed in the view rectangle where the click occurred. 
Discussion

Call TEClick whenever a mouse-down event occurs in the view rectangle of the edit structure and the window associated with that edit structure is active. The TEClick function keeps control until the mouse button is released. Use the QuickDraw function GlobalToLocal to convert the global coordinates of the mouse location given in the event structure to the local coordinate system for pt.

The TEClick function removes highlighting of the old selection range unless the selection range is being extended. If the mouse moves, meaning that a drag is occurring, TEClick expands or shortens the selection range accordingly a character at a time. In the case of a double-click, the word where the cursor is positioned becomes the selection range. 
Availability
Available in Mac OS X v10.0 and later.
Deprecated in Mac OS X v10.4.
Declared In
TextEdit.h*/
void TEClick (
   Point pt,
   Boolean fExtend,
   TEHandle h
){};




/*TEScroll

Scrolls the text within the view rectangle of the specified edit structure by the designated number of pixels. (Deprecated in Mac OS X v10.4. Use Multilingual Text Engine instead; see Handling Unicode Text Editing With MLTE.)

void TEScroll (
   short dh,
   short dv,
   TEHandle hTE
);
Parameters
dh

The distance in pixels that the text is to be scrolled horizontally. A positive value moves the text to the right; a negative value moves the text to the left.
dv

The distance in pixels that the text is to be scrolled vertically. A positive value moves the text down; a negative value moves the text up.
hTE

A handle to the edit structure whose text is to be scrolled. 
Discussion

The TEScroll function updates the text on the screen automatically to reflect the new scroll position. The destination rectangle is offset by the amount scrolled. The TEScroll and TEPinScroll functions behave the same, except that TEPinScroll stops scrolling when the last line of text is scrolled into view. 
Availability
Available in Mac OS X v10.0 and later.
Deprecated in Mac OS X v10.4.
Declared In
TextEdit.h*/
void TEScroll (
   short dh,
   short dv,
   TEHandle hTE
){};

/*TEKey

Replaces the selection range in the text of the specified edit structure with the input character and positions the insertion point just past the inserted character. (Deprecated in Mac OS X v10.4. Use Multilingual Text Engine instead; see Handling Unicode Text Editing With MLTE.)

void TEKey (
   CharParameter key,
   TEHandle hTE
);
Parameters
key

The input character. 
hTE

A handle to the edit structure in whose text the character is to be entered. 
Discussion

The TextEdit function TEKey allows you to handle key-down events and enter text input through the keyboard. If the selection range is an insertion point, TEKey inserts the character. (Two-byte characters are passed one byte at a time.)

If the key parameter contains a backspace character, the selection range or the character immediately before the insertion point is deleted. When the primary line direction is right-to-left, the character to the right of the insertion point is deleted. When the primary line direction is left-to-right, the character to the left of the insertion point is deleted.

When the user deletes text up to the beginning of a set of character attributes, TEKey saves the attributes in the null scrap’s style scrap structure. The attributes are saved temporarily to be applied to characters inserted after the deletion. As soon as the user clicks in another area of the text, TEKey removes the attributes. TEKey redraws the text as necessary.

Call TEKey every time the Event Manager function WaitNextEvent reports a keyboard event that your application determines should be handled by TextEdit.

Because TEKey inserts every character passed in the key parameter, your application must filter all characters which aren’t actual text, such as keys typed in conjunction with the Command key. 
Availability
Available in Mac OS X v10.0 and later.
Deprecated in Mac OS X v10.4.
Declared In
TextEdit.h*/
void TEKey (
   CharParameter key,
   TEHandle hTE
){};


/*TETextBox

Draws the indicated text in a given rectangle, with the specified alignment. (Deprecated in Mac OS X v10.4. Use Multilingual Text Engine instead; see Handling Unicode Text Editing With MLTE.)

void TETextBox (
   const void * text,
   long length,
   const Rect * box,
   short just
);
Parameters
text

A pointer to the text to be drawn.
length

The number of bytes comprising the text.
box

A pointer to the rectangle where the text is to be drawn. The rectangle is specified in local coordinates (of the current graphics port) and must be at least as wide as the first character drawn. (A good rule of thumb is to make the rectangle at least 20 pixels wide. 
just

The kind of justification (alignment) used for the specified text.
Discussion

The TETextBox function provides you with an easy way to display static text to a user. It creates its own monostyled edit structure, which it deletes when finished with it, so you cannot edit the text it draws. The TETextBox function breaks a line of text correctly. You can specify how text is aligned in the box using any of the “Text Alignment Constants”. 
Availability
Available in Mac OS X v10.0 and later.
Deprecated in Mac OS X v10.4.
Declared In
TextEdit.h*/
void TETextBox (
   const void * text,
   long length,
   const Rect * box,
   short just
){};

/*TEGetText

Returns a handle to the text of the specified edit structure. (Deprecated in Mac OS X v10.4. Use Multilingual Text Engine instead; see Handling Unicode Text Editing With MLTE.)

CharsHandle TEGetText (
   TEHandle hTE
);
Parameters
hTE

A handle to the edit structure containing the text whose handle you want returned. You pass this handle as an input parameter. 
Return Value

A handle to the text contained in the specified edit structure. See page 82 for a description of the CharsHandle data type.
Discussion

Given an edit structure that contains text, you can use the TEGetText function to get a handle to the text itself. The TEGetText function doesn’t make a copy of the text. Rather, it returns the handle to the text which is stored as a packed array of characters. (This handle belongs to TextEdit your application must not destroy it.) The teLength field of the edit structure contains the length of the text whose handle is returned.

The handle of type CharsHandle that is returned by TEGetText corresponds to the hText field of the TERec structure. 
Availability
Available in Mac OS X v10.0 and later.
Deprecated in Mac OS X v10.4.
Declared In
TextEdit.h*/
CharsHandle TEGetText (
   TEHandle hTE
){};



/*TEDelete

Removes the selected range of text from the designated edit structure, redrawing the remaining text as necessary. (Deprecated in Mac OS X v10.4. Use Multilingual Text Engine instead; see Handling Unicode Text Editing With MLTE.)

void TEDelete (
   TEHandle hTE
);
Parameters
hTE

A handle to the edit structure containing the text to be deleted. 
Discussion

When the TEDelete function deletes a selected range of text, it does not transfer the text to either the private scrap or the Scrap Manager’s desk scrap.

For multistyled structures, when you use TEDelete to delete a selected range of text, the associated character attributes are saved in the null scrap to be applied to characters entered after the text is deleted. When the user clicks in some other area of the text, the character attributes are removed from the null scrap. You can use TEDelete to implement the Clear command. The TEDelete function recalculates line starts and line heights. 
Availability
Available in Mac OS X v10.0 and later.
Deprecated in Mac OS X v10.4.
Declared In
TextEdit.h*/
void TEDelete (
   TEHandle hTE
){};


/*TEDispose

Removes a specified edit structure and releases all memory associated with it. (Deprecated in Mac OS X v10.4. Use Multilingual Text Engine instead; see Handling Unicode Text Editing With MLTE.)

void TEDispose (
   TEHandle hTE
);
Parameters
hTE

A handle to the edit structure for which the allocated memory should be released. 
Discussion

Call the TEDispose function only when you’re completely through with an edit structure.

Note that if your program retains a handle to text associated with the edit structure that you are destroying with TEDispose , the handle becomes invalid because the TEDispose function disposes of it, as well as the dispatch structure handle. If the structure is multistyled, TEDispose also disposes all of the style-related handles: STHandle, LHHandle, STScrpHandle, nullSTHandle, and TEStyleHandle.

To continue to refer to the text after you’ve destroyed the edit structure, you need to make a copy of the handle in the hText field of the edit structure using the Operating System Utilities HandToHand function before you call TEDispose.

In addition to disposing of the edit structure, the edit structure handle, and the dispatch structure handle, the TEDispose function destroys the null scrap associated with the edit structure and releases the memory used for it. 
Availability
Available in Mac OS X v10.0 and later.
Deprecated in Mac OS X v10.4.
Declared In
TextEdit.h*/
void TEDispose (
   TEHandle hTE
){};


/*TENew

Creates and initializes a monostyled edit structure and allocates a handle to it. (Deprecated in Mac OS X v10.4. Use Multilingual Text Engine instead; see Handling Unicode Text Editing With MLTE.)

TEHandle TENew (
   const Rect * destRect,
   const Rect * viewRect
);
Parameters
destRect

A pointer to the destination rectangle for the new edit structure, specified in the local coordinates of the current graphics port. This is the area in which text is laid out. 
viewRect

A pointer to the view, or visible, rectangle for the new edit structure, specified in the local coordinates of the current graphics port. This is the area of the window in which text is actually displayed.
Return Value

A handle to the newly created edit structure. Your application needs to store the handle to the edit structure that is returned; many functions require it as an input parameter. See the description of the TEHandle data type.
Discussion

A monostyled edit structure is one in which all text is restricted to a single font, size, and style. Use the TENew function when the text is to be rendered in attributes that are consistent from character to character. Otherwise, use the TEStyleNew function.

Call TENew once for every edit structure you want allocated. Your application should store the handle to the edit structure that is returned; many functions require it as an input parameter. The edit structure assumes the drawing environment of the graphics port.

If your application contains more than one window where text editing occurs, you need to create an edit structure for each window.

Before this function is called, the window must be in the current graphics port. 
Availability
Available in Mac OS X v10.0 and later.
Deprecated in Mac OS X v10.4.
Declared In
TextEdit.h*/
TEHandle TENew (
   const Rect * destRect,
   const Rect * viewRect
){};




/*TEAutoView

Enables and disables automatic scrolling of the text in the specified edit structure. (Deprecated in Mac OS X v10.4. Use Multilingual Text Engine instead; see Handling Unicode Text Editing With MLTE.)

void TEAutoView (
   Boolean fAuto,
   TEHandle hTE
);
Parameters
fAuto

A flag indicating whether to enable or disable automatic scrolling. A value of TRUE enables automatic scrolling; a value of FALSE disables automatic scrolling. 
hTE

A handle to the edit structure for which automatic scrolling is to be enabled or disabled. 
Discussion

The TEAutoView function does not actually scroll the text automatically: TESelView does. However, when fAuto is set to FALSE , a call to TESelView has no effect.

If there is a scroll bar associated with the edit structure, your application must manage scrolling of it. You can replace the default click loop function, which scrolls the text only, with a customized version that also updates the scroll bar.

You can also enable or disable automatic scrolling for an edit structure through the teFAutoScroll feature of the TEFeatureFlag function. For more information, see TEFeatureFlag. 
Availability
Available in Mac OS X v10.0 and later.
Deprecated in Mac OS X v10.4.
Declared In
TextEdit.h*/
void TEAutoView (
   Boolean fAuto,
   TEHandle hTE
){};

/*TEFromScrap

Copies the contents of the desk scrap to the TextEdit private scrap. (Deprecated in Mac OS X v10.4. Use Multilingual Text Engine instead; see Handling Unicode Text Editing With MLTE.)

OSErr TEFromScrap ();
Return Value

A result code. See “TextEdit Result Codes”.
Discussion

You use this function to move monostyled text across applications or between an application and a desk accessory. 
Availability
Available in Mac OS X v10.0 and later.
Deprecated in Mac OS X v10.4.
Declared In
TextEdit.h*/
OSErr TEFromScrap (){};


/*TEPaste

Replaces the edit structure’s selected text with the contents of the private scrap and leaves an insertion point after the inserted text. If the selection range is an insertion point, TEPaste inserts the contents of the private scrap there. (Deprecated in Mac OS X v10.4. Use Multilingual Text Engine instead; see Handling Unicode Text Editing With MLTE.)

void TEPaste (
   TEHandle hTE
);
Parameters
hTE

A handle to the edit structure into which the text is to be pasted. 
Discussion

When you call TEPaste, after it pastes the text from the private scrap, it redraws all of the text as necessary. If the private scrap is empty, TEPaste deletes the selection range. If you call TEPaste for a multistyled edit structure, it pastes only the text in the private scrap. In this case, TEPaste ignores any associated character attribute information stored in the style scrap; instead, it applies the character attributes of the first character of the selection range being replaced to the text. If the selection range is an insertion point, TEPaste applies the character attributes of the character preceding the insertion point. 
Availability
Available in Mac OS X v10.0 and later.
Deprecated in Mac OS X v10.4.
Declared In
TextEdit.h*/
void TEPaste (
   TEHandle hTE
){};





/*TECopy

Copies the text selection range from the edit structure, leaving the selection range intact. (Deprecated in Mac OS X v10.4. Use Multilingual Text Engine instead; see Handling Unicode Text Editing With MLTE.)

void TECopy (
   TEHandle hTE
);
Parameters
hTE

A handle to the edit structure containing the text to be copied. 
Discussion

The TECopy function copies the text to the private scrap. For text of a monostyled edit structure, the text is written to the private scrap only. For text of a multistyled edit structure, the text is written to the TextEdit private scrap, the character attribute information is written to the TextEdit style scrap, and both are written to the Scrap Manager’s desk scrap. Anything previously in the private scrap is deleted before the copied text is written to it.

For both multistyled and monostyled text, if the selection range is an insertion point, TECopy empties the TextEdit private scrap. When the selection range is an insertion point and the text is multistyled, TECopy has no effect on the null scrap, the style scrap, or the Scrap Manager’s desk scrap. 
Availability
Available in Mac OS X v10.0 and later.
Deprecated in Mac OS X v10.4.
Declared In
TextEdit.h*/
void TECopy (
   TEHandle hTE
){};


