I would like to see that too.
[CSS, theme] use real colors to highlight colors props
In general, a plugin that does this would not be difficult…
but here is the catch: the current api does not allow to specify a color for highlight, the color must be assigned to a scope that is already defined in a theme file. (at least as far as I understand)
If the api gets updated with support to feed in a color for highlight, then this would be pretty easy.
awesome idea! would be simple, but it does seem like this will require a patch to core. I’d sign the petition.
Great Idea and I also think that the Plugin API needs to be updated to achieve this. Its not powerful enough as far as I can see.
In general, coloring text with the help of plugins should be possible.
So, i found out that even without proper API i can implement this feature.
Everyone who is interested, you are welcome to test and report bugs.
What works:
- On-the-fly colorizing
- Colorizing/uncolorizing using ST commands
It crashes when used with RGBA:
Traceback (most recent call last):
File ".\sublime_plugin.py", line 127, in on_load
callback.on_load(v)
File ".\css-colors.py", line 268, in on_load
File ".\css-colors.py", line 231, in colorize_css
File ".\css-colors.py", line 200, in generate_color_theme
File ".\css-colors.py", line 199, in <genexpr>
File ".\css-colors.py", line 182, in template
File ".\css-colors.py", line 38, in hex
File ".\css-colors.py", line 72, in _rgb_to_hex
File ".\css-colors.py", line 72, in <genexpr>
ValueError: invalid literal for int() with base 10: '0.8'
Also gives the this error when a file with colorization is edited:
Error loading colour scheme
Packages/C:\Users\tre\AppData\Roaming\Sublime Text 2\Color Scheme - Default\Colorized-Monokai.tmTheme: Error parsing plist xml:
Falied to open file In file
"Packages/C:\Users\tre\AppData\Roaming\Sublime Text 2\Color Scheme - Default\Colorized-Monokai.tmTheme"
-
You can only specify strings with scopes as stated earlier.
-
I edit my tmTheme file all the time, so it doesn’t crash when you edit it…it crashes when you edit it wrong. I would have to see what you added or changed to tell you why it is crashing, but it is a syntax error for sure.
The only way you can accomplish what you want in the current framework is to define all permutations between #000000 and #FFFFFF with individual scopes and then define colors for each of those scopes in a tmTheme file…that is way to many to be practical, which is why I say the API needs to be modified to allow for on the fly color definitions if you wanted to do what you are trying. I would make the request to jps and wait and see.
I’m not talking about the theme file, but a css file. And it’s not a syntax error, I get the error whenever I write down a color.
[quote]Error loading colour scheme
Packages/C:\Users\tre\AppData\Roaming\Sublime Text 2\Color Scheme - Default\Colorized-Monokai.tmTheme: Error parsing plist xml:
Falied to open file In file
“Packages/C:\Users\tre\AppData\Roaming\Sublime Text 2\Color Scheme - Default\Colorized-Monokai.tmTheme”[/quote]
Isn’t this what you posted as your error? This is a plist parsing error, meaning the the xml structure of the plist is corrupt. Maybe I don’t know what you are doing, but the error is telling me the plist is corrupt.
Thanks for your feedback.
Fixed, thanks.
Strange, seems if fails to find your color-scheme because of bad path:
“**Packages/**C:\Users\tre\AppData\Roaming\Sublime Text 2\Color Scheme - Default\Colorized-Monokai.tmTheme”
Can you go to C:\Users\tre\AppData\Roaming\Sublime Text 2
and check if there is Packages folder.
I apologize, I didn’t see the post where you mentioned you figured out how to do it. I will download and give it a try. I am intrigued at how you did it.
Actually i did it, like you wrote few posts before. So nothing innovative
And it is still quite buggy. So more testers is good.
Clever. Dynamic theme file changing. It is a shame API doesn’t make this easier on you, but it looks like it didn’t slow you down too much. Very cool, hadn’t considered this approach.
[quote=“ask”]
Strange, seems if fails to find your color-scheme because of bad path:
“**Packages/**C:\Users\tre\AppData\Roaming\Sublime Text 2\Color Scheme - Default\Colorized-Monokai.tmTheme”
Can you go to C:\Users\tre\AppData\Roaming\Sublime Text 2
and check if there is Packages folder.[/quote]
After some more testing, I’ve found out that it only occurs when having an extra ‘Default.sublime-theme’ in the packages/user directory.
At the very beginning of writing this plugin, i did’t pay attention to add_regions command, so i generated syntax file too (:
I’m trying to generate theme file only if it’s really necessary.
Hm, yeah. Now it assumes that your color scheme is located in Color Scheme - Default folder.
Will fix it in near future.
Thanks
Yeah, add_regions is the way to go. I use that any time I need to highlight anything in a plugin.
So, do you actually switch out the theme file for just the CSS view or for all views? I have only skimmed the code. It would be nice if ST2 allowed access to the structure in memory so you didn’t have to save a modified physical copy, but sadly I don’t think that is available either.
Hmm. Only get grey scale colors here. I may take a deeper look into it later.
I’m generating theme file only:
- in css file
- new colors are in file, otherwise just re-do add_regions
Hope is future ST releases, we will have richer API.
Ugdate from github. I made some fixes. Hope they will help.