Re: Syntax Coloring?
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