Home Download Buy Blog Forum Support

Getting own output panel

Getting own output panel

Postby guillermooo on Sun Apr 24, 2011 9:43 pm

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.

Code: Select all
        # 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:
                # 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"})
Posts: 738
Joined: Thu Jul 23, 2009 9:06 am

Re: Getting own output panel

Postby jbjornson on Tue Apr 26, 2011 9:40 am

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?


Code: Select all
    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')

        self.window.run_command("show_panel", {"panel": "output." + panel_name})
Posts: 359
Joined: Tue Oct 27, 2009 4:25 pm
Location: Zurich, Switzerland

Re: Getting own output panel

Postby guillermooo on Tue Apr 26, 2011 10:56 am

Thanks, Josh; I'll give that a shot!
Posts: 738
Joined: Thu Jul 23, 2009 9:06 am

Re: Getting own output panel

Postby quarnster on Tue Jan 10, 2012 9:46 am

I also just ran into this. Is this behavior intentional? If so could it be documented? Thanks
Posts: 389
Joined: Tue Nov 29, 2011 11:34 am

Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 5 guests