
    ^h                     ^    S SK Jr  S SKJrJrJr  S SKJr  S SKJ	r	  S SK
Jr   " S S\5      rg)	    )StringIO)HTMLdisplayupdate_display)Console)Markdown)ChatDBGMarkdownPrinterc                   \   ^  \ rS rSrU 4S jrS rSU 4S jjrS rS rS r	S r
S	 rS
rU =r$ )ChatDBGJupyterPrinter	   c                 8   > [         TU ]  [        5       XU5        g N)super__init__r   )selfdebugger_promptchat_prefixwidth	__class__s       N/home/james-whalen/.local/lib/python3.13/site-packages/chatdbg/util/jupyter.pyr   ChatDBGJupyterPrinter.__init__   s    _5I    c                 D    [        SUSU R                  U R                  S9$ )NFT)	soft_wrapfilerecordthemer   )r   _theme_width)r   outs     r   _make_console#ChatDBGJupyterPrinter._make_console   s"    #d$++T[[
 	
r   c                 d   > [         TU ]  XS9  [        [        U R	                  5       5      5        g )N)end)r   _printr   r   _export_html)r   textr$   r   s      r   r%   ChatDBGJupyterPrinter._print   s'    t%T&&()*r   c                 R    U R                   R                  SSS9nSnSU S3nX!-   nU$ )NT)clearinline_stylesau  
        <style>
            .rich-text pre,code,div {
                line-height: normal !important;
                margin-bottom: 0 !important;
                font-size: 14px !important;
            }

            .rich-text .jp-RenderedHTMLCommon pre, .jp-RenderedHTMLCommon code {
                white-space: pre;
            }            
        </style>
        z<div class="rich-text">z</div>)_consoleexport_html)r   exported_html
custom_cssmodified_htmls       r   r&   "ChatDBGJupyterPrinter._export_html   s@    11D1Q
 2-G"2r   c                 ,   U =R                   U-  sl         U R                  [        U R                   U R                  S95      nU R                  R                  U5        U R                  5       n[        [        U5      U R                  R                  S9  g )N)
code_theme
display_id)	_streamed_wrap_in_panelr   _code_themer,   printr&   r   r   _display_handler5   )r   r'   mr.   s       r   _stream_append$ChatDBGJupyterPrinter._stream_append-   sl    $DDTDT UVA))+tM*t7K7K7V7VWr   c                     SU l         g )N )r6   r   s    r   on_begin_stream%ChatDBGJupyterPrinter.on_begin_stream4   s	    r   c                 v    U R                   S:X  a  [        [        S5      SS9U l        U R	                  U5        g )Nr?   Tr4   )r6   r   r   r:   r<   )r   r'   s     r   on_stream_delta%ChatDBGJupyterPrinter.on_stream_delta7   s/    >>R#*48#ED D!r   c                     g r    r@   s    r   on_end_stream#ChatDBGJupyterPrinter.on_end_stream<   s    r   )r:   r6   )r?   )__name__
__module____qualname____firstlineno__r   r!   r%   r&   r<   rA   rD   rH   __static_attributes____classcell__)r   s   @r   r   r   	   s2    J
+&X"
 r   r   N)ior   IPython.displayr   r   r   rich.consoler   rich.markdownr   chatdbg.util.markdownr	   r   rG   r   r   <module>rU      s$     9 9   " 842 4r   