Home Download Buy Blog Forum Support

[CSS, theme] use real colors to highlight colors props

[CSS, theme] use real colors to highlight colors props

Postby ask on Sun Nov 06, 2011 1:01 pm

Hi, sublime hackers.

Being an ex-vim user, i used css_color plugin,
this plugin "underlays the hexadecimal CSS colorcodes with their real color"

And this is how it looks:
Image
So i think the idea deserves to be implemented as sublimetext plugin.

I did't find a good color highlighting explanation, so this is my question:
Can i dynamically (in plugin's code) set color highlighting rules, rather than generating theme files on-the-fly ?
ask
 
Posts: 26
Joined: Wed Sep 14, 2011 12:40 pm

Re: [CSS, theme] use real colors to highlight colors props

Postby iamntz on Sun Nov 06, 2011 2:24 pm

I would like to see that too.
iamntz
 
Posts: 910
Joined: Fri Apr 29, 2011 8:52 am
Location: Romania

Re: [CSS, theme] use real colors to highlight colors props

Postby gavsim on Sun Nov 06, 2011 3:18 pm

Yeah like this idea, would be great if someone wrote a plugin to do this.
gavsim
 
Posts: 9
Joined: Wed Oct 26, 2011 9:35 pm

Re: [CSS, theme] use real colors to highlight colors props

Postby facelessuser on Sun Nov 06, 2011 3:32 pm

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.
facelessuser
 
Posts: 1575
Joined: Tue Apr 05, 2011 7:38 pm

Re: [CSS, theme] use real colors to highlight colors props

Postby minism on Tue Nov 08, 2011 9:19 am

awesome idea! would be simple, but it does seem like this will require a patch to core. I'd sign the petition.
minism
 
Posts: 8
Joined: Tue Nov 01, 2011 5:30 am

Re: [CSS, theme] use real colors to highlight colors props

Postby manuelh9r on Tue Nov 08, 2011 1:56 pm

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.
manuelh9r
 
Posts: 2
Joined: Mon Nov 07, 2011 8:46 am

Re: [CSS, theme] use real colors to highlight colors props

Postby ask on Sat Nov 12, 2011 8:07 am

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
ask
 
Posts: 26
Joined: Wed Sep 14, 2011 12:40 pm

Re: [CSS, theme] use real colors to highlight colors props

Postby tretretre on Sat Nov 12, 2011 12:59 pm

It crashes when used with RGBA:

Code: Select all
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:

Code: Select all
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"
tretretre
 
Posts: 23
Joined: Fri Oct 21, 2011 7:13 pm

Re: [CSS, theme] use real colors to highlight colors props

Postby facelessuser on Sat Nov 12, 2011 3:15 pm

1. You can only specify strings with scopes as stated earlier.

2. 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.
facelessuser
 
Posts: 1575
Joined: Tue Apr 05, 2011 7:38 pm

Re: [CSS, theme] use real colors to highlight colors props

Postby tretretre on Sat Nov 12, 2011 4:38 pm

facelessuser wrote:2. 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.


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.
tretretre
 
Posts: 23
Joined: Fri Oct 21, 2011 7:13 pm

Next

Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 10 guests