def show_panel(self, window: sublime.Window): name = window.active_panel() if name == self.panel.output_panel_name: self.is_hidden = False self.write_pending() else: self.is_hidden = True
def on_show_panel(window: sublime.Window): name = window.active_panel() if Settings.hide_status_bar: if name != 'output.Debugger': self.window.set_status_bar_visible(True) else: self.window.set_status_bar_visible(False)
def update_diagnostics_panel(window: sublime.Window): assert window, "missing window!" base_dir = get_project_path(window) panel = ensure_diagnostics_panel(window) if not panel and not window.is_valid(): return assert panel, "must have a panel now!" diagnostics_by_file = get_window_diagnostics(window) if diagnostics_by_file is not None: active_panel = window.active_panel() is_active_panel = (active_panel == "output.diagnostics") panel.settings().set("result_base_dir", base_dir) panel.set_read_only(False) if diagnostics_by_file: to_render = [] for file_path, source_diagnostics in diagnostics_by_file.items(): try: relative_file_path = os.path.relpath(file_path, base_dir) if base_dir else file_path except ValueError: relative_file_path = file_path if source_diagnostics: to_render.append(format_diagnostics(relative_file_path, source_diagnostics)) panel.run_command("code_intel_update_panel", {"characters": "\n".join(to_render)}) if settings.auto_show_diagnostics_panel and not active_panel: window.run_command("show_panel", {"panel": "output.diagnostics"}) else: panel.run_command("code_intel_clear_panel") if is_active_panel: window.run_command("hide_panel", {"panel": "output.diagnostics"}) panel.set_read_only(True)
def update_diagnostics_panel(window: sublime.Window): assert window, "missing window!" if not window.is_valid(): debug('ignoring update to closed window') return base_dir = get_project_path(window) diagnostics_by_file = get_window_diagnostics(window) if diagnostics_by_file is not None: active_panel = window.active_panel() is_active_panel = (active_panel == "output.diagnostics") if diagnostics_by_file: panel = ensure_diagnostics_panel(window) assert panel, "must have a panel now!" panel.settings().set("result_base_dir", base_dir) auto_open_panel = False to_render = [] for file_path, source_diagnostics in diagnostics_by_file.items(): try: relative_file_path = os.path.relpath( file_path, base_dir) if base_dir else file_path except ValueError: relative_file_path = file_path if source_diagnostics: formatted = format_diagnostics(relative_file_path, source_diagnostics) if formatted: to_render.append(formatted) if not auto_open_panel: auto_open_panel = has_relevant_diagnostics( source_diagnostics) panel.set_read_only(False) panel.run_command("lsp_update_panel", {"characters": "\n".join(to_render)}) panel.set_read_only(True) if settings.auto_show_diagnostics_panel and not active_panel: if auto_open_panel: window.run_command("show_panel", {"panel": "output.diagnostics"}) else: panel = window.find_output_panel("diagnostics") if panel: panel.run_command("lsp_clear_panel") if is_active_panel: window.run_command("hide_panel", {"panel": "output.diagnostics"})
def on_hide_panel(window: sublime.Window): name = window.active_panel() or '' # show main debugger panel after closing other debugger panels if window == self.window and name != 'output.Debugger' and name.startswith( 'output.Debugger:'): core.log_info(f'Showing debug panel') self.panel_show() return True if Settings.hide_status_bar: self.window.set_status_bar_visible(True) return False
def __init__(self, window: sublime.Window, label: str, text: str, on_change: Callable[[str], None], on_done: Callable[[Optional[str]], None]): def on_cancel() -> None: self.close() on_done(None) def on_done_inner(value: str) -> None: self.close() on_done(value) self.window = window self.active_panel = window.active_panel() window.show_input_panel(label, text, on_done=on_done_inner, on_change=on_change, on_cancel=on_cancel)
def sublime_show_input_panel_async( window: sublime.Window, caption: str, initial_text: str, on_change: Optional[Callable[[str], None]] = None) -> awaitable[Optional[str]]: result = create_future() active_panel = window.active_panel() def on_done(value: str) -> None: call_soon_threadsafe(result.set_result, value) def on_cancel() -> None: call_soon_threadsafe(result.set_result, None) view = window.show_input_panel(caption, initial_text, on_done, on_change, on_cancel) r = yield from result # restore the previous panel window.run_command('show_panel', {'panel': '{}'.format(active_panel)}) return r
def on_hide_panel(self, window: sublime.Window): if self.on_hidden and window == self.window and window.active_panel( ) == self.output_panel_name: self.on_hidden()
def on_show_panel(self, window: sublime.Window): if self.on_opened and window == self.window and window.active_panel( ) == self.output_panel_name: self.on_opened()
def toggle_output_panel(window: Window, panel_type: str) -> None: panel_name = "output.{}".format(panel_type) command = "{}_panel".format("hide" if window.active_panel() == panel_name else "show") window.run_command(command, {"panel": panel_name})
def is_server_panel_open(window: sublime.Window) -> bool: return window.is_valid() and window.active_panel() == "output.{}".format( PanelName.LanguageServers)