Syntax Colouring
Syntax Colouring
- Subject: Syntax Colouring
- From: Chris Boot <email@hidden>
- Date: Tue, 29 Jul 2003 13:12:01 +0100
Hi all,
This probably sounds pretty familiar, but I've looked all round the
'net for good examples of syntax colouring and have come up with a few
individual pieces but nothing concrete.
Apple's Cocoa documentation suggests that NSTextStorage's
textStorageWillProcessEditing: delegate method is the one to use to get
told when the text changes, and even mentions syntax highlighting of
sorts in the description. There is also mention of syntax colouring in
the discussion of temporary attributes in NSLayoutManager. My first
problem is that if I set temporary attributes from a
textStorageWillProcessEditing: method, the layout manager seems to
compensate for the change in the text storage's length twice, so the
colours are shifted over by one or more places.
I ended up using NSText's textDidChange: delegate method and and
NSMutableAttributesString's addAttributes:range: methods to do the
colouring, which works quite well except for the fact that it slows to
a crawl with any large quantity of text. I am already making sure that
I only colour things that the user could have changed, but running an
NSScanner or regular expression engine over 400K of text takes a good
few seconds. Any suggestions on speeding it up a bit?
Thanks in advance.
--
Chris Boot
email@hidden
http://www.bootc.net/
"To err is human. To really screw up, you need a computer." - Scott
Adams
_______________________________________________
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.