Code Collector Pro 1.4.4 (And Its Dirty Little Secret)

Posted on the 03/09/2010 at 03:11 PM

Code Collector Pro 1.4.4 is now out and features a few improvements and bug fixes. The big public improvements are that you can now drag files to groups to create a snippet in that group and drag a snippet to the finder to create a file on disk.

The biggest improvement though isn't yet turned on by default. Ever since CCP 1.0, the syntax highlighting has been something I've been disappointed with. It was slow, it was buggy and it was inaccurate. It has also been the number one source of complaints about CCP. So obviously it needed to be re-written, which is what I've been working on recently.

The plan was to get improved syntax highlighting into CCP 1.5, and the plan still is for it to be public and turned on by default in 1.5. However, it could benefit people now, even in its relatively early state.


Turning On The New Engine

The new syntax highlighting engine is off by default, as at the moment it is classed as a beta feature (meaning it could be buggy and could crash the app). It also only works if you are running on Mac OS X 10.6, so if you enable it on 10.5 you will see no difference as it will still use the old engine. To turn it on you need to drop down to terminal and enter the following:

defaults write com.mcubedsw.codecollectorpro M3EnableNewSyntaxHighlighting -bool YES

If you then restart Code Collector Pro it should start using the new engine to colour some of your snippets.

Why only some though? Well the reason is performance. While the new engine is far more accurate and less buggy, it has not had one bit of performance optimisation done on it. As such is is limited in two ways. The first is that it doesn't render anything that contains a line longer than 500 characters. The main cause of this is condensed jQuery. This will be fixed before 1.5 but for now it just falls back to the old engine.

The second is that it doesn't render anything that is longer than 120 lines. This is just an arbitrary number I've picked based on some timing tests. The good news is though that you can customise this number. While the line length issue can cause CCP's memory usage to balloon rapidly and possibly crash, the number of lines issue is simply one that may cause the app to hang for several seconds while it processes. If you don't mind this and want to try it on bigger snippets then you can modify it from terminal like so (this example sets the limit to 200 lines:

defaults write com.mcubedsw.codecollectorpro M3NewSyntaxHighlightingLineCountLimit 
-int 200

Extra Colours

Along with the new engine there are some extra options for colouring. These don't do anything in the old engine, but they allow you to set colours for pre-processor macros, variables and attributes in your code.


Examples

Below are before and after shots of some snippets in Ruby, Actionscript, HTML and Objective-C to show you the sorts of improvements in the new engine.


Ruby

As you can see, Ruby code is massively improved, with all the strings and keywords being correctly found and comments being coloured in.




Objective-C

The Objective-C snippet gets the comment properly coloured, the correct keywords highlighted, variables and classes highlighted and the preprocessors highlighted




HTML

Tags are properly highlighted now, and attribute names and values can also be coloured




ActionScript

ActionScript has variables and symbols correctly coloured in and fewer incorrect highlights (see the resizeHandler argument)



Feedback

As this is still a feature under development, I'm eager to hear any feedback and any bugs you find. It isn't yet perfect so if you find a snippet that it doesn't colour properly then send an email to support@mcubedsw.com and include the snippet, so I can try and fix it





Comments

Post a Comment

Name:

Email:

URL:

Remember my personal information

Notify me of follow-up comments?


<< Back to main



Copyright © 2006-2012 M Cubed Software