Sublime Forum

Colortip

#1

This is a POC. I want to generate a proper wheel, but I don’t know how well it’ll work.

You can get it from here.

Note: Colours aren’t currently inserted into the view yet.

0 Likes

#2

@jbrooksuk, this will allow you to insert:

[pre=#232628]class ColortipEventCommand(sublime_plugin.EventListener):

def run(self, view, where):

    for scope in scopes:
        if (scope+'') in scope_name:
            if (scope == 'constant.other.color.rgb-value.css' and '#' in view.substr(view.word(view.sel()0]))) or scope == 'meta.property-value.css':
                view.show_popup(''.join(self.colors), sublime.COOPERATE_WITH_AUTO_COMPLETE, location=-1, max_width=500, on_navigate=lambda color, view=view: handle_selected_color(view, color))

def handle_selected_color(view, color):
view.run_command(“insert”, { “characters”: color })
view.hide_popup()[/pre]

0 Likes

#3

You’re awesome, thanks!

0 Likes

#4

Speaking of awesomeness:

:sunglasses:

0 Likes

#5

And the magic behind that:

view.show_popup('<i style="color:red">▇</i><i style="color:blue">▇</i><i style="color:green">▇</i>', on_navigate=print)

Long story short, pick a block char from here: copypastecharacter.com/all-characters and go crazy :sunglasses:

0 Likes

#6

[quote=“iamntz”]And the magic behind that:

view.show_popup('<i style="color:red">▇</i><i style="color:blue">▇</i><i style="color:green">▇</i>', on_navigate=print)

Long story short, pick a block char from here: copypastecharacter.com/all-characters and go crazy :sunglasses:[/quote]

All we need now is a proper color grid.

0 Likes

#7

Btw, if you’re doing sublime.set_timeout(lambda:self.run(view, 'selection_modified'), 0) you might as well use the async events. Since show_popup is ST3-only anyway you don’t need to worry about backwards compatability.

0 Likes

#8

It would be nice if we could set the colors. So I could work with a color pallette for a given project. Or it could find colors already used. But thats a lot of dreaming :smile:

0 Likes

#9

True.

You should check out Color Picker Tooltip for that.

0 Likes

#10

I’ve just applied an update that will allow you to add your own hex colors as project colors. You can get it at https://github.com/huot25/SmartColorPicker. I still have some work to do on validation and a few other things, but I think it will do what you need for now. I welcome any feedback you may have if you decide to try it as it is :smiley: .

[quote=“jbrooksuk”]
You should check out Color Picker Tooltip for that.[/quote]

Thank you for the plug :smiley: !

0 Likes