def showAsTooltip(self, context, outputFormat = None): message = html.escape(context.outputValue.strip()) timeout = len(message) * 20 if timeout > 2000: timeout = 2000 self.window().showTooltip(message, timeout = timeout)
def showAsTooltip(self, context, outputFormat=None): message = html.escape(context.outputValue.strip()) timeout = len(message) * 20 if 0 < len(message) <= 100 else 2000 callbacks = {"copy": lambda s=message: self.editor.application().clipboard().setText(s)} point = self.editor.viewport().mapToGlobal(self.editor.cursorRect().bottomRight()) self.editor.showMessage(message, frmt=outputFormat or "text", timeout=timeout, point=point, links=callbacks)
def showErrorInBrowser(self, title, summary, exitcode = -1, **settings): from prymatex.support.utils import makeHyperlinks from prymatex.utils import html commandScript = ''' source "$TM_SUPPORT_PATH/lib/webpreview.sh" html_header "An error has occurred while executing command %(name)s" echo -e "<pre>%(output)s</pre>" echo -e "<p>Exit code was: %(exitcode)d</p>" html_footer ''' % { 'name': html.escape(title), 'output': html.escape(summary), 'exitcode': exitcode} bundle = self.application.supportManager.getBundle(self.application.supportManager.defaultBundleForNewBundleItems) command = self.application.supportManager.buildAdHocCommand(commandScript, bundle, name = "Error runing %s" % title, commandOutput = 'showAsHTML') self.bundleItem_handler(command, **settings)
def error(self, context): #TODO: Mover esto a un lugar donde no dependa del processor mostrar un error en el borwser, quiza a la mainWindow #para poder llamarlos como showErrorInBrowser o algo asi :) if self.errorCommand: #Prevenir la entrada recursiva raise Exception(context.errorValue) from prymatex.support.utils import makeHyperlinks from prymatex.utils import html commandScript = ''' source "$TM_SUPPORT_PATH/lib/webpreview.sh" html_header "An error has occurred while executing command %(name)s" echo -e "<pre>%(output)s</pre>" echo -e "<p>Exit code was: %(exitcode)d</p>" html_footer ''' % {'output': html.escape(context.errorValue), 'name': html.escape(context.description()), 'exitcode': context.outputType} command = self.editor.application.supportManager.buildAdHocCommand(commandScript, context.bundleItem.bundle, name = "Error runing %s" % context.description(), commandOutput = 'showAsHTML') self.editor.insertBundleItem(command, errorCommand = True)
def showErrorInBrowser(self, title, summary, exitcode=-1, **settings): from prymatex.support.utils import makeHyperlinks from prymatex.utils import html commandScript = ''' source "$TM_SUPPORT_PATH/lib/webpreview.sh" html_header "An error has occurred while executing command %(name)s" echo -e "<pre>%(output)s</pre>" echo -e "<p>Exit code was: %(exitcode)d</p>" html_footer ''' % { 'name': html.escape(title), 'output': html.escape(summary), 'exitcode': exitcode } bundle = self.application.supportManager.getBundle( self.application.supportManager.defaultBundleForNewBundleItems) command = self.application.supportManager.buildAdHocCommand( commandScript, bundle, name="Error runing %s" % title, commandOutput='showAsHTML') self.bundleItem_handler(command, **settings)
def showAsTooltip(self, context, outputFormat = None): message = html.escape(context.outputValue.strip()) timeout = len(message) * 20 if timeout > 2000: timeout = 2000 point = self.editor.cursorRect(self.inputWrapper).bottomRight() point = self.editor.mapToGlobal(point) callbacks = { 'copy': lambda s = message: QtGui.qApp.instance().clipboard().setText(s) } self.editor.mainWindow().showTooltip(message, frmt = outputFormat or "text", timeout = timeout, point = point, links = callbacks)
def showErrorInBrowser(self, title, summary, exitcode = -1, **settings): commandScript = ''' source "$TM_SUPPORT_PATH/lib/webpreview.sh" html_header '%(name)s error' echo -e '<pre>%(output)s</pre>' echo -e '<p>Exit code was: %(exitcode)d</p>' html_footer ''' % { 'name': html.escape(title), 'output': html.htmlize(summary), 'exitcode': exitcode} bundle = self.application.supportManager.getBundle(self.application.supportManager.defaultBundleForNewBundleItems) command = self.application.supportManager.buildAdHocCommand(commandScript, bundle, name = "%s error" % title, commandOutput = 'showAsHTML') self.bundleItem_handler(command, **settings)