grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026a BjŒj14ã@sdddlmZmZddlmZddlmZmZmZddl Z ej Z e j Z e j Z e j Z e jZe jZe jZdd„Zdeƒvr|eƒZn dsˆJdƒ‚dad ad d „Zd d „Zdd„Zeeƒdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Z d d!„Z!d"d#„Z"d$d%„Z#Gd&d'„d'e$ƒZ%d(d)„Z&d*d+„Z'd,d-„Z(d.d/„Z)Gd0d1„d1e*ƒZ+d2d3„Z,Gd4d5„d5e-ƒZ.dS)6é)Ú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_encodingz It worked!TcCsx| ¡}|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 ¡}qd}|dkrdS|D]$\}}|||kr0|S||7}qdS)z- Return the attribute at offset pos. rNr)ÚrlerFÚxÚarErrrrIòs   rIcCs‚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©r5)rQÚstartÚendÚlrRrSrErrrrHs$  rHcCs:d}|D],}t|ƒtks$Jt|ƒƒ‚|\}}||7}q|S)z] Return the number of characters covered by a run length encoded attribute list. r)r,ÚtupleÚrepr)rQrEÚvrSÚrrrrÚrle_lens  r\cCs\|\}}|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)rQÚa_rrSr[rOrErrrrJ#s rJcCsN|\}}|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. éÿÿÿÿrNrT)rQr]rSr[ZlaZlrrrrr75s  r7cCs*|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 ©r7)rQÚrle2rrrÚrle_join_modifyCsrac 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)Úminr7r6) Úrle1r`Zi1Zi2Úa1Zr1Úa2Zr2rWr[rrrÚ rle_productOs"        rfcCs>g}g}|D](\\}}}t|||fƒt|||fƒq ||fS)z! Inverse of rle_product. r_)rQrcr`rdrer[rrrÚ rle_factorms rgc@s eZdZdS)ÚTagMarkupExceptionN)Ú__name__Ú __module__Ú __qualname__rrrrrhyórhcCsFt|dƒ\}}|ddd… |¡}|r>|dddur>|d=||fS)z:Return (text string, attribute list) for tagmarkup passed.Nrr^)Ú_tagmarkup_recurser8)ÚtmÚtlrOr?rrrÚdecompose_tagmarkup{s rpc 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,ÚlistrmrXr6rhr3rr) rnrLZrtlZralÚelementrorOZ last_attrZlast_runZtop_attrZtop_runrrrrm‡s,        rmcCs*t|ƒtko(t|ƒdko(|d d¡dkS)NérZmouse)r,rXr6Úfind©ZevrrrÚis_mouse_event®srwcCs| d¡dkS)NZpressr)rurvrrrÚis_mouse_press±srxcs 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)ÚsuperryÚ__init__ÚhasattrÚAttributeErrorÚsetattr)ÚclsÚnameÚbasesÚd©Ú __class__rrr{¸szMetaSuper.__init__)rirjrkÚ__doc__r{Ú __classcell__rrrƒrry¶srycCs0t||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 rq)Ú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Úwrappedrrrr{ÚszStoppingContext.__init__cCs|Sr‹r)r�rrrÚ __enter__ÝszStoppingContext.__enter__cGs|j ¡dSr‹)rŒÚstop)r�Úexc_inforrrÚ__exit__àszStoppingContext.__exit__N)rirjrkr…r{r�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=rGrPrIrHr\rJr7rarfrgÚ Exceptionrhrprmrwrxr,ryr‰ÚobjectrŠrrrrÚsN   " =     '