Current Line Highlighting for VS2010
I’ve created another simple extension for Visual Studio 2010 beta 1 that will highlight the current line the caret is in with a different background color. Here’s a screenshot of the extension in action:
The extension itself is pretty simple, but it was a good way to understand how adornments for the text editor worked. I think it’s a fairly elegant mechanism that offers quite a bit of potential. A couple of things that I liked quite a bit about it:
- You can easily configure the order in which your adornment layer is rendered in, compared to the rest of the stuff in the editor. For example, you might want to render it last of all, or perhaps after the text, but before the selection mask. Like other editor extensions, the [Order] attribute on your
AdornmentLayerDefinitioncontrols this. - You can ask VS to position your adornment relative to the span of text it is associated with, or to the view layout, and VS will do most of the hard work of keeping it in the right place as the buffer view is scrolled and moved. It makes some things a lot easier.
The other thing I found interesting about creating the sample was how you could leverage the Classifications system to integrate with the Fonts and Colors configuration options for an extension that is not a custom classifier extension.
If you look at the extension code, you’ll notice that I have a custom ClassificationFormatDefinition named “Current Line”, which allows the user to easily change the colors used to render the current line adornment. Then, in the code, I can get the settings the user configured (or the default ones provided by the classification format) by using the IClassificationFormatMapService.
This service gives you an IClassificationFormatMap that provides two key things:
- Get the
TextFormattingRunPropertiesthat contains the brushes and other settings you need to use for drawing your adornment, and - An event you can attach to in order to get notified when the user changes the fonts/color settings so that you can refresh your customization.
Pretty cool stuff. You can grab the code for the extension from the GitHub repository.






But why is Envy Code R appearing in fake-italic (oblique)…
[)amien
Because until the editor options actually support enabling italics, I’m still using Envy Code R VS
Too lazy to figure out a way to work around it for now.
Hi Tomas
what’s the Name of this Theme.
very very nice.
Rene
@Rene: It’s not yet a full theme, really. It’s just something I’ve been using lately which is a modified version of my Distant Shores theme, but it’s very rough. Might try to finish it up one of these days and post it
Great News!
Distant Shores is my favorite theme at the moment.
thank you
Could this be adapted for VS2008?
@Patrick: Not really… this uses the completely new extensibility model and editor features in VS2010. I know there are other plugins for VS2008 that support this feature, though (like resharper).
Gr8 Job .. Please finish the theme soon .. would love to have this theme on VS 2008 & VS 2010
Thanks
Cool,i love this theme very much!
BTW:What is this font?
The font is Damien Guard’s Envy Code R: http://damieng.com/blog/2008/05/26/envy-code-r-preview-7-coding-font-released