-
Notifications
You must be signed in to change notification settings - Fork 29.5k
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
[themes] let extensions contribute colors #14309
Comments
If I understand right what you suggest is that extensions can extend color themes and that there is API to access these colors. Maybe related: User definable colors for a color theme: #11556 |
@aeschli Pretty much. #11556 is related and will help the situation for users. Extending color themes isn't strictly necessary, but I cannot think of a better way. It is good to discourage generic color themes from providing extension- and language-specific colors, but there needs to be a way for extensions that contribute their own styling to work with color themes and to have their colors be overridden by the user. Providing dark-vs-light styles (currently supported) is a good start for default colors, but it is not sufficient because getting a color to work with all dark or all light themes is still very difficult. And it should ultimately be up to the user because they may have specific needs: poor vision, color blindness, a bad monitor, poor lighting, conflicting extension colors, etc. So to reiterate, this feature request addresses the extension's needs:
Additional features that could make this work better:
|
I'll use #26974 as the request to give extensions the API to access the workbench colors. That's IMO the first and most important step. |
I don't see how extensions (e.g. an extension who provides a custom document representation) could access the current theme colors. How do I resolve theme colors to css colors so I could embed these inside of my html document? |
With the recently added APIs you can just reference existing colors. There's currently no access to the RGB values, nor a theme change event where you have to listen to. Do you want to use colors in an HTML preview? |
Yes, thats exactly what I need to do. |
For August I added the 'colors' contribution point that lets extensions define new colors that then can be defined in themes and users settings. "colors": [{
"id": "superstatus.error",
"description": "Color or the error message in the status bar.",
"defaults": {
"dark": "#FF0000",
"light": "errorForeground",
"highContrast": "errorForeground"
}
}] Defaults can be actual colors or a reference to an existing color. |
Future improvements can be to allow functions on colors, e.g. take an existing color and add transparency, make it darker/lighter... There's also still the request to have APIs to access colors and theme change events. My hope is to avoid such API and force that only color references are used. All APIs in the extension host should take color id ('ThemableColor').
Closing this issue. If the current APIs are not good enough for you, please continue to comment here or open a new issue for the missing features explaining your use cases. |
Is there already a way to use the colors/theme in a preview view? |
@KnisterPeter Yes, there is. Just download the Insiders Version from https://code.visualstudio.com :) |
@aeschli Thanks for this! About not having an event for when these change - if I create a decoration type and use the the name of that new colour in it and then the user changes the theme colour, will the decorations automatically update to the new colour? If so; the lack of an event doesn't bother me :-) |
@DanTup Yes, updating of decorations on theme change happens automatically. |
Feature request: provide an interface for the user to customize extension-specific colors/styles.
Specifically:
Use case: I'm working on an extension that makes heavy use of highlighting. (It is a theorem prover, where lines are highlighted green, blue, red, etc. to indicate what the theorem prover has accepted, rejected, or is still working on. There are ~10 highlights used). I want the colors for the highlights to be user-configurable.
The current solution: an extension can provide configuration settings for the user to specify colors. Problems with this approach:
Colors should not be hard-coded by an extension. I believe that all extensions using
DecorationRenderOptions
or providing an HTML preview will benefit from a unified way for the user to specify colors.The text was updated successfully, but these errors were encountered: