Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sublime Text 3: Write text to output panel

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?

like image 509
user2221343 Avatar asked Dec 17 '15 15:12

user2221343


People also ask

How do I get output in Sublime Text 3?

In order for taking input and receiving output from a code, we need to manually set up our input and output files. Step 1: From the top menu, select View->Layout->Columns :3 or press Shift+Alt+3. Step 2: Now select View->Groups->Max columns: 2. Step 3: Now you can view three files simultaneously in sublime text.

How do I display Python output in Sublime Text?

This question is specifically about displaying the output of the python code in the build results window. Super+Shift+B is the right answer. It is not a duplicate of the other question, but an extension of it.

How do I see results in Sublime Text?

Save this answer. Show activity on this post. In Sublime 2, in order to call up the build results window you can use the Tools > Build Results > Show Build Results menu item.

Can you print from Sublime Text?

Use Alt+Shift+P to print. My favorite tool for printing from Sublime Text is Print to HTML package. You can "print" a selection or a whole file - via the web browser.


1 Answers

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!

like image 145
user2221343 Avatar answered Oct 04 '22 22:10

user2221343