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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to