• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Handling a very large NSTextView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Handling a very large NSTextView


  • Subject: Re: Handling a very large NSTextView
  • From: Douglas Davidson <email@hidden>
  • Date: Thu, 7 Apr 2005 08:35:58 -0700


On Apr 6, 2005, at 7:01 PM, Peter Lennie wrote:

I would welcome advice on a text display problem.

I have an NSTextView that uses a subclass of NSTextStorage to provide its underlying text storage. The attributed string is assembled from what is essentially a database of text records that the user can choose to view formatted in different ways. Each database record contributes a short paragraph (~100-200 characters). A change of view can involve reconstruction of the whole attributed string (very fast), and the consequent resetting of its layout (slow). As the database grows large (thousands of records) revising the layout becomes unbearably slow.

Since I can instantly generate the text that corresponds to any arbitrary window into the formatted database I have no need -- except to use the nice text scrolling features available through NSTextView and its enclosing scroll view--for a hugely tall NSTextView and associated NSTextContainer that might hold the tens of thousands of short paragraphs in a formatted document. What I'd like is something like an NSScrollView that works as though it is looking into a very tall text view, but whose actual NSTextView and container are small and can be refilled, (as demanded by the scroll view) with the text that represents the appropriate part of the underlying document.


The main question is whether you have some fast means of determining the height of each individual record's text. If you do, then you can use a variety of mechanisms--a custom view that draws each record using string drawing methods or cell drawing or NSTextViews as subviews, or an NSTableView or NSOutlineView or what have you. The reason NSTextView spends so much time in layout is because it needs to lay out all of the text to determine where each paragraph will fall. It has to do this because it is designed to support arbitrary text, in which height cannot be determined a priori without complete layout. If you have some additional information that would allow you to determine position without complete layout, then you can avoid this.


If you don't have any such means, then you might be able to use some approximation with a custom view. However, the use of an approximation would mean that the scroll position would be only approximately correct.

Douglas Davidson

_______________________________________________
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


References: 
 >Handling a very large NSTextView (From: Peter Lennie <email@hidden>)

  • Prev by Date: Re: Temporarily change the preferred language setting?
  • Next by Date: Re: NSTypesetter and NSLineSweepDirection
  • Previous by thread: Handling a very large NSTextView
  • Next by thread: Accessing undo stack?
  • Index(es):
    • Date
    • Thread