ColorHighlighter icon indicating copy to clipboard operation
ColorHighlighter copied to clipboard

add support for color functions

Open icylace opened this issue 10 years ago • 15 comments

I don't know how difficult this would be to implement but it would be amazing if the color functions for Stylus, Sass, etc. were supported.

icylace avatar May 28 '14 16:05 icylace

@icylace Wow! That's not easy. I'll try.

Monnoroch avatar May 29 '14 09:05 Monnoroch

You can do it! I believe in you!

icylace avatar May 29 '14 15:05 icylace

Found this - may help with color functions. I'll play with it myself when I get some time.

https://github.com/Kronuz/pyScss

andytruett avatar Jul 16 '14 18:07 andytruett

I've been thinking about this - there seem to be two viable options for implementing highlighting of color functions:

  1. Use Python functions to emulate Sass color functions, à la pyScss
  2. Run the Sass color function in the shell, returning the value to ColorHighlighter. Might be able to use/get inspiration from SassBeautify.

Option 2 seems easier to me. Hopefully it won't take too much to implement.

andytruett avatar Jul 21 '14 18:07 andytruett

This would be awesome!

garand avatar Jul 27 '14 17:07 garand

Also, I just saw this I wonder if you could steal some of the code here? https://atom.io/packages/atom-color-highlight

garand avatar Jul 28 '14 17:07 garand

@garand Atom.io packages are Javascript, vs Sublime's Python, so this would require at least a rewrite/port across languages.

andytruett avatar Jul 28 '14 17:07 andytruett

Gotcha. Anyways, just thought it was interesting. :smile:

garand avatar Jul 28 '14 17:07 garand

This may be of some use as well: https://github.com/klen/python-scss

andytruett avatar Aug 01 '14 19:08 andytruett

Been working on this a little today. @Monnoroch Is this the right logic flow for Sass vars in ColorHighlighter?

search lines in file for bound_symbols
look at Word after symbol
if Word begins with @ or $ it's Sass/Less
    try name_to_hex against variable name
if Word matches a regex string in color_fmts_data
    convert to 8char hex (#rrggbbff) for plugin use

So to implement Sass color function darken(color,amount), it would be necessary to write some new regex for color_fmts_data that would match darken(color,amount) and provide a helper to parse (run?) the function and convert to 8char hex?

andytruett avatar Sep 10 '14 19:09 andytruett

Yes, this logic is correct. You could write your own mechanism for dealing with functions, but the simplest way is to list them all in color_fmts_data.

The problem here is that lots of regex matches creates this problem: https://github.com/Monnoroch/ColorHighlighter/issues/116 . There is a huge problem with performance already.

Since you here to write some code, maby you could think how to make this all faster.

Monnoroch avatar Sep 11 '14 11:09 Monnoroch

+1 for this implementation

Nikita240 avatar Nov 05 '14 04:11 Nikita240

Another +1 for this. Great work, guys!

mjswensen avatar Nov 05 '14 16:11 mjswensen

Please implement. +1 :D

SavePointSam avatar Dec 18 '14 16:12 SavePointSam

This hasn't seem much activity since 2015 but I'd love to be able to see how my darken/lighten functions affect my base colour.

livekeen avatar Apr 11 '17 18:04 livekeen