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):
"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)
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.