SetStylScrap
SetStylScrap Apply styles in an StScrpRec to a range of text
#include <TextEdit.h> TextEdit
void SetStylScrap(rangeStart, rangeEnd, theStylScrap, redraw, hTE );
long rangeStart range start (0 is start of all edit text)
long rangeEnd range end (past end is OK)
StScrpHandle theStylScrap ; handle leading to a list of style runs (an StScrpRec)
Boolean redraw ; TRUE= redraw immediately
TEHandle hTE ; edit record of interest
returns handle leading to a StScrpRec (or 0)
The SetStylScrap procedure, new with system software version 6.0,
performs the opposite function of the GetStylScrap function.
SetStylScrp applies the set of styles defined in an StScrpRec to text in a
given range of an edit record. You might use this in conjunction with
GetStylScrap to implement a "copy styles" feature.
rangeStart and...[tjer missing text here. TJER]
rangeEnd specify the text to which the styles should be applied. If you specify
a range which is longer than the style runs identified in
newStylScrap, the final style is applied to the rest of the text in the
range.
theStylScrap is a handle leading to an StScrpRec, which in turn leads to a
ScrpSTTable (a list of style-run blocks). One way to obtain one of
these handles is to use GetStylScrap. Another way is to fetch one
from the desk scrap via GetScrap(...,'styl',...).
redraw specifies whether or not to redraw the text (update the screen to
reflect the changes). It is one of:
FALSE (0) don't redraw now; wait for an update event and TEUpdate
TRUE (1) redraw immediately
hTE is a handle leading to an edit record created via TENew or
The SetStylScrap procedure uses the newStyles parameter (a handle to a
style scrap record) and sets its style information into the style scrap record
for a range of text specified by rangeStart and rangeEnd. If newStyles is NIL or
hTE is a handle to an unstyled edit record, SetStylScrap does nothing.
If the redraw parameter is TRUE, the text is redrawn to reflect this new style
information; and line breaks, line heights, and line ascents are recalculated.
Otherwise, this new information is not reflected in the view rectangle until the
TEUpdate procedure is called. Regardless of whether the text is redrawn, the
current selection range is not changed. So if characters are highlighted before
SetStylScrap is called, they remain highlighted after it is called. They also
reflect the new style information if redraw was TRUE and if they were within
the range of the specified text.
Each element in the style scrap record contains a scrpStartChar field that is
the offset to the start of the element's style. As with the style run array, the
scrpStartChar field defines the boundaries for the scrap's style runs.
SetStylScrap applies the first element's style to the characters from
rangeStart up to the scrpStartChar field of the next element.
SetStylScrap 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, SetStylScrap applies the last style in the style
scrap record to the remainder of the range.
Returns: none

Notes: SetStylScrap does not use or affect the current selection
range. If you want theStylScrap to apply to the selection range, you may
read rangeStart and rangeEnd from the edit record:
SetStylScrap( (*hTE)->selStart,(*hTE)->selEnd, theStylScrap, hTE );
If theStylScrap is NIL (0), or if hTE is an old-format edit record, this
function has no effect.
Macintosh Technical Note #207, in which this function was first
described, listed the parameters incorrectly. The above template is
correct.