diff --git a/preditor/gui/console.py b/preditor/gui/console.py index 1ee5f657..b037b0d2 100644 --- a/preditor/gui/console.py +++ b/preditor/gui/console.py @@ -358,7 +358,7 @@ def executeString(self, commandText, filename='', extraPrint=True # Report the total time it took to execute this code. if self.reportExecutionTime is not None: - self.reportExecutionTime(delta) + self.reportExecutionTime((delta, commandText)) return cmdresult, wasEval def executeCommand(self): diff --git a/preditor/gui/status_label.py b/preditor/gui/status_label.py index b7acba02..f1f17d3c 100644 --- a/preditor/gui/status_label.py +++ b/preditor/gui/status_label.py @@ -54,17 +54,28 @@ def setText(self, text): def showSeconds(self, seconds): self.times.append(seconds) - self.setText(self.secondsText(seconds)) + self.setText(self.secondsText(seconds[0])) def showMenu(self): menu = QMenu(self) if self.times: # Show the time it took to run the last X code calls + times = [] for seconds in self.times: - menu.addAction(self.secondsText(seconds)) + secs, cmd = seconds + times.append(secs) + + # Add a simplified copy of the command that was run + cmd = cmd.strip() + cmds = cmd.split("\n") + if len(cmds) > 1 or len(cmds[0]) > 50: + cmd = "{} ...".format(cmds[0][:50]) + # Escape &'s so they dont' get turned into a shortcut' + cmd = cmd.replace("&", "&&") + menu.addAction("{}: {}".format(self.secondsText(secs), cmd)) menu.addSeparator() - avg = sum(self.times) / len(self.times) + avg = sum(times) / len(times) menu.addAction("Average: {:0.04f}s".format(avg)) act = menu.addAction("Clear") act.triggered.connect(self.clearTimes) diff --git a/preditor/scintilla/documenteditor.py b/preditor/scintilla/documenteditor.py index 72b5cc4d..94dad5eb 100644 --- a/preditor/scintilla/documenteditor.py +++ b/preditor/scintilla/documenteditor.py @@ -21,8 +21,9 @@ import six from PyQt5.Qsci import QsciScintilla +from PyQt5.QtCore import QTextCodec from Qt import QtCompat -from Qt.QtCore import Property, QFile, QPoint, Qt, QTextCodec, Signal +from Qt.QtCore import Property, QFile, QPoint, Qt, Signal from Qt.QtGui import QColor, QFont, QFontMetrics, QIcon from Qt.QtWidgets import ( QAction,