【发布时间】:2016-03-24 03:10:24
【问题描述】:
我正在尝试创建一个 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')),这会显示新面板但不会打印任何信息它。如何在此面板中写入文本?
【问题讨论】:
-
对我有用...你能验证一下 SfprintCommand 的 run 方法中的
self.view.id()是否与 Sfcommand 的 run 方法中的self.panel.id()相同吗? Sublime 控制台中是否有任何错误?
标签: python sublimetext3 sublime-text-plugin