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 / About TextEdit


The TextEdit Private, Null, and Style Scraps

There are three scrap areas that TextEdit uses exclusively: the TextEdit private scrap, the TextEdit null scrap, and the TextEdit style scrap. The TextEdit routines use all of these scraps to hold transient information.

TextEdit uses the private scrap for all cut, copy, and paste activity whether the text is multistyled or monostyled. The private scrap belongs to the application. When the text is multistyled, TextEdit also copies the text to the Scrap Manager's desk scrap.

TextEdit uses the null scrap to store character attribute information associated with a null selection (an insertion point) or text that is deleted when the user backspaces over it. The null scrap belongs to the multistyled edit record. Character attribute information stored in the null scrap is retained until it is used, for example, when applied to newly inserted text, or until some other editing action renders it unnecessary, such as when TextEdit sets a new selection range. A number of routines that deal with multistyled text check the null scrap for character attribute information and, if there is any, apply it to newly inserted text when character attributes for that text are not available.

When you cut or copy multistyled text, memory is allocated dynamically for the style scrap and the character attribute information is copied to it. Your application can also use the style scrap for other purposes. For example, to save and restore multistyled text both the text and the associated character attribute information must be preserved; you can save character attributes associated with a range of text in the style scrap. Also, you can create a style scrap record and store character attribute information in it to be applied to inserted text. Your application can create as many style scraps as it needs. For more information, see the discussion of the style scrap record under "Data Structures" on page 2-60.

As part of TextEdit initialization, TEInit creates the private scrap and allocates a handle to it. TextEdit creates and initializes a null scrap for a multistyled edit record when an application calls TEStyleNew to create the edit record. (The null scrap remains throughout the life of the edit record: it is disposed of when the application calls TEDispose to destroy the edit record and release the memory allocated for it.) TextEdit allocates memory used for the style scrap dynamically when your application calls a routine that uses it.

Note
Because these scraps are in RAM, they are volatile, and a power failure can cause the data in a scrap to be lost.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996