src/eric7/QScintilla/Shell.py

branch
server
changeset 10632
1109854f15f9
parent 10630
552a790fd9bc
parent 10621
f5631f40c4d9
child 10633
dda7e43934dc
equal deleted inserted replaced
10631:00f5aae565a3 10632:1109854f15f9
320 self.menu.addAction(self.tr("Save Contents..."), self.saveContents) 320 self.menu.addAction(self.tr("Save Contents..."), self.saveContents)
321 self.menu.addSeparator() 321 self.menu.addSeparator()
322 self.menu.addAction(self.tr("Configure..."), self.__configure) 322 self.menu.addAction(self.tr("Configure..."), self.__configure)
323 self.menu.addSeparator() 323 self.menu.addSeparator()
324 self.menu.addAction(self.tr("Special Commands Help"), self.__showHelp) 324 self.menu.addAction(self.tr("Special Commands Help"), self.__showHelp)
325 self.menu.addSeparator()
326 self.__showSourceAct = self.menu.addAction(
327 self.tr("Show Source"), self.__showSource
328 )
325 329
326 self.customContextMenuRequested.connect(self.__showContextMenu) 330 self.customContextMenuRequested.connect(self.__showContextMenu)
327 self.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) 331 self.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
328 332
329 self.__bindLexer() 333 self.__bindLexer()
2124 2128
2125 @param pos position for the context menu 2129 @param pos position for the context menu
2126 @type QPoint 2130 @type QPoint
2127 """ 2131 """
2128 if not self.__windowed: 2132 if not self.__windowed:
2133 # check, if the cursor is positioned on an exception line
2134 # The exception line looks like 'File: /path/of/file.py, Line: 111'.
2135 line = self.getCursorPosition()[0]
2136 text = self.text(line).strip()
2137 self.__showSourceAct.setEnabled(
2138 bool(re.search(r'File: (.*?), Line: (\d+)', text))
2139 )
2140
2129 self.menu.popup(self.mapToGlobal(pos)) 2141 self.menu.popup(self.mapToGlobal(pos))
2130 2142
2131 def clear(self): 2143 def clear(self):
2132 """ 2144 """
2133 Public slot to clear the display. 2145 Public slot to clear the display.
2619 parent=self, 2631 parent=self,
2620 ) 2632 )
2621 self.__helpDialog.show() 2633 self.__helpDialog.show()
2622 2634
2623 ################################################################# 2635 #################################################################
2624 ## Project Support 2636 ## Project Support methods
2625 ################################################################# 2637 #################################################################
2626 2638
2627 def __projectOpened(self): 2639 def __projectOpened(self):
2628 """ 2640 """
2629 Private slot to start the shell for the opened project. 2641 Private slot to start the shell for the opened project.
2645 """ 2657 """
2646 if not self.__shuttingDown and Preferences.getProject("RestartShellForProject"): 2658 if not self.__shuttingDown and Preferences.getProject("RestartShellForProject"):
2647 self.dbs.startClient(False) 2659 self.dbs.startClient(False)
2648 self.__getBanner() 2660 self.__getBanner()
2649 2661
2662 #######################################################################
2663 ## Tool methods
2664 #######################################################################
2665
2666 def __showSource(self):
2667 """
2668 Private method to open an editor for an exception line.
2669
2670 Note: The exception line looks like 'File: /path/of/file.py, Line: 111'.
2671 """
2672 line = self.getCursorPosition()[0]
2673 text = self.text(line).strip()
2674 match = re.search(r'File: (.*?), Line: (\d+)', text)
2675 if match:
2676 filename = match.group(1)
2677 linenumber = int(match.group(2))
2678 self.vm.openSourceFile(filename, lineno=linenumber)
2679
2650 ################################################################# 2680 #################################################################
2651 ## eric-ide Server Support 2681 ## eric-ide Server Support
2652 ################################################################# 2682 #################################################################
2653 2683
2654 @pyqtSlot(bool) 2684 @pyqtSlot(bool)

eric ide

mercurial