コード例 #1
0
ファイル: support.py プロジェクト: facelessuser/QuickCal
    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)
コード例 #2
0
ファイル: support.py プロジェクト: facelessuser/QuickCal
    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)
コード例 #3
0
ファイル: changes.py プロジェクト: MattDMo/ApplySyntax
    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)
コード例 #4
0
ファイル: cndict.py プロジェクト: divinites/cndict
    def run(self):
        if self.checkword(self.word):
            json_data = self.acquiredata(self.word)
            snippet = '!!! panel-success "' + self.args + '"\n'
            format_data = json_data = self.format(json_data)
            self.parse_to_clipboard(format_data)
            snippet += format_data
        else:
            snippet = '!!! panel-error "Error"\n' + "    忘记选字了吧?\n"

        settings = sublime.load_settings("cndict.sublime-settings")
        if settings.get("format") == "phantom":
            mdpopups.add_phantom(
                view=self.view,
                key="trans",
                region=self.view.sel()[0],
                content=snippet,
                layout=sublime.LAYOUT_BELOW,
                on_navigate=self.on_close_phantom_and_popup,
                md=True)
        elif settings.get("format") == "pannel":
            print("pannel")
            board = self.window.create_output_panel("trans")
            board.run_command('append', {'characters': snippet})
            self.window.run_command("show_panel", {"panel": "output.trans"})
        else:
            mdpopups.show_popup(
                view=self.view,
                content=snippet,
                on_navigate=self.on_close_phantom_and_popup,
                md=True)
コード例 #5
0
ファイル: support.py プロジェクト: skeptycal/FavoriteFiles
    def run(self, page):
        """Open page."""

        try:
            import mdpopups
            has_phantom_support = (mdpopups.version() >= (1, 10, 0)) and (int(
                sublime.version()) >= 3124)
        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('FavoriteFiles - 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="favorite-files",
                                     on_navigate=self.on_navigate)
            else:
                view.run_command('insert', {"characters": text})
            view.set_read_only(True)
            view.set_scratch(True)
コード例 #6
0
ファイル: support.py プロジェクト: skeptycal/FavoriteFiles
    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()) >= 3124)
        except Exception:
            has_phantom_support = False

        text = sublime.load_resource('Packages/FavoriteFiles/CHANGES.md')
        view = self.window.new_file()
        view.set_name('FavoriteFiles - 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="favorite-files",
                                 css=CSS,
                                 on_navigate=self.on_navigate)
        else:
            view.run_command('insert', {"characters": text})
        view.set_read_only(True)
        view.set_scratch(True)
コード例 #7
0
ファイル: support.py プロジェクト: intmov/HexViewer
    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/HexViewer/CHANGES.md')
        view = self.window.new_file()
        view.set_name('HexViewer - 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="hex-viewer",
                                 css=CSS,
                                 on_navigate=self.on_navigate)
        else:
            view.run_command('insert', {"characters": text})
        view.set_read_only(True)
        view.set_scratch(True)
コード例 #8
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('ScopeHunter - 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="scope-hunter",
                    on_navigate=self.on_navigate
                )
            else:
                view.run_command('insert', {"characters": text})
            view.set_read_only(True)
            view.set_scratch(True)
コード例 #9
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)
コード例 #10
0
ファイル: tests.py プロジェクト: 1901/sublime_sync
def show_phantom(text):
    """Show the phantom."""
    close = '\n[(close)](#)'
    view = active_view()
    region = view.visible_region()
    mdpopups.add_phantom(
        active_view(), 'mdpopups_test', region, text + close, 2, on_navigate=on_close_phantom
    )
コード例 #11
0
ファイル: support.py プロジェクト: Briles/gruvbox
 def run(self, edit):
     import mdpopups
     md = sublime.load_resource('Packages/' + PACKAGE_NAME + '/CONTRIBUTING.md')
     v = sublime.active_window().new_file()
     v.set_name(PACKAGE_NAME + ': CONTRIBUTING')
     v.settings().set('gutter', False)
     mdpopups.add_phantom(v, 'contributing', sublime.Region(0), md, sublime.LAYOUT_INLINE, wrapper_class='gruvbox-docs', on_navigate=self.on_navigate)
     v.set_read_only(True)
     v.set_scratch(True)
コード例 #12
0
 def run(self):
     import mdpopups
     text = sublime.load_resource('Packages/Material Theme/CHANGELOG.md')
     view = self.window.new_file()
     view.set_name('Material Theme Changelog')
     view.settings().set('gutter', False)
     html = '<div class="mt-config-changes">%s</div>' % mdpopups.md2html(view, text)
     mdpopups.add_phantom(view, 'changelog', sublime.Region(0), html, sublime.LAYOUT_INLINE, css=STYLES, on_navigate=self.on_navigate)
     view.set_read_only(True)
     view.set_scratch(True)
コード例 #13
0
ファイル: test.py プロジェクト: facelessuser/mdpopup_test
def show_phantom(text):
    """Show the phantom."""
    clear_cache()
    close = '\n[close](#){: .btn .btn-small .btn-info}\n'
    view = active_view()
    region = view.visible_region()
    mdpopups.add_phantom(
        active_view(), 'mdpopups_test', region, text + close, 2,
        on_navigate=on_close_phantom, wrapper_class='mdpopups-test'
    )
コード例 #14
0
 def run(self):
     import mdpopups
     text = sublime.load_resource('Packages/Material Theme/CHANGELOG.md')
     view = self.window.new_file()
     view.set_name('Material Theme Changelog')
     view.settings().set('gutter', False)
     html = '<div class="mt-config-changes">%s</div>' % mdpopups.md2html(view, text)
     mdpopups.add_phantom(view, 'changelog', sublime.Region(0), html, sublime.LAYOUT_INLINE, css=STYLES)
     view.set_read_only(True)
     view.set_scratch(True)
コード例 #15
0
ファイル: tests.py プロジェクト: Salt7900/Sublime_Settings
def show_phantom(text):
    """Show the phantom."""
    close = '\n[(close)](#)'
    view = active_view()
    region = view.visible_region()
    mdpopups.add_phantom(active_view(),
                         'mdpopups_test',
                         region,
                         text + close,
                         2,
                         on_navigate=on_close_phantom)
コード例 #16
0
    def show_phantom(self, region, content):
        def on_navigate(href):
            self.handle_href(href)
            self.view.erase_phantoms("Translator")

        mdpopups.add_phantom(view=self.view,
                             css=sublime.load_resource(self.mdpopups_css),
                             key="Translator",
                             region=region,
                             content=content,
                             layout=sublime.LAYOUT_BELOW,
                             on_navigate=on_navigate,
                             md=True)
コード例 #17
0
ファイル: test.py プロジェクト: skeptycal/mdpopup_test
def show_phantom(text):
    """Show the phantom."""
    clear_cache()
    close = '\n[close](#){: .btn .btn-small .btn-info}\n'
    view = active_view()
    region = view.visible_region()
    mdpopups.add_phantom(active_view(),
                         'mdpopups_test',
                         region,
                         text + close,
                         2,
                         on_navigate=on_close_phantom,
                         wrapper_class='mdpopups-test')
コード例 #18
0
ファイル: support.py プロジェクト: qscgu23/gruvbox
 def run(self, edit):
     import mdpopups
     md = sublime.load_resource('Packages/' + PACKAGE_NAME +
                                '/CONTRIBUTING.md')
     v = sublime.active_window().new_file()
     v.set_name(PACKAGE_NAME + ': CONTRIBUTING')
     v.settings().set('gutter', False)
     mdpopups.add_phantom(v,
                          'contributing',
                          sublime.Region(0),
                          md,
                          sublime.LAYOUT_INLINE,
                          wrapper_class='gruvbox-docs',
                          on_navigate=self.on_navigate)
     v.set_read_only(True)
     v.set_scratch(True)
コード例 #19
0
ファイル: uml.py プロジェクト: facelessuser/SublimeRandomCrap
    def add_phantom(self, phantom, index):
        """Add a phantom."""

        key = 'uml%d' % index
        regions = self.view.get_regions(key)

        if regions:
            mdpopups.add_phantom(
                self.view,
                "uml",
                regions[0],
                phantom,
                sublime.LAYOUT_BLOCK,
                md=False
            )
        self.view.erase_regions(key)
        self.view.settings().set('uml.regions', self.view.settings().get('uml.regions', 0) - 1)
コード例 #20
0
ファイル: uml.py プロジェクト: skeptycal/SublimeRandomCrap
    def add_phantom(self, phantom, index):
        """Add a phantom."""

        key = 'uml%d' % index
        regions = self.view.get_regions(key)

        if regions:
            mdpopups.add_phantom(self.view,
                                 "uml",
                                 regions[0],
                                 phantom,
                                 sublime.LAYOUT_BLOCK,
                                 md=False)
        self.view.erase_regions(key)
        self.view.settings().set(
            'uml.regions',
            self.view.settings().get('uml.regions', 0) - 1)
コード例 #21
0
    def search(self, query):
        """Get the packages from GoDoc and display them in a Phantom.
        """
        packages = search_packages(query)
        content = jinja2.Template(PACKAGES).render(packages=packages)

        view = self.window.new_file()
        view.set_name('GoDoc Search - {0}'.format(query))
        view.settings().set('gutter', False)
        view.settings().set('word_wrap', True)

        mdpopups.add_phantom(view,
                             'packages',
                             sublime.Region(0),
                             content,
                             sublime.LAYOUT_INLINE,
                             wrapper_class='gide',
                             css=CSS,
                             on_navigate=self.on_navigate)

        view.set_read_only(True)
        view.set_scratch(True)