Path: utzoo!dciem!nrcaer!scs!spl1!laidbak!att!pacbell!lll-tis!helios.ee.lbl.gov!pasteur!ucbvax!decwrl!nsc!voder!apple!tecot
From: tecot@Apple.COM (Ed Tecot)
Newsgroups: comp.sys.mac.programmer
Subject: Re: TESetStyle bug
Message-ID: <11442@apple.Apple.Com>
Date: 1 Jun 88 21:58:07 GMT
Article-I.D.: apple.11442
References: <9416@agate.BERKELEY.EDU> <9453@apple.Apple.Com> <311@uva.UUCP>
Reply-To: tecot@apple.UUCP (Ed Tecot)
Organization: Apple Computer Inc, Cupertino, CA
Lines: 20
Really-From: Russ Wetmore

In article <311@uva.UUCP> freek@uva.UUCP (Freek Wiedijk) writes:
>Why doesn't TESetStyle behave the same was as the Style menu in MacWrite does?

It does now, with the "doToggle" bit in the "mode" parameter of the TESetStyle
call.  Otherwise, the given attributes are applied to the entire selection.

>Also: Is it possible to obtain the style information of the selection when it
>is longer than one character, without checking all individual characters with
>TEGetStyle?

Yes.  With the new call "TEContinuousStyle", you can test for style information
continuity across the selection (i.e. is the _whole_ selection italicized?)
Otherwise, the most cost-effective way to handle style analysis is to step
through the "runs" array of the TEStyleRec structure.  It is kept in sorted
order by character position of the start of each unique style (so you can do
a binary search to find the style element for the first character, and search
linearly over the rest of the selection.)

A technical note on these additions is being written and should appear in
the next batch.