Re: Swapping the NSTextContainer on an NSTextView
Re: Swapping the NSTextContainer on an NSTextView
- Subject: Re: Swapping the NSTextContainer on an NSTextView
- From: Robert Goldsmith <email@hidden>
- Date: Tue, 3 Feb 2004 22:14:05 +0000
>
You should be able to swap the text storage in and out. What system
>
version are you running, and what is the exact code you were using to
>
do this?
I am using 10.3.2 with the default gcc3.3 under xCode 1.1. I was simply
creating an NSTextStorage using the default init with an NSString
containing the initial content and swapping using:
[[textView layoutManager] replaceTextStorage:] (or setTextStorage, same
problem).
when the selection changes in the associated NSBrowser (which holds the
list of text items)
>
An alternative solution would be to keep the text storage the same and
>
simply swap its entire contents around, using
>
-[NSMutableAttributedString setAttributedString:].
I was hoping to find a balance between the number of layoutManagers and
the work required to re-render a textStorage. However, although all
these methods work to the point that I can select a different text
source and the view changes and I can edit the text and it is
remembered next time I come back, all of them suffer from the selection
/ caret move exception throwing.
>
>
Keep in mind that having a single layout manager and swapping text on
>
it means that layout has to be re-done each time you change the
>
contents. If you keep a separate layout manager around for each
>
document then you will have the layout information cached with it, so
>
you won't have to do any layout when you change views. The layout
>
manager is by far the heaviest-weight object here; having a single
>
text view won't save you much compared with the cost of having
>
separate layout managers. If you have many documents to manage, you
>
could do something intermediate--say, have a pool of N layout managers
>
for the N most recently displayed documents, and swap the text for one
>
of them only when you need to display something outside of that pool.
My thought was to just test the different options (the different points
at which I can duplicate or reuse objects) and see. I suspect that I
would end up just switching the textStorage and recycling the rest
because although there are quite a lot of files, they are all
reasonably short (assembly source files - the code I am writing if for
an assembler IDE). However, if multiple layoutManagers shared many of
their 'helper' classes, as the docs say they do, there may be some
benefit in duplicating at least some of them (as you suggest, with a
pool).
The problem is that, no matter where I switch, I still have the
exceptions thrown.
Robert
---
GnuPG public key:
http://www.Far-Blue.co.uk/
[demime 0.98b removed an attachment of type application/pgp-signature which had a name of PGP.sig]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.