python runner.py 文件源码

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

项目:st-user-package 作者: math2001 项目源码 文件源码
def run(self, edit, *args, **kwargs):
        self.window = self.view.window()
        self.selection = sublime.Selection(self.view.id())
        self.settings = self.view.settings()

        group_index, view_index = self.window.get_view_index(self.view)

        error = True

        def build(view):

            main_group_index, main_view_index = self.window.get_view_index(view)
            view_to_focus = None
            if main_group_index != group_index:
                view_to_focus = self.window.active_view_in_group(main_group_index)
            self.window.focus_view(view)
            self.window.run_command('build')
            if view_to_focus is not None:
                self.window.focus_view(view_to_focus)
            self.window.focus_view(self.view)



        if self.can_be_run(self.view):
            build(self.view)
            return

        for view in self.window.views():
            if self.can_be_run(view):
                build(view)
                error = False
                return

        if error is True:
            self.window.show_quick_panel(
                [
                    [
                        'Error: no "_main.py" is open.',
                        'The plugin won\'t do anything.'
                    ],
                    [
                        'Forget it buddy, run this file',
                        self.view.file_name()
                    ],
                ],
                self.on_done,
                sublime.KEEP_OPEN_ON_FOCUS_LOST,
                1)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号