Home Download Buy Blog Forum Support

How to track if an output panel is closed/hidden?

How to track if an output panel is closed/hidden?

Postby aponxi on Thu Jan 17, 2013 3:01 am

Output panels are hidden when I bring out the console with CTRL+` or trigger some other output panel to be shown... How can I track that the output panel I have is "closed" or hidden?

My panel is created with this code

Code: Select all
        panel = window.get_output_panel(self.PANEL_NAME)
aponxi
 
Posts: 7
Joined: Sat Dec 22, 2012 11:53 pm

Re: How to track if an output panel is closed/hidden?

Postby FichteFoll on Sat Jan 19, 2013 3:50 am

Edit: After thinking about this only a bit I realize that the thing I wanted to use only works for "context managers" added by plugins, not for internals.

I don't know of a way to track the visibility of output panels but re-running the show_panel command does not break anything and would be the desired way to make the panel appear "always". If you only want to "check" if a panel is visible/focused, I can't really help you. I tried a few things, though.

In the key bindings I found this (extracts):
Code: Select all
"command": "show_panel", "args": {"panel": "console", "toggle": true}

"context": [{"key": "panel", "operand": "find"}, {"key": "panel_has_focus"}]

   { "keys": ["escape"], "command": "hide_panel", "args": {"cancel": true},
      "context":
      [
         { "key": "panel_visible", "operator": "equal", "operand": true }
      ]
   },


However, triggering these context events did not really help and always returned "False" for my tests. (sublime_lib.WindowAndTextCommand)

Code: Select all
class TestCommandCommand(sublime_lib.WindowAndTextCommand):
    def is_checked(self):
        return False

    def run(self, param):
        print(self.view, self._window_command)
        self.window.run_command("show_panel", {"panel": "output.aaa_package_dev"})
        visible = sublime_plugin.on_query_context(self.view, key="panel_visible", operator=sublime.OP_EQUAL, operand=True, match_all=False)
        focus = sublime_plugin.on_query_context(self.view, key="panel_has_focus", operator=sublime.OP_EQUAL, operand="output.aaa_package_dev", match_all=False)
        print("is visible", visible, "has focus", focus)


So, not really helpful but maybe you can find something out of this.
FichteFoll
 
Posts: 406
Joined: Fri Mar 16, 2012 11:49 pm
Location: Germany

Re: How to track if an output panel is closed/hidden?

Postby brizjin on Wed Oct 02, 2013 7:10 am

I found:

Code: Select all
view = window.get_output_panel(self.PANEL_NAME)
if view.window():
    #visible is true
else:
    #visible is false
brizjin
 
Posts: 1
Joined: Wed Oct 02, 2013 7:02 am

Re: How to track if an output panel is closed/hidden?

Postby FichteFoll on Sun Oct 06, 2013 9:15 pm

That's interesting and indeed seems to work (well). There are probably some edge cases like when there is no window created yet, but I'm not even sure if you can actually get an output panel in that case. I should add that to the docs.

I used this (for the default output panel):
Code: Select all
class TestCommandCommand(sublime_plugin.WindowCommand):
    def run(self):
        out = self.window.get_output_panel("exec")
        print "visible:", bool(out.window())
FichteFoll
 
Posts: 406
Joined: Fri Mar 16, 2012 11:49 pm
Location: Germany


Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 8 guests