Re: Is there a way to prepare NSAttaributedString like "attribute runs"?
Re: Is there a way to prepare NSAttaributedString like "attribute runs"?
- Subject: Re: Is there a way to prepare NSAttaributedString like "attribute runs"?
- From: "Nigel Garvey" <email@hidden>
- Date: Mon, 11 Dec 2017 21:03:02 +0000
Shane Stanley wrote on Mon, 11 Dec 2017 22:33:19 +1100:
>On 11 Dec 2017, at 7:34 pm, Takaaki Naganoya <email@hidden>
wrote:
>> Is there a way to prepare NSAttributedString like “attribute runs”?
>set theLength to attString's |length|()
>set startIndex to 0
>repeat
> set {theAtts, theRange} to attString's attributesAtIndex:startIndex
>longestEffectiveRange:(reference) inRange:{0, attString's |length|()}
> -- do stuff with theAtts here
> set rangeEnd to current application's NSMaxRange(theRange)
> if rangeEnd ≥ theLength - 1 then exit repeat
> set startIndex to rangeEnd + 1
>end repeat
Shouldn't startIndex be set directly to the NSMaxRange result?
set theLength to attString's |length|()
set startIndex to 0
repeat until (startIndex = theLength)
set {theAtts, theRange} to attString's attributesAtIndex:startIndex
longestEffectiveRange:(reference) inRange:{startIndex, theLength - startIndex}
-- do stuff with theAtts here
set startIndex to current application's NSMaxRange(theRange)
-- Or faster:
-- set startIndex to (theRange's location()) + (theRange's |length|())
end repeat
NG
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden