grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026a BjŒj14ã@sXddlmZmZddlmZddlmZmZmZddl Z ej Z e j Z e j Z e j Z e jZe jZe jZdd„Zdeƒvr|eƒZndadad d „Zd d „Zd d„Zeeƒdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Z dd „Z!d!d"„Z"d#d$„Z#Gd%d&„d&e$ƒZ%d'd(„Z&d)d*„Z'd+d,„Z(d-d.„Z)Gd/d0„d0e*ƒZ+d1d2„Z,Gd3d4„d4e-ƒZ.dS)5é)ÚdivisionÚprint_function)Úescape)ÚbytesÚ text_typeÚ text_typesNcCsLddl}| ¡}�zzdz| |jd¡Wn|jy<Yn0| ¡dpLdWWz| |j|¡WS|jyvYS0Styì}z\|jrÖ|jd d¡rÖWYd}~Wz| |j|¡Wn|jyÐYn0dS‚WYd}~n d}~00Wz| |j|¡Wn|j�yYn0n,z| |j|¡Wn|j�yDYn00dS)NrÚézunknown locale)ÚlocaleÚ getlocaleÚ setlocaleÚLC_ALLÚErrorÚ ValueErrorÚargsÚ startswith)r ÚinitialÚe©rú0/usr/lib64/python3.9/site-packages/urwid/util.pyÚdetect_encoding(s<õ ùýrÚdetected_encodingTcCsx| ¡}|dvr t d¡dan&|dvr8t d¡dant d¡dadaz|r^d  |¡|aWntyrYn0d S) z~ Set the byte encoding to assume when processing strings and the encoding to use when converting unicode strings. )zutf-8Úutf8ÚutfrF)zeuc-jpzeuc-krzeuc-cnzeuc-twÚgb2312ÚgbkÚbig5zcn-gbÚuhcÚeucjpÚeuckrÚeuccnZeuctwZcncbZwideTZnarrowÚasciirN)ÚlowerÚstr_utilZset_byte_encodingÚ_use_dec_specialÚ_target_encodingÚencodeÚ LookupError)ÚencodingrrrÚ set_encodingGs    r)cCst ¡S)z© Get the mode Urwid is using when processing text strings. Returns 'narrow' for 8-bit encodings, 'wide' for CJK encodings or 'utf8' for UTF-8 encodings. )r#Zget_byte_encodingrrrrÚget_encoding_modeisr*c CsÒtrdt|ƒtkrdz| tj¡}WnBtybttjtj ƒD] \}}|  |tj |tj ¡}qÚattrÚcsr?r@rAÚeposrBrCZattrtrZcstrÚalrrrÚtrim_text_attr_csÝs$ÿ       ÿÿrOcCs>d}|dkrdS|D]$\}}|||kr0|S||7}qdS)z- Return the attribute at offset pos. rNr)ÚrlerEÚxÚarDrrrrHòs   rHcCs‚g}d}|D]p\}}|rF||kr2||8}||7}q ||7}||8}d}||krRq~|||krf||}||7}| ||f¡q |S)z$Return a sub segment of an rle list.r©r4)rPÚstartÚendÚlrQrRrDrrrrGs$  rGcCs"d}|D]}|\}}||7}q|S)z] Return the number of characters covered by a run length encoded attribute list. rr)rPrDÚvrRÚrrrrÚrle_lens  rYcCs\|\}}|s ||fg|dd…<n8|d\}}||krF|||f|d<n||fg|dd…<dS)z� Append (a, r) (unpacked from *a_r*) to BEGINNING of rle. Merge with first run when possible MODIFIES rle parameter contents. Returns None. Nrr)rPÚa_rrRrXrNrDrrrrI#s rIcCsN|\}}|r|dd|kr.| ||f¡dS|d\}}|||f|d<dS)z� Append (a, r) (unpacked from *a_r*) to the rle list rle. Merge with last run when possible. MODIFIES rle parameter contents. Returns None. éÿÿÿÿrNrS)rPrZrRrXZlaZlrrrrr65s  r6cCs*|sdSt||dƒ||dd…7}dS)z¡ Append attribute list rle2 to rle. Merge last run of rle with first run of rle2 when possible. MODIFIES attr parameter contents. Returns None. Nrr ©r6)rPÚrle2rrrÚrle_join_modifyCsr^c Csºd}}|r|sgS|d\}}|d\}}g}|r¶|r¶t||ƒ} t|||f| fƒ|| 8}|dkr„|t|ƒkr„||\}}|d7}|| 8}|dkr0|t|ƒkr0||\}}|d7}q0|S)a Merge the runs of rle1 and rle2 like this: eg. rle1 = [ ("a", 10), ("b", 5) ] rle2 = [ ("Q", 5), ("P", 10) ] rle_product: [ (("a","Q"), 5), (("a","P"), 5), (("b","P"), 5) ] rle1 and rle2 are assumed to cover the same total run. r r)Úminr6r5) Úrle1r]Zi1Zi2Úa1Zr1Úa2Zr2rVrXrrrÚ rle_productOs"        rccCs>g}g}|D](\\}}}t|||fƒt|||fƒq ||fS)z! Inverse of rle_product. r\)rPr`r]rarbrXrrrÚ rle_factorms rdc@s eZdZdS)ÚTagMarkupExceptionN)Ú__name__Ú __module__Ú __qualname__rrrrreyórecCsFt|dƒ\}}|ddd… |¡}|r>|dddur>|d=||fS)z:Return (text string, attribute list) for tagmarkup passed.Nrr[)Ú_tagmarkup_recurser7)ÚtmÚtlrNr>rrrÚdecompose_tagmarkup{s rmc Csæt|ƒtkr~g}g}|D]\}t||ƒ\}}|rd|d\}}|d\} } || krd| || f|d<|d=||7}||7}q||fSt|ƒtkr¶t|ƒdkr¤td|fƒ‚|\}}t||ƒSt|ttfƒsÒtd|ƒ‚|g|t|ƒfgfS)zsReturn (text list, attribute list) for tagmarkup passed. tm -- tagmarkup attr -- current attribute or Noner[réz5Tuples must be in the form (attribute, tagmarkup): %rzInvalid markup element: %r) r,ÚlistrjÚtupler5reÚ isinstancerr) rkrKZrtlZralÚelementrlrNZ last_attrZlast_runZtop_attrZtop_runrrrrj‡s,        rjcCs*t|ƒtko(t|ƒdko(|d d¡dkS)NérZmouse)r,rpr5Úfind©ZevrrrÚis_mouse_event®srvcCs| d¡dkS)NZpressr)rtrurrrÚis_mouse_press±srwcs eZdZdZ‡fdd„Z‡ZS)Ú MetaSuperzadding .__supercsBtt|ƒ |||¡t|d|ƒr*tdƒ‚t|d|t|ƒƒdS)Nz _%s__superz/Class has same name as one of its super classes)ÚsuperrxÚ__init__ÚhasattrÚAttributeErrorÚsetattr)ÚclsÚnameÚbasesÚd©Ú __class__rrrz¸szMetaSuper.__init__)rfrgrhÚ__doc__rzÚ __classcell__rrr‚rrx¶srxcCs0t||dd|dƒ}|dd}||S)aW Scale val in the range [0, val_range-1] to an integer in the range [0, out_range-1]. This implementation uses the "round-half-up" rounding method. >>> "%x" % int_scale(0x7, 0x10, 0x10000) '7777' >>> "%x" % int_scale(0x5f, 0x100, 0x10) '6' >>> int_scale(2, 6, 101) 40 >>> int_scale(1, 3, 4) 2 r rn)Úint)ÚvalZ val_rangeZ out_rangeZnumZdemrrrÚ int_scaleÀs rˆc@s(eZdZdZdd„Zdd„Zdd„ZdS) ÚStoppingContextz±Context manager that calls ``stop`` on a given object on exit. Used to make the ``start`` method on `MainLoop` and `BaseScreen` optionally act as context managers. cCs ||_dS©N)Ú_wrapped)ÚselfÚwrappedrrrrzÚszStoppingContext.__init__cCs|SrŠr)rŒrrrÚ __enter__ÝszStoppingContext.__enter__cGs|j ¡dSrŠ)r‹Ústop)rŒÚexc_inforrrÚ__exit__àszStoppingContext.__exit__N)rfrgrhr„rzrŽr‘rrrrr‰Õsr‰)/Z __future__rrZurwidrZ urwid.compatrrrr2r#r=Z calc_widthZ is_wide_charZmove_next_charZmove_prev_charZwithin_double_byterÚlocalsrr%r$r)r*r;r<rFrOrHrGrYrIr6r^rcrdÚ Exceptionrermrjrvrwr,rxrˆÚobjectr‰rrrrÚsL  " =     '