コード例 #1
0
ファイル: pyzoSourceStructure.py プロジェクト: ysalmon/pyzo
 def _navigate_to_line(self, linenr):
     
     # Get editor
     editor = pyzo.editors.getCurrentEditor()
     if not editor:
         return None
     # Keep current line nr
     old_linenr = editor.textCursor().blockNumber() + 1
     # Move to line
     editor.gotoLine(linenr)
     # Give focus
     pyzo.callLater(editor.setFocus)
     return old_linenr
コード例 #2
0
    def _navigate_to_line(self, linenr):

        # Get editor
        editor = pyzo.editors.getCurrentEditor()
        if not editor:
            return None
        # Keep current line nr
        old_linenr = editor.textCursor().blockNumber() + 1
        # Move to line
        editor.gotoLine(linenr)
        # Give focus
        pyzo.callLater(editor.setFocus)
        return old_linenr
コード例 #3
0
ファイル: pyzoSourceStructure.py プロジェクト: BrenBarn/pyzo
 def onItemClick(self, item):
     """ Go to the right line in the editor and give focus. """
     
     # Get editor
     editor = pyzo.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
     pyzo.callLater(editor.setFocus)
コード例 #4
0
ファイル: pyzoSourceStructure.py プロジェクト: operade/pyzo
    def onItemClick(self, item):
        """ Go to the right line in the editor and give focus. """

        # Get editor
        editor = pyzo.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
        pyzo.callLater(editor.setFocus)
コード例 #5
0
ファイル: editorTabs.py プロジェクト: ghisvail/pyzo
    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.
        pyzo.callLater(self.restoreEditorState)
コード例 #6
0
 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.
     pyzo.callLater(self.restoreEditorState)
コード例 #7
0
ファイル: commandline.py プロジェクト: solversa/pyzo
def handle_command(command, arg):
    """ Function that handles all pyzo 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."
        pyzo.callLater(pyzo.editors.loadFile, arg)
        return "Opened file %r" % arg

    elif command == "new":
        # Open a new (temp) file in the editor
        pyzo.callLater(pyzo.editors.newFile)
        return "Created new file"

    elif command == "close":
        # Close pyzo
        pyzo.callLater(pyzo.main.close)
        return "Closing Pyzo"

    else:
        # Assume the user wanted to open a file
        fname = (command + " " + arg).rstrip()
        if not pyzo.editors:
            return "Still warming up ..."
        else:
            pyzo.callLater(pyzo.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
コード例 #8
0
ファイル: commandline.py プロジェクト: tjguk/pyzo
def handle_command(command, arg):
    """ Function that handles all pyzo 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.'
        pyzo.callLater(pyzo.editors.loadFile, arg)
        return 'Opened file %r' % arg

    elif command == 'new':
        # Open a new (temp) file in the editor
        pyzo.callLater(pyzo.editors.newFile)
        return 'Created new file'

    elif command == 'close':
        # Close pyzo
        pyzo.callLater(pyzo.main.close)
        return 'Closing Pyzo'

    else:
        # Assume the user wanted to open a file
        fname = (command + ' ' + arg).rstrip()
        if not pyzo.editors:
            return 'Still warming up ...'
        else:
            pyzo.callLater(pyzo.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
コード例 #9
0
ファイル: commandline.py プロジェクト: BrenBarn/pyzo
def handle_command(command, arg):
    """ Function that handles all pyzo 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.'
        pyzo.callLater(pyzo.editors.loadFile, arg)
        return 'Opened file %r' % arg
    
    elif command == 'new':
        # Open a new (temp) file in the editor 
        pyzo.callLater(pyzo.editors.newFile)
        return 'Created new file'
    
    elif command == 'close':
        # Close pyzo
        pyzo.callLater(pyzo.main.close)
        return 'Closing Pyzo'
    
    else:
        # Assume the user wanted to open a file
        fname = (command + ' ' + arg).rstrip()
        if not pyzo.editors:
            return 'Still warming up ...'
        else:
            pyzo.callLater(pyzo.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
コード例 #10
0
ファイル: commandline.py プロジェクト: vishalbelsare/pyzo
    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))
            pyzo.callLater(print, msg)
            return msg
        else:
            pyzo.callLater(print, "Request:", request)
            pyzo.callLater(print, "Reply:", reply)
            return reply
コード例 #11
0
ファイル: commandline.py プロジェクト: BrenBarn/pyzo
 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))
         pyzo.callLater(print, msg)
         return msg
     else:
         pyzo.callLater(print, 'Request:', request)
         pyzo.callLater(print, 'Reply:', reply)
         return reply