def _sym_def_href(location, **kwargs): args = { "path": location.path_encoded_position(), "hide_popup": True } args.update(kwargs) return sublime.command_url("open_symbol_definition ", args)
def add_annotation(response): args = { "reference": response["expected"], "actual": response["actual"] } return """ <a style="font-size: 0.8rem" href='{}'>{}</a> """.format( sublime.command_url("tutkain_open_diff_window", args=args), "diff" if response.get("type", edn.Keyword("fail")) == edn.Keyword("fail") else "show", )
def make_command_link(command: str, text: str, command_args: Optional[Dict[str, Any]] = None, class_name: Optional[str] = None, view: Optional[sublime.View] = None) -> str: if view: cmd = "lsp_run_text_command_helper" args = { "view_id": view.id(), "command": command, "args": command_args } # type: Optional[Dict[str, Any]] else: cmd = command args = command_args return make_link(sublime.command_url(cmd, args), text, class_name)
def image_popup(view: sublime.View, region: sublime.Region, width: int, height: int, src: str, name: str, on_pre_show_popup, on_hide_popup) -> None: sublime_version = int(sublime.version()) def on_navigate(href: str) -> None: sublime.active_window().open_file(href[len(FILE_PREFIX):]) device_scale_factor = EM_SCALE_FACTOR * view.em_width() scaled_width, scaled_height = scale_image(width, height, device_scale_factor) settings = sublime.load_settings(SETTINGS_FILE) popup_border_width = settings.get('popup_border_width') popup_width = scaled_width + int(2 * popup_border_width * device_scale_factor) label = image_size_label(width, height) if 'open_image_button' in settings.get('popup_style'): if src.startswith(FILE_PREFIX) or src.startswith(DATA_PREFIX) and sublime_version >= 4096: href = sublime.command_url('quick_view_open_image', {'href': src, 'name': name}) if sublime_version >= 4096 else src label += '<span> </span><a class="icon" href="{}" title="Open Image in new Tab">❐</a>'.format(href) location = popup_location(view, region, popup_width) img_preview = '<img src="{}" width="{}" height="{}" /><div class="img-label">{}</div>'.format(src, scaled_width, scaled_height, label) content = format_template(view, popup_width, img_preview) on_pre_show_popup(region) if sublime_version >= 4096: view.show_popup(content, POPUP_FLAGS, location, 1024, 1024, None, on_hide_popup) else: view.show_popup(content, POPUP_FLAGS, location, 1024, 1024, on_navigate, on_hide_popup)