python类active_window()的实例源码

NoDialogs.py 文件源码 项目:NoDialogs 作者: maximsmol 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def run(self):
        self.window = sublime.active_window()

        for view in self.window.views():
            self.view = view

            if not self.will_closing_discard(view):
                continue

            self.last_focused_view = self.window.active_view()
            self.window.focus_view(view)

            self.show_discard_prompt()
            return # wait for input, then start over

        self.window.run_command('close_window')
A File Icon.py 文件源码 项目:a-file-icon 作者: ihodev 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def ensure_reload():
        """
        Ensure all modules reload to initialize plugin successfully.
        """
        start_upgrade_msg = "Do not close the Sublime Text. Upgrading {}".format(
            PACKAGE_NAME
        )
        finish_upgrade_msg = "{} upgrade finished.".format(PACKAGE_NAME)

        active_view = sublime.active_window().active_view()
        active_view.set_status("afi_status", start_upgrade_msg)

        def erase_status():
            active_view.erase_status("afi_status")

        def reload():
            sublime.run_command("afi_reload")
            active_view.set_status("afi_status", finish_upgrade_msg)
            sublime.set_timeout(erase_status, 2000)

        sublime.set_timeout_async(reload, 5000)
common.py 文件源码 项目:SublimeOutline 作者: warmdev 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def set_status(self):
        '''Update status-bar;
        self.show_hidden must be assigned before call it'''
        # if view isnot focused, view.window() may be None
        window          = self.view.window() or sublime.active_window()
        path_in_project = any(folder == self.path[:-1] for folder in window.folders())
        settings        = self.view.settings()
        copied_items    = settings.get('outline_to_copy', [])
        cut_items       = settings.get('outline_to_move', [])
        status = u" ?? [?: Help] {0}Hidden: {1}{2}{3}".format(
            'Project root, ' if path_in_project else '',
            'On' if self.show_hidden else 'Off',
            ', copied(%d)' % len(copied_items) if copied_items else '',
            ', cut(%d)' % len(cut_items) if cut_items else ''
        )
        self.view.set_status("__FileBrowser__", status)
core.py 文件源码 项目:SublimeGotoUsage 作者: syko 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def get_usages_in_files(subject, files):
    """
    Smart approach: reads files from a list and parses them.
    """

    usage_list = []

    for file_path in files:
        try:
            usages = get_usages_in_file(file_path, subject)
            usage_list.extend(usages)
        except UnicodeDecodeError:
            utils.log("Failed to open file", file_path, warning=True)
        except FileNotFoundError:
            utils.log("File not found", file_path, warning=True)
            utils.log("Probably the file has been (re)moved and the dependency graph is stale. Please rebuild!", warning=True)
            sublime.active_window().status_message("GotoUsage Error! Dependency graph looks out of date. Please rebuild!")

    return usage_list
SideBar.py 文件源码 项目:.sublime 作者: cxdongjack 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def confirm(self, paths, in_parent, data, key):
        import functools
        window = sublime.active_window()
        window.show_input_panel("BUG!", '', '', None, None)
        window.run_command('hide_panel');

        yes = []
        yes.append('Yes, Replace the following items:');
        for item in data:
            yes.append(SideBarItem(item, os.path.isdir(item)).pathWithoutProject())

        no = []
        no.append('No');
        no.append('Continue without replacing');

        while len(no) != len(yes):
            no.append('ST3 BUG');

        window.show_quick_panel([yes, no], functools.partial(self.on_done, paths, in_parent, key))
SideBar.py 文件源码 项目:.sublime 作者: cxdongjack 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def confirm(self, paths, display_paths):
        import functools
        window = sublime.active_window()
        window.show_input_panel("BUG!", '', '', None, None)
        window.run_command('hide_panel');

        yes = []
        yes.append('Yes, delete the selected items.');
        for item in display_paths:
            yes.append(item);

        no = []
        no.append('No');
        no.append('Cancel the operation.');

        while len(no) != len(yes):
            no.append('');

        if sublime.platform() == 'osx':
            sublime.set_timeout(lambda:window.show_quick_panel([yes, no], functools.partial(self.on_confirm, paths)), 200);
        else:
            window.show_quick_panel([yes, no], functools.partial(self.on_confirm, paths))
EasyClangComplete.py 文件源码 项目:EasyClangComplete 作者: niosus 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def on_plugin_loaded(self):
        """Call upon plugin load event."""
        # init settings manager
        self.loaded = True
        log.debug("handle plugin loaded")
        EasyClangComplete.settings_manager = SettingsManager()
        # self.on_settings_changed()
        EasyClangComplete.settings_manager.add_change_listener(
            self.on_settings_changed)
        self.on_settings_changed()
        # init view config manager
        EasyClangComplete.view_config_manager = ViewConfigManager()

        # As the plugin has just loaded, we might have missed an activation
        # event for the active view so completion will not work for it until
        # re-activated. Force active view initialization in that case.
        self.on_activated_async(sublime.active_window().active_view())
Log Highlight.py 文件源码 项目:Log-Highlight 作者: poucotm 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def run(self, edit, **args):
        try:
            path = args.get('paths', [])[0]
            if os.path.isfile(path):
                path = os.path.dirname(path)

            view = sublime.active_window().active_view()
            if check_syntax(view):
                disp_msg('base directory of current log is set as : ' + path)
                self.view.settings().set('result_base_dir', path)
                global smry_view
                if smry_view is not None:
                    smry_view.settings().set('result_base_dir', path)
                # save to project
                prj = view.window().project_file_name()
                if prj != "":
                    pdata = view.window().project_data()
                    pdata['base_dir'] = path
                    view.window().set_project_data(pdata)
            pass

        except Exception:
            disp_exept()
diagnostics.py 文件源码 项目:LSP 作者: tomv564 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def handle_diagnostics(update: 'Any'):
    file_path = uri_to_filename(update.get('uri'))
    window = sublime.active_window()

    if not is_in_workspace(window, file_path):
        debug("Skipping diagnostics for file", file_path,
              " it is not in the workspace")
        return

    diagnostics = list(
        Diagnostic.from_lsp(item) for item in update.get('diagnostics', []))

    origin = 'lsp'  # TODO: use actual client name to be able to update diagnostics per client
    update_file_diagnostics(window, file_path, origin, diagnostics)
    Events.publish("document.diagnostics", DiagnosticsUpdate(file_path, diagnostics))
    # TODO: expose updates to features
main.py 文件源码 项目:LSP 作者: tomv564 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def start_active_views():
    window = sublime.active_window()
    if window:
        views = list()  # type: List[sublime.View]
        num_groups = window.num_groups()
        for group in range(0, num_groups):
            view = window.active_view_in_group(group)
            if is_supported_view(view):
                if window.active_group() == group:
                    views.insert(0, view)
                else:
                    views.append(view)

        if len(views) > 0:
            first_view = views.pop(0)
            debug('starting active=', first_view.file_name(), 'other=', len(views))
            initialize_on_open(first_view)
            if len(views) > 0:
                for view in views:
                    didopen_after_initialize.append(view)
tooltips.py 文件源码 项目:sublimeTextConfig 作者: luoye-fe 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def _load_css_themes(self) -> None:
        """
        Load any css theme found in the anaconda CSS themes directory
        or in the User/Anaconda.themes directory
        """

        css_files_pattern = os.path.join(
            os.path.dirname(__file__), os.pardir, 'css', '*.css')
        for css_file in glob.glob(css_files_pattern):
            logging.info('anaconda: {} css theme loaded'.format(
                self._load_css(css_file))
            )

        packages = sublime.active_window().extract_variables()['packages']
        user_css_path = os.path.join(packages, 'User', 'Anaconda.themes')
        if os.path.exists(user_css_path):
            css_files_pattern = os.path.join(user_css_path, '*.css')
            for css_file in glob.glob(css_files_pattern):
                logging.info(
                    'anaconda: {} user css theme loaded',
                    self._load_css(css_file)
                )
state.py 文件源码 项目:NeoVintageous 作者: NeoVintageous 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def scroll_into_view(self):
        try:
            view = sublime.active_window().active_view()
            # TODO(guillermooo): Maybe some commands should show their
            # surroundings too?
            # Make sure we show the first caret on the screen, but don't show
            # its surroundings.
            view.show(view.sel()[0], False)
        except:
            pass
state.py 文件源码 项目:NeoVintageous 作者: NeoVintageous 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def _run_parser_via_panel(self, command):
        """
        Return `True` if the current parser needs to be run via a panel.

        If needed, it runs the input-panel-based parser.
        """
        if command.input_parser.type == input_types.VIA_PANEL:
            if self.non_interactive:
                return False
            sublime.active_window().run_command(command.input_parser.command)
            return True
        return False
rcfile.py 文件源码 项目:NeoVintageous 作者: NeoVintageous 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def _run():
    _logger.debug('run \'%s\'', file_name())
    try:
        window = sublime.active_window()
        with _open(file_name(), 'r') as f:
            for line in f:
                cmd, args = _parse_line(line)
                if cmd:
                    _logger.debug('run command \'%s\' with args %s', cmd, args)
                    window.run_command(cmd, args)
    except FileNotFoundError:
        _logger.debug('rcfile not found')
help.py 文件源码 项目:hyperhelp 作者: OdatNurd 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def show_toc(self, pkg_info, items, stack):
        captions = [[item["caption"], item["topic"] +
            (" ({} topics)".format(len(item["children"])) if "children" in item else "")]
            for item in items]

        if len(captions) == 0 and len(stack) == 0:
            return log("No help topics defined for %s", pkg_info.package,
                       status=True)

        if len(stack) > 0:
            captions.insert(0, ["..", "Go back"])

        sublime.active_window().show_quick_panel(
            captions,
            on_select=lambda index: self.select_toc_item(pkg_info, items, stack, index))
help.py 文件源码 项目:hyperhelp 作者: OdatNurd 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def select_package(self):
        help_list = help_index_list()
        if len(help_list) <= 1:
            return log("No packages with help are currently installed",
                        status=True)

        pkg_list = sorted([key for key in help_list])
        captions = [[help_list[key].package,
                     help_list[key].description]
            for key in pkg_list]

        sublime.active_window().show_quick_panel(
            captions,
            on_select=lambda index: self.select_package_item(captions, index))
ESLint-Formatter.py 文件源码 项目:ESLint-Formatter 作者: TheSavior 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def project_path():
    project_data = sublime.active_window().project_data()

    # if cannot find project data, use cwd
    if project_data is None:
      return os.getcwd()

    folders = project_data['folders']
    folder_path = folders[0]['path']
    return folder_path
ESLint-Formatter.py 文件源码 项目:ESLint-Formatter 作者: TheSavior 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def get_pref(key):
    global_settings = sublime.load_settings(SETTINGS_FILE)
    value = global_settings.get(key)

    # Load active project settings
    project_settings = sublime.active_window().active_view().settings()

    # Overwrite global config value if it's defined
    if project_settings.has(PROJECT_NAME):
      value = project_settings.get(PROJECT_NAME).get(key, value)

    return value
ESLint-Formatter.py 文件源码 项目:ESLint-Formatter 作者: TheSavior 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def normalize_path(path, realpath=False):
    if realpath:
      return os.path.realpath(os.path.expanduser(path))
    else:
      project_dir = sublime.active_window().project_file_name()
      if project_dir:
        cwd = os.path.dirname(project_dir)
      else:
        cwd = os.getcwd()
      return os.path.normpath(os.path.join(cwd, os.path.expanduser(path)))

  # Yield path and every directory above path.
sublime_plugin.py 文件源码 项目:SublimeTerm 作者: percevalw 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def on_api_ready():
    global api_ready
    api_ready = True

    for m in list(sys.modules.values()):
        if "plugin_loaded" in m.__dict__:
            try:
                m.plugin_loaded()
            except:
                traceback.print_exc()

    # Synthesize an on_activated call
    w = sublime.active_window()
    if w:
        view_id = sublime_api.window_active_view(w.window_id)
        if view_id != 0:
            try:
                on_activated(view_id)
            except:
                traceback.print_exc()

    # Create ViewEventListener instances
    if len(view_event_listener_classes) > 0:
        for w in sublime.windows():
            for v in w.views():
                attach_view(v)


问题


面经


文章

微信
公众号

扫码关注公众号