コード例 #1
0
    def show_color_info(self, update=False):
        """Show the color under the cursor."""

        color = self.get_cursor_color()
        template_vars = {}

        if color is not None:
            html = []

            html.append(self.format_info(color, template_vars))

            if update:
                mdpopups.update_popup(
                    self.view,
                    util.FRONTMATTER + sublime.load_resource(
                        'Packages/ColorHelper/panels/info.html'),
                    wrapper_class="color-helper content",
                    css=util.ADD_CSS,
                    template_vars=template_vars)
            else:
                mdpopups.show_popup(
                    self.view,
                    util.FRONTMATTER + sublime.load_resource(
                        'Packages/ColorHelper/panels/info.html'),
                    wrapper_class="color-helper content",
                    css=util.ADD_CSS,
                    location=-1,
                    max_width=1024,
                    max_height=512,
                    on_navigate=self.on_navigate,
                    flags=sublime.COOPERATE_WITH_AUTO_COMPLETE,
                    template_vars=template_vars)
        elif update:
            self.view.hide_popup()
コード例 #2
0
ファイル: signature_help.py プロジェクト: nh2/LSP
    def on_query_context(self, key, _, operand, __):
        if key != "lsp.signature_help":
            return False  # Let someone else handle this keybinding.
        elif not self._visible:
            return False  # Let someone else handle this keybinding.
        elif len(self._signatures) < 2:
            return False  # Let someone else handle this keybinding.
        else:
            # We use the "operand" for the number -1 or +1. See the keybindings.
            new_index = self._active_signature + operand

            # clamp signature index
            new_index = max(0, min(new_index, len(self._signatures) - 1))

            # only update when changed
            if new_index != self._active_signature:
                self._active_signature = new_index
                mdpopups.update_popup(
                    self.view,
                    self._build_popup_content(),
                    css=self.__class__.css,
                    md=True,
                    wrapper_class=self.__class__.wrapper_class)

            return True  # We handled this keybinding.
コード例 #3
0
    def show_colors(self, palette_type, palette_name, delete=False, update=False):
        """Show colors under the given palette."""

        target = None
        current = False
        if palette_type == "__special__":
            if palette_name == "Current Colors":
                current = True
                target = {
                    "name": palette_name,
                    "colors": self.view.settings().get('color_helper_file_palette', [])
                }
            elif palette_name == "Project Colors":
                data = self.view.window().project_data()
                current = True
                target = {
                    "name": palette_name,
                    "colors": [] if data is None else data.get('color_helper_project_palette', [])
                }
            elif palette_name == "Favorites":
                target = util.get_favs()
        elif palette_type == "__global__":
            for palette in util.get_palettes():
                if palette_name == palette['name']:
                    target = palette
        elif palette_type == "__project__":
            for palette in util.get_project_palettes(self.view.window()):
                if palette_name == palette['name']:
                    target = palette

        if target is not None:
            html = []

            if not delete:
                html.append(BACK_PALETTE_MENU)
                if not current:
                    html.append(DELETE_COLOR_MENU % (palette_type, target['name']))
            else:
                html.append(BACK_COLORS_MENU % (palette_type, target['name']))

            if delete:
                html.append(DELETE_COLOR)

            html.append(
                self.format_colors(target['colors'], target['name'], palette_type, delete)
            )

            if update:
                mdpopups.update_popup(self.view, ''.join(html), css=ADD_CSS)
            else:
                mdpopups.show_popup(
                    self.view,
                    ''.join(html), location=-1, max_width=600,
                    on_navigate=self.on_navigate,
                    flags=sublime.COOPERATE_WITH_AUTO_COMPLETE,
                    css=ADD_CSS
                )
コード例 #4
0
    def show_insert(self,
                    color,
                    dialog_type,
                    palette_name=None,
                    update=False,
                    raw=None):
        """Show insert panel."""

        original = color
        color = Color(color)

        sels = self.view.sel()
        if color is not None and len(sels) == 1:
            outputs = []
            if raw is not None:
                outputs.append((util.encode_color(raw), util.html_encode(raw)))
            custom = self.custom_color_class(color)
            for output in self.output_options:
                params = output.get("format", {})
                value = custom.convert(output["space"]).to_string(**params)
                outputs.append(
                    (util.encode_color(value), util.html_encode(value)))

            template_vars = {
                "dialog_type":
                dialog_type,
                "palette_name":
                palette_name,
                "current_color":
                original,
                "tool_color":
                util.encode_color(raw if raw else color.to_string(
                    **util.COLOR_FULL_PREC))
            }
            template_vars['outputs'] = outputs

            if update:
                mdpopups.update_popup(
                    self.view,
                    util.FRONTMATTER + sublime.load_resource(
                        'Packages/ColorHelper/panels/insert.html'),
                    wrapper_class="color-helper content",
                    css=util.ADD_CSS,
                    template_vars=template_vars)
            else:
                mdpopups.show_popup(
                    self.view,
                    util.FRONTMATTER + sublime.load_resource(
                        'Packages/ColorHelper/panels/insert.html'),
                    wrapper_class="color-helper content",
                    css=util.ADD_CSS,
                    location=-1,
                    max_width=1024,
                    max_height=512,
                    on_navigate=self.on_navigate,
                    flags=sublime.COOPERATE_WITH_AUTO_COMPLETE,
                    template_vars=template_vars)
コード例 #5
0
    def show_colors(self, palette_type, palette_name, delete=False, update=False):
        """Show colors under the given palette."""

        target = None
        current = False
        if palette_type == "__special__":
            if palette_name == "Current Colors":
                current = True
                target = {
                    "name": palette_name,
                    "colors": self.view.settings().get('color_helper.file_palette', [])
                }
            elif palette_name == "Favorites":
                target = util.get_favs()
        elif palette_type == "__global__":
            for palette in util.get_palettes():
                if palette_name == palette['name']:
                    target = palette
        elif palette_type == "__project__":
            for palette in util.get_project_palettes(self.view.window()):
                if palette_name == palette['name']:
                    target = palette

        if target is not None:
            template_vars = {
                "delete": delete,
                'show_delete_menu': not delete and not current,
                "back": '__colors__' if delete else '__palettes__',
                "palette_type": palette_type,
                "palette_name": target["name"],
                "colors": self.format_colors(target['colors'], target['name'], palette_type, delete)
            }

            if update:
                mdpopups.update_popup(
                    self.view,
                    util.FRONTMATTER + sublime.load_resource('Packages/ColorHelper/panels/colors.html.j2'),
                    wrapper_class="color-helper content",
                    css=util.ADD_CSS,
                    template_vars=template_vars
                )
            else:
                mdpopups.show_popup(
                    self.view,
                    util.FRONTMATTER + sublime.load_resource('Packages/ColorHelper/panels/colors.html.j2'),
                    wrapper_class="color-helper content",
                    css=util.ADD_CSS, location=-1, max_width=1024, max_height=512,
                    on_navigate=self.on_navigate,
                    flags=sublime.COOPERATE_WITH_AUTO_COMPLETE,
                    template_vars=template_vars
                )
コード例 #6
0
def update_lsp_popup(view: sublime.View,
                     contents: str,
                     md: bool = False,
                     css: Optional[str] = None,
                     wrapper_class: Optional[str] = None) -> None:
    css = css if css is not None else lsp_css().popups
    wrapper_class = wrapper_class if wrapper_class is not None else lsp_css(
    ).popups_classname
    contents += LSP_POPUP_SPACER_HTML
    mdpopups.update_popup(view,
                          contents,
                          css=css,
                          md=md,
                          wrapper_class=wrapper_class)
コード例 #7
0
    def show_color_info(self, update=False):
        """Show the color under the cursor."""

        color = None
        sels = self.view.sel()
        if (len(sels) == 1 and sels[0].size() == 0):
            point = sels[0].begin()
            visible = self.view.visible_region()
            start = point - 50
            end = point + 50
            alpha = None
            if start < visible.begin():
                start = visible.begin()
            if end > visible.end():
                end = visible.end()
            bfr = self.view.substr(sublime.Region(start, end))
            ref = point - start
            for m in util.COLOR_RE.finditer(bfr):
                if ref >= m.start(0) and ref < m.end(0):
                    color, alpha = util.translate_color(m)
                    break
        if color is not None:
            if alpha is not None:
                color += "%02X" % int('%.0f' % (float(alpha) * 255.0))

            html = []

            html.append(
                self.format_info(color.lower(), alpha)
            )

            if update:
                mdpopups.update_popup(self.view, ''.join(html), css=ADD_CSS)
            else:
                mdpopups.show_popup(
                    self.view,
                    ''.join(html), location=-1, max_width=600,
                    on_navigate=self.on_navigate,
                    flags=sublime.COOPERATE_WITH_AUTO_COMPLETE,
                    css=ADD_CSS
                )
        elif update:
            self.view.hide_popup()
コード例 #8
0
	def udpate_ProgressBar( self, view ):

		self.progressPercent   += 1
		progressPercent_String  = str( self.progressPercent ) + "%"
		progressBar_Colors      = []

		popUp_Label = self.popUp_Label_InProgress

		for index in range( 0, self.maxPercent ):
			if  index <= self.progressPercent \
			and self.progressPercent < self.maxPercent:
				progressBar_Colors.append( self.progressBar_Progress_Color )
			elif index > self.progressPercent \
			and  self.progressPercent < self.maxPercent:
				progressBar_Colors.append( self.progressBar_Incomplete_Color )
			elif self.progressPercent >= self.maxPercent:
				progressBar_Colors.append( self.progressBar_Complete_Color )
				popUp_Label = self.popUp_Label_Complete

		progressBar = mdpopups.color_box(
			progressBar_Colors,           # [ colors ]
			self.progressBar_BorderColor, # border1_color
			None,                         # border2_color
			self.progressBar_Height,      # height
			self.progressBar_Width,       # width
			0,                            # border_size
			4,                            # check_size
			self.maxPercent               # max_colors
		)

		space     = "&nbsp;"
		blankLine = space + "\n"
		h5        = "#####"
		h6        = "######"

		markdown_PopUp_Text =                  \
				h5 + popUp_Label + "\n"            \
			+	blankLine                          \
			+	h6 + progressPercent_String + "\n" \
			+	progressBar

		mdpopups.update_popup( view, markdown_PopUp_Text, True, self.popupCSS )
コード例 #9
0
ファイル: docphp.py プロジェクト: husanjun/docphp
    def on_navigate(self, url):
        if re.search('^https?://', url):
            webbrowser.open_new(url)
            return True
        symbol = None
        m = re.search('^(changeto|constant)\\.(.*)', url)
        if m:
            if m.group(1) == 'changeto':
                symbol, content = getSymbolDescription(self.currentSymbol,
                                                       m.group(2))
            else:
                self.view.run_command('docphp_insert', {"string": m.group(2)})
                self.view.hide_popup()

        elif url == 'history.back':
            symbol = self.history.pop()
            self.currentSymbol = symbol
        else:
            self.history.append(self.currentSymbol)
            symbol = url[:url.find('.html')]
            self.currentSymbol = symbol
        if not symbol:
            if getSetting('prompt_when_not_found'):
                self.view.show_popup('Not found',
                                     sublime.COOPERATE_WITH_AUTO_COMPLETE)
                return
            return
        symbol, content = getSymbolDescription(symbol)

        if content is False:
            return False

        content = self.formatPopup(content,
                                   symbol=symbol,
                                   can_back=len(self.history) > 0)
        content = content[:65535] if content else ''
        popups, popups_classname = self.getCss()
        mdpopups.update_popup(self.view,
                              content,
                              css=popups,
                              wrapper_class=popups_classname)
    def run(self, edit, point, flags):
        '''ポップアップを表示

        Todo:
            *パーサーメソッドを用意しdocstringを読み込む
            *ホバーしているメソッド呼び出しのメソッドが同じファイルにあるか判別
            >パース>コンテンツ生成>show popup
        '''
        #popupの位置に使う
        line = self.view.rowcol(point)[0] + 1
        location = _visivle_text_point(self.view, line - 1, 0)

        #potisonからスコープネームや単語を取得
        str_word = self.view.substr(self.view.word(point)) #カーソル位置の単語取得
        scope = self.view.scope_name(point)
        print(scope)
        score_class = self.view.score_selector(point, 'entity.name.class.python')
        score_method = self.view.score_selector(point, 'entity.name.function.python')
        score_fanc_call = self.view.score_selector(point, 'meta.function-call.python')
        #関数かクラスか判別
        if score_class > 0:
            scope_type = 'Class'
        elif score_method > 0 or score_fanc_call > 0:
            scope_type = 'Function'
        else:
            return

        css = _load_popup_css('popup.css')

        content = (
                    '<div class="content">'
                    '{0} : {1}'
                    '</div>'
                ).format(scope_type, str_word)
        #show_popupのcontentはHTML形式で記述
        self.view.show_popup(content, sublime.HIDE_ON_MOUSE_MOVE_AWAY, point)
        #mdpopups.show_popup(self.view, content, css, flags, location)
        mdpopups.update_popup(self.view, content, None, css)

        ext = self.view.extract_scope(point)
        lines = self.view.substr(ext)
コード例 #11
0
 def _update_popup(self) -> None:
     mdpopups.update_popup(self.view,
                           self._build_popup_content(),
                           css=popup_css,
                           md=True,
                           wrapper_class=popup_class)
コード例 #12
0
    def show_palettes(self, delete=False, color=None, update=False):
        """Show preview of all palettes."""

        show_div = False
        s = sublime.load_settings('color_helper.sublime-settings')
        show_global_palettes = s.get('enable_global_user_palettes', True)
        show_project_palettes = s.get('enable_project_user_palettes', True)
        show_favorite_palette = s.get('enable_favorite_palette', True)
        show_current_palette = s.get('enable_current_file_palette', True)

        html = []

        if (not self.no_info and not delete) or color:
            html.append(BACK_INFO_MENU)
        elif delete:
            html.append(BACK_PALETTE_MENU)

        if not delete and not color and (show_global_palettes or show_project_palettes or show_favorite_palette):
            html.append(DELETE_PALETTE_MENU)

        if delete:
            html.append(DELETE_PALETTE)

        if color:
            html.append(NEW_PALETTE % {'color': color})

        if show_favorite_palette:
            favs = util.get_favs()
            if len(favs['colors']) or color:
                show_div = True
                html.append(
                    self.format_palettes(favs['colors'], favs['name'], '__special__', delete=delete, color=color)
                )

        if show_current_palette:
            current_colors = self.view.settings().get('color_helper_file_palette', [])
            if not delete and not color and len(current_colors):
                show_div = True
                html.append(
                    self.format_palettes(current_colors, "Current Colors", '__special__', delete=delete, color=color)
                )

        if show_global_palettes:
            palettes = util.get_palettes()
            if len(palettes) and show_div:
                show_div = False
                html.append('\n\n---\n\n')
            for palette in palettes:
                show_div = True
                name = palette.get("name")
                html.append(
                    self.format_palettes(
                        palette.get('colors', []), name, '__global__', palette.get('caption'),
                        delete=delete,
                        color=color
                    )
                )

        if show_project_palettes:
            palettes = util.get_project_palettes(self.view.window())
            if len(palettes) and show_div:
                show_div = False
                html.append(DIVIDER)
            for palette in palettes:
                name = palette.get("name")
                html.append(
                    self.format_palettes(
                        palette.get('colors', []), name, '__project__', palette.get('caption'),
                        delete=delete,
                        color=color
                    )
                )

        if update:
            mdpopups.update_popup(self.view, ''.join(html), css=ADD_CSS)
        else:
            mdpopups.show_popup(
                self.view,
                ''.join(html), location=-1, max_width=600,
                on_navigate=self.on_navigate,
                flags=sublime.COOPERATE_WITH_AUTO_COMPLETE,
                css=ADD_CSS
            )
コード例 #13
0
ファイル: factory.py プロジェクト: willianflores/GitGutter
def _show_diff_popup_impl(git_gutter, line, highlight_diff, flags, diff_info):
    """Show and update the diff popup.

    Arguments:
        git_gutter (GitGutterCommand):
            The main command object, which represents GitGutter.
        line (int):
            The line number the diff popup is requested for
        highlight_diff (bool):
            If True to the diff is displayed instead of the old revision.
        flags (int):
            Sublime Text popup flags.
        diff_info (tuple):
            All the information required to display the diff popup.
    """
    del_lines, start, size, meta = diff_info
    if start == -1:
        return

    view = git_gutter.view

    # extract the type of the hunk: removed, modified, (x)or added
    is_removed = size == 0
    is_modified = not is_removed and bool(del_lines)
    is_added = not is_removed and not is_modified

    def navigate(href):
        # allow navigate() to manipulate the outer variables
        nonlocal highlight_diff

        if href == 'hide':
            view.hide_popup()
        elif href == 'copy':
            del_text = '\n'.join(del_lines)
            sublime.set_clipboard(del_text)
            sublime.status_message('Copied: {0} characters'.format(
                len(del_text)))
        elif href == 'revert':
            # hide the popup and update the view
            view.hide_popup()
            revert.revert_change_impl(view, diff_info)
        elif href == 'disable_hl_diff':
            # show a diff popup with the same diff info (previous revision)
            highlight_diff = False
            _show_diff_popup_impl(git_gutter, line, highlight_diff, flags,
                                  diff_info)
        elif href == 'enable_hl_diff':
            # show a diff popup with the same diff info (highlight diff)
            highlight_diff = True
            _show_diff_popup_impl(git_gutter, line, highlight_diff, flags,
                                  diff_info)
        elif href in ('first_change', 'next_change', 'prev_change'):
            next_line = meta.get(href, line)
            point = view.text_point(next_line - 1, 0)

            def show_new_popup():
                # wait until scrolling has completed
                if not view.visible_region().contains(point):
                    return sublime.set_timeout_async(show_new_popup, 20)
                # show a diff popup with new diff info
                _show_diff_popup_impl(
                    git_gutter, next_line, highlight_diff, 0,
                    git_gutter.git_handler.diff_line_change(next_line))

            view.hide_popup()
            view.show_at_center(point)
            show_new_popup()

    # write the symbols/text for each button
    buttons = _built_toolbar_buttons(start, meta)
    location = _visible_text_point(view, line - 1, 0)
    code_wrap = view.settings().get('word_wrap')
    if code_wrap == 'auto':
        code_wrap = view.match_selector(location, 'source')

    if highlight_diff:
        # (*) show a highlighted diff of the merged git and editor content
        new_lines = meta['added_lines']
        tab_width = view.settings().get('tab_width', 4)
        min_indent = _get_min_indent(del_lines + new_lines, tab_width)
        content = (
            '<div class="toolbar">'
            '{hide} '
            '{first_change} {prev_change} {next_change} '
            '{disable_hl_diff} {revert}'
            '</div>'.format(**buttons)) + differ.highlight_diff([
                line.expandtabs(tab_width)[min_indent:] for line in del_lines
            ], [line.expandtabs(tab_width)[min_indent:] for line in new_lines])

    elif not is_added:
        # (modified/removed) show content from git database
        tab_width = view.settings().get('tab_width', 4)
        min_indent = _get_min_indent(del_lines, tab_width)
        source_content = '\n'.join(
            (line.expandtabs(tab_width)[min_indent:] for line in del_lines))
        content = ('<div class="toolbar">'
                   '{hide} '
                   '{first_change} {prev_change} {next_change} '
                   '{enable_hl_diff} {copy} {revert}'
                   '</div>'.format(**buttons)) + mdpopups.syntax_highlight(
                       view,
                       source_content,
                       language=mdpopups.get_language_from_view(view) or '',
                       allow_code_wrap=code_wrap)

    else:
        # (added) only show the button line without the copy button
        # (there is nothing to show or copy)
        content = ('<div class="toolbar">'
                   '{hide} '
                   '{first_change} {prev_change} {next_change} '
                   '{enable_hl_diff} {revert}'
                   '</div>'.format(**buttons))

    # common arguments used to create or update the popup
    popup_kwargs = {
        'view': view,
        'content': content,
        'md': False,
        'css': _load_popup_css(git_gutter.settings.theme_path),
        'wrapper_class': 'git-gutter'
    }
    # update visible popup
    if view.is_popup_visible():
        return mdpopups.update_popup(**popup_kwargs)
    # calculate optimal popup width to apply desired wrapping
    popup_width = int(view.viewport_extent()[0])
    if code_wrap:
        line_length = view.settings().get('wrap_width', 0)
        if line_length > 0:
            popup_width = (line_length + 5) * view.em_width()
    # create new popup
    return mdpopups.show_popup(location=location,
                               max_width=popup_width,
                               flags=flags,
                               on_navigate=navigate,
                               **popup_kwargs)
コード例 #14
0
ファイル: factory.py プロジェクト: DavidPesta/GitGutter
def _show_diff_popup_impl(git_gutter, line, highlight_diff, flags, diff_info):
    """Show and update the diff popup.

    Arguments:
        git_gutter (GitGutterCommand):
            The main command object, which represents GitGutter.
        line (int):
            The line number the diff popup is requested for
        highlight_diff (bool):
            If True to the diff is displayed instead of the old revision.
        flags (int):
            Sublime Text popup flags.
        diff_info (tuple):
            All the information required to display the diff popup.
    """
    del_lines, start, size, meta = diff_info
    if start == -1:
        return

    view = git_gutter.view

    # extract the type of the hunk: removed, modified, (x)or added
    is_removed = size == 0
    is_modified = not is_removed and bool(del_lines)
    is_added = not is_removed and not is_modified

    def navigate(href):
        # allow navigate() to manipulate the outer variables
        nonlocal highlight_diff

        if href == 'hide':
            view.hide_popup()
        elif href == 'copy':
            del_text = '\n'.join(del_lines)
            sublime.set_clipboard(del_text)
            sublime.status_message(
                'Copied: {0} characters'.format(len(del_text)))
        elif href == 'revert':
            # hide the popup and update the view
            view.hide_popup()
            revert.revert_change_impl(view, diff_info)
        elif href == 'disable_hl_diff':
            # show a diff popup with the same diff info (previous revision)
            highlight_diff = False
            _show_diff_popup_impl(
                git_gutter, line, highlight_diff, flags, diff_info)
        elif href == 'enable_hl_diff':
            # show a diff popup with the same diff info (highlight diff)
            highlight_diff = True
            _show_diff_popup_impl(
                git_gutter, line, highlight_diff, flags, diff_info)
        elif href in ('first_change', 'next_change', 'prev_change'):
            next_line = meta.get(href, line)
            point = view.text_point(next_line - 1, 0)

            def show_new_popup():
                # wait until scrolling has completed
                if not view.visible_region().contains(point):
                    return sublime.set_timeout_async(show_new_popup, 20)
                # show a diff popup with new diff info
                _show_diff_popup_impl(
                    git_gutter, next_line, highlight_diff, 0,
                    git_gutter.git_handler.diff_line_change(next_line))
            view.hide_popup()
            view.show_at_center(point)
            show_new_popup()

    # write the symbols/text for each button
    buttons = _built_toolbar_buttons(start, meta)
    location = _visible_text_point(view, line - 1, 0)
    code_wrap = view.settings().get('word_wrap')
    if code_wrap == 'auto':
        code_wrap = view.match_selector(location, 'source')

    if highlight_diff:
        # (*) show a highlighted diff of the merged git and editor content
        new_lines = meta['added_lines']
        tab_width = view.settings().get('tab_width', 4)
        min_indent = _get_min_indent(del_lines + new_lines, tab_width)
        content = (
            '<div class="toolbar">'
            '{hide} '
            '{first_change} {prev_change} {next_change} '
            '{disable_hl_diff} {revert}'
            '</div>'
            .format(**buttons)
        ) + differ.highlight_diff(
            [line.expandtabs(tab_width)[min_indent:] for line in del_lines],
            [line.expandtabs(tab_width)[min_indent:] for line in new_lines])

    elif not is_added:
        # (modified/removed) show content from git database
        tab_width = view.settings().get('tab_width', 4)
        min_indent = _get_min_indent(del_lines, tab_width)
        source_content = '\n'.join(
            (line.expandtabs(tab_width)[min_indent:] for line in del_lines))
        # common arguments used to highlight the content
        popup_kwargs = {
            'allow_code_wrap': code_wrap,
            'language': mdpopups.get_language_from_view(view) or ''
        }
        content = (
            '<div class="toolbar">'
            '{hide} '
            '{first_change} {prev_change} {next_change} '
            '{enable_hl_diff} {copy} {revert}'
            '</div>'
            .format(**buttons)
        ) + mdpopups.syntax_highlight(view, source_content, **popup_kwargs)

    else:
        # (added) only show the button line without the copy button
        # (there is nothing to show or copy)
        content = (
            '<div class="toolbar">'
            '{hide} '
            '{first_change} {prev_change} {next_change} '
            '{enable_hl_diff} {revert}'
            '</div>'
            .format(**buttons)
        )

    # common arguments used to create or update the popup
    popup_kwargs = {
        'view': view,
        'content': content,
        'md': False,
        'css': _load_popup_css(git_gutter.settings.theme_path),
        'wrapper_class': 'git-gutter',
        'allow_code_wrap': code_wrap
    }
    # update visible popup
    if view.is_popup_visible():
        return mdpopups.update_popup(**popup_kwargs)
    # calculate optimal popup width to apply desired wrapping
    popup_width = int(view.viewport_extent()[0])
    if code_wrap:
        line_length = view.settings().get('wrap_width', 0)
        if line_length > 0:
            popup_width = (line_length + 5) * view.em_width()
    # create new popup
    return mdpopups.show_popup(
        location=location, max_width=popup_width, flags=flags,
        on_navigate=navigate, **popup_kwargs)
コード例 #15
0
 def _update_popup(self, content: str) -> None:
     mdpopups.update_popup(self.view,
                           content,
                           css=popups.stylesheet,
                           md=True,
                           wrapper_class=popups.classname)
コード例 #16
0
    def show_palettes(self, delete=False, color=None, update=False):
        """Show preview of all palettes."""

        show_div = False
        s = sublime.load_settings('color_helper.sublime-settings')
        show_global_palettes = s.get('enable_global_user_palettes', True)
        show_project_palettes = s.get('enable_project_user_palettes', True)
        show_favorite_palette = s.get('enable_favorite_palette', True)
        # show_current_palette = s.get('enable_current_file_palette', True)
        s = sublime.load_settings('color_helper.sublime-settings')
        show_picker = s.get('enable_color_picker', True) and self.no_info
        palettes = util.get_palettes()
        project_palettes = util.get_project_palettes(self.view.window())

        template_vars = {
            "color":
            (Color(color if color else '#ffffffff').to_string(**util.DEFAULT)),
            "show_picker_menu":
            show_picker,
            "show_delete_menu":
            (not delete and not color
             and (show_favorite_palette or show_global_palettes
                  or show_project_palettes)),
            "back_target":
            "__info__" if
            (not self.no_info and not delete) or color else "__palettes__",
            "show_delete_ui":
            delete,
            "show_new_ui":
            bool(color),
            "show_favorite_palette":
            show_favorite_palette,
            "show_global_palettes":
            show_global_palettes and len(palettes),
            "show_project_palettes":
            show_project_palettes and len(project_palettes)
        }

        if show_favorite_palette:
            favs = util.get_favs()
            if len(favs['colors']) or color:
                show_div = True
                template_vars['favorite_palette'] = (self.format_palettes(
                    favs['colors'],
                    favs['name'],
                    '__special__',
                    delete=delete,
                    color=color))

        if show_global_palettes and len(palettes):
            if show_div:
                template_vars['show_separator'] = True
                show_div = False
            global_palettes = []
            for palette in palettes:
                show_div = True
                name = palette.get("name")
                global_palettes.append(
                    self.format_palettes(palette.get('colors', []),
                                         name,
                                         '__global__',
                                         palette.get('caption'),
                                         delete=delete,
                                         color=color))
            template_vars['global_palettes'] = global_palettes

        if show_project_palettes and len(project_palettes):
            if show_div:
                show_div = False
                template_vars['show_project_separator'] = True
            proj_palettes = []
            for palette in project_palettes:
                name = palette.get("name")
                proj_palettes.append(
                    self.format_palettes(palette.get('colors', []),
                                         name,
                                         '__project__',
                                         palette.get('caption'),
                                         delete=delete,
                                         color=color))
                template_vars['project_palettes'] = proj_palettes

        if update:
            mdpopups.update_popup(
                self.view,
                util.FRONTMATTER + sublime.load_resource(
                    'Packages/ColorHelper/panels/palettes.html'),
                wrapper_class="color-helper content",
                css=util.ADD_CSS,
                template_vars=template_vars)
        else:
            mdpopups.show_popup(
                self.view,
                util.FRONTMATTER + sublime.load_resource(
                    'Packages/ColorHelper/panels/palettes.html'),
                wrapper_class="color-helper content",
                css=util.ADD_CSS,
                location=-1,
                max_width=1024,
                max_height=512,
                on_navigate=self.on_navigate,
                flags=sublime.COOPERATE_WITH_AUTO_COMPLETE,
                template_vars=template_vars)
コード例 #17
0
ファイル: signature_help.py プロジェクト: james2doyle/LSP
 def _update_popup(self) -> None:
     mdpopups.update_popup(self.view,
                           self._build_popup_content(),
                           css=popup_css,
                           md=True,
                           wrapper_class=popup_class)
コード例 #18
0
 def _update_popup(self, content: str) -> None:
     mdpopups.update_popup(self.view,
                           content,
                           css=popup_css,
                           md=True,
                           wrapper_class=popup_class)