Carbon


TEUseStyleScrap

Header: TextEdit.h Carbon status: Not Recommended

Assigns new character attributes to the specified range of text in the designated edit structure.

void TEUseStyleScrap (
    SInt32 rangeStart, 
    SInt32 rangeEnd, 
    StScrpHandle newStyles, 
    Boolean fRedraw, 
    TEHandle hTE
);
Parameter descriptions
rangeStart

The offset of the first character in the text of the edit structure to which the character attributes are to be applied.

rangeEnd

The offset of the last character in the text of the edit structure to which the character attributes are to be applied.

newStyles

A handle to a style scrap structure. The style scrap structure contains the attributes to be applied to the specified range of text. If the value of newStyles is NULL, no action is performed. Each element in the style scrap structure contains a field that is the offset of the beginning of the element’s character attributes. This field (scrpStartChar) defines the boundaries for the scrap’s style runs.

Depending on the requirements of your application, you can create a style scrap structure directly and pass its handle to TEUseStyleScrap as the value of newStyles or you can use a style scrap structure created by TEGetStyleScrapHandle.

fRedraw

A flag that specifies whether TextEdit should immediately redraw the selection range using the new character attributes. If the fRedraw parameter is set to TRUE, the attributes are applied immediately to the specified range of text, and line breaks, line heights, and line ascents are recalculated. If fRedraw is set to FALSE, the new character attributes are not reflected in the view rectangle until the next update event occurs.

hTE

A handle to the edit structure containing the range of text to which the character attributes are to be applied. If the handle points to a monostyled edit structure (created using TENew), no action is performed.

DISCUSSION

The TEUseStyleScrap function writes the character attribute information into the style structure’s style table and updates the style run table.

Regardless of whether the text is redrawn, the current selection range is not changed; if characters are highlighted before TEUseStyleScrap is called, they remain highlighted after it is called. However, if characters within the current selection range also fall within the specified range of text, they are rendered in the new character attributes when the text is redrawn.

The TEUseStyleScrap function applies the first element’s attributes to the characters from rangeStart up to the scrpStartChar field of the next element. The function terminates without error if it prematurely reaches the end of the range or if there are not enough scrap style elements to cover the whole range. In the latter case, the function applies the last set of character attributes in the style scrap structure to the remainder of the range.

AVAILABILITY

Not recommended in Carbon. Available in Carbon 1.0.2 and later when running Mac OS 8.1 or later.


© 2000 Apple Computer, Inc. (Last Updated 6/30/2000)