Ejemplo n.º 1
0
def plugin_loaded():
    if len(sublime.windows()) == 1 and len(sublime.windows()[0].views()) == 0:
        hijack_window()

    window = sublime.active_window()
    if not ST3:
        global recursive_plugin_loaded
        # recursion limit is 1000 generally, so it will try to refresh for 100*1000 ms (100 s)
        # if no active_window in 100 s, then no refresh
        # if view still loading, refresh fail because view cant be edited
        if not window or any(view.is_loading() for view in window.views()):
            recursive_plugin_loaded += 1
            try:
                return sublime.set_timeout(plugin_loaded, 100)
            except RuntimeError:
                print(
                    '\ndired.plugin_loaded run recursively %d time(s); and failed to refresh\n'
                    % recursive_plugin_loaded)
                return

    for w in sublime.windows():
        for v in w.views():
            if v.settings() and v.settings().get("dired_path"):
                # reset sels because dired_index not exists yet, so we cant restore sels
                v.run_command("dired_refresh", {"reset_sels": True})

    import sys
    dfsobserver = '%s0_dired_fs_observer' % ('FileBrowser.' if ST3 else '')
    if dfsobserver not in sys.modules or sys.modules[
            dfsobserver].Observer is None:
        return sublime.error_message(
            u'FileBrowser:\n\n'
            u'watchdog module is not importable, hence we cannot know about '
            u'changes on file system, and auto-refresh will not work.\n\n'
            u'Despite that, FileBrowser is fully usable without auto-refresh, '
            u'you can just ignore this message and manually refresh view with r key.\n\n'
            u'But if you want working auto-refresh:\n'
            u' • if you install manually, then look at Readme how to install it,\n'
            u' • if you install via Package Control, report an issue.')

    sublime.load_settings('dired.sublime-settings').add_on_change(
        'dired_autorefresh', lambda: emit_event(
            u'toggle_watch_all',
            sublime.load_settings('dired.sublime-settings').get(
                'dired_autorefresh', None)))
Ejemplo n.º 2
0
def plugin_loaded():
    if len(sublime.windows()) == 1 and len(sublime.windows()[0].views()) == 0:
        hijack_window()

    window = sublime.active_window()
    if not ST3:
        global recursive_plugin_loaded
        # recursion limit is 1000 generally, so it will try to refresh for 100*1000 ms (100 s)
        # if no active_window in 100 s, then no refresh
        # if view still loading, refresh fail because view cant be edited
        if not window or any(view.is_loading() for view in window.views()):
            recursive_plugin_loaded += 1
            try:
                return sublime.set_timeout(plugin_loaded, 100)
            except RuntimeError:
                print('\ndired.plugin_loaded run recursively %d time(s); and failed to refresh\n' % recursive_plugin_loaded)
                return

    for v in window.views():
        if v.settings() and v.settings().get("dired_path"):
            # reset sels because dired_index not exists yet, so we cant restore sels
            v.run_command("dired_refresh", {"reset_sels": True})
Ejemplo n.º 3
0
def plugin_loaded():
    if len(sublime.windows()) == 1 and len(sublime.windows()[0].views()) == 0:
        hijack_window()

    window = sublime.active_window()
    if not ST3:
        global recursive_plugin_loaded
        # recursion limit is 1000 generally, so it will try to refresh for 100*1000 ms (100 s)
        # if no active_window in 100 s, then no refresh
        # if view still loading, refresh fail because view cant be edited
        if not window or any(view.is_loading() for view in window.views()):
            recursive_plugin_loaded += 1
            try:
                return sublime.set_timeout(plugin_loaded, 100)
            except RuntimeError:
                print('\ndired.plugin_loaded run recursively %d time(s); and failed to refresh\n' % recursive_plugin_loaded)
                return

    for w in sublime.windows():
        for v in w.views():
            if v.settings() and v.settings().get("dired_path"):
                # reset sels because dired_index not exists yet, so we cant restore sels
                v.run_command("dired_refresh", {"reset_sels": True})

    import sys
    dfsobserver = '%s0_dired_fs_observer' % ('FileBrowser.' if ST3 else '')
    if dfsobserver not in sys.modules or sys.modules[dfsobserver].Observer is None:
        return sublime.error_message(
            u'FileBrowser:\n\n'
            u'watchdog module is not importable, hence we cannot know about '
            u'changes on file system, and auto-refresh will not work.\n\n'
            u'Despite that, FileBrowser is fully usable without auto-refresh, '
            u'you can just ignore this message and manually refresh view with r key.\n\n'
            u'But if you want working auto-refresh:\n'
            u' • if you install manually, then look at Readme how to install it,\n'
            u' • if you install via Package Control, report an issue.')

    sublime.load_settings('dired.sublime-settings').add_on_change('dired_autorefresh', lambda: emit_event(u'toggle_watch_all', sublime.load_settings('dired.sublime-settings').get('dired_autorefresh', None)))
Ejemplo n.º 4
0
def plugin_loaded():
    if len(sublime.windows()) == 1 and len(sublime.windows()[0].views()) == 0:
        hijack_window()

    window = sublime.active_window()
    if not ST3:
        global recursive_plugin_loaded
        # recursion limit is 1000 generally, so it will try to refresh for 100*1000 ms (100 s)
        # if no active_window in 100 s, then no refresh
        # if view still loading, refresh fail because view cant be edited
        if not window or any(view.is_loading() for view in window.views()):
            recursive_plugin_loaded += 1
            try:
                return sublime.set_timeout(plugin_loaded, 100)
            except RuntimeError:
                print(
                    '\ndired.plugin_loaded run recursively %d time(s); and failed to refresh\n'
                    % recursive_plugin_loaded)
                return

    for v in window.views():
        if v.settings() and v.settings().get("dired_path"):
            # reset sels because dired_index not exists yet, so we cant restore sels
            v.run_command("dired_refresh", {"reset_sels": True})
Ejemplo n.º 5
0
 def on_window_command(self, window, command_name, args):
     if command_name != "new_window":
         return
     hijack_window()
Ejemplo n.º 6
0
 def on_window_command(self, window, command_name, args):
     if command_name != "new_window":
         return
     hijack_window()