Esempio n. 1
0
def main():
    """Main function."""
    options, files = parse_commandline()
    urls = list(map(url, files))
    
    if not app.qApp.isSessionRestored():
        if not options.new and remote.enabled():
            api = remote.get()
            if api:
                api.command_line(options, urls)
                api.close()
                sys.exit(0)
    
        if QSettings().value("splash_screen", True) not in ("false", False):
            import splashscreen
            splashscreen.show()

    QTimer.singleShot(0, remote.setup)  # Start listening for IPC
    
    import mainwindow       # contains MainWindow class
    import session          # Initialize QSessionManager support
    import sessions         # Initialize our own named session support
    import document         # contains Document class

    # boot Frescobaldi-specific stuff that should be running on startup
    import viewhighlighter  # highlight arbitrary ranges in text
    import matcher          # matches braces etc in active text window
    import progress         # creates progress bar in view space
    import autocomplete     # auto-complete input
    
    if app.qApp.isSessionRestored():
        # Restore session, we are started by the session manager
        session.restoreSession()
        return

    # load specified session
    doc = None
    if options.session and options.session != "none":
        doc = sessions.loadSession(options.session)
        
    # Just create one MainWindow
    win = mainwindow.MainWindow()
    win.show()
    
    if urls:
        for u in urls:
            doc = win.openUrl(u, options.encoding)
    elif not options.session:
        # no docs, load default session
        doc = sessions.loadDefaultSession()
    win.setCurrentDocument(doc or document.Document())
    if urls and options.line is not None:
        # set the last loaded document active and apply navigation if requested
        pos = doc.findBlockByNumber(options.line - 1).position() + options.column
        cursor = QTextCursor(doc)
        cursor.setPosition(pos)
        win.currentView().setTextCursor(cursor)
        win.currentView().centerCursor()
Esempio n. 2
0
File: core.py Progetto: Dad0u/Myrror
def get(prop: str, flist: list[File]):
    """
  Get a property in a list of files

  Does not return anything ! The files are updated in place
  """
    s = set()
    for f in flist:
        s.add(f.loc)
    if not s:
        return
    if len(s) != 1:
        raise AttributeError("Can only call get() on a list of files "
                             "from the same location")
    # Only get the prop of the files that need it !
    flist = [f for f in flist if not hasattr(f, prop)]
    if flist:
        if s.pop().is_local:
            local.get(prop, flist)
        else:
            remote.get(prop, flist)
Esempio n. 3
0
def main():
    """Main function."""
    args = parse_commandline()

    if args.version_debug:
        import debuginfo
        sys.stdout.write(debuginfo.version_info_string() + '\n')
        sys.exit(0)

    if args.python_ly:
        # The python-ly path has to be inserted at the *second* position
        # because the first element in sys.path is the directory of the invoked
        # script (an information we need in determining if Frescobaldi is run
        # from its Git repository)
        sys.path.insert(1, args.python_ly)

    check_ly()

    if args.list_sessions:
        import sessions
        for name in sessions.sessionNames():
            sys.stdout.write(name + '\n')
        sys.exit(0)

    urls = list(map(url, args.files))

    if not app.qApp.isSessionRestored():
        if not args.new and remote.enabled():
            api = remote.get()
            if api:
                api.command_line(args, urls)
                api.close()
                sys.exit(0)

        if QSettings().value("splash_screen", True, bool):
            import splashscreen
            splashscreen.show()

    # application icon
    import icons
    QApplication.setWindowIcon(icons.get("frescobaldi"))

    QTimer.singleShot(0, remote.setup)  # Start listening for IPC

    import mainwindow  # contains MainWindow class
    import session  # Initialize QSessionManager support
    import sessions  # Initialize our own named session support

    # boot Frescobaldi-specific stuff that should be running on startup
    import viewhighlighter  # highlight arbitrary ranges in text
    import progress  # creates progress bar in view space
    import musicpos  # shows music time in statusbar
    import autocomplete  # auto-complete input
    import wordboundary  # better wordboundary behaviour for the editor

    if sys.platform.startswith('darwin'):
        import macosx.setup
        macosx.setup.initialize()

    if app.qApp.isSessionRestored():
        # Restore session, we are started by the session manager
        session.restoreSession(app.qApp.sessionKey())
        return

    # load specified session?
    doc = None
    if args.session and args.session != "-":
        doc = sessions.loadSession(args.session)

    # Just create one MainWindow
    win = mainwindow.MainWindow()
    win.show()
    win.activateWindow()

    # load documents given as arguments
    import document
    for u in urls:
        doc = win.openUrl(u, args.encoding, ignore_errors=True)
        if not doc:
            doc = document.EditorDocument(u, args.encoding)

    # were documents loaded?
    if not doc:
        if app.documents:
            doc = app.documents[-1]
        elif not args.session:
            # no docs, load default session
            doc = sessions.loadDefaultSession()

    if doc:
        win.setCurrentDocument(doc)
    else:
        win.cleanStart()

    if urls and args.line is not None:
        # set the last loaded document active and apply navigation if requested
        pos = doc.findBlockByNumber(args.line - 1).position() + args.column
        cursor = QTextCursor(doc)
        cursor.setPosition(pos)
        win.currentView().setTextCursor(cursor)
        win.currentView().centerCursor()
Esempio n. 4
0
def main():
    """Main function."""
    args = parse_commandline()

    if args.version_debug:
        import debuginfo
        sys.stdout.write(debuginfo.version_info_string() + '\n')
        sys.exit(0)

    check_ly()
    patch_pyqt()

    if args.list_sessions:
        import sessions
        for name in sessions.sessionNames():
            sys.stdout.write(name + '\n')
        sys.exit(0)

    urls = list(map(url, args.files))

    if not app.qApp.isSessionRestored():
        if not args.new and remote.enabled():
            api = remote.get()
            if api:
                api.command_line(args, urls)
                api.close()
                sys.exit(0)

        if QSettings().value("splash_screen", True, bool):
            import splashscreen
            splashscreen.show()

    # application icon
    import icons
    QApplication.setWindowIcon(icons.get("frescobaldi"))

    QTimer.singleShot(0, remote.setup)  # Start listening for IPC

    import mainwindow       # contains MainWindow class
    import session          # Initialize QSessionManager support
    import sessions         # Initialize our own named session support

    # boot Frescobaldi-specific stuff that should be running on startup
    import viewhighlighter  # highlight arbitrary ranges in text
    import progress         # creates progress bar in view space
    import musicpos         # shows music time in statusbar
    import autocomplete     # auto-complete input
    import wordboundary     # better wordboundary behaviour for the editor

    if sys.platform.startswith('darwin'):
        import macosx.setup
        macosx.setup.initialize()

    if app.qApp.isSessionRestored():
        # Restore session, we are started by the session manager
        session.restoreSession(app.qApp.sessionKey())
        return

    # load specified session?
    doc = None
    if args.session and args.session != "-":
        doc = sessions.loadSession(args.session)

    # Just create one MainWindow
    win = mainwindow.MainWindow()
    win.show()
    win.activateWindow()

    # load documents given as arguments
    import document
    for u in urls:
        doc = win.openUrl(u, args.encoding, ignore_errors=True)
        if not doc:
            doc = document.Document(u, args.encoding)

    # were documents loaded?
    if not doc:
        if app.documents:
            doc = app.documents[-1]
        elif not args.session:
            # no docs, load default session
            doc = sessions.loadDefaultSession()

    if doc:
        win.setCurrentDocument(doc)
    else:
        win.cleanStart()

    if urls and args.line is not None:
        # set the last loaded document active and apply navigation if requested
        pos = doc.findBlockByNumber(args.line - 1).position() + args.column
        cursor = QTextCursor(doc)
        cursor.setPosition(pos)
        win.currentView().setTextCursor(cursor)
        win.currentView().centerCursor()
Esempio n. 5
0
def main():
    """Main function."""
    options, files = parse_commandline()

    if options.list_sessions:
        import sessions
        for name in sessions.sessionNames():
            sys.stdout.write(name + '\n')
        sys.exit(0)

    urls = list(map(url, files))

    if not app.qApp.isSessionRestored():
        if not options.new and remote.enabled():
            api = remote.get()
            if api:
                api.command_line(options, urls)
                api.close()
                sys.exit(0)

        if QSettings().value("splash_screen", True, bool):
            import splashscreen
            splashscreen.show()

    # application icon
    import icons
    QApplication.setWindowIcon(icons.get("frescobaldi"))

    QTimer.singleShot(0, remote.setup)  # Start listening for IPC

    import mainwindow  # contains MainWindow class
    import session  # Initialize QSessionManager support
    import sessions  # Initialize our own named session support

    # boot Frescobaldi-specific stuff that should be running on startup
    import viewhighlighter  # highlight arbitrary ranges in text
    import progress  # creates progress bar in view space
    import musicpos  # shows music time in statusbar
    import autocomplete  # auto-complete input
    import wordboundary  # better wordboundary behaviour for the editor

    if sys.platform.startswith('darwin'):
        import macosx.setup

    if app.qApp.isSessionRestored():
        # Restore session, we are started by the session manager
        session.restoreSession()
        return

    # load specified session?
    doc = None
    if options.session and options.session != "-":
        doc = sessions.loadSession(options.session)

    # Just create one MainWindow
    win = mainwindow.MainWindow()
    win.show()

    # load documents given as arguments
    for u in urls:
        doc = win.openUrl(u, options.encoding)

    # were documents loaded?
    if not doc:
        if app.documents:
            doc = app.documents[-1]
        elif not options.session:
            # no docs, load default session
            doc = sessions.loadDefaultSession()

    if doc:
        win.setCurrentDocument(doc)
    else:
        win.cleanStart()

    if urls and options.line is not None:
        # set the last loaded document active and apply navigation if requested
        pos = doc.findBlockByNumber(options.line -
                                    1).position() + options.column
        cursor = QTextCursor(doc)
        cursor.setPosition(pos)
        win.currentView().setTextCursor(cursor)
        win.currentView().centerCursor()
Esempio n. 6
0
	def get(self, server, files):
		ssh = self.connect(server)
		return remote.get(ssh, files)
Esempio n. 7
0
def main():
    """Main function."""
    options, files = parse_commandline()
    
    if options.list_sessions:
        import sessions
        for name in sessions.sessionNames():
            sys.stdout.write(name + '\n')
        sys.exit(0)
        
    urls = list(map(url, files))
    
    if not app.qApp.isSessionRestored():
        if not options.new and remote.enabled():
            api = remote.get()
            if api:
                api.command_line(options, urls)
                api.close()
                sys.exit(0)
    
        if QSettings().value("splash_screen", True, bool):
            import splashscreen
            splashscreen.show()

    # application icon
    import icons
    QApplication.setWindowIcon(icons.get("frescobaldi"))
    
    QTimer.singleShot(0, remote.setup)  # Start listening for IPC
    
    import mainwindow       # contains MainWindow class
    import session          # Initialize QSessionManager support
    import sessions         # Initialize our own named session support
    import document         # contains Document class

    # boot Frescobaldi-specific stuff that should be running on startup
    import viewhighlighter  # highlight arbitrary ranges in text
    import progress         # creates progress bar in view space
    import autocomplete     # auto-complete input
    import wordboundary     # better wordboundary behaviour for the editor
    
    # on Mac OS X, handle FileOpen requests (e.g. double-clicking a file in the
    # Finder), these events also can occur right on application start.
    # We do this just before creating the window, so that when multiple files
    # are opened on startup (I don't know whether that really could happen),
    # they are not made the current document, as that slows down loading
    # multiple documents drastically.
    if sys.platform.startswith('darwin'):
        import file_open_eventhandler
        import icon_drag_eventhandler   # handle window icon drag events
    
    if app.qApp.isSessionRestored():
        # Restore session, we are started by the session manager
        session.restoreSession()
        return

    # load specified session?
    doc = None
    if options.session and options.session != "-":
        doc = sessions.loadSession(options.session)
    
    # Just create one MainWindow
    win = mainwindow.MainWindow()
    win.show()
    
    # load documents given as arguments
    for u in urls:
        doc = win.openUrl(u, options.encoding)
    
    # were documents loaded?
    if not doc:
        if app.documents:
            doc = app.documents[-1]
        elif not options.session:
            # no docs, load default session
            doc = sessions.loadDefaultSession()
    
    win.setCurrentDocument(doc or document.Document())
    
    if urls and options.line is not None:
        # set the last loaded document active and apply navigation if requested
        pos = doc.findBlockByNumber(options.line - 1).position() + options.column
        cursor = QTextCursor(doc)
        cursor.setPosition(pos)
        win.currentView().setTextCursor(cursor)
        win.currentView().centerCursor()