• 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: Syntax Coloring...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Syntax Coloring...


  • Subject: Re: Syntax Coloring...
  • From: Douglas Davidson <email@hidden>
  • Date: Thu, 13 Jun 2002 10:32:05 -0700

On Monday, June 10, 2002, at 10:06 AM, Charles Jolley wrote:

1. I would make changes directly to the textStorage attributes, NOT using text view. This way you know exactly what is happening. I can almost gaurantee the text view method is doing more than you would like it to. Even better, use the temporary attributes of the NSLayoutManager to handle your syntax coloring. It is intended exactly for this purpose.

2. Remember that attributes do not have to be used for display only. You could use this to keep some state information about your evaluated syntax. For example, you might have an attribute that tells you how many nest level's deep you are or another one that tells you what type of syntax a particular range of characters is part of.

3. With this type of system in place, you could use the syntax coloring state for the character preceding the start of your edited range and then commence evaluating the text from there until at least the end of the edited range. I would continue from there, however, until your evaluated state starts to match the marked state. This would address a situation where someone deletes the beginning of a comment marker.

4. When you are finished with everything, then use the NSLayoutManager invalidateCharacterRange: with the entire range you evaluated.

These are good suggestions. I would note that setting temporary attributes and setting attributes on the text storage both will cause appropriate invalidation in the layout manager; it should not be necessary to invalidate manually for these purposes. In particular, it may not be necessary to perform layout again simply to change temporary attributes--one good reason for using them in preference to setting attributes on the text storage. Keep in mind that temporary attributes do not transfer in a copy/paste, while attributes on the text storage do--in the case of syntax coloring, that may be desirable behavior.

Douglas Davidson
_______________________________________________
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.

References: 
 >Re: Syntax Coloring... (From: Charles Jolley <email@hidden>)

  • Prev by Date: Re: Adding Links to Attributed String
  • Next by Date: Re: Cocoa Design Question ..
  • Previous by thread: Re: Syntax Coloring...
  • Next by thread: ATSU and CGContextRef newbie question
  • Index(es):
    • Date
    • Thread