Sublime Text 3:将文本写入输出面板

时间:2015-12-17 15:23:49

标签: python sublimetext3 sublime-text-plugin

我正在尝试创建一个Sublime Text 3插件,该插件将输出写入当前窗口中的输出面板。我发现了许多使用begin_edit和end_edit执行此操作的示例,这些示例在ST3中不再受支持。根据我的理解,ST3要求我定义一个TextCommand以支持我的输出面板上的编辑操作。到目前为止,我所拥有的是:

class SfprintCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        self.view.insert(edit, self.view.size(), 'hello')

class SfCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        self.panel = self.view.window().create_output_panel('sf_st3_output')
        self.view.window().run_command('show_panel', { 'panel': 'output.sf_st3_output' })
        self.panel.run_command('sfprint');

我希望这应该在我的输出面板中打印文本“hello”,但是当我尝试通过控制台调用它时(通过运行view.run_command('sf')),这将显示新面板但不打印任何给它的信息。如何在此面板上写文字?

1 个答案:

答案 0 :(得分:3)

重新启动所有内容后,相同的代码现在似乎正在运行。我的经验教训:显然最好不要太过于相信ST3的热插件重装!