def _write_inline_html_phantom(self, content: str, region: sublime.Region, view: sublime.View): if self._show_inline_output: # region = self._inline_view.sel()[-1] id = HERMES_FIGURE_PHANTOMS + datetime.now().isoformat() html = TEXT_PHANTOM.format(content=content) view.add_phantom( id, region, html, sublime.LAYOUT_BLOCK, on_navigate=lambda href, id=id: view.erase_phantoms(id)) self._logger.info("Created inline phantom {}".format(html))
def _write_inline_image_phantom(self, data: str, region: sublime.Region, view: sublime.View): if self._output_style == "inline": # region = self._inline_view.sel()[-1] id = HERMES_FIGURE_PHANTOMS + datetime.now().isoformat() html = IMAGE_PHANTOM.format(data=data) view.add_phantom( id, region, html, sublime.LAYOUT_BLOCK, on_navigate=lambda href, id=id: view.erase_phantoms(id)) self._logger.info("Created inline phantom image")
def _add_phantom(self, view: sublime.View, id: str, region: sublime.Region, html: str): int_id = view.add_phantom( id, region, html, sublime.LAYOUT_BLOCK, on_navigate=lambda href, id=id, view=view: self._erase_phantom( id, view=view), ) self.phantoms[id] = int_id if int_id > MAX_PHANTOMS: sublime.message_dialog( "Please close and reopen your current tab. " + "Otherwise the 'Clear All Cells' command might not work as intended." ) self._logger.info("Created inline phantom image")