コード例 #1
0
ファイル: be_editor.py プロジェクト: barry-scott/BarrysEmacs
    def __init__( self, app ):
        _bemacs.BemacsEditor.__init__( self,
                str(be_platform_specific.getUserDir()),
                str(be_platform_specific.getLibraryDir()) )

        be_debug.EmacsDebugMixin.__init__( self )

        self.app = app
        self.log = app.log

        self.window = None

        self.__quit_editor = False
        self.__event_queue = Queue( self.log )

        self.__gui_result_event = threading.Event()

        self.__clipboard_data = None

        self.hook_ui_handlers = {
            "edit-copy":        self.uiHookEditCopy,
            "edit-paste":       self.uiHookEditPaste,
            "yes-no-dialog":    self.uiHookYesNoDialog,
            "set-window-title": self.uiHookSetWindowTitle,
            "filter-string":    self.uiHookFilterString,
            "open-file-dialog": self.uiHookOpenFileDialog,
            "release-waiting-client":   self.uiHookReleaseWaitingClient,
            "test1":            self.uiHookTest1,
            "test2":            self.uiHookTest2,
            }
コード例 #2
0
ファイル: be_editor.py プロジェクト: uchuugaka/BarrysEmacs
    def __init__(self, app):
        _bemacs.BemacsEditor.__init__(
            self, str(be_platform_specific.getUserDir()),
            str(be_platform_specific.getLibraryDir()))

        be_debug.EmacsDebugMixin.__init__(self)

        self.app = app
        self.log = app.log

        self.window = None

        self.__quit_editor = False
        self.__event_queue = Queue(self.log)

        self.__gui_result_event = threading.Event()

        self.__clipboard_data = None

        self.hook_ui_handlers = {
            "edit-copy": self.uiHookEditCopy,
            "edit-paste": self.uiHookEditPaste,
            "yes-no-dialog": self.uiHookYesNoDialog,
            "set-window-title": self.uiHookSetWindowTitle,
            "filter-string": self.uiHookFilterString,
            "open-file-dialog": self.uiHookOpenFileDialog,
            "release-waiting-client": self.uiHookReleaseWaitingClient,
            "test1": self.uiHookTest1,
            "test2": self.uiHookTest2,
        }
コード例 #3
0
ファイル: be_app.py プロジェクト: uchuugaka/BarrysEmacs
    def __init__(self, args):
        be_debug.EmacsDebugMixin.__init__(self)

        self.may_quit = False

        self.args = args
        self.opt_name = None
        self.release_waiting_client_reply = None

        self.startup_dir = os.getcwd()

        be_platform_specific.setupPlatform(args[0])

        # on the Mac the app's cwd is the resource folder
        if sys.platform == 'darwin':
            if 'PWD' in os.environ:
                os.chdir(os.environ['PWD'])
            else:
                os.chdir(os.environ['HOME'])

        self.__debug_noredirect = False
        self.__debug = True
        self.__mock_editor = False
        self.__log_stdout = False

        self.__callback_queue = queue.Queue()

        while len(args) > 1:
            arg = args[1]
            if arg.startswith('-psn_'):
                del args[1]

            elif arg.startswith('--name='):
                self.opt_name = arg[len('--name='):]
                del args[1]

            elif arg == '--noredirect':
                self.__debug_noredirect = True
                del args[1]

            elif arg == '--log-stdout':
                self.__log_stdout = True
                del args[1]

            elif arg == '--debug' and len(args) > 2:
                self.__debug = True
                be_debug.setDebug(args[2])
                del args[1]
                del args[1]

            elif arg == '--mock-editor':
                self.__mock_editor = True
                del args[1]

            elif arg == '--start-dir' and len(args) > 2:
                os.chdir(args[2])
                del args[1]
                del args[1]

            elif arg == '--':
                break

            else:
                break

        self.__call_gui_result = None
        self.__call_gui_result_event = threading.Event()

        self.editor = None

        self.main_thread = threading.currentThread()
        if self.__mock_editor:
            self.editor_thread = None
            self.command_line_thread = None
            self.editor = MockEditor(self)

        else:
            self.editor_thread = threading.Thread(name='Editor',
                                                  target=self.__runEditor)
            self.command_line_thread = threading.Thread(
                name='CommandLine', target=self.__runCommandLineHandler)

        self.progress_format = None
        self.progress_values = {}

        locale_path = be_platform_specific.getLocalePath(self)
        self.translation = gettext.translation(
            'bemacs',
            str(locale_path),
            # language defaults
            fallback=True)

        import builtins
        # T_( 'non plural' )
        builtins.__dict__['T_'] = self.translation.gettext
        # S_( 'singular', 'plural', n )
        builtins.__dict__['S_'] = self.translation.ngettext
        # U_( 'static string' )
        builtins.__dict__['U_'] = lambda s: s

        # Debug settings
        self.__last_client_error = []

        self.setupLogging()

        self.log.info('startup_dir %s' % (self.startup_dir, ))
        self.log.info('locale_path %s' % (locale_path, ))
        self.log.info('find %r' % (gettext.find('bemacs', str(locale_path)), ))
        self.log.info('info %r' % (self.translation.info(), ))
        self.log.info(T_("Barry's Emacs"))

        self.log.info('Application dir %s' %
                      (be_platform_specific.getAppDir(), ))
        self.log.info('emacs_user %s' % (be_platform_specific.getUserDir(), ))
        self.log.info('emacs_library %s' %
                      (be_platform_specific.getLibraryDir(), ))

        self.prefs_mgr = be_preferences.BemacsPreferenceManager(
            self, be_platform_specific.getPreferencesFilename(),
            be_platform_specific.getSessionFilename())

        self.main_window = None
        self.log.info('Qt argv[0] %r' % (sys.argv[0], ))
        self.log.info('Qt libraryPaths %r' %
                      (QtWidgets.QApplication.libraryPaths(), ))

        # init QApplication now that we have the plugin dir setup
        QtWidgets.QApplication.__init__(self, [sys.argv[0]])

        self.main_window = be_main_window.BemacsMainWindow(self)

        self.MarshallToGuiThreadSignal.connect(self.handleMarshallToGuiThread)

        self.setFallbackSessionManagementEnabled(False)

        self.saveStateRequest.connect(self.saveStateHandler)
        self.commitDataRequest.connect(self.commitDataHandler)
コード例 #4
0
ファイル: be_app.py プロジェクト: barry-scott/BarrysEmacs
    def __init__( self, args ):
        be_debug.EmacsDebugMixin.__init__( self )

        self.may_quit = False

        self.args = args
        self.opt_name = None
        self.release_waiting_client_reply = None

        self.startup_dir = os.getcwd()

        be_platform_specific.setupPlatform( args[0] )

        # on the Mac the app's cwd is the resource folder
        if sys.platform == 'darwin':
            if 'PWD' in os.environ:
                os.chdir( os.environ['PWD'] )
            else:
                os.chdir( os.environ['HOME'] )

        self.__debug_noredirect = False
        self.__debug = True
        self.__mock_editor = False
        self.__log_stdout = False

        self.__callback_queue = queue.Queue()

        while len(args) > 1:
            arg = args[ 1 ]
            if arg.startswith( '-psn_' ):
                del args[ 1 ]

            elif arg.startswith( '--name=' ):
                self.opt_name = arg[len('--name='):]
                del args[ 1 ]

            elif arg == '--noredirect':
                self.__debug_noredirect = True
                del args[ 1 ]

            elif arg == '--log-stdout':
                self.__log_stdout = True
                del args[ 1 ]

            elif arg == '--debug' and len(args) > 2:
                self.__debug = True
                be_debug.setDebug( args[2] )
                del args[ 1 ]
                del args[ 1 ]

            elif arg == '--mock-editor':
                self.__mock_editor = True
                del args[ 1 ]

            elif arg == '--start-dir' and len(args) > 2:
                os.chdir( args[2]  )
                del args[1]
                del args[1]

            elif arg == '--':
                break

            else:
                break

        self.__call_gui_result = None
        self.__call_gui_result_event = threading.Event()

        self.editor = None

        self.main_thread = threading.currentThread()
        if self.__mock_editor:
            self.editor_thread = None
            self.command_line_thread = None
            self.editor = MockEditor( self )

        else:
            self.editor_thread = threading.Thread( name='Editor', target=self.__runEditor )
            self.command_line_thread = threading.Thread( name='CommandLine', target=self.__runCommandLineHandler )

        self.progress_format = None
        self.progress_values = {}

        locale_path = be_platform_specific.getLocalePath( self )
        self.translation = gettext.translation(
                'bemacs',
                str(locale_path),
                # language defaults
                fallback=True )

        import builtins
        # T_( 'non plural' )
        builtins.__dict__['T_'] = self.translation.gettext
        # S_( 'singular', 'plural', n )
        builtins.__dict__['S_'] = self.translation.ngettext
        # U_( 'static string' )
        builtins.__dict__['U_'] = lambda s: s

        # Debug settings
        self.__last_client_error = []

        self.setupLogging()

        self.log.info( 'startup_dir %s' % (self.startup_dir,) )
        self.log.info( 'locale_path %s' % (locale_path,) )
        self.log.info( 'find %r' % (gettext.find( 'bemacs', str(locale_path) ),) )
        self.log.info( 'info %r' % (self.translation.info(),) )
        self.log.info( T_("Barry's Emacs") )

        self.log.info( 'Application dir %s' % (be_platform_specific.getAppDir(),) )
        self.log.info( 'emacs_user %s' % (be_platform_specific.getUserDir(),) )
        self.log.info( 'emacs_library %s' % (be_platform_specific.getLibraryDir(),) )

        self.prefs_mgr = be_preferences.BemacsPreferenceManager(
                self,
                be_platform_specific.getPreferencesFilename(),
                be_platform_specific.getSessionFilename() )

        self.main_window = None
        self.log.info( 'Qt argv[0] %r' % (sys.argv[0],) )
        self.log.info( 'Qt libraryPaths %r' % (QtWidgets.QApplication.libraryPaths(),) )

        # init QApplication now that we have the plugin dir setup
        QtWidgets.QApplication.__init__( self, [sys.argv[0]] )

        is_dark_mode = self.palette().text().color().lightnessF() > self.palette().window().color().lightnessF()

        prefs = self.getPrefs()
        if not is_dark_mode and prefs.window.theme.name == 'Dark':
            self.setDarkPalette()

        self.main_window = be_main_window.BemacsMainWindow( self )

        self.MarshallToGuiThreadSignal.connect( self.handleMarshallToGuiThread )

        self.setFallbackSessionManagementEnabled( False )

        self.saveStateRequest.connect( self.saveStateHandler )
        self.commitDataRequest.connect( self.commitDataHandler )