319 self.menu.addAction(self.tr("Save Contents..."), self.saveContents) |
319 self.menu.addAction(self.tr("Save Contents..."), self.saveContents) |
320 self.menu.addSeparator() |
320 self.menu.addSeparator() |
321 self.menu.addAction(self.tr("Configure..."), self.__configure) |
321 self.menu.addAction(self.tr("Configure..."), self.__configure) |
322 self.menu.addSeparator() |
322 self.menu.addSeparator() |
323 self.menu.addAction(self.tr("Special Commands Help"), self.__showHelp) |
323 self.menu.addAction(self.tr("Special Commands Help"), self.__showHelp) |
|
324 self.menu.addSeparator() |
|
325 self.__showSourceAct = self.menu.addAction( |
|
326 self.tr("Show Source"), self.__showSource |
|
327 ) |
324 |
328 |
325 self.customContextMenuRequested.connect(self.__showContextMenu) |
329 self.customContextMenuRequested.connect(self.__showContextMenu) |
326 self.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) |
330 self.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) |
327 |
331 |
328 self.__bindLexer() |
332 self.__bindLexer() |
2117 |
2121 |
2118 @param pos position for the context menu |
2122 @param pos position for the context menu |
2119 @type QPoint |
2123 @type QPoint |
2120 """ |
2124 """ |
2121 if not self.__windowed: |
2125 if not self.__windowed: |
|
2126 # check, if the cursor is positioned on an exception line |
|
2127 # The exception line looks like 'File: /path/of/file.py, Line: 111'. |
|
2128 line = self.getCursorPosition()[0] |
|
2129 text = self.text(line).strip() |
|
2130 self.__showSourceAct.setEnabled( |
|
2131 bool(re.search(r'File: (.*?), Line: (\d+)', text)) |
|
2132 ) |
|
2133 |
2122 self.menu.popup(self.mapToGlobal(pos)) |
2134 self.menu.popup(self.mapToGlobal(pos)) |
2123 |
2135 |
2124 def clear(self): |
2136 def clear(self): |
2125 """ |
2137 """ |
2126 Public slot to clear the display. |
2138 Public slot to clear the display. |
2610 parent=self, |
2622 parent=self, |
2611 ) |
2623 ) |
2612 self.__helpDialog.show() |
2624 self.__helpDialog.show() |
2613 |
2625 |
2614 ################################################################# |
2626 ################################################################# |
2615 ## Project Support |
2627 ## Project Support methods |
2616 ################################################################# |
2628 ################################################################# |
2617 |
2629 |
2618 def __projectOpened(self): |
2630 def __projectOpened(self): |
2619 """ |
2631 """ |
2620 Private slot to start the shell for the opened project. |
2632 Private slot to start the shell for the opened project. |
2632 """ |
2644 """ |
2633 if not self.__shuttingDown and Preferences.getProject("RestartShellForProject"): |
2645 if not self.__shuttingDown and Preferences.getProject("RestartShellForProject"): |
2634 self.dbs.startClient(False) |
2646 self.dbs.startClient(False) |
2635 self.__getBanner() |
2647 self.__getBanner() |
2636 |
2648 |
2637 |
2649 ####################################################################### |
|
2650 ## Tool methods |
|
2651 ####################################################################### |
|
2652 |
|
2653 def __showSource(self): |
|
2654 """ |
|
2655 Private method to open an editor for an exception line. |
|
2656 |
|
2657 Note: The exception line looks like 'File: /path/of/file.py, Line: 111'. |
|
2658 """ |
|
2659 line = self.getCursorPosition()[0] |
|
2660 text = self.text(line).strip() |
|
2661 match = re.search(r'File: (.*?), Line: (\d+)', text) |
|
2662 if match: |
|
2663 filename = match.group(1) |
|
2664 linenumber = int(match.group(2)) |
|
2665 self.vm.openSourceFile(filename, lineno=linenumber) |
2638 # |
2666 # |
2639 # eflag: noqa = M601 |
2667 # eflag: noqa = M601 |