def onItemClick(self, item): """ Go to the right line in the editor and give focus. """ # Get editor editor = iep.editors.getCurrentEditor() if not editor: return # If item is attribute, get parent if not item.linenr: item = item.parent() # Move to line editor.gotoLine(item.linenr) # Give focus iep.callLater(editor.setFocus)
def __init__(self, parent): QtGui.QWidget.__init__(self,parent) # keep a booking of opened directories self._lastpath = '' # keep track of all breakpoints self._breakPoints = {} # create tab widget self._tabs = FileTabWidget(self) self._tabs.tabCloseRequested.connect(self.closeFile) self._tabs.currentChanged.connect(self.onCurrentChanged) # Double clicking a tab saves the file, clicking on the bar opens a new file self._tabs.tabBar().tabDoubleClicked.connect(self.saveFile) self._tabs.tabBar().barDoubleClicked.connect(self.newFile) # Create find/replace widget self._findReplace = FindReplaceWidget(self) # create box layout control and add widgets self._boxLayout = QtGui.QVBoxLayout(self) self._boxLayout.addWidget(self._tabs, 1) self._boxLayout.addWidget(self._findReplace, 0) # spacing of widgets self._boxLayout.setSpacing(0) # apply self.setLayout(self._boxLayout) #self.setAttribute(QtCore.Qt.WA_AlwaysShowToolTips,True) # accept drops self.setAcceptDrops(True) # restore state (call later so that the menu module can bind to the # currentChanged signal first, in order to set tab/indentation # checkmarks appropriately) # todo: Resetting the scrolling would work better if set after # the widgets are properly sized. iep.callLater(self.restoreEditorState)
def handle_command(command, arg): """ Function that handles all IEP commands. This gets called either from the server, or from the code that processed command line args. """ if not command: return 'empty command?' elif command == 'testerr': return 1/0 elif command == 'stopserver': # For efficiently stopping the server if server: server.stop() return 'Stopped the server' elif command == 'echo': # For testing return 'echo %r' % arg elif command == 'open': # Open a file in the editor if not arg: return 'The open command requires a filename.' iep.callLater(iep.editors.loadFile, arg) return 'Opened file %r' % arg elif command == 'new': # Open a new (temp) file in the editor iep.callLater(iep.editors.newFile) return 'Created new file' elif command == 'close': # Close IEP iep.callLater(iep.main.close) return 'Closing IEP' else: # Assume the user wanted to open a file fname = (command + ' ' + arg).rstrip() if not iep.editors: return 'Still warming up ...' else: iep.callLater(iep.editors.loadFile, fname) return 'Try opening file %r' % fname # We should always return. So if we get here, it is a bug. # Return something so that we can be aware. return 'error ' + command
def __init__(self, parent): QtGui.QWidget.__init__(self,parent) # keep a booking of opened directories self._lastpath = '' # create tab widget self._tabs = FileTabWidget(self) self._tabs.tabCloseRequested.connect(self.closeFile) self._tabs.currentChanged.connect(self.onCurrentChanged) # Double clicking a tab saves the file, clicking on the bar opens a new file self._tabs.tabBar().tabDoubleClicked.connect(self.saveFile) self._tabs.tabBar().barDoubleClicked.connect(self.newFile) # Create find/replace widget self._findReplace = FindReplaceWidget(self) # create box layout control and add widgets self._boxLayout = QtGui.QVBoxLayout(self) self._boxLayout.addWidget(self._tabs, 1) self._boxLayout.addWidget(self._findReplace, 0) # spacing of widgets self._boxLayout.setSpacing(0) # apply self.setLayout(self._boxLayout) #self.setAttribute(QtCore.Qt.WA_AlwaysShowToolTips,True) # accept drops self.setAcceptDrops(True) # restore state (call later so that the menu module can bind to the # currentChanged signal first, in order to set tab/indentation # checkmarks appropriately) # todo: Resetting the scrolling would work better if set after # the widgets are properly sized. iep.callLater(self.restoreEditorState)
def handle_request(self, request): """ This is where the requests enter. """ # Get command request = request.strip() command, _, arg = request.partition(' ') # Handle command try: reply = handle_command(command, arg) except Exception as err: msg = 'Error handling request %r:\n%s' % (request, str(err)) iep.callLater(print, msg) return msg else: iep.callLater(print, 'Request:', request) iep.callLater(print, 'Reply:', reply) return reply