grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026a BjŒjìã@sÂddlmZmZddlmZddlmZddlmZm Z dd  dd„e d d ƒDƒ¡Z d Z d ZGd d„deƒZGdd„de ƒZee eƒZe ¡\ZZZZZZddd„Zdd„Zdd„Zdd„ZdS)é)ÚdivisionÚprint_function)Úutil)Ú ExitMainLoop)ÚAttrSpecÚ BaseScreenz ????????????????????????????????ÚcCsg|] }t|ƒ‘qS©)Úchr)Ú.0Úxr r ú9/usr/lib64/python3.9/site-packages/urwid/html_fragment.pyÚ !óré éZblackz light grayc@s eZdZdS)ÚHtmlGeneratorSimulationErrorN)Ú__name__Ú __module__Ú __qualname__r r r r r&srcsreZdZgZgZgZdZ‡fdd„Zddd„Zddd„Z d d „Z d d „Z d d„Z dd„Z dd„Zddd„Z‡ZS)Ú HtmlGeneratorTcs2tt|ƒ ¡d|_d|_d|_| dtt¡dS)NéFT) ÚsuperrÚ__init__ÚcolorsÚbright_is_boldÚ has_underlineZregister_palette_entryÚ_default_foregroundÚ_default_background©Úself©Ú __class__r r r0sÿzHtmlGenerator.__init__NcCs@|dur|j}|dur|j}|dur*|j}||_||_||_dS©N)rrr)r rrrr r r Úset_terminal_properties8sz%HtmlGenerator.set_terminal_propertiescCsdS)zNot yet implementedNr )r Úenabler r r Úset_mouse_trackingFsz HtmlGenerator.set_mouse_trackingcGsdSr#r ©r Úargsr r r Úset_input_timeoutsJsz HtmlGenerator.set_input_timeoutscGsdSr#r r'r r r Úreset_default_terminal_paletteMsz,HtmlGenerator.reset_default_terminal_palettec Cs4g}|\}}|jdur"|j\}}nd}}d}| ¡D]â} |d7}d} | D]Â\} } } tturd|  ¡} |  t¡} t| tƒr~| }n|j | dddddœ|j }||krü| |krüt   | dt | ƒ¡}| ||krâ| t| ||| ƒ¡n| t| |ƒ¡| |7} qJ| t| |ƒ¡qJ| d¡q6|j d d  |¡¡dS) zkCreate an html fragment from the render object. Append it to HtmlGenerator.fragments list. Néÿÿÿÿéréé)r,réXrÚ z
%s
r)ÚcursorZcontentÚstrÚbytesÚdecodeÚ translateÚ _trans_tableÚ isinstancerZ_paletterrZ calc_widthÚlenÚappendÚ html_spanÚ fragmentsÚjoin)r ÚsizeÚrÚlZcolsZrowsZcxÚcyÚyÚrowÚcolÚaÚcsÚrunÚaspecZ run_widthr r r Ú draw_screenPs>     ÿÿ ÿ  zHtmlGenerator.draw_screencCsdS)z’ Force the screen to be completely repainted on the next call to draw_screen(). (does nothing for html_fragment) Nr rr r r Úclear€szHtmlGenerator.clearcCs|jstdƒ‚|j d¡S)z3Return the next screen size in HtmlGenerator.sizes.z"Ran out of screen sizes to return!r)ÚsizesrÚpoprr r r Ú get_cols_rows‰szHtmlGenerator.get_cols_rowsFcCs,|js tƒ‚|r |j d¡gfS|j d¡S)z9Return the next list of keypresses in HtmlGenerator.keys.r)ÚkeysrrK)r Zraw_keysr r r Ú get_input�s zHtmlGenerator.get_input)NNN)T)F)rrrr;rJrMÚstartedrr$r&r)r*rHrIrLrNÚ __classcell__r r r!r r)s ÿ  0 rr+cs| ¡\}}}}}}|dur,ttt}}}|durDttt}}}d|||f} d|||f} |jrp| | } } d|jd|j ‰‡fdd„} |dk�rt   |dt |ƒ|¡\} } t   || t |ƒ¡}| | | |d| …ƒ| | | || |…ƒ| | | ||d…ƒS| | | |ƒSdS)Nz #%02x%02x%02xz;text-decoration:underlinez;font-weight:boldcs|sdSd||ˆt|ƒfS)Nrz0%s)Ú html_escape)ZfgÚbgÚs©Zextrar r r:¨sþzhtml_span..html_spanr)Úget_rgb_valuesÚ_d_fg_rÚ_d_fg_gÚ_d_fg_bÚ_d_bg_rÚ_d_bg_gÚ_d_bg_bZstandoutZ underlineZboldrZ calc_text_posr8Zmove_next_char)rSrGr1Zfg_rZfg_gZfg_bZbg_rZbg_gZbg_bZhtml_fgZhtml_bgr:Zc_offZ_ignZc2_offr rTr r:›s, ÿ  ÿþr:cCs(| dd¡}| dd¡}| dd¡}|S)z;Escape text so that it will be displayed safely within HTMLú&z&úz>)Úreplace)Útextr r r rQ¸s   rQc Csžz|D]\}}qWnttfy0tdƒ‚Yn0z|D]}|D]}q@q8Wnttfyhtdƒ‚Yn0ddlm}t|_ddlm}t|_|t_|t_ dS)a¹ Replace curses_display.Screen and raw_display.Screen class with HtmlGenerator. Call this function before executing an application that uses curses_display.Screen to have that code use HtmlGenerator instead. sizes -- list of ( columns, rows ) tuples to be returned by each call to HtmlGenerator.get_cols_rows() keys -- list of lists of keys to be returned by each call to HtmlGenerator.get_input() Lists of keys may include "window resize" to force the application to call get_cols_rows and read a new screen size. For example, the following call will prepare an application to: 1. start in 80x25 with its first call to get_cols_rows() 2. take a screenshot when it calls draw_screen(..) 3. simulate 5 "down" keys from get_input() 4. take a screenshot when it calls draw_screen(..) 5. simulate keys "a", "b", "c" and a "window resize" 6. resize to 20x10 on its second call to get_cols_rows() 7. take a screenshot when it calls draw_screen(..) 8. simulate a "Q" keypress to quit the application screenshot_init( [ (80,25), (20,10) ], [ ["down"]*5, ["a","b","c","window resize"], ["Q"] ] ) z:sizes must be in the form [ (col1,row1), (col2,row2), ...]z@keys must be in the form [ [keyA1, keyA2, ..], [keyB1, ..], ...]r,)Úcurses_display)Ú raw_displayN) ÚAssertionErrorÚ ValueErrorÚ ExceptionrrarZScreenrbrJrM)rJrMrBrCr?Úkrarbr r r Úscreenshot_init¿s"   rgcCstj}gt_|S)z/Return screenshots as a list of HTML fragments.)rr;)r?r r r Úscreenshot_collectôsrhN)r+)Z __future__rrZurwidrZurwid.main_looprZurwid.display_commonrrr<Úranger6rrrerrZ_default_aspecrUrVrWrXrYrZr[r:rQrgrhr r r r Ús  n ÿ 5