Sublime Forum

Getting own output panel

#1

The exec command uses its own output panel. I’ve tried to get one in my plugin too, but I can’t make it work.

# Run command, don't modify the buffer, output to output panel. if not as_filter: self.output_view = self.view.window().get_output_panel("powershell") out, error = run_posh_command(userPoShCmd) if out or error: self.view.window().get_output_panel("powershell") # FIXME: Use a dedicated output panel for powershell. # print out # print error append(self.output_view, out + "\n") append(self.output_view, error) self.view.window().run_command("show_panel", {"panel": "ouput.powershell"}) return

0 Likes

#2

Hi guillermooo,

I’ve also been struggling with this for a few days and found that the following code solves the problem. I think there is some confusion introduced by the window.get_output_panel function because of it’s name. I discovered from a few simple tests that “get_output_panel” should really be called “create*_output_panel*” since it clobbers any text you’ve written to it before the call.

@jps Maybe this could be renamed in the API?

Cheers,
Josh

    def append(self, text, panel_name = 'example'):        
        # get_output_panel doesn't "get" the panel, it *creates* it, 
        # so we should only call get_output_panel once
        if not hasattr(self, 'output_view'):
            self.output_view = self.window.get_output_panel(panel_name)
        v = self.output_view

        # Write this text to the output panel and display it
        edit = v.begin_edit()
        v.insert(edit, v.size(), text + '\n')
        v.end_edit(edit)
        v.show(v.size())

        self.window.run_command("show_panel", {"panel": "output." + panel_name})
0 Likes

Console output is exceeding sublimes buffer size can we get an allocation increase
#3

Thanks, Josh; I’ll give that a shot!

0 Likes

#4

I also just ran into this. Is this behavior intentional? If so could it be documented? Thanks

0 Likes