RE: NSTextView layout - less efficient when loaded from file?
RE: NSTextView layout - less efficient when loaded from file?
- Subject: RE: NSTextView layout - less efficient when loaded from file?
- From: Keith Blount <email@hidden>
- Date: Fri, 25 Feb 2005 12:19:56 -0800 (PST)
- Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
Sorry to reply to my own message again, but this has
been driving me crazy for two days now and I still
haven't found a solution...
Does anybody know if, when you load RTFD data from a
file, does the text view then keep referring to the
file on disk rather than in memory when working out
layout? I can't think of any other explanation for the
problems I am having (in short: in textDidChange: I
have to call layout manager's lineFragmentUsedRect...
to calculate the position of various elements attached
to the text in the text view. This doesn't normally
cause a problem. If I drag an image into the text view
and type after it, everything works fine. But if I
then save the file and reopen it and try to type after
the same image, everything slows down painfully - and
this only happens when typing after an image, nowhere
else...).
If this is the case, is there a way to force
NSTextView to load the RTFD data into memory and act
as though it hasn't been saved to disk at all? I am
probably way off base with the problem here - maybe it
is caused by something else entirely. But if anyone
can give me some hints, I would be very grateful.
Thanks again and all the best,
Keith
--- Original message ---
Hello,
I am encountering a strange problem with NSTextView
and would be very grateful for any ideas.
I have a text view attached to a custom view that
stores margin notes that are attached to the text in
the text view. Whenever the user changes any text, I
calculate the new positions of all the margin notes
below that point. All this works very quickly for the
most part.
However, what I have found is that if I have an image
in the text, and try placing the insertion point after
the image and typing, typing is *extremely* slow. This
is apparently caused by the calculations I do using
lineFragmentUsedRectForGlyphAtIndex, because it only
affects text if there are lots of margin notes below
it - and yet in other areas of text (when not typing
next to an image) these calculations are usually so
fast that they do not affect the speed at all.
On further testing what I found was this: if I drag an
image into the text view and try typing after it,
there is no slowdown. But if I then save the file to
disk, close and reopen it, the slowdown appears.
My wild guess at this is that perhaps, before the file
is saved to disk, the text and images are in memory
and so lineFragmentUsedRectForGlyphAtIndex... works
quickly, but after the file is read from disk, the
calculations slow down... or something.
If there are any text system experts out there who
might be able to help me find the cause of this
problem, I would be very grateful.
Many thanks in advance,
Keith
__________________________________
Do you Yahoo!?
Yahoo! Mail - 250MB free storage. Do more. Manage less.
http://info.mail.yahoo.com/mail_250
_______________________________________________
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