ColorHighlighter icon indicating copy to clipboard operation
ColorHighlighter copied to clipboard

New version of Color Highlighter.

Open Monnoroch opened this issue 8 years ago • 33 comments

I've had some spare time and rewrote the plugin from scratch using all the good coding practices to reduce the number of potential bugs. It's not full-featured just yet, but the core functionality is already there. The code can be found in the branch v8.0.

The code should be put in Packages/color_highlighter, not Packages/ColorHighlighter.

The following features are not supported yet:

  • ~~Color picker.~~
  • ~~Color conversion.~~
  • CSS/preprocessor variables.
  • Named CSS colors.

What's new:

  • Most complicated code is covered with tests, so less bugs.
  • About 2x speedup (and I haven't optimized anything yet).
  • Highlighting with phantoms.
  • User friendly main menu.

Any volunteers to help me test it?

Monnoroch avatar Sep 03 '17 22:09 Monnoroch

@davmillar.

Monnoroch avatar Sep 03 '17 22:09 Monnoroch

About color variables. Currently the plugin parses them all using regexes. This is very hard to do correctly and because of that there are various bugs with coloring only parts of names and whatnot. The correct way to do it would be using CSS/Less/Sass/Styl parsers. I have tried to find these and failed so far. Perhaps someone knows about any python libraries to parse these stylesheet formats?

Monnoroch avatar Sep 04 '17 09:09 Monnoroch

This lib may help https://bitbucket.org/cthedot/cssutils

But it lacks less/sass/styl support =(

realzoberg avatar Sep 19 '17 10:09 realzoberg

@realzoberg I have already considered it. However it doesn't support CSS variables. It does partially support some old draft of the old variables standard, but that's not what we need for obvious reasons.

Monnoroch avatar Sep 19 '17 11:09 Monnoroch

I just installed v8.0 and it's already working much better than the previous version, great job! The only thing I noticed so far is that the default settings file does not open correctly from Preferences > Package Settings > Color Highlighter > Settings - Default. I was able to change all the visual settings I wanted from the Tools > Color Highlighter > Color highlighters menu though, very nice!

willrowe avatar Sep 19 '17 14:09 willrowe

Thanks! Good to hear. The new version with the color picker and color conversion is on the way, perhaps the settings issue will get fixed.

Monnoroch avatar Sep 19 '17 15:09 Monnoroch

The new alpha is released in the same branch:

  • Even more speedup.
  • Color picker.
  • Color conversion.
  • Good old hotkeys for the above.
  • Optimized ST loading time with the plugin.
  • New highlighting mode: highlight colors under the cursor (no need to click on them any more!).
  • I specifically tested opening settings (both user and default) and it worked.

Still to go:

  • Named CSS colors.
  • CSS/preprocessor variables.

Monnoroch avatar Sep 19 '17 19:09 Monnoroch

Thank you very much for this rewrite, my only problem with this plugin was how slow it was and this seems to have addressed that very well! 😄

Only thing it's missing for me personally is Preprocessor Vars, which as you've said is soon to come.

EthanC avatar Sep 19 '17 22:09 EthanC

Known bugs:

  • ~~Color picker blocks the UI.~~
  • Bugs in color format regexes (#FFFs is highlighted).

Missing features:

  • Color variables.
  • Color functions.
  • Named colors.
  • ~~Rehighlighting changed selected lines.~~

Monnoroch avatar Sep 20 '17 20:09 Monnoroch

Fixed problems with starting the plugin on windows systems!

Monnoroch avatar Sep 20 '17 22:09 Monnoroch

I have Tools > Color Highlighter > Color Highlighters > Highlight colors in all text > Inline highlighting style set to Outlined and it does not update the outline when the color is changed. The highlighted region also does not update and disappears from the parts of it are changed completely.

willrowe avatar Sep 22 '17 13:09 willrowe

@willrowe thanks, I was already working on these problems. Should be fixed now (I've uploaded the code just now).

Monnoroch avatar Sep 22 '17 13:09 Monnoroch

I'm still seeing the same issue.

  • I start with a color value of white and it correctly looks like this: before

  • Then I change it to black and it does not update unless I restart Sublime Text or change one of the visual settings: after

willrowe avatar Sep 22 '17 15:09 willrowe

@willrowe are you using ST2 or ST3? What are your CH settings? What platform are you running it on? What does the log file say?

Monnoroch avatar Sep 22 '17 16:09 Monnoroch

OS: Mac OS X v10.11.6 Sublime Text: v3 Build 3144 Color Highlighter Settings:

{
	"search_colors_in":
	{
		"all_content":
		{
			"color_highlighters":
			{
				"color_scheme":
				{
					"enabled": true,
					"highlight_style": "outlined"
				},
				"gutter_icons":
				{
					"enabled": false,
					"icon_style": "circle"
				},
				"phantoms":
				{
					"enabled": false
				}
			},
			"enabled": true
		},
		"hover":
		{
			"color_highlighters":
			{
				"color_scheme":
				{
					"enabled": false,
					"highlight_style": "filled"
				},
				"gutter_icons":
				{
					"enabled": false,
					"icon_style": "circle"
				},
				"phantoms":
				{
					"enabled": false
				}
			},
			"enabled": false
		},
		"selection":
		{
			"color_highlighters":
			{
				"color_scheme":
				{
					"enabled": true,
					"highlight_style": "filled"
				},
				"gutter_icons":
				{
					"enabled": false,
					"icon_style": "circle"
				},
				"phantoms":
				{
					"enabled": false
				}
			},
			"enabled": true
		}
	}
}

I did just notice that It is updating now when the file is saved.

willrowe avatar Sep 22 '17 16:09 willrowe

@willrowe ok, can you please describe exactly what are you doing?

Monnoroch avatar Sep 22 '17 16:09 Monnoroch

@willrowe I think I solved your issue now. If you have more, please provide the log file as well, this one would be easily identifiable by looking at the logs.

Monnoroch avatar Sep 22 '17 16:09 Monnoroch

Thanks, it is working as expected now. For future reference, where is the log file located?

willrowe avatar Sep 22 '17 16:09 willrowe

ctrl+~ shoud open the terminal which has the log.

Monnoroch avatar Sep 22 '17 18:09 Monnoroch

For parsing, maybe PostCSS might help? For instance, postcss might help to figure out how to deal with parsing of Sass.

ArmorDarks avatar Sep 26 '17 12:09 ArmorDarks

@ArmorDarks that is a nodejs module that can't be used from python apart from running the node, which is just way too slow.

Monnoroch avatar Sep 26 '17 12:09 Monnoroch

Yeap, right. Not sure there is something like this for Python, unfortunately :(

ArmorDarks avatar Sep 26 '17 15:09 ArmorDarks

New version that doesn't mess with user preferences and can be smoothly upgraded from a current master version of the plugin in uploaded to the same branch!

Monnoroch avatar Sep 26 '17 20:09 Monnoroch

The new version was released and can now be installed from Package Controls! Weee!

Monnoroch avatar Sep 30 '17 22:09 Monnoroch

Have a bug after installed last version 8.0 (Sublime 3143, Windows 7-64). File of settings doesn't exist - look at video https://yadi.sk/i/GhEiYAQX3NN2dH

Eugene-nsk avatar Oct 01 '17 10:10 Eugene-nsk

@Eugene-nsk thanks for the report, but it's ment to be like that. The new settings file is very different and complitely incompatible, so I had to delete the old one for everything to work smoothly. It only deletes the old settings version, so it won't delete them again if you change the new settings.

Monnoroch avatar Oct 01 '17 12:10 Monnoroch

@Eugene-nsk I've added a FAQ section to the README to explain this to everyone.

Monnoroch avatar Oct 01 '17 13:10 Monnoroch

I updated to the official branch 8.0 and it seems there's an issue with the Mac color picker. If I use the eye-dropper, it should pick the color and stay open for further adjustment. Instead the picker closes (crashes?). Here's a screen recording: https://youtu.be/yL_IAMFYBkM

alexkadis avatar Oct 01 '17 14:10 alexkadis

@alexkadis thanks for the report! Unfortunately, I don't have a mac or an apple dev account, the osx color picker was imlemented by another contributor. If you have time and energy to help me fix the problem, it would be great!

Also, could you please create a separate bug for it, as I think it deserves it's own discussion.

Monnoroch avatar Oct 01 '17 14:10 Monnoroch

@Monnoroch will do! Which contributer created it? I'll tag them. Now opened as #375

alexkadis avatar Oct 01 '17 14:10 alexkadis

@alexkadis don't remember, it was a few years ago :) Would have to search it in PRs.

Monnoroch avatar Oct 01 '17 14:10 Monnoroch

Named CSS colors - I need it :(

antaNTby avatar Oct 02 '17 17:10 antaNTby

@antaNTby working on it already.

Monnoroch avatar Oct 02 '17 17:10 Monnoroch