Reputation: 131092
I've been using John Lam's Vibrant Ink VS color scheme lately and wanted to tweak it so it highlights the method names for a class with a different color. Turns out there is no option in VS for that.
Resharper has a feature that provides custom syntax highlighting. I was wondering how hard is it to write a little plugin that gives you granular custom syntax highlighting? Are there any open source ad-ins like that out there?
EDIT
Thanks all, I managed to hack stuff up using DXCore and my VS is looking oh so similar to textmate.
VS is looking fantastic http://img14.imageshack.us/img14/637/awesomevsgq1.png
** NOTE **
I had to slightly modify the snippet by Rory so it works with dotted method names and equality operators in C#.
I am now using:
string name = ea.LanguageElement.Name.Split('.').Last();
if (name == ("op_Equality")) {
name = "==";
} else if (name == "op_Inequality") {
name = "!=";
}
ea.PaintArgs.OverlayText(name,
ea.LanguageElement.NameRange.Start,
Color.FromArgb(255,204,0));
Upvotes: 20
Views: 4395
Reputation: 6068
Get DXCore, and then start with this plugin: http://www.rorybecker.me.uk/PaintIt.html that should get you started with some code to colorize method names. Rory makes his code available, and I think he is a member here at SO...
Upvotes: 2
Reputation: 15701
Well as Brian has already said... My PaintIt plugin will give you some idea as to what can be done with the DXCore.
Also there are some other "Decorative plugins" on our "Community Plugin Site" and we have a decent community over in the
DevExpress IDE Tools forums if you have any specific questions.
DXCore is the framework on which RefactorPro and CodeRush are built which should give you an idea of what sort
of graphical capability they are capable of.
That said you do not need either of these tools to use the DXCore.
Everything on the Community Site is "Open Source" (So is PaintIt)
To give you an idea of how simple things are... the following code is all you need to add to a basic plugin template get the basics up and running using DXCore...
Private Sub PlugIn_EditorPaintLanguageElement(ByVal ea As DevExpress.CodeRush.Core.EditorPaintLanguageElementEventArgs) Handles Me.EditorPaintLanguageElement
If ea.LanguageElement.ElementType = LanguageElementType.Method Then
ea.PaintArgs.OverlayText(ea.LanguageElement.Name, _
ea.LanguageElement.NameRange.Start, _
Color.HotPink)
End If
End Sub
I have created a plugin (called CR_ColorizeMemberNames) based on this code and added it to the Community Plugin Site.
The binary is available from my site here.
You need only download and install DXCore and place the binary of the plugin in the plugins folder (Defaults to C:\Program Files\Developer Express Inc\DXCore for Visual Studio .NET\2.0\Bin\Plugins).. Then start VS and your method names should all be in HotPink (Lovely)
Upvotes: 11
Reputation: 29953
If you want to roll your own, I'd recommend getting DXCore from DevExpress. I know you can add your own visual elements into VS2008 using this add in, and I believe it's free as well. there's a good sized community for assistance with writing your own plugins, and there may even be one already made for you.
I'm a big fan of DevExpress, and I run Refactor! and CodeRush.
Upvotes: 3
Reputation: 845
To go beyond the simple keyword coloring, details on the Visual Studio Syntax coloring is defined here; and details to implement here.
These documents outline how the underlying plumbing is, well, plumbed -- and more importantly, goes into detail on how to wire in your own --
Upvotes: 4
Reputation: 10591
I can't really answer how hard it is or whether there's any open source, but to get it done, you want to take a looki at Custom Text Markers. See these two articles for details:
Upvotes: 0