So I'm currently working on a Sublime Text plugin [my firt] that displays pips in the gutter that match colors in lines of css. Similar to what JetBrains does:
I have a bit of a problem though. As far as I can tell when adding a region I can only give the region a scope which the template then themes. Now I could write out a template file that defines every hex code as a scope and a theme to match but that sounds ghastly. Is there a better way to do this? Is it possible to color a region separately from the theme? I'm very new to ST plugins so if there's a crucial piece of the docs I've missed let me know :)
Here's a very stripped down version of my plugin to show how I'm achieving this currently:
import sublime, sublime_plugin
class FooCommand(sublime_plugin.TextCommand):
def run(self, edit):
regions = [s for s in self.view.sel()]
for region in regions:
lines = self.view.split_by_newlines(region)
for index, line in enumerate(lines):
self.view.add_regions("csspip-{0}".format(index), [line], "csspip", "dot",
sublime.HIDDEN | sublime.PERSISTENT)
Make a selection and run view.run_command('foo')
from the console to see what it does currently [not much].