-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dark Theme #14
Comments
T4Toolbox currently defines colors only for the light theme of Visual Studio. If you are using the dark theme, you can modify the T4 Toolbox colors using the Tools -> Options dialog, Environment -> Fonts and Colors page. The T4 Toolbox color names start with Text Template, for example, Text Template Code Block. Based on a quick research, it appears that the "right" way to support themes is to define theme-specific colors in a In particular, the PowerShell Tools extension defines classification format definitions very similarly to how we do it in T4Toolbox: ClassificationType.cs. And here is the color definition file: PowerShellToolsColors.pkgdef. Notice the two GUIDs, which I believe represent the dark and one other theme. Unfortunately, the |
Thanks for the tip! I’d suggest that you need to automatically recongnize the theme and just work, and you should be using the standard coding text background and foregrounds not custom ones. |
Reusing the built-in content types as a base for the T4 Toolbox classification types would be ideal. Unfortunately, the list of predefined classification types doesn't seem to include the HTML/ASP.NET editor items the T4 Toolbox tries to mimic. Keep in mind that we could only use the built-in content type definitions that are guaranteed to be available with the minimum set of Visual Studio features installed, even when Web Developer Tools are not installed. I haven't found such content types at the time, which is why the colors are hard-coded today. Both this approach and the .pkgdef-based one I described above will just work when Visual Studio theme is changed. They will also work with the theme editor and can be exported/imported correctly. |
I've started active work on this (forked). My approach isn't pkgdef, but, to integrate detecting current theme and available themes from the registry (Light, Dark, Blue, HighContrast defaults) and supply customization, and have a "Syntax" page in Tools > Options > T4Toolbox. The one question on my mind is caching initial registry hits, rather than each iteration over the buffer calling through TemplateClassificationTaggerProvider.cs to ClassificationFormatDefinitions.cs ... except that the way this is done is specific for the buffer's call stack and methods VS calls to get information. (Learning.) |
Small Note: Checked out VS 2013 Color Editor. Changed the values for Tools > Options > Environment > Fonts & Colors variables (Attribute Name/Val, Code Block, Delimiter, Directive), saved as both .vssettings and .pkgdef format.
Correct me if I'm wrong, but, distributing a full export and trying to load it could override existing environment customizations (at least temporarily while opening a .tt file for editing). Research: What's A PkgDef? And Why? When editing values directly in Tools > Options > Environment > Fonts & Colors, versus editing and saving a VS 2013 Custom Color Theme, changes could happen in different places. (What if you don't have the Color Theme editor installed, and you modify things in the typical pages?) It's a registry setting and / or stored in a different User Preferences folder. (Note: Have not worked out how all of this completely works and comes together, but, the above link is enough to investigate and fully document the effects of changes one vs. the other.) |
The nice thing about defining theme colors in a .pkgdef file is that Visual Studio automatically takes care of detecting and applying the theme colors. I think that early attempts to support this in PowerShell Tools also relied on code-based approach, however, it was later replaced to use the .pkgdef-based approach. It feels that implementing support for Dark theme using code-based approach requires a lot more work and produce a less-reliable solution because of so many possible scenarios where theme colors are involved. @AndreSayreMSFT, @adamdriscoll, I hate to bug you with this, but could you point us in the right direction? I think we know how to get a .pkgdef file with theme colors exported using the Visual Studio 2013 Color Theme Editor, but we don't understand how to extract the binary data into T4Toolbox-specific theme keys, similar to how the PoshTools colors are organized. |
This might be a stretch of an ask, but, any possibility of having the VS 2013 Color Editor released on Microsoft on GitHub? Specifically: |
I think that's a good suggestion to post on the gallery page of the VS Color Theme Editor. In the meantime, with a nudge in the right direction from @AndreSayreMSFT, I think I may have figured out how to produce the .pkgdef theme file for T4Toolbox. Here is what I've done:
<Themes>
<Theme Name="T4Toolbox.Dark" GUID="{02f39cd3-e77d-4d98-b333-354f4c9eee3a}">
<Category Name="T4Toolbox" GUID="{8fb347e9-e52e-4949-9806-fe95b0e8929c}">
<Color Name="Text Template Attribute Name">
<Foreground Type="CT_RAW" Source="FF9CDCFE" />
</Color>
<Color Name="Text Template Attribute Value">
<Foreground Type="CT_RAW" Source="FFC8C8C8" />
</Color>
<Color Name="Text Template Code Block">
<Background Type="CT_RAW" Source="FF505050" />
</Color>
<Color Name="Text Template Delimiter">
<Background Type="CT_RAW" Source="FFFFFFB3" />
<Foreground Type="CT_RAW" Source="FF000000" />
</Color>
<Color Name="Text Template Directive Name">
<Foreground Type="CT_RAW" Source="FF569CD6" />
</Color>
</Category>
</Theme>
</Themes>
This looks very similar to the PowerShellToolsColors.pkgdef, with notable differences. In the
Now we need to figure out how to integrate it with the T4Toolbox VSIX package. |
I submitted a new connect issue to report the NullReferenceException problem during import in the Color Theme Editor. Please take moment to up-vote it. |
Reproduced & up-voted on MS Connect. |
Thanks, @MudaKaizen 🍨 |
I'll look into how poshtools integrates .pkgdef and see if I can't come up with an implementation path. |
Research Notes: Commit History: PowerShellToolsColors.pkgdef commit history The referenced
===== USAGE =====
===== OUTPUT ===== Notice that Output doesn't have anything like the .pkgdef for Dark / Light. The poshtools-dev\PowerShellTools\RegistrationAttributes.cs:FontAndColorsRegistrationAttribute However, when I run the same command against Not sure how it's being referenced by the project or VS. Code-wise, most everything is in order, between Maybe it's just a matter of providing the pkgdef file as a resource, and the FontsAndColors RegistrationAttribute (which is declared in / End Thoughts ToDo: Simple copy-over build & test. |
Copying the Also tried a few pkgdef key variations on procedure from 2 days ago... Looks like CreatePkgDef already runs by default as part of the VSIX build process in VS 2015. (Was getting errors about a root-level .pkgdef not being available until resolving some errors -- StyleCop / CodeAnalysis.)
|
That's right, the <Asset Type="Microsoft.VisualStudio.VsPackage" Path="T4Toolbox.VisualStudio.pkgdef" /> You can see it by opening the The I think that for the dark theme to work, the <Content Include="T4Toolbox.Dark.pkgdef">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
</Content> I'm not sure if this will also take care of creating an To validate the changes after building a |
Thanks for the help. Testing & working through it now. (I'm a n00b @ this -- extending Vs.) My default theme is "Dark" -- thus, I see it right away (registry or not, my Experimental instance launches Dark). One possible future Note: switching back and forth (between Themes), I believe, requires subscribing to a notification from Visual Studio, or at least I saw this somewhere in some documentation (not fully tested; maybe it just works in VS 2015). |
Great news. 👍 I'm looking forward to the pull request. Why do you think detection of theme switching is necessary? Do you see the default T4 Toolbox colors when you switch from Dark to Blue or Light theme in your experimental instance of Visual Studio? |
Just got an update on the NullReferenceException bug. The bad news is that it is still happening in the newly released Visual Studio 2015 version of the Color Theme Editor. The good news is that they are promising to release a "different tool" that should work for editing extension color themes. In the meantime, it's nice that we don't have to go to Visual Studio 2013 to edit the .pkgdef files anymore. |
Currently when in the Dark Theme in Visual Studio 2015 the text is all highlighted in a weird background color and the text is white making it almost impossible to read.
The text was updated successfully, but these errors were encountered: