Skip to content

Commit aa3ec1d

Browse files
macevhiczMHendricks
authored andcommitted
Optionally visually separate internal preditor code in tracebacks
1 parent a28e9df commit aa3ec1d

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

preditor/gui/console.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ def __init__(self, parent):
6363

6464
self._firstShow = True
6565

66+
self.addSepNewline = False
67+
6668
# When executing code, that takes longer than this seconds, flash the window
6769
self.flash_time = 1.0
6870
self.flash_window = None
@@ -817,6 +819,10 @@ def write(self, msg, error=False):
817819
hasattr(window, 'uiErrorHyperlinksACT')
818820
and window.uiErrorHyperlinksACT.isChecked()
819821
)
822+
sepPreditorTrace = (
823+
hasattr(window, 'uiSeparateTracebackACT')
824+
and window.uiSeparateTracebackACT.isChecked()
825+
)
820826
self.moveCursor(QTextCursor.MoveOperation.End)
821827

822828
charFormat = QTextCharFormat()
@@ -855,6 +861,17 @@ def write(self, msg, error=False):
855861
filename = info.get("filename", "") if info else ""
856862
isConsolePrEdit = '<ConsolePrEdit>' in filename
857863

864+
# To make it easier to see relevant lines of a traceback, optionally insert
865+
# a newline separating internal PrEditor code from the code run by user.
866+
if self.addSepNewline:
867+
if sepPreditorTrace:
868+
msg += "\n"
869+
self.addSepNewline = False
870+
871+
preditorCalls = ("cmdresult = e", "exec(compiled,")
872+
if msg.strip().startswith(preditorCalls):
873+
self.addSepNewline = True
874+
858875
if info and doHyperlink and not isConsolePrEdit:
859876
fileStart = info.get("fileStart")
860877
fileEnd = info.get("fileEnd")

preditor/gui/loggerwindow.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,7 @@ def recordPrefs(self, manual=False):
813813
'uiStatusLbl_limit': self.uiStatusLBL.limit(),
814814
'textEditorPath': self.textEditorPath,
815815
'textEditorCmdTempl': self.textEditorCmdTempl,
816+
'uiSeparateTracebackACT': self.uiSeparateTracebackACT.isChecked(),
816817
'currentStyleSheet': self._stylesheet,
817818
'flash_time': self.uiConsoleTXT.flash_time,
818819
'find_files_regex': self.uiFindInWorkboxesWGT.uiRegexBTN.isChecked(),
@@ -965,6 +966,8 @@ def restorePrefs(self):
965966
self.textEditorPath = pref.get('textEditorPath', defaultExePath)
966967
self.textEditorCmdTempl = pref.get('textEditorCmdTempl', defaultCmd)
967968

969+
self.uiSeparateTracebackACT.setChecked(pref.get('uiSeparateTracebackACT', True))
970+
968971
self.uiWordWrapACT.setChecked(pref.get('wordWrap', True))
969972
self.setWordWrap(self.uiWordWrapACT.isChecked())
970973
self.uiClearBeforeRunningACT.setChecked(pref.get('clearBeforeRunning', False))

preditor/gui/ui/loggerwindow.ui

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
<x>0</x>
9393
<y>0</y>
9494
<width>796</width>
95-
<height>21</height>
95+
<height>22</height>
9696
</rect>
9797
</property>
9898
<widget class="QMenu" name="uiDebugMENU">
@@ -193,6 +193,8 @@
193193
<addaction name="uiSetFlashWindowIntervalACT"/>
194194
<addaction name="separator"/>
195195
<addaction name="uiErrorHyperlinksACT"/>
196+
<addaction name="uiSeparateTracebackACT"/>
197+
<addaction name="separator"/>
196198
<addaction name="uiSetPreferredTextEditorPathACT"/>
197199
<addaction name="uiSetWorkboxEditorACT"/>
198200
</widget>
@@ -1003,6 +1005,14 @@ at the indicated line in the specified text editor.
10031005
<string>Highlight Exact Completion</string>
10041006
</property>
10051007
</action>
1008+
<action name="uiSeparateTracebackACT">
1009+
<property name="checkable">
1010+
<bool>true</bool>
1011+
</property>
1012+
<property name="text">
1013+
<string>Visually Separate PrEditor Traceback</string>
1014+
</property>
1015+
</action>
10061016
</widget>
10071017
<customwidgets>
10081018
<customwidget>

0 commit comments

Comments
 (0)