我正在尝试创建一个 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')
),这会显示新面板,但不会向其打印任何信息。如何向该面板写入文本?
最佳答案
重新启动一切后,相同的代码现在似乎可以正常工作了。我的经验教训:显然最好不要过于相信 ST3 的热插件重载!
关于python - 崇高文本 3 : Write text to output panel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34338160/