QuickEdit.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:QuickEdit 作者: gamcoh 项目源码 文件源码
def formatCodeVar(self):
        reportHtml = '<div class="var">'
        reportHtml += '<p class="files"><em>in this file, at line : </em><a href="line-{line}">{line}</a></p>'.format(line=self.varsFound['line'])

        # format the code for a better syntax coloration
        reportHtmlContent = re.sub('(\$|=|new|->)', '<p class="monokai_red">\g<1></p>', self.varsFound['code'])
        reportHtmlContent = re.sub('(class)(;|,)', '<p class="monokai_blue">\g<1></p>\g<2>', reportHtmlContent)
        reportHtmlContent = re.sub('(\[| |=|>)([0-9]+)(\]| |;|,)', '\g<1><p class="monokai_int">\g<2></p>\g<3>', reportHtmlContent)
        # print(reportHtmlContent)

        reportHtml += reportHtmlContent
        reportHtml += '</div>'

        # load the font
        settings = sublime.load_settings('Preferences.sublime-settings')
        font = ''
        if settings.has('font_face'):
            font = '"%s",' % settings.get('font_face')

        # getting the errors that occured during the execution
        htmlErrors = ''
        if self.QuickEditSetting.get('show_errors'):
            for e in self.aErrors:
                htmlErrors += '<p class="error">• %s</p>' % e

            # if errors were found 
            if htmlErrors:
                htmlErrors = '<div class="panel panel-error mt20"><div class="panel-header">Errors that occured during the search</div><div class="panel-body">{errors}</div></div>'.format(errors=htmlErrors)

        # load css, and html ui
        css = sublime.load_resource('Packages/QuickEdit/resources/ui.css').replace('@@font', font)
        html = sublime.load_resource('Packages/QuickEdit/resources/report.html').format(css=css, html=reportHtml, errors=htmlErrors)

        self.view.erase_phantoms('quick_edit')
        self.view.add_phantom("quick_edit", self.view.sel()[0], html, sublime.LAYOUT_BLOCK, self.click)

    ########################################################################
    # format the code for the functions
    ########################################################################
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号