############################################################################### # This file is a part of Dear ImGui Bundle, NOT a part of imgui_md # ----------------------------------------------------------------------------- # imgui_md.pyi: auto-generated bindings for imgui_md, a Markdown renderer # for ImGui. # See https://github.com/mekhontsev/imgui_md # Here, we also provide bindings for an additional wrapper, which is part of # ImGui Bundle: see external/imgui_md/imgui_md_wrapper # # Most of the code of this file is automatically generated (using https://pthom.github.io/litgen/), # and is generally very close to the C++ version. Comments, docs are identical. # Do not manually edit the autogenerated parts (look for "Autogenerated" comments)! ############################################################################### # ruff: noqa: B008 import enum from typing import Optional, Callable from imgui_bundle.imgui import ImTextureID, ImVec2, ImVec4, ImFont import numpy as np # using VoidFunction = std::function; # using StringFunction = std::function; # using HtmlDivFunction = std::function; # using HtmlSpanFunction = std::function; # using MarkdownImageFunction = std::function(const std::string&)>; # using MarkdownDownloadFunction = std::function; VoidFunction = Callable[[], None] StringFunction = Callable[[str], None] HtmlDivFunction = Callable[[str, bool], None] HtmlSpanFunction = Callable[[str, bool], bool] MarkdownImageFunction = Callable[[str], Optional[MarkdownImage]] MarkdownDownloadFunction = Callable[[str], MarkdownDownloadResult] # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! AUTOGENERATED CODE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # // Autogenerated code below! Do not edit! #################### #################### class MarkdownFontOptions: font_base_path: str = "fonts/Roboto/Roboto" # This size is in density-independent pixels regular_size: float = 16.0 # Multipliers for header sizes, from h1 to h6 header_size_factors: ( np.ndarray ) # ndarray[type=float, size=6] default:float( 1.42, 1.33, 1.24, 1.15, 1.10, 1.05 ) def __init__(self) -> None: """Autogenerated default constructor""" pass class MarkdownImage: texture_id: ImTextureID size: ImVec2 uv0: ImVec2 uv1: ImVec2 col_tint: ImVec4 col_border: ImVec4 def __init__(self) -> None: """Autogenerated default constructor""" pass class SizedFont: """Note: Since v1.92, Fonts can be displayed at any size: in order to display a font at a given size, we need to call ImGui::PushFont(font, size) (or call separately ImGui::PushFontSize) """ font: ImFont size: float def __init__(self) -> None: """Autogenerated default constructor""" pass class MarkdownDownloadStatus(enum.IntEnum): """Status of a download (used by OnDownloadData callback)""" not_started = enum.auto() # (= 0) # Download has not been initiated downloading = enum.auto() # (= 1) # Download is in progress (show placeholder) ready = enum.auto() # (= 2) # Download complete, data is available failed = enum.auto() # (= 3) # Download failed, errorMessage has details class MarkdownDownloadResult: """Result of a download attempt""" status: MarkdownDownloadStatus = MarkdownDownloadStatus.not_started error_message: str # Only valid if status == Failed def __init__(self) -> None: """Autogenerated default constructor""" pass def fill_from_bytes(self, data: bytes) -> None: """Fill the result data from a Python bytes object.""" ... def on_image_default(image_path: str) -> Optional[MarkdownImage]: pass def on_open_link_default(url: str) -> None: pass class MarkdownCallbacks: # The default version will open the link in a browser iif it starts with "http" on_open_link: StringFunction = on_open_link_default # The default version will load the image as a cached texture and display it on_image: MarkdownImageFunction = on_image_default # OnHtmlDiv does nothing by default, by you could write: # In C++: # markdownOptions.callbacks.onHtmlDiv = [](const std::string& divClass, bool openingDiv) # { # if (divClass == "red") # { # if (openingDiv) # ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(255, 0, 0, 255)); # else # ImGui::PopStyleColor(); # } # }; # In Python: # def on_html_div(div_class: str, opening_div: bool) -> None: # if div_class == 'red': # if opening_div: # imgui.push_style_color(imgui.Col_.text.value, imgui.ImColor(255, 0, 0, 255).value) # else: # imgui.pop_style_color() # md_options = imgui_md.MarkdownOptions() # md_options.callbacks.on_html_div = on_html_div # immapp.run( # gui_function=gui, with_markdown_options=md_options #, more options here # ) on_html_div: HtmlDivFunction # OnHtmlSpan: optional callback for inline HTML tags encountered in # markdown text (one call per open/close tag; e.g. "sub", "sup", # "kbd", "mark", or any custom tag). # Return True to indicate the tag was fully handled, False to let # the built-in renderer apply its default rendering (if any). # Example (C++): # callbacks.OnHtmlSpan = [](const std::string& tag, bool opening) { # if (tag == "small") { # // ... push/pop a smaller font # return True; # } # return False; # }; on_html_span: HtmlSpanFunction def __init__(self) -> None: """Autogenerated default constructor""" pass @property def on_download_data(self) -> Optional[str]: """Returns None if not set, or a status string if set. Reading back the callable itself is not supported.""" ... @on_download_data.setter def on_download_data( self, fn: Optional[Callable[[str], MarkdownDownloadResult]] ) -> None: """Set a callable that downloads data from a URL. The callable receives a URL string and should return a MarkdownDownloadResult. The callback is stateful: it will be called every frame for a given URL until it returns Ready or Failed. For synchronous downloads, return Ready or Failed immediately. For async downloads, return Downloading on first call, then Ready/Failed once done. Set to None to disable URL image support.""" ... class MarkdownOptions: font_options: MarkdownFontOptions callbacks: MarkdownCallbacks # Enable native LaTeX math rendering via MicroTeX. # When True, $...$ and $$...$$ in markdown will be rendered as math formulas # (requires building with IMGUI_RICHMD_WITH_LATEX=ON, which is the default # when IMGUI_BUNDLE_WITH_MICROTEX and FreeType are both available). # When False, $ is rendered as a literal character (legacy behavior). with_latex: bool = False # Recognize bare URLs, email addresses and www.* as clickable links # without requiring <...> or []() syntax # (MD_FLAG_PERMISSIVEAUTOLINKS — URL + email + WWW). # Set to False to get strict CommonMark link behavior. autolinks: bool = True def __init__(self) -> None: """Autogenerated default constructor""" pass def initialize_markdown(options: Optional[MarkdownOptions] = None) -> None: """Python bindings defaults: If options is None, then its default value will be: MarkdownOptions() """ pass def de_initialize_markdown() -> None: pass def get_font_loader_function() -> VoidFunction: """GetFontLoaderFunction() will return a function that you should call during ImGui initialization.""" pass def render(markdown_string: str) -> None: """Renders a markdown string""" pass def render_unindented(markdown_string: str) -> None: """Renders a markdown string (after having unindented its main indentation)""" pass def get_code_font() -> SizedFont: pass class MarkdownFontSpec: italic: bool = False bold: bool = False header_level: int = 0 # 0 means no header, 1 means h1, 2 means h2, etc. def __init__( self, italic_: bool = False, bold_: bool = False, header_level_: int = 0 ) -> None: pass def get_font(font_spec: MarkdownFontSpec) -> SizedFont: pass def link_color() -> ImVec4: pass def render_text_as_link(text: str, url: str) -> None: """Renders a link with the given text and url. Can be used outside of markdown rendering.""" pass def _set_on_initialize_markdown_callback( callback: Optional[Callable[[MarkdownOptions], None]], ) -> None: """Private. Set a callback called during initialize_markdown() to customize options. Used internally by imgui_bundle to inject URL image download support.""" pass #################### #################### # // Autogenerated code end!