diff --git a/CHANGES.md b/CHANGES.md index fb47a44..3a1530e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,11 +2,15 @@ ## 2.15.0 -- **NEW**: Require new `coloraide` dependency. +- **NEW**: Format dialog a little more compact. +- **NEW**: Require new `coloraide` dependency. With this dependency, schemes that use `min-contrast` should work now. - **NEW**: ScopeHunter now only shows information in tooltip. Showing info in separate panel and console has been dropped as tooltip functionality is available on all latest Sublime versions. - **NEW**: Backtrace info available in Sublime Text build 4087. +- **NEW**: Add `image_border_color` option. - **FIX**: Fix bug with copying color scheme name. +- **FIX**: Fix some issues related to schemes (Celeste theme) using invalid colors, such as `"none"` to reset background + colors etc. ## 2.14.0 @@ -36,7 +40,8 @@ ## 2.11.1 -- **FIX**: Allow `-` in variables names. Write color translations to main scheme object and ensure filtering is done after color translations. +- **FIX**: Allow `-` in variables names. Write color translations to main scheme object and ensure filtering is done + after color translations. ## 2.11.0 diff --git a/docs/src/markdown/usage.md b/docs/src/markdown/usage.md index 08d455d..fa6720f 100644 --- a/docs/src/markdown/usage.md +++ b/docs/src/markdown/usage.md @@ -155,4 +155,15 @@ defined limit, it will not be highlighted. You can control that limit here. If you have the [SubNotify][subnotify] installed, this will enable or disable messages through it. +#### `image_border_color` + +Set color preview border colors. + +```js + // By default, image border is calculated based on theme background, but if for + // some reason, it isn't sufficient in your popup, set it to any color using + // valid CSS for RGB, HSL, or HWB colors. + "image_border_color": null +``` + --8<-- "refs.txt" diff --git a/lib/color_scheme_matcher.py b/lib/color_scheme_matcher.py index 3b8caa6..3ca9344 100644 --- a/lib/color_scheme_matcher.py +++ b/lib/color_scheme_matcher.py @@ -260,38 +260,41 @@ def parse_scheme(self): color = item.get('foreground', None) if isinstance(color, list): # Hashed Syntax Highlighting - for index, c in enumerate(color): - color[index] = Color( - c.strip(), variables=self.variables - ).convert("srgb").to_string(**HEX) - elif isinstance(color, str): - if color == "none": + try: + for index, c in enumerate(color): + color[index] = Color( + c.strip(), variables=self.variables + ).convert("srgb").to_string(**HEX) + except Exception: item['foreground'] = "none" - else: + elif isinstance(color, str): + try: item['foreground'] = Color( color.strip(), variables=self.variables ).convert("srgb").to_string(**HEX) + except Exception: + item['foreground'] = "none" # Background color bgcolor = item.get('background', None) if isinstance(bgcolor, str): - if bgcolor == "none": - item['background'] = bgcolor - else: + try: item['background'] = Color( bgcolor.strip(), variables=self.variables ).convert("srgb").to_string(**HEX) fgadj = item.get('foreground_adjust', None) - if isinstance(fgadj, str) and fgadj and fgadj != "none": + if isinstance(fgadj, str) and fgadj: item['foreground_adjust'] = fgadj + except Exception: + pass # Selection foreground color scolor = item.get('selection_foreground', None) if isinstance(scolor, str): - if scolor == "none": - item['selection_foreground'] = "none" - else: + try: item['selection_foreground'] = Color( scolor.strip(), variables=self.variables ).convert("srgb").to_string(**HEX) + except Exception: + pass def setup_matcher(self): """Setup colors for color matcher.""" @@ -367,10 +370,7 @@ def add_entry(self, name, scope, color, bgcolor, fgadj, scolor, style): else: fg, fg_sim = None, None if bgcolor is not None: - if bgcolor == "none": - bg, bg_sim = bgcolor, None - else: - bg, bg_sim = self.process_color(bgcolor) + bg, bg_sim = self.process_color(bgcolor) else: bg, bg_sim = None, None if scolor is not None: @@ -541,7 +541,7 @@ def guess_color(self, scope_key, selected=False, explicit_background=False, no_b else: color_sim = self.colors[key]["color_simulated"] color_selector = SchemeSelectors(self.colors[key]["name"], self.colors[key]["scope"]) - if ( + elif ( self.colors[key]["color_gradient"] is not None and match > best_match_fg_gradient ): @@ -581,15 +581,8 @@ def guess_color(self, scope_key, selected=False, explicit_background=False, no_b if self.colors[key]["bgcolor"] is not None and match > best_match_bg: best_match_bg = match bgcolor = self.colors[key]["bgcolor"] - if bgcolor == "none": - bgcolor = self.special_colors['background']['color'] if not explicit_background else None - bgcolor_sim = ( - self.special_colors['background']['color_simulated'] if not explicit_background else None - ) - fgadj = None - else: - bgcolor_sim = self.colors[key]["bgcolor_simulated"] - fgadj = self.colors[key]["foreground_adjust"] + bgcolor_sim = self.colors[key]["bgcolor_simulated"] + fgadj = self.colors[key]["foreground_adjust"] bg_selector = SchemeSelectors(self.colors[key]["name"], self.colors[key]["scope"]) if len(style) == 0: diff --git a/messages/recent.md b/messages/recent.md index 36913d8..f5881ad 100644 --- a/messages/recent.md +++ b/messages/recent.md @@ -1,4 +1,4 @@ -# ScopeHunter 2.14.0 +# ScopeHunter 2.15.0 New release! diff --git a/popup.j2 b/popup.j2 index ff7654f..82a776c 100644 --- a/popup.j2 +++ b/popup.j2 @@ -1,172 +1,117 @@ -## Scope {: .header} +### Scope [(copy)](copy-scope:{{plugin.scope_index}}){: .small} {: .header} {{plugin.scope}} -[(copy)](copy-scope:{{plugin.scope_index}}){: .small} - {% if plugin.context_backtrace %} -## Scope Context Backtrace {: .header} +## Scope Context Backtrace [(copy)](copy-context-backtrace:{{plugin.context_backtrace_index}}){: .small} {: .header} {% for ctx in plugin.context_backtrace_stack %} **{{loop.index}}:**{: .keyword} {{ctx}} {% endfor %} -[(copy)](copy-context-backtrace:{{plugin.context_backtrace_index}}){: .small} {% endif %} {% if plugin.pt_extent or plugin.rowcol_extent %} -## Scope Extent {: .header} - {% if plugin.pt_extent %} -**pts:**{: .keyword} ({{plugin.extent_start}}, {{plugin.extent_end}}) - -[(copy)](copy-points:{{plugin.extent_pt_index}}){: .small} - - {% endif %} - {% if plugin.pt_extent or plugin.rowcol_extent %} -**line/char:**{: .keyword} (**Line:** {{plugin.l_start}} **Char:** {{plugin.c_start}}, **Line:** {{plugin.l_end}} **Char:** {{plugin.c_end}}) - -[(copy)](copy-line-char:{{plugin.line_char_index}}){: .small} - {% endif %} -{% endif %} - -{% if plugin.appearance %} -## Appearance {: .header} -**fg:**{: .keyword} {{plugin.fg_preview}} {{plugin.fg_color}} - -[(copy)](copy-fg:{{plugin.fg_index}}){: .small} +### Appearance {: .header} +**fg:**{: .keyword} {{plugin.fg_preview}} {{plugin.fg_color}} [(copy)](copy-fg:{{plugin.fg_index}}){: .small} {% if plugin.fg_sim %} -**fg (simulated alpha):**{: .keyword} {{plugin.fg_sim_preview}} {{plugin.fg_sim_color}} - -[(copy)](copy-fg-sim:{{plugin.fg_sim_index}}){: .small} +**fg (simulated alpha):**{: .keyword} {{plugin.fg_sim_preview}} {{plugin.fg_sim_color}} [(copy)](copy-fg-sim:{{plugin.fg_sim_index}}){: .small} {% endif %} {% if plugin.fg_hash %} -**hashed fg:**{: .keyword} {{plugin.fg_hash_preview}} {{plugin.fg_hash_color}} - -[(copy)](copy-fg-hash:{{plugin.fg_hash_index}}){: .small} +**hashed fg:**{: .keyword} {{plugin.fg_hash_preview}} {{plugin.fg_hash_color}} [(copy)](copy-fg-hash:{{plugin.fg_hash_index}}){: .small} {% endif %} {% if plugin.fg_hash_sim %} -**hashed fg (simulated alpha):**{: .keyword} {{plugin.fg_hash_sim_preview}} {{plugin.fg_hash_sim_color}} - -[(copy)](copy-fg-hash-sim:{{plugin.fg_hash_sim_index}}){: .small} +**hashed fg (simulated alpha):**{: .keyword} {{plugin.fg_hash_sim_preview}} {{plugin.fg_hash_sim_color}} [(copy)](copy-fg-hash-sim:{{plugin.fg_hash_sim_index}}){: .small} {% endif %} -**bg:**{: .keyword} {{plugin.bg_preview}} {{plugin.bg_color}} - -[(copy)](copy-bg:{{plugin.bg_index}}){: .small} +**bg:**{: .keyword} {{plugin.bg_preview}} {{plugin.bg_color}} [(copy)](copy-bg:{{plugin.bg_index}}){: .small} {% if plugin.bg_sim %} -**bg (simulated alpha):**{: .keyword} {{plugin.bg_sim_preview}} {{plugin.bg_sim_color}} - -[(copy)](copy-bg-sim:{{plugin.bg_sim_index}}){: .small} +**bg (simulated alpha):**{: .keyword} {{plugin.bg_sim_preview}} {{plugin.bg_sim_color}} [(copy)](copy-bg-sim:{{plugin.bg_sim_index}}){: .small} {% endif %} -**style:**{: .keyword} {{plugin.style_open}}{{plugin.style}}{{plugin.style_close}} - -[(copy)](copy-style:{{plugin.style_index}}){: .small} +**style:**{: .keyword} {{plugin.style_open}}{{plugin.style}}{{plugin.style_close}} [(copy)](copy-style:{{plugin.style_index}}){: .small} {% endif %} {% if plugin.selectors %} -## Selectors {: .header} - {% if plugin.fg_name %} -**fg name:**{: .keyword} {{plugin.fg_name}} - -[(copy)](copy-fg-sel-name:{{plugin.fg_name_index}}){: .small} +### Scope Extent {: .header} + {% if plugin.pt_extent %} +**pts:**{: .keyword} ({{plugin.extent_start}}, {{plugin.extent_end}}) [(copy)](copy-points:{{plugin.extent_pt_index}}){: .small} {% endif %} -**fg scope:**{: .keyword} {{plugin.fg_scope}} + {% if plugin.pt_extent or plugin.rowcol_extent %} +**line:char:**{: .keyword} ({{plugin.l_start}}:{{plugin.c_start}}, {{plugin.l_end}}:{{plugin.c_end}}) [(copy)](copy-line-char:{{plugin.line_char_index}}){: .small} + {% endif %} +{% endif %} -[(copy)](copy-fg-sel-scope:{{plugin.fg_scope_index}}){: .small} +{% if plugin.appearance %} +### Selectors {: .header} + {% if plugin.fg_name %} +**fg name:**{: .keyword} {{plugin.fg_name}} [(copy)](copy-fg-sel-name:{{plugin.fg_name_index}}){: .small} - {% if plugin.fg_hash_name %} -**hashed fg name:**{: .keyword} {{plugin.fg_hash_name}} + {% endif %} +**fg scope:**{: .keyword} [(copy)](copy-fg-sel-scope:{{plugin.fg_scope_index}}){: .small} {{plugin.fg_scope}} -[(copy)](copy-fg-hash-sel-name:{{plugin.fg_hash_name_index}}){: .small} + {% if plugin.fg_hash_name %} +**hashed fg name:**{: .keyword} {{plugin.fg_hash_name}} [(copy)](copy-fg-hash-sel-name:{{plugin.fg_hash_name_index}}){: .small} {% endif %} {% if plugin.fg_hash_scope %} -**hashed fg scope:**{: .keyword} {{plugin.fg_hash_scope}} - -[(copy)](copy-fg-hash-sel-scope:{{plugin.fg_hash_scope_index}}){: .small} +**hashed fg scope:**{: .keyword} [(copy)](copy-fg-hash-sel-scope:{{plugin.fg_hash_scope_index}}){: .small} {{plugin.fg_hash_scope}} {% endif %} {% if plugin.bg_name %} -**bg name:**{: .keyword} {{plugin.bg_name}} - -[(copy)](copy-bg-sel-name:{{plugin.bg_name_index}}){: .small} +**bg name:**{: .keyword} {{plugin.bg_name}} [(copy)](copy-bg-sel-name:{{plugin.bg_name_index}}){: .small} {% endif %} -**bg scope:**{: .keyword} {{plugin.bg_scope}} - -[(copy)](copy-bg-sel-scope:{{plugin.bg_scope_index}}){: .small} +**bg scope:**{: .keyword} [(copy)](copy-bg-sel-scope:{{plugin.bg_scope_index}}){: .small} {{plugin.bg_scope}} {% if plugin.bold %} {% if plugin.bold_name %} -**bold name:**{: .keyword} {{plugin.bold_name}} - -[(copy)](copy-bold-sel-name:{{plugin.bold_name_index}}){: .small} +**bold name:**{: .keyword} {{plugin.bold_name}} [(copy)](copy-bold-sel-name:{{plugin.bold_name_index}}){: .small} {% endif %} -**bold scope:**{: .keyword} {{plugin.bold_scope}} - -[(copy)](copy-bold-sel-scope:{{plugin.bold_scope_index}}){: .small} +**bold scope:**{: .keyword} [(copy)](copy-bold-sel-scope:{{plugin.bold_scope_index}}){: .small} {{plugin.bold_scope}} {% endif %} {% if plugin.italic %} {% if plugin.italic_name %} -**italic name:**{: .keyword} {{plugin.italic_name}} - -[(copy)](copy-italic-sel-name:{{plugin.italic_name_index}}){: .small} +**italic name:**{: .keyword} {{plugin.italic_name}} [(copy)](copy-italic-sel-name:{{plugin.italic_name_index}}){: .small} {% endif %} -**italic scope:**{: .keyword} {{plugin.italic_scope}} - -[(copy)](copy-italic-sel-scope:{{plugin.italic_scope_index}}){: .small} +**italic scope:**{: .keyword} [(copy)](copy-italic-sel-scope:{{plugin.italic_scope_index}}){: .small} {{plugin.italic_scope}} {% endif %} {% if plugin.underline %} {% if plugin.underline_name %} -**underline name:**{: .keyword} {{plugin.underline_name}} - -[(copy)](copy-underline-sel-name:{{plugin.glow_underline_index}}){: .small} +**underline name:**{: .keyword} {{plugin.underline_name}} [(copy)](copy-underline-sel-name:{{plugin.glow_underline_index}}){: .small} {% endif %} -**underline scope:**{: .keyword} {{plugin.underline_scope}} - -[(copy)](copy-underline-sel-scope:{{plugin.underline_scope_index}}){: .small} +**underline scope:**{: .keyword} [(copy)](copy-underline-sel-scope:{{plugin.underline_scope_index}}){: .small} {{plugin.underline_scope}} {% endif %} {% if plugin.glow %} {% if plugin.glow_name %} -**glow name:**{: .keyword} {{plugin.glow_name}} - -[(copy)](copy-glow-sel-name:{{plugin.glow_name_index}}){: .small} +**glow name:**{: .keyword} {{plugin.glow_name}} [(copy)](copy-glow-sel-name:{{plugin.glow_name_index}}){: .small} {% endif %} -**glow scope:**{: .keyword} {{plugin.glow_scope}} - -[(copy)](copy-glow-sel-scope:{{plugin.glow_scope_index}}){: .small} +**glow scope:**{: .keyword} [(copy)](copy-glow-sel-scope:{{plugin.glow_scope_index}}){: .small} {{plugin.glow_scope}} {% endif %} {% endif %} {% if plugin.files %} -## Files {: .header} -**syntax:**{: .keyword} [{{plugin.syntax}}](syntax) - -[(copy)](copy-syntax:{{plugin.syntax_index}}){: .small} +### Files {: .header} +**syntax:**{: .keyword} [{{plugin.syntax}}](syntax) [(copy)](copy-syntax:{{plugin.syntax_index}}){: .small} {% if plugin.scheme %} -**tmTheme:**{: .keyword} [{{plugin.scheme}}](scheme) - -[(copy)](copy-scheme:{{plugin.scheme_index}}){: .small} +**tmTheme:**{: .keyword} [{{plugin.scheme}}](scheme) [(copy)](copy-scheme:{{plugin.scheme_index}}){: .small} {% endif %} {% for item in plugin.overrides %} -**Scheme {{loop.index}}:**{: .keyword} [{{item}}](override:{{plugin.overrides_index}}:{{loop.index}}) - -[(copy)](copy-overrides:{{plugin.overrides_index}}:{{loop.index}}){: .small} +**Scheme {{loop.index}}:**{: .keyword} [{{item}}](override:{{plugin.overrides_index}}:{{loop.index}}) [(copy)](copy-overrides:{{plugin.overrides_index}}:{{loop.index}}){: .small} {% endfor %} {% endif %} diff --git a/scope_hunter.py b/scope_hunter.py index a13f5f3..c4961cd 100644 --- a/scope_hunter.py +++ b/scope_hunter.py @@ -13,6 +13,12 @@ from textwrap import dedent from ScopeHunter.lib.color_scheme_matcher import ColorSchemeMatcher import mdpopups +from coloraide import Color + +HEX = {"hex": True} +HEX_NA = {"hex": True, "alpha": False} +SRGB_SPACES = ('srgb', 'hsl', 'hwb') +SPACER = Color("transparent", filters=SRGB_SPACES).to_string(**HEX) SCOPE_CONTEXT_BACKTRACE_SUPPORT = int(sublime.version()) >= 4087 @@ -55,8 +61,8 @@ CONTEXT_BACKTRACE_KEY = "Scope Context Backtrace" PTS_KEY = "Scope Extents (Pts)" PTS_VALUE = "({:d}, {:d})" -CHAR_LINE_KEY = "Scope Extents (Line/Char)" -CHAR_LINE_VALUE = "(line: {:d} char: {:d}, line: {:d} char: {:d})" +CHAR_LINE_KEY = "Scope Extents (Line:Char)" +CHAR_LINE_VALUE = "({:d}:{:d}, {:d}:{:d})" FG_KEY = "Fg" FG_SIM_KEY = "Fg (Simulated Alpha)" BG_KEY = "Bg" @@ -94,6 +100,16 @@ def debug(msg): log(msg) +def scheme_scope_format(scope): + """Scheme scope format.""" + + return '\n\n{}'.format( + '\n'.join( + ['- {}'.format(x) for x in scope.split(',')] + ) + ) + + def extent_style(option): """Configure style of region based on option.""" @@ -164,9 +180,67 @@ def clear(cls): cls.pt = None -class GetSelectionScope(object): +class GetSelectionScope: """Get the scope and the selection(s).""" + def setup(self, sh_settings): + """Setup.""" + + self.show_out_of_gamut_preview = True + self.setup_image_border(sh_settings) + self.setup_sizes() + + def setup_image_border(self, sh_settings): + """Setup_image_border.""" + + border_color = sh_settings.get('image_border_color') + border_color = None + if border_color is not None: + try: + border_color = Color(border_color, filters=SRGB_SPACES) + border_color.fit("srgb", in_place=True) + except Exception: + border_color = None + + if border_color is None: + # Calculate border color for images + border_color = Color( + self.view.style()['background'], + filters=SRGB_SPACES + ).convert("hsl") + border_color.lightness = border_color.lightness + (30 if border_color.luminance() < 0.5 else -30) + + self.default_border = border_color.convert("srgb").to_string(**HEX) + self.out_of_gamut = Color("transparent", filters=SRGB_SPACES).to_string(**HEX) + self.out_of_gamut_border = Color( + self.view.style().get('redish', "red"), + filters=SRGB_SPACES + ).to_string(**HEX) + + def setup_sizes(self): + """Get sizes.""" + + # Calculate color box height + self.line_height = self.view.line_height() + top_pad = self.view.settings().get('line_padding_top', 0) + bottom_pad = self.view.settings().get('line_padding_bottom', 0) + if top_pad is None: + # Sometimes we strangely get None + top_pad = 0 + if bottom_pad is None: + bottom_pad = 0 + box_height = self.line_height - int(top_pad + bottom_pad) - 6 + + self.height = self.width = box_height * 2 + + def check_size(self, height, scale=4): + """Get checkered size.""" + + check_size = int((height - 2) / scale) + if check_size < 2: + check_size = 2 + return check_size + def init_template_vars(self): """Initialize template variables.""" @@ -181,23 +255,20 @@ def next_index(self): def get_color_box(self, color, key, index): """Display an HTML color box using the given color.""" - border = '#CCCCCC' - border2 = '#333333' - padding = int(self.view.settings().get('line_padding_top', 0)) - padding += int(self.view.settings().get('line_padding_bottom', 0)) - box_height = int(self.view.line_height()) - padding - 2 - check_size = int((box_height - 4) / 4) + border = self.default_border + box_height = int(self.height) + box_width = int(self.width) + check_size = int(self.check_size(box_height)) if isinstance(color, list): - box_width = box_height * (len(color) if len(color) >= 1 else 1) + box_width = box_width * (len(color) if len(color) >= 1 else 1) colors = [c.upper() for c in color] else: - box_width = box_height colors = [color.upper()] if check_size < 2: check_size = 2 self.template_vars['{}_preview'.format(key)] = mdpopups.color_box( - colors, border, border2, height=box_height, - width=box_width, border_size=2, check_size=check_size + colors, border, height=box_height, + width=box_width, border_size=1, check_size=check_size ) self.template_vars['{}_color'.format(key)] = ', '.join(colors) self.template_vars['{}_index'.format(key)] = index @@ -258,7 +329,7 @@ def get_scope(self, pt): self.scope_bfr.append(ENTRY.format(SCOPE_KEY + ':', self.view.scope_name(pt).strip().replace(" ", spacing))) - self.template_vars['scope'] = self.view.scope_name(pt).strip() + self.template_vars['scope'] = '
'.join(self.view.scope_name(pt).strip().split(' ')) self.template_vars['scope_index'] = self.next_index() return scope @@ -412,40 +483,40 @@ def get_selectors(self, color_selector, bg_selector, style_selectors, color_grad self.template_vars['selectors'] = True self.template_vars['fg_name'] = color_selector.name self.template_vars['fg_name_index'] = self.next_index() - self.template_vars['fg_scope'] = color_selector.scope + self.template_vars['fg_scope'] = scheme_scope_format(color_selector.scope) self.template_vars['fg_scope_index'] = self.next_index() if color_gradient_selector: self.template_vars['fg_hash_name'] = color_gradient_selector.name self.template_vars['fg_hash_name_index'] = self.next_index() - self.template_vars['fg_hash_scope'] = color_gradient_selector.scope + self.template_vars['fg_hash_scope'] = scheme_scope_format(color_gradient_selector.scope) self.template_vars['fg_hash_scope_index'] = self.next_index() self.template_vars['bg_name'] = bg_selector.name self.template_vars['bg_name_index'] = self.next_index() - self.template_vars['bg_scope'] = bg_selector.scope + self.template_vars['bg_scope'] = scheme_scope_format(bg_selector.scope) self.template_vars['bg_scope_index'] = self.next_index() if style_selectors["bold"].name != "" or style_selectors["bold"].scope != "": self.template_vars['bold'] = True self.template_vars['bold_name'] = style_selectors["bold"].name self.template_vars['bold_name_index'] = self.next_index() - self.template_vars['bold_scope'] = style_selectors["bold"].scope + self.template_vars['bold_scope'] = scheme_scope_format(style_selectors["bold"].scope) self.template_vars['bold_scope_index'] = self.next_index() if style_selectors["italic"].name != "" or style_selectors["italic"].scope != "": self.template_vars['italic'] = True self.template_vars['italic_name'] = style_selectors["italic"].name self.template_vars['italic_name_index'] = self.next_index() - self.template_vars['italic_scope'] = style_selectors["italic"].scope + self.template_vars['italic_scope'] = scheme_scope_format(style_selectors["italic"].scope) self.template_vars['italic_scope_index'] = self.next_index() if style_selectors["underline"].name != "" or style_selectors["underline"].scope != "": self.template_vars['underline'] = True self.template_vars['underline_name'] = style_selectors["underline"].name self.template_vars['underline_name_index'] = self.next_index() - self.template_vars['underline_scope'] = style_selectors["underline"].scope + self.template_vars['underline_scope'] = scheme_scope_format(style_selectors["underline"].scope) self.template_vars['underline_scope_index'] = self.next_index() if style_selectors["glow"].name != "" or style_selectors["glow"].scope != "": self.template_vars['glow'] = True self.template_vars['glow_name'] = style_selectors["glow"].name self.template_vars['glow_name_index'] = self.next_index() - self.template_vars['glow_scope'] = style_selectors["glow"].scope + self.template_vars['glow_scope'] = scheme_scope_format(style_selectors["glow"].scope) self.template_vars['glow_scope_index'] = self.next_index() def get_info(self, pt): @@ -625,6 +696,8 @@ def run(self, v): """Run ScopeHunter and display in the approriate way.""" self.view = v + self.setup(sh_settings) + self.window = self.view.window() self.scope_bfr = [] self.scope_bfr_tool = [] diff --git a/scope_hunter.sublime-settings b/scope_hunter.sublime-settings index 20ec499..7ac29cd 100644 --- a/scope_hunter.sublime-settings +++ b/scope_hunter.sublime-settings @@ -67,5 +67,14 @@ "highlight_max_size": 100, // Use SubNotify plugin messages if installed - "use_sub_notify": true + "use_sub_notify": true, + + /////////////////////////// + // Graphics + /////////////////////////// + + // By default, image border is calculated based on theme background, but if for + // some reason, it isn't sufficient in your popup, set it to any color using + // valid CSS for RGB, HSL, or HWB colors. + "image_border_color": null } diff --git a/support.py b/support.py index 6ebc77f..273be10 100644 --- a/support.py +++ b/support.py @@ -88,6 +88,12 @@ def run(self): info["arch"] = sublime.arch() info["plugin_version"] = __version__ info["pc_install"] = is_installed_by_package_control() + try: + import coloraide + info["coloraide"] = format_version(coloraide, '__version__') + except Exception: + info["coloraide"] = 'Version could not be acquired!' + try: import mdpopups info["mdpopups_version"] = format_version(mdpopups, 'version', call=True) @@ -114,16 +120,17 @@ def run(self): msg = textwrap.dedent( """\ - - ST ver.: %(version)s - - Platform: %(platform)s - - Arch: %(arch)s - - Plugin ver.: %(plugin_version)s - - Install via PC: %(pc_install)s - - mdpopups ver.: %(mdpopups_version)s - - markdown ver.: %(markdown_version)s - - pygments ver.: %(pygments_version)s - - jinja2 ver.: %(jinja_version)s - """ % info + - ST ver.: {version} + - Platform: {platform} + - Arch: {arch} + - Plugin ver.: {plugin_version} + - Install via PC: {pc_install} + - coloraide ver.: {coloraide} + - mdpopups ver.: {mdpopups_version} + - markdown ver.: {markdown_version} + - pygments ver.: {pygments_version} + - jinja2 ver.: {jinja_version} + """.format(**info) ) sublime.message_dialog(msg + '\nInfo has been copied to the clipboard.') @@ -157,9 +164,8 @@ def run(self, page): try: import mdpopups - import pymdownx has_phantom_support = (mdpopups.version() >= (1, 10, 0)) and (int(sublime.version()) >= 3124) - fmatter = mdpopups.format_frontmatter(frontmatter) if pymdownx.version_info[:3] >= (4, 3, 0) else '' + fmatter = mdpopups.format_frontmatter(frontmatter) except Exception: fmatter = '' has_phantom_support = False