• 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: Rob Keniger <email@hidden>
  • Date: Mon, 24 Aug 2009 14:12:45 +1000

On 24/08/2009, at 10:32 AM, BareFeet wrote:

I approached it using regex to parse the quoted and commented strings into single objects, then parse using regex for the language, then reinsert the quoted and commented strings. But this was using perl and scripting, whereas I now need to port to Cocoa.

I implemented basic syntax coloring for HTML documents without too much difficulty. You need to set an object as the delegate of your NSTextView's NSTextStorage object.


In this delegate, implement - textStorageDidProcessEditing: which is called when the text changes, and do your syntax coloring in that method.

I use NSScanner to do the tokenizing.

For large documents you'd probably want to keep track of which parts of the text change and only re-color the modified sections.

--
Rob Keniger



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Syntax Coloring? (From: Keitaroh Kobayashi <email@hidden>)
 >Re: Syntax Coloring? (From: BareFeet <email@hidden>)

  • Prev by Date: Simple array controller master-detail binding problem
  • Next by Date: Re: Drawing over a transparent background
  • Previous by thread: Re: Syntax Coloring?
  • Next by thread: Re: Syntax Coloring?
  • Index(es):
    • Date
    • Thread