Re: NSTextStorage subclassing issue in 10.4
Re: NSTextStorage subclassing issue in 10.4
- Subject: Re: NSTextStorage subclassing issue in 10.4
- From: "Martin" <email@hidden>
- Date: Tue, 24 May 2005 17:51:29 -0700
On May 24 2005, Keith Blount <email@hidden> wrote:
>In my concrete subclass of
>NSTextStorage, I call my own -fixNoteAttributes method
>to update the associated ranges of the notes from
>-replaceCharactersInRange:withString:,
>-setAttributes:range:, and -addAttribute:value:range:,
>as specified by the docs and elsewhere. All this works
>fine and quickly EXCEPT when there is a large amount
>of text and the user selects it all and applies
>Tiger's list formatting (eg. bullets) to the whole
>selection. It seems that one problem is that
>-fixNoteAttributes gets called *every* time a bullet
>point is added rather than after all of the bullet
>points have been added.
The best would be to call "fixNoteAttributes" from within NSTextStorage's "processEditing", rather than in each of the primitive mutators. I would assume that the new list stuff in Cocoa is smart enough to wrap all the list bullet modifications with calls to "beginEditing" and "endEditing", so that way you will only have to fix your note attributes once. You can also restrict the range to fix to the "editedRange" rather than the whole storage, though of course that doesn't help you in this particular case, but I imagine it would for typing and other small/rapid changes.
If the above is unfeasible (eg: your existing code relies heavily on your note object ranges being correct while the text storage is being edited), then I would make your fixing code do less work. For instance, when "replaceCharactersInRange:withString:" is invoked, you don't need to scan any note objects preceeding the replaced range. Similarly, when attributes are applied, only note objects in the affected range could possibly have been added or removed.
~Martin
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden