diff -r 00f5aae565a3 -r 1109854f15f9 src/eric7/QScintilla/Shell.py --- a/src/eric7/QScintilla/Shell.py Fri Mar 08 15:30:53 2024 +0100 +++ b/src/eric7/QScintilla/Shell.py Fri Mar 08 15:51:14 2024 +0100 @@ -322,6 +322,10 @@ self.menu.addAction(self.tr("Configure..."), self.__configure) self.menu.addSeparator() self.menu.addAction(self.tr("Special Commands Help"), self.__showHelp) + self.menu.addSeparator() + self.__showSourceAct = self.menu.addAction( + self.tr("Show Source"), self.__showSource + ) self.customContextMenuRequested.connect(self.__showContextMenu) self.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) @@ -2126,6 +2130,14 @@ @type QPoint """ if not self.__windowed: + # check, if the cursor is positioned on an exception line + # The exception line looks like 'File: /path/of/file.py, Line: 111'. + line = self.getCursorPosition()[0] + text = self.text(line).strip() + self.__showSourceAct.setEnabled( + bool(re.search(r'File: (.*?), Line: (\d+)', text)) + ) + self.menu.popup(self.mapToGlobal(pos)) def clear(self): @@ -2621,7 +2633,7 @@ self.__helpDialog.show() ################################################################# - ## Project Support + ## Project Support methods ################################################################# def __projectOpened(self): @@ -2647,6 +2659,24 @@ self.dbs.startClient(False) self.__getBanner() + ####################################################################### + ## Tool methods + ####################################################################### + + def __showSource(self): + """ + Private method to open an editor for an exception line. + + Note: The exception line looks like 'File: /path/of/file.py, Line: 111'. + """ + line = self.getCursorPosition()[0] + text = self.text(line).strip() + match = re.search(r'File: (.*?), Line: (\d+)', text) + if match: + filename = match.group(1) + linenumber = int(match.group(2)) + self.vm.openSourceFile(filename, lineno=linenumber) + ################################################################# ## eric-ide Server Support #################################################################