SublimeHelper.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:enjoy-sublime 作者: colacao 项目源码 文件源码
def __init__(self, window, data_key, command, working_dir, title=None, syntax=None, panel=False, console=None, target=None):

        self.target = target
        if target == 'point' and console is None:
            console = window.active_view()

        # If a panel has been requested then create one and show it,
        # otherwise create a new buffer, and set its caption:
        #
        if console is not None:
            self.console = console
        else:
            if panel is True:
                self.console = window.get_output_panel('ShellCommand')
                window.run_command('show_panel', {'panel': 'output.ShellCommand'})
            else:
                self.console = window.new_file()
                caption = title if title else '*ShellCommand Output*'
                self.console.set_name(caption)

            # Indicate that this buffer is a scratch buffer:
            #
            self.console.set_scratch(True)
            self.console.set_read_only(True)

            # Set the syntax for the output:
            #
            if syntax is not None:
                resources = sublime.find_resources(syntax + '.tmLanguage')
                self.console.set_syntax_file(resources[0])

            # Set a flag on the view that we can use in key bindings:
            #
            settings = self.console.settings()
            settings.set(data_key, True)

            # Also, save the command and working directory for later,
            # since we may need to refresh the panel/window:
            #
            data = {
                'command': command,
                'working_dir': working_dir
            }
            settings.set(data_key + '_data', data)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号