• 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
Optimizing text layout in a log view: should I subclass NSLayoutManager?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Optimizing text layout in a log view: should I subclass NSLayoutManager?


  • Subject: Optimizing text layout in a log view: should I subclass NSLayoutManager?
  • From: Camillo Lugaresi <email@hidden>
  • Date: Tue, 24 Jan 2006 14:22:05 +0100

Greetings,

I hope someone familiar with the Cocoa text system can help me with this (Douglas Davidson, maybe?).

I have a non-editable text view that is used for a log. Lines can be added at the bottom and removed at the top (to keep it to a certain length). I wrapped an NSTextView in another view that uses a bottom- based (unflipped) coordinate system, so that the view sticks to the bottom by default when resizing. This part works perfectly.

The problem is that deleting lines at the top invalidates the layout for the entire text view, which makes things slow for long logs, and in general causes undesirable CPU usage. I will implement the obvious fix of deleting lines less often (eg let the buffer grow to 1.1 times the desired maximum, and then clip off the extra 10% in one fell swoop). However, I'd like to solve this problem more radically.

Clearly, when deleting whole lines at the top, the layout of the rest of the text does not really need to be recalculated: it should be sufficient to cache an offset from the old line positions, and add it to the stored information whenever it is requested (the line that was at ordinate 30 is now at 30-14, etc.).

My question is: is it possible and desirable to add such an optimization by subclassing NSTextLayout, or in some other way? It is unclear to me if that class is designed for subclassing, and to what extent; before pursuing this solution, I would like to know if it is a recommended approach or if I should instead write a fully custom text view that does not use the Cocoa text system.

Thanks,
Camillo
_______________________________________________
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


  • Prev by Date: Re: invertrect, any cocoa versions suggested?
  • Next by Date: NS .... lex/yacc ?
  • Previous by thread: Re: Conceptual question
  • Next by thread: Re: Optimizing text layout in a log view: should I subclass NSLayoutManager?
  • Index(es):
    • Date
    • Thread