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
########################################################################
评论列表
文章目录