def is_enabled(self):
        try:
            import mdpopups
        except Exception:
            return False

        return (mdpopups.version() >= (1, 7, 3)) and (int(sublime.version()) >= 3118)
Beispiel #2
0
    def run(self):
        """Show the changelog in a new view."""
        try:
            import mdpopups
            has_phantom_support = (mdpopups.version() >= (1, 10, 0)) and (int(sublime.version()) >= 3118)
        except Exception:
            has_phantom_support = False

        text = sublime.load_resource('Packages/ApplySyntax/CHANGES.md')
        view = self.window.new_file()
        view.set_name('ApplySyntax - Changelog')
        view.settings().set('gutter', False)
        if has_phantom_support:
            mdpopups.add_phantom(
                view,
                'changelog',
                sublime.Region(0),
                text,
                sublime.LAYOUT_INLINE,
                wrapper_class="apply-syntax",
                css=CSS
            )
        else:
            view.run_command('insert', {"characters": text})
        view.set_read_only(True)
        view.set_scratch(True)
Beispiel #3
0
 def is_visible(self):
     try:
         import mdpopups
     except Exception as e:
         return False
     return (mdpopups.version() >=
             (1, 7, 3)) and (int(sublime.version()) >= 3118)
Beispiel #4
0
    def run(self):
        """Show the changelog in a new view."""
        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 ''
        except Exception:
            fmatter = ''
            has_phantom_support = False

        text = sublime.load_resource('Packages/QuickCal/CHANGES.md')
        view = self.window.new_file()
        view.set_name('QuickCal - Changelog')
        view.settings().set('gutter', False)
        view.settings().set('word_wrap', False)
        if has_phantom_support:
            mdpopups.add_phantom(
                view,
                'changelog',
                sublime.Region(0),
                fmatter + text,
                sublime.LAYOUT_INLINE,
                wrapper_class="quick-cal",
                css=CSS,
                on_navigate=self.on_navigate
            )
        else:
            view.run_command('insert', {"characters": text})
        view.set_read_only(True)
        view.set_scratch(True)
Beispiel #5
0
    def run(self):
        """Show the changelog in a new view."""
        try:
            import mdpopups
            has_phantom_support = (mdpopups.version() >= (1, 10, 0)) and (int(sublime.version()) >= 3118)
        except Exception:
            has_phantom_support = False

        text = sublime.load_resource('Packages/BracketHighlighter/CHANGES.md')
        view = self.window.new_file()
        view.set_name('BracketHighlighter - Changelog')
        view.settings().set('gutter', False)
        view.settings().set('word_wrap', False)
        if has_phantom_support:
            mdpopups.add_phantom(
                view,
                'changelog',
                sublime.Region(0),
                text,
                sublime.LAYOUT_INLINE,
                wrapper_class="bracket-highlighter",
                css=CSS,
                on_navigate=self.on_navigate
            )
        else:
            view.run_command('insert', {"characters": text})
        view.set_read_only(True)
        view.set_scratch(True)
Beispiel #6
0
    def run(self, page):
        """Open 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 ''
        except Exception:
            fmatter = ''
            has_phantom_support = False

        if not has_phantom_support:
            sublime.run_command('open_file', {"file": page})
        else:
            text = sublime.load_resource(page.replace('${packages}', 'Packages'))
            view = self.window.new_file()
            view.set_name('QuickCal - Quick Start')
            view.settings().set('gutter', False)
            view.settings().set('word_wrap', False)
            if has_phantom_support:
                mdpopups.add_phantom(
                    view,
                    'quickstart',
                    sublime.Region(0),
                    fmatter + text,
                    sublime.LAYOUT_INLINE,
                    css=CSS,
                    wrapper_class="quick-cal",
                    on_navigate=self.on_navigate
                )
            else:
                view.run_command('insert', {"characters": text})
            view.set_read_only(True)
            view.set_scratch(True)
  def is_enabled(self):
      try:
          import mdpopups
      except Exception:
          return False

      return (mdpopups.version() >= (1, 9, 0)) and (int(sublime.version()) >= 3119)
Beispiel #8
0
    def run(self, page):
        """Open page."""

        try:
            import mdpopups
            has_phantom_support = (mdpopups.version() >= (1, 10, 0)) and (int(sublime.version()) >= 3118)
        except Exception:
            has_phantom_support = False

        if not has_phantom_support:
            sublime.run_command('open_file', {"file": page})
        else:
            text = sublime.load_resource(page.replace('${packages}', 'Packages'))
            view = self.window.new_file()
            view.set_name('ExportHtml - Quick Start')
            view.settings().set('gutter', False)
            view.settings().set('word_wrap', False)
            if has_phantom_support:
                mdpopups.add_phantom(
                    view,
                    'quickstart',
                    sublime.Region(0),
                    text,
                    sublime.LAYOUT_INLINE,
                    css=CSS,
                    wrapper_class="export-html",
                    on_navigate=self.on_navigate
                )
            else:
                view.run_command('insert', {"characters": text})
            view.set_read_only(True)
            view.set_scratch(True)
Beispiel #9
0
    def run(self, page):
        """Open 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 ''
        except Exception:
            fmatter = ''
            has_phantom_support = False

        if not has_phantom_support:
            sublime.run_command('open_file', {"file": page})
        else:
            text = sublime.load_resource(page.replace('${packages}', 'Packages'))
            view = self.window.new_file()
            view.set_name('SubNotify - Quick Start')
            view.settings().set('gutter', False)
            view.settings().set('word_wrap', False)
            if has_phantom_support:
                mdpopups.add_phantom(
                    view,
                    'quickstart',
                    sublime.Region(0),
                    fmatter + text,
                    sublime.LAYOUT_INLINE,
                    css=CSS,
                    wrapper_class="sub-notify",
                    on_navigate=self.on_navigate
                )
            else:
                view.run_command('insert', {"characters": text})
            view.set_read_only(True)
            view.set_scratch(True)
Beispiel #10
0
    def run(self, page):
        """Open page."""

        try:
            import mdpopups
            has_phantom_support = (mdpopups.version() >= (1, 10, 0)) and (int(sublime.version()) >= 3118)
        except Exception:
            has_phantom_support = False

        if not has_phantom_support:
            sublime.run_command('open_file', {"file": page})
        else:
            text = sublime.load_resource(page.replace('${packages}', 'Packages'))
            view = self.window.new_file()
            view.set_name('BracketHighlighter - Quick Start')
            view.settings().set('gutter', False)
            view.settings().set('word_wrap', False)
            if has_phantom_support:
                mdpopups.add_phantom(
                    view,
                    'quickstart',
                    sublime.Region(0),
                    text,
                    sublime.LAYOUT_INLINE,
                    css=CSS,
                    wrapper_class="bracket-highlighter",
                    on_navigate=self.on_navigate
                )
            else:
                view.run_command('insert', {"characters": text})
            view.set_read_only(True)
            view.set_scratch(True)
Beispiel #11
0
    def run(self):
        """Show the changelog in a new view."""
        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 ''
        except Exception:
            fmatter = ''
            has_phantom_support = False

        text = sublime.load_resource('Packages/ExportHtml/CHANGES.md')
        view = self.window.new_file()
        view.set_name('ExportHtml - Changelog')
        view.settings().set('gutter', False)
        view.settings().set('word_wrap', False)
        if has_phantom_support:
            mdpopups.add_phantom(view,
                                 'changelog',
                                 sublime.Region(0),
                                 fmatter + text,
                                 sublime.LAYOUT_INLINE,
                                 wrapper_class="export-html",
                                 css=CSS,
                                 on_navigate=self.on_navigate)
        else:
            view.run_command('insert', {"characters": text})
        view.set_read_only(True)
        view.set_scratch(True)
 def show_popup_between(self, view, point, region, region2, icon):
     """Show popup between."""
     if HOVER_SUPPORT:
         markup = ''
         if not self.is_bracket_visible(view, region):
             markup += self.get_markup(view, point, region, icon)
         if not self.is_bracket_visible(view, region2):
             markup += '\n\n'
             markup += self.get_markup(view, point, region2, icon)
         if markup:
             self.popup_view = view
             mdpopups.show_popup(
                 view,
                 markup,
                 wrapper_class=WRAPPER_CLASS,
                 css=CSS,
                 flags=sublime.HIDE_ON_MOUSE_MOVE_AWAY,
                 max_width=800,
                 location=point,
                 on_navigate=self.on_navigate,
                 template_vars={'mdpopups_version': mdpopups.version()},
                 template_env_options=template_options
             )
         else:
             self.show_unmatched_popup(view, point)
Beispiel #13
0
    def is_enabled(self):
        """Check if is enabled."""
        try:
            import mdpopups
        except Exception:
            return False

        return (mdpopups.version() >=
                (1, 7, 3)) and (int(sublime.version()) >= 3118)
Beispiel #14
0
    def show_unmatched_popup(self, view, point):
        """Show unmatched popup."""

        if HOVER_SUPPORT:
            self.popup_view = view
            mdpopups.show_popup(
                view,
                textwrap.dedent(MATCH_ERR % {"pt": str(point)}),
                wrapper_class=WRAPPER_CLASS,
                flags=sublime.HIDE_ON_MOUSE_MOVE_AWAY,
                css=CSS,
                max_width=800,
                max_height=800,
                location=point,
                on_navigate=self.on_navigate_unmatched,
                template_vars={'mdpopups_version': mdpopups.version()})
Beispiel #15
0
    def show_popup(self, view, point, region, icon):
        """Show the popup."""

        if HOVER_SUPPORT:
            if not self.is_bracket_visible(view, region):
                markup = self.get_markup(view, point, region, icon)

                self.popup_view = view
                mdpopups.show_popup(
                    view,
                    markup,
                    wrapper_class=WRAPPER_CLASS,
                    css=CSS,
                    flags=sublime.HIDE_ON_MOUSE_MOVE_AWAY,
                    max_width=800,
                    location=point,
                    on_navigate=self.on_navigate,
                    template_vars={'mdpopups_version': mdpopups.version()})
    def show_unmatched_popup(self, view, point):
        """Show unmatched popup."""

        if HOVER_SUPPORT:
            self.popup_view = view
            mdpopups.show_popup(
                view,
                textwrap.dedent(MATCH_ERR % {"pt": str(point)}),
                wrapper_class=WRAPPER_CLASS,
                flags=sublime.HIDE_ON_MOUSE_MOVE_AWAY,
                css=CSS,
                max_width=800,
                max_height=800,
                location=point,
                on_navigate=self.on_navigate_unmatched,
                template_vars={'mdpopups_version': mdpopups.version()},
                template_env_options=template_options
            )
    def show_popup(self, view, point, region, icon):
        """Show the popup."""

        if HOVER_SUPPORT:
            if not self.is_bracket_visible(view, region):
                markup = self.get_markup(view, point, region, icon)

                self.popup_view = view
                mdpopups.show_popup(
                    view,
                    markup,
                    wrapper_class=WRAPPER_CLASS,
                    css=CSS,
                    flags=sublime.HIDE_ON_MOUSE_MOVE_AWAY,
                    max_width=800,
                    location=point,
                    on_navigate=self.on_navigate,
                    template_vars={'mdpopups_version': mdpopups.version()},
                    template_env_options=template_options
                )
Beispiel #18
0
 def show_popup_between(self, view, point, region, region2, icon):
     """Show popup between."""
     if HOVER_SUPPORT:
         markup = ''
         if not self.is_bracket_visible(view, region):
             markup += self.get_markup(view, point, region, icon)
         if not self.is_bracket_visible(view, region2):
             markup += '\n\n'
             markup += self.get_markup(view, point, region2, icon)
         if markup:
             self.popup_view = view
             mdpopups.show_popup(
                 view,
                 markup,
                 wrapper_class=WRAPPER_CLASS,
                 css=CSS,
                 flags=sublime.HIDE_ON_MOUSE_MOVE_AWAY,
                 max_width=800,
                 location=point,
                 on_navigate=self.on_navigate,
                 template_vars={'mdpopups_version': mdpopups.version()})
         else:
             self.show_unmatched_popup(view, point)
Beispiel #19
0
def _show_diff_popup_impl(view, point, highlight_diff, flags, diff_info):
    (deleted_lines, start, size, meta) = diff_info
    if start == -1:
        return

    line = view.rowcol(point)[0] + 1
    # extract the type of the hunk: removed, modified, (x)or added
    is_removed = size == 0
    is_modified = not is_removed and bool(deleted_lines)
    is_added = not is_removed and not is_modified

    def navigate(href):
        if href == "hide":
            view.hide_popup()
        elif href == "revert":
            new_text = "\n".join(deleted_lines)
            # (removed) if there is no text to remove, set the
            # region to the end of the line, where the hunk starts
            # and add a new line to the start of the text
            if is_removed:
                if start != 0:
                    # set the start and the end to the end of the start line
                    start_point = end_point = view.text_point(start, 0) - 1
                    # add a leading newline before inserting the text
                    new_text = "\n" + new_text
                else:
                    # (special handling for deleted at the start of the file)
                    # if we are before the start we need to set the start
                    # to 0 and add the newline behind the text
                    start_point = end_point = 0
                    new_text = new_text + "\n"
            # (modified/added)
            # set the start point to the start of the hunk
            # and the end point to the end of the hunk
            else:
                start_point = view.text_point(start - 1, 0)
                end_point = view.text_point(start + size - 1, 0)
                # (modified) if there is text to insert, we
                # don't want to capture the trailing newline,
                # because we insert lines without a trailing newline
                if is_modified and end_point != view.size():
                    end_point -= 1
            replace_param = {
                "a": start_point,
                "b": end_point,
                "text": new_text
            }
            view.run_command("git_gutter_replace_text", replace_param)
            # hide the popup and update the gutter
            view.hide_popup()
            view.run_command("git_gutter")
        elif href in ["disable_hl_diff", "enable_hl_diff"]:
            do_diff = {
                "disable_hl_diff": False,
                "enable_hl_diff": True
            }.get(href)
            # show a diff popup with the same diff info
            _show_diff_popup_impl(
                view, point, highlight_diff=do_diff, flags=0,
                diff_info=diff_info)
        elif href == "copy":
            sublime.set_clipboard("\n".join(deleted_lines))
            copy_message = "  ".join(l.strip() for l in deleted_lines)
            sublime.status_message("Copied: " + copy_message)
        elif href in ["next_change", "prev_change", "first_change"]:
            next_line = meta.get(href, line)
            pt = view.text_point(next_line - 1, 0)

            def show_new_popup():
                if view.visible_region().contains(pt):
                    popup_kwargs = {
                        'action': 'show_diff_popup',
                        'highlight_diff': highlight_diff,
                        'point': pt,
                        'flags': 0
                    }
                    view.run_command('git_gutter', popup_kwargs)
                else:
                    sublime.set_timeout(show_new_popup, 10)
            view.show_at_center(pt)
            show_new_popup()

    # write the symbols/text for each button
    use_icons = settings.get("diff_popup_use_icon_buttons")

    # the buttons as a map from the href to the caption/icon
    button_descriptions = {
        "hide": chr(0x00D7) if use_icons else "(close)",
        "copy": chr(0x2398) if use_icons else "(copy)",
        "revert": chr(0x27F2) if use_icons else "(revert)",
        "disable_hl_diff": chr(0x2249) if use_icons else "(diff)",
        "enable_hl_diff": chr(0x2248) if use_icons else "(diff)",
        "first_change": chr(0x2912) if use_icons else "(first)",
        "prev_change": chr(0x2191) if use_icons else "(previous)",
        "next_change": chr(0x2193) if use_icons else "(next)"
    }

    def is_button_enabled(k):
        if k in ["first_change", "next_change", "prev_change"]:
            return meta.get(k, start) != start
        return True
    buttons = {}
    for k, v in button_descriptions.items():
        if is_button_enabled(k):
            button = '<a href={1}>{0}</a>'.format(v, k)
        else:
            button = v
        buttons[k] = (
            '<span class="gitgutter-button">{0}</span>'
            .format(button)
        )

    if highlight_diff:
        # (*) show a highlighted diff of the merged git and editor content
        min_indent = _get_min_indent(deleted_lines + meta["added_lines"])

        old_content = "\n".join(l[min_indent:] for l in deleted_lines)
        new_content = "\n".join(l[min_indent:] for l in meta["added_lines"])
        source_html = _highlight_diff(old_content, new_content)

        button_line = (
            '{hide} '
            '{first_change} {prev_change} {next_change} '
            '{disable_hl_diff} {revert}'
            .format(**buttons)
        )
        content = (
            '{button_line}'
            '{source_html}'
            .format(**locals())
        )
    elif not is_added:
        # (modified/removed) show the button line above the content,
        # which in git
        lang = mdpopups.get_language_from_view(view) or ""
        # strip the indent to the minimal indentation
        is_tab_indent = any(l.startswith("\t") for l in deleted_lines)
        indent_char = "\t" if is_tab_indent else " "
        min_indent = _get_min_indent(deleted_lines)
        source_content = "\n".join(l[min_indent:] for l in deleted_lines)
        # replace spaces by non-breakable ones to avoid line wrapping
        # (this has been added to mdpopups in version 1.11.0)
        if mdpopups.version() < (1, 11, 0):
            source_content = source_content.replace(" ", "\u00A0")
        source_html = mdpopups.syntax_highlight(
            view, source_content, language=lang)
        button_line = (
            '{hide} '
            '{first_change} {prev_change} {next_change} '
            '{enable_hl_diff} {copy} {revert}'
            .format(**buttons)
        )
        content = (
            '{button_line}'
            '{source_html}'
            .format(**locals())
        )
    else:
        # (added) only show the button line without the copy button
        # (there is nothing to show or copy)
        button_line = (
            '{hide} '
            '{first_change} {prev_change} {next_change} '
            '{enable_hl_diff} {revert}'
            .format(**buttons)
        )
        content = button_line
    css = ''
    if _MD_POPUPS_USE_WRAPPER_CLASS:
        wrapper_class = ".git-gutter"
    else:
        wrapper_class = ""

    # load the user css file
    css = sublime.load_resource("Packages/GitGutter/gitgutter_popup.css")
    try:
        user_css = sublime.load_resource("Packages/User/gitgutter_popup.css")
        css += "\n"
        css += user_css
    except OSError:
        pass

    # apply the jinja template
    jinja_kwargs = {
        "wrapper_class": wrapper_class,
        "use_icons": use_icons
    }
    tmpl = jinja2.environment.Template(css)
    css = tmpl.render(**jinja_kwargs)

    # create the popup
    location = view.line(point).a
    window_width = int(view.viewport_extent()[0])
    mdpopups.show_popup(
        view, content, location=location, on_navigate=navigate, md=False,
        wrapper_class=wrapper_class[1:], css=css,
        flags=flags, max_width=window_width)
Beispiel #20
0
Copyright (c) 2015 - 2016 Isaac Muse <*****@*****.**>
License: MIT
"""
import mdpopups
from mdpopups import colorbox
import sublime
import sublime_plugin
from ColorHelper.lib import csscolors
import ColorHelper.color_helper_util as util
import copy
from ColorHelper.multiconf import get as qualify_settings

DISTORTION_FIX = int(sublime.version()) < 3118

try:
    popupver = mdpopups.version()
except Exception:
    popupver = (0, 0, 0)

BORDER_MAP_SUPPORT = popupver >= (1, 3, 0)

color_map_data = [
    ['036', '369', '36c', '039', '009', '00c', '006'],
    ['066', '069', '09c', '06c', '03c', '00f', '33f', '339'],
    ['699', '099', '3cc', '0cf', '09f', '06f', '36f', '33c', '669'],
    ['396', '0c9', '0fc', '0ff', '3cf', '39f', '69f', '66f', '60f', '60c'],
    [
        '393', '0c6', '0f9', '6fc', '6ff', '6cf', '9cf', '99f', '96f', '93f',
        '90f'
    ],
    [
Beispiel #21
0
# -*- coding: utf-8 -*-
import html
import re

import sublime

try:
    # mdpopups needs 3119+ for wrapper_class, which diff popup relies on
    if int(sublime.version()) < 3119:
        raise ImportError('Sublime Text 3119+ required.')

    import mdpopups

    # mdpopups 1.9.0+ is required because of wrapper_class and templates
    if mdpopups.version() < (1, 9, 0):
        raise ImportError('mdpopups 1.9.0+ required.')

    _HAVE_MDPOPUPS = True
except ImportError:
    _HAVE_MDPOPUPS = False

from .base import Tooltip


class MarkDownTooltip(Tooltip):

    @classmethod
    def guess(cls, docstring):
        return _HAVE_MDPOPUPS

    def _get_style(self):
"""Popup color picker."""
import mdpopups
from mdpopups import colorbox
import sublime
import sublime_plugin
from ColorHelper.lib import csscolors
import ColorHelper.color_helper_util as util
import copy

try:
    popupver = mdpopups.version()
except Exception:
    popupver = (0, 0, 0)

BORDER_MAP_SUPPORT = popupver >= (1, 3, 0)

color_map_data = [
    ['036', '369', '36c', '039', '009', '00c', '006'],
    ['066', '069', '09c', '06c', '03c', '00f', '33f', '339'],
    ['699', '099', '3cc', '0cf', '09f', '06f', '36f', '33c', '669'],
    ['396', '0c9', '0fc', '0ff', '3cf', '39f', '69f', '66f', '60f', '60c'],
    ['393', '0c6', '0f9', '6fc', '6ff', '6cf', '9cf', '99f', '96f', '93f', '90f'],
    ['060', '0c0', '0f0', '6f9', '9fc', 'cff', 'ccf', 'c9f', 'c6f', 'c3f', 'c0f', '90c'],
    ['030', '093', '3c3', '6f6', '9f9', 'cfc', 'fff', 'fcf', 'f9f', 'f6f', 'f0f', 'c0c', '606'],
    ['360', '090', '6f3', '9f6', 'cf9', 'ffc', 'fcc', 'f9c', 'f6c', 'f3c', 'c09', '939'],
    ['330', '690', '9f3', 'cf6', 'ff9', 'fc9', 'f99', 'f69', 'f39', 'c39', '909'],
    ['663', '9c0', 'cf3', 'ff6', 'fc6', 'f96', 'f66', 'f06', 'c69', '936'],
    ['996', 'cc0', 'ff0', 'fc0', 'f93', 'f60', 'ff5050', 'c06', '603'],
    ['963', 'c90', 'f90', 'c60', 'f30', 'f00', 'c00', '903'],
    ['630', '960', 'c30', '930', '900', '800000', '933']
]
Beispiel #23
0
"""
ColorHelper.

Copyright (c) 2015 - 2016 Isaac Muse <*****@*****.**>
License: MIT
"""
import sublime
import re
import decimal
from ColorHelper.lib import csscolors
from ColorHelper.lib.rgba import RGBA, round_int, clamp
from textwrap import dedent
import mdpopups
RELATIVE_FONT_SUPPORT = mdpopups.version() >= (1, 7, 2)
BETTER_RELATIVE_FONT_SUPPORT = mdpopups.version() >= (1, 8, 0)

FLOAT_TRIM_RE = re.compile(r'^(?P<keep>\d+)(?P<trash>\.0+|(?P<keep2>\.\d*[1-9])0+)$')

COLOR_PARTS = {
    "percent": r"[+\-]?(?:(?:\d*\.\d+)|\d+)%",
    "float": r"[+\-]?(?:(?:\d*\.\d+)|\d+)"
}

COMPLETE = r'''
    (?P<hexa>\#(?P<hexa_content>[\dA-Fa-f]{8}))\b |
    (?P<hex>\#(?P<hex_content>[\dA-Fa-f]{6}))\b |
    (?P<hexa_compressed>\#(?P<hexa_compressed_content>[\dA-Fa-f]{4}))\b |
    (?P<hex_compressed>\#(?P<hex_compressed_content>[\dA-Fa-f]{3}))\b |
    \b(?P<rgb>rgb\(\s*(?P<rgb_content>(?:%(float)s\s*,\s*){2}%(float)s | (?:%(percent)s\s*,\s*){2}%(percent)s)\s*\)) |
    \b(?P<rgba>rgba\(\s*(?P<rgba_content>
        (?:%(float)s\s*,\s*){3}(?:%(percent)s|%(float)s) | (?:%(percent)s\s*,\s*){3}(?:%(percent)s|%(float)s)
Beispiel #24
0
# -*- coding: utf-8 -*-
import html
import re

import sublime

try:
    # mdpopups needs 3119+ for wrapper_class, which diff popup relies on
    if int(sublime.version()) < 3119:
        raise ImportError('Sublime Text 3119+ required.')

    import mdpopups

    # mdpopups 1.9.0+ is required because of wrapper_class and templates
    if mdpopups.version() < (1, 9, 0):
        raise ImportError('mdpopups 1.9.0+ required.')

    _HAVE_MDPOPUPS = True
except ImportError:
    _HAVE_MDPOPUPS = False

from .base import Tooltip


class MarkDownTooltip(Tooltip):

    @classmethod
    def guess(cls, docstring):
        return _HAVE_MDPOPUPS

    def _get_style(self):
Beispiel #25
0
# -*- coding: utf-8 -*-
"""Diff Popup Module initialization.

Check dependencies and enable/disable diff popup.
Declare public API functions.
"""
try:
    # mdpopups 2.0.0+ is required
    import mdpopups
    if mdpopups.version() < (2, 0, 0):
        raise ImportError('mdpopups 2.0.0+ required.')

    # mdpopups 2.0.0+ requires Sublime Text 3124+
    import sublime
    if int(sublime.version()) < 3124:
        raise ImportError('Sublime Text 3124+ required.')

    # public function
    from .factory import show_diff_popup
except ImportError:
    show_diff_popup = None
Handles popups.
"""
import sublime
import re
import textwrap
import traceback
from BracketHighlighter.bh_logging import log

HOVER_SUPPORT = int(sublime.version()) >= 3116
WRAPPER_CLASS = "bracket-highlighter"
CSS = '.bracket-highlighter { padding: 0; margin: 0; }\n'
if HOVER_SUPPORT:
    import mdpopups
    # This is the version with the latest mdpopus
    LATEST_SUPPORTED_MDPOPUPS = mdpopups.version() >= (1, 9, 0)


class BhOffscreenPopup(object):
    """Handle offscreen popups."""

    popup_view = None

    def on_navigate(self, href):
        """Navigate to code position."""
        if HOVER_SUPPORT:
            try:
                pt = int(href)
                self.popup_view.sel().clear()
                self.popup_view.sel().add(sublime.Region(pt))
                self.popup_view.show(pt)
Beispiel #27
0
# -*- coding: utf-8 -*-
"""Diff Popup Module initialization.

Check dependencies and enable/disable diff popup.
Declare public API functions.
"""
try:
    # mdpopups needs 3119+ for wrapper_class, which diff popup relies on
    import sublime
    if int(sublime.version()) < 3119:
        raise ImportError('Sublime Text 3119+ required.')

    # mdpopups 1.9.0+ is required because of wrapper_class and templates
    import mdpopups
    if mdpopups.version() < (1, 9, 0):
        raise ImportError('mdpopups 1.9.0+ required.')

    # mdpopups 2.0.0+ requires Sublime Text 3124+
    if mdpopups.version() >= (2, 0, 0) and int(sublime.version()) < 3124:
        raise ImportError('Sublime Text 3124+ required.')

    # public Sublime Text Commands
    from .commands import (GitGutterDiffPopupCommand,
                           GitGutterReplaceTextCommand)
    # public function
    from .factory import show_diff_popup
except ImportError:
    # Some dummy interface objects to avoid import errors
    GitGutterDiffPopupCommand = None
    GitGutterReplaceTextCommand = None
    show_diff_popup = None
Beispiel #28
0
Handles popups.
"""
import sublime
import re
import textwrap
import traceback
from BracketHighlighter.bh_logging import log

HOVER_SUPPORT = int(sublime.version()) >= 3116
WRAPPER_CLASS = "bracket-highlighter"
CSS = '.bracket-highlighter { padding: 0; margin: 0; }\n'
if HOVER_SUPPORT:
    import mdpopups
    # This is the version with the latest mdpopus
    LATEST_SUPPORTED_MDPOPUPS = mdpopups.version() >= (1, 9, 0)


class BhOffscreenPopup(object):
    """Handle offscreen popups."""

    popup_view = None

    def on_navigate(self, href):
        """Navigate to code position."""
        if HOVER_SUPPORT:
            try:
                pt = int(href)
                self.popup_view.sel().clear()
                self.popup_view.sel().add(sublime.Region(pt))
                self.popup_view.show(pt)