当前位置: 首页>>代码示例>>Python>>正文


Python sublime.active_window方法代码示例

本文整理汇总了Python中sublime.active_window方法的典型用法代码示例。如果您正苦于以下问题:Python sublime.active_window方法的具体用法?Python sublime.active_window怎么用?Python sublime.active_window使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sublime的用法示例。


在下文中一共展示了sublime.active_window方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import active_window [as 别名]
def run(self, *args, **kwargs):
        # wait until any previous thread is finished
        if self.thread and self.thread.is_alive():
            sublime.status_message('Waiting for earlier compilation to finish...')
            self.thread.stop()
            self.thread.join()

        # find the view containing the code to compile
        view = None
        if kwargs.get('recompile', None) and self.last_filename:
            view = CompileKspThread.find_view_by_filename(self.last_filename)
        if view is None:
            view = sublime.active_window().active_view()

        self.thread = CompileKspThread(view)
        self.thread.start()
        self.last_filename = view.file_name() 
开发者ID:nojanath,项目名称:SublimeKSP,代码行数:19,代码来源:ksp_plugin.py

示例2: run

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import active_window [as 别名]
def run(self, *args, **kwargs):
        view = sublime.active_window().active_view()

        #settings = sublime.load_settings('KSP.sublime-settings')
        #scheme_file = settings.get('color_scheme', 'Packages/SublimeKSP/KScript Light.tmTheme')
        scheme_file = 'Packages/SublimeKSP/KScript Light.tmTheme'
        plist = readPlistFromBytes(sublime.load_binary_resource(scheme_file))

        result = ['[pre]']
        start, end = view.sel()[0].a, view.sel()[0].b
        if start == end:
            start, end = 0, view.size()
        for a, b, scopes in get_ranges(view.scope_name(i) for i in range(start, end)):
            result.append(self.apply_style(scopes, plist, view.substr(sublime.Region(start+a, start+b))))
        result.append('[/pre]')
        sublime.set_clipboard(''.join(result)) 
开发者ID:nojanath,项目名称:SublimeKSP,代码行数:18,代码来源:bbcode.py

示例3: start

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import active_window [as 别名]
def start(self, view, session_id=None, show_gui=False):
        global is_active
        if is_active:
            msg = "Cannot start. An instance is already running on :{}".format(
                self._agent_port,
            )
            show_message(msg, show_gui)
            return

        self._connect_to = session_id

        if self._connect_to is not None:
            view = sublime.active_window().new_file()

        self._initialize(view)

        self._start_agent()
        is_active = True

        if self._connect_to is None:
            self.check_buffer(view.buffer_id()) 
开发者ID:typeintandem,项目名称:tandem,代码行数:23,代码来源:tandem.py

示例4: on_api_ready

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import active_window [as 别名]
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() 
开发者ID:Wramberg,项目名称:TerminalView,代码行数:22,代码来源:sublime_plugin.py

示例5: _get_project_setting

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import active_window [as 别名]
def _get_project_setting(key):
    """Get a project setting.

    JsPrettier project settings are stored in the sublime project file
    as a dictionary, e.g.:

        "settings":
        {
            "js_prettier": { "key": "value", ... }
        }

    :param key: The project setting key.
    :return: The project setting value.
    :rtype: str
    """
    project_settings = sublime.active_window().active_view().settings()
    if not project_settings:
        return None
    js_prettier_settings = project_settings.get(PROJECT_SETTINGS_KEY)
    if js_prettier_settings and key in js_prettier_settings:
        return js_prettier_settings[key]
    return None 
开发者ID:jonlabelle,项目名称:SublimeJsPrettier,代码行数:24,代码来源:sthelper.py

示例6: get_st_project_path

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import active_window [as 别名]
def get_st_project_path():
    """Get the active Sublime Text project path.

    Original: https://gist.github.com/astronaughts/9678368

    :rtype: object
    :return: The active Sublime Text project path.
    """
    window = sublime.active_window()
    folders = window.folders()
    if len(folders) == 1:
        return folders[0]
    else:
        active_view = window.active_view()
        if active_view:
            active_file_name = active_view.file_name()
        else:
            active_file_name = None
        if not active_file_name:
            return folders[0] if len(folders) else os.path.expanduser('~')
        for folder in folders:
            if active_file_name.startswith(folder):
                return folder
        return os.path.dirname(active_file_name) 
开发者ID:jonlabelle,项目名称:SublimeJsPrettier,代码行数:26,代码来源:sthelper.py

示例7: run

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import active_window [as 别名]
def run(self, edit):
        view = self.view.window().new_file()
        view.settings().add_on_change('color_scheme', lambda: set_proper_scheme(view))
        view.set_name("Browse: shortcuts")
        view.set_scratch(True)
        view.settings().set('rulers', [])
        view.settings().set('syntax', 'Packages/FileBrowser/dired-help' + SYNTAX_EXTENSION)
        view.settings().set('margin', 16)
        view.settings().set('line_numbers', False)
        view.settings().set('gutter', False)
        view.settings().set('fold_buttons', False)
        view.settings().set('draw_indent_guides', False)
        view.settings().set('word_wrap', False)
        view.settings().set('spell_check', False)
        view.settings().set('drag_text', False)
        view.run_command('dired_show_help')
        sublime.active_window().focus_view(view) 
开发者ID:aziz,项目名称:SublimeFileBrowser,代码行数:19,代码来源:dired_misc.py

示例8: open_from_preview

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import active_window [as 别名]
def open_from_preview(self, payload):
        msg, path = payload.split('\v')

        def show_errors(_):
            self.view.update_popup(
                '<br><a href="back\v">←<br><br>'
                '</a>Errors:<br> %s<br>' % '<br> '.join(self.errors))

        def go_back(_):
            self.update_preview(loading=False)

        def open_dir(path):
            self.view.settings().set('dired_path', path)
            self.view.run_command('dired_refresh')

        def open_file(path):
            (self.view.window() or sublime.active_window()).open_file(path)

        case = {
            'dir': open_dir,
            'file': open_file,
            'errors': show_errors,
            'back': go_back
        }
        case[msg](path) 
开发者ID:aziz,项目名称:SublimeFileBrowser,代码行数:27,代码来源:dired_misc.py

示例9: on_new

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import active_window [as 别名]
def on_new(self, view):
        if not self.MOVE:
            return
        w = sublime.active_window()
        if w.num_groups() < 2:
            return
        if is_any_dired_in_group(w, 0):
            if w.active_group() == 0:
                # at this point views are exist, so we cannot avoid the use of
                # set_view_index, but ST2 return None if group has no views
                # ST3 return None if group has active image’s view
                avig1 = w.active_view_in_group(1)
                if avig1:
                    _group, active_view_index_in_other_group = w.get_view_index(avig1)
                    index = active_view_index_in_other_group + 1
                else:
                    index = 0
                sublime.set_timeout(lambda: w.set_view_index(view, 1, index), 1) 
开发者ID:aziz,项目名称:SublimeFileBrowser,代码行数:20,代码来源:dired_misc.py

示例10: run

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import active_window [as 别名]
def run(self, edit):
        self.which = self.view.settings().get('which', '')
        if not self.which:
            return sublime.error_message('oops, does not work!')

        self.refresh = False
        value = self.view.substr(Region(0, self.view.size()))
        fqn = self.on_done(value)
        if not fqn:
            return sublime.status_message('oops, does not work!')

        sublime.active_window().run_command('hide_panel', {'cancel': True})

        dired_view = sublime.active_window().active_view()
        if dired_view.settings().has('dired_path'):
            self.refresh = True
        if self.which == 'directory':
            dired_view.settings().set('dired_path', fqn + os.sep)
        else:
            sublime.active_window().open_file(fqn)
        if self.refresh:
            emit_event(u'watch_view', dired_view.id(), plugin=u'FileBrowserWFS')
            dired_view.run_command('dired_refresh', {'goto': fqn}) 
开发者ID:aziz,项目名称:SublimeFileBrowser,代码行数:25,代码来源:dired_file_operations.py

示例11: run

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import active_window [as 别名]
def run(self, edit):
        self.edit = edit
        self.prompt_region = Region(0, self.view.size())
        content, path, prefix = self.get_content()
        if not valid(path or content):
            return

        completions, error = self.get_completions(path, prefix)
        if error:
            return  # content of path is unavailable (access, permission, etc.)
        if not completions:
            return sublime.status_message('No matches')

        new_content = self.get_new_content(path, prefix, completions)

        if new_content:
            self.fill_prompt(new_content)
        else:
            self.completions = completions
            self._path = path
            self.w = self.view.window() or sublime.active_window()
            return self.w.show_quick_panel(completions, self.on_done) 
开发者ID:aziz,项目名称:SublimeFileBrowser,代码行数:24,代码来源:prompt.py

示例12: run

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import active_window [as 别名]
def run(self, edit, deploy_file_list=None):
        self.window = sublime.active_window()
        if deploy_file_list:
            self.open_files = deploy_file_list
            self.current_file = None
            self.sel_type_list = ["Deploy Directory", "Deploy Directory To Server(check only)"]
            self.sel_type_key_list = ["DeployOpenFiles", "CheckDeployOpenFiles"]
        else:
            self.open_files = []
            for _view in self.window.views():
                file_name = _view.file_name()
                if file_name:
                    self.open_files.append(file_name)
            self.current_file = self.view.file_name()
            self.sel_type_list = ["Config Ant Metadata Tool", "Backup All Metadata", "Deploy Open Files To Server", "Deploy Open Files To Server(check only)"]
            self.sel_type_key_list = ["Build", "Backup", "DeployOpenFiles", "CheckDeployOpenFiles"]

        if self.current_file:
            file_path, file_name = os.path.split(self.current_file)
            self.sel_type_list.append("Deploy Current File To Server : %s" % file_name)
            self.sel_type_list.append("Deploy Current File To Server : %s (check only)" % file_name)
            self.sel_type_key_list.append("DeployOne")
            self.sel_type_key_list.append("CheckDeployOne")
        self.window.show_quick_panel(self.sel_type_list, self.panel_done, sublime.MONOSPACE_FONT) 
开发者ID:exiahuang,项目名称:SalesforceXyTools,代码行数:26,代码来源:main_toolbox.py

示例13: plugin_loaded

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import active_window [as 别名]
def plugin_loaded():
    """
    perform some work to set up env correctly.
    """
    global global_path
    global local_path
    global settings
    settings = sublime.load_settings(SETTINGS_FILE)
    view = sublime.active_window().active_view()
    if platform != "windows":
        maybe_path = calculate_user_path()
        if len(maybe_path) > 0:
            global_path = maybe_path[0]
    search_path = generate_search_path(view)
    local_path = search_path
    print_status(global_path, search_path) 
开发者ID:bcomnes,项目名称:sublime-standard-format,代码行数:18,代码来源:standard-format.py

示例14: run

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import active_window [as 别名]
def run(self, edit, **args):
    data = run_command(self.view, {"type": "definition", "lineCharPositions": True})
    if data is None: return
    file = data.get("file", None)
    if file is not None:
      # Found an actual definition
      row, col = self.view.rowcol(self.view.sel()[0].b)
      cur_pos = self.view.file_name() + ":" + str(row + 1) + ":" + str(col + 1)
      jump_stack.append(cur_pos)
      if len(jump_stack) > 50: jump_stack.pop(0)
      real_file = (os.path.join(get_pfile(self.view).project.dir, file) +
        ":" + str(data["start"]["line"] + 1) + ":" + str(data["start"]["ch"] + 1))
      sublime.active_window().open_file(real_file, sublime.ENCODED_POSITION)
    else:
      url = data.get("url", None)
      if url is None:
        sublime.error_message("Could not find a definition")
      else:
        webbrowser.open(url) 
开发者ID:PhaserEditor2D,项目名称:PhaserSublimePackage,代码行数:21,代码来源:tern.py

示例15: command_variables

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import active_window [as 别名]
def command_variables(args, view, command, format=True):
    if format and args.get("format"):
      command = args["format"].replace('${input}', command)

    for region in view.sel():
      (row,col) = view.rowcol(view.sel()[0].begin())

      command = command.replace('${row}', str(row+1))
      command = command.replace('${region}', view.substr(region))
      break

    # packages, platform, file, file_path, file_name, file_base_name,
    # file_extension, folder, project, project_path, project_name,
    # project_base_name, project_extension.
    command = sublime.expand_variables(command, sublime.active_window().extract_variables())

    return command 
开发者ID:gbaptista,项目名称:sublime-3-shell-exec,代码行数:19,代码来源:ShellExec.py


注:本文中的sublime.active_window方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。