Home Download Buy Blog Forum Support

Web Colors

Re: Web Colors

Postby dsarch on Thu Jun 23, 2011 3:58 pm

Hello @jbrooksuk,

Here is an updated version, with some pep8 fixes and removing some unused modules:

Code: Select all
import sublime_plugin
import webcolors


class WebColorsCommand(sublime_plugin.WindowCommand):
    colorList = []

    def __init__(self, *args, **kwargs):
        super(WebColorsCommand, self).__init__(*args, **kwargs)
        self.generateColorDialog()

    def run(self):
        self.window.show_quick_panel(self.colorList, self.callback)

    def callback(self, index):
        if (index > -1):
            colorValue = self.colorList[index][1]
            self.window.active_view().run_command("insert_web_colors",
                                                  {"value": colorValue})

    def generateColorDialog(self):
        for name, color in webcolors.css3_names_to_hex.iteritems():
            self.colorList.append([name, color.upper()])


class InsertWebColorsCommand(sublime_plugin.TextCommand):
    def run(self, edit, value):
        for region in self.view.sel():
            self.view.replace(edit, region, value)

dsarch
 
Posts: 62
Joined: Tue May 03, 2011 2:31 am

Re: Web Colors

Postby jbrooksuk on Fri Aug 26, 2011 10:43 am

I've uploaded this to GitHub. Few things I want to do:
  • Add/remove custom colours/names
  • Formatting of the quick panel
  • I need to add the Linux keymap file
jbrooksuk
 
Posts: 781
Joined: Sun Apr 11, 2010 10:37 am
Location: England

Previous

Return to Plugin Announcements

Who is online

Users browsing this forum: No registered users and 3 guests