Sublime Text 3: Write text to output panel
Asked Answered
J

1

6

I am trying to create a Sublime Text 3 plugin which writes output to an output panel in the current window. I have found a number of examples doing this using begin_edit and end_edit, which are no longer supported in ST3. To my understanding, ST3 requires that I define a TextCommand to support the editing action on my output panel. So far, what I have is this:

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');

I would expect that this should print the text "hello" in my output panel, but when I try to invoke this through the console (by running view.run_command('sf')), this displays the new panel but does not print any information to it. How can I write text to this panel?

Justification answered 17/12, 2015 at 15:23 Comment(1)
works for me... can you verify that self.view.id() in SfprintCommand's run method is the same as self.panel.id() in Sfcommand's run method? are there any errors in the Sublime console?Quarter
J
4

After restarting everything, the same code seems to be working now. My lesson learned: apparently it's best not too put too much faith into ST3's hot plugin reloading!

Justification answered 18/12, 2015 at 20:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.