grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026a BjŒjGã@sÀddlmZmZddlmZmZmZmZmZm Z ddl m Z m Z m Z mZGdd„dƒZGdd„deƒZGdd „d eƒZeƒZGd d „d ƒZd d „Zdd„Zdd„Zdd„Zdd„Zddd„ZdS)é)ÚdivisionÚprint_function)Ú calc_widthÚ calc_text_posÚcalc_trim_textÚ is_wide_charÚmove_prev_charÚmove_next_char)ÚbytesÚPYTHON3ÚBÚxrangec@s$eZdZdd„Zdd„Zdd„ZdS)Ú TextLayoutcCsdS)z/Return True if align is a supported align mode.T©©ÚselfÚalignrrú7/usr/lib64/python3.9/site-packages/urwid/text_layout.pyÚsupports_align_modeszTextLayout.supports_align_modecCsdS)z-Return True if wrap is a supported wrap mode.Tr©rÚwraprrrÚsupports_wrap_mode szTextLayout.supports_wrap_modecCs tdƒ‚dS)a� Return a layout structure for text. :param text: string in current encoding or unicode string :param width: number of screen columns available :param align: align mode for text :param wrap: wrap mode for text Layout structure is a list of line layouts, one per output line. Line layouts are lists than may contain the following tuples: * (column width of text segment, start offset, end offset) * (number of space characters to insert, offset or None) * (column width of insert text, offset, "insert text") The offset in the last two tuples is used to determine the attribute used for the inserted spaces or text respectively. The attribute used will be the same as the attribute at that text offset. If the offset is None when inserting spaces then no attribute will be used. zVThis function must be overridden by a real text layout class. (see StandardTextLayout)N)ÚNotImplementedError)rÚtextÚwidthrrrrrÚlayout#szTextLayout.layoutN)Ú__name__Ú __module__Ú __qualname__rrrrrrrrsrc@s eZdZdS)ÚCanNotDisplayTextN)rrrrrrrr<src@sDeZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dS)ÚStandardTextLayoutcCsdS)Nr)rrrrÚ__init__@szStandardTextLayout.__init__cCs|dvS)z4Return True if align is 'left', 'center' or 'right'.)ÚleftÚcenterÚrightrrrrrrKsz&StandardTextLayout.supports_align_modecCs|dvS)z||8}||7}q t|ƒ}|||krh| ||||¡S|| |||¡7}d}||7}q ||kr”qÎ|||krÂt|ƒ}|| |d||¡7}qÎ| |¡q |S)z· Return a trimmed line of a text layout structure. text -- text to which this layout structure applies start -- starting screen column end -- ending screen column r)rGrSr3) r+rrQrMr/ÚxrNr5rTrrrÚ trim_lineus0    rXcCs¤d}d}d}|dkr>|D] }t|ƒ}|jdur|jSqdS|dkr¢|D]}t|ƒ}|jdurJ|}qJ|}|durvdS|jdur†|jSt||j|j|jdƒdS|D]À}t|ƒ}|jdu�r\|jdu�r||k�r|||jk�rt||j|j||ƒdS||k�r||jd}|}|du�sBt||ƒt||ƒk�rL|}|j}||k�r\�qh||j7}q¦|du�s€t|ƒtk�r„|S|}t||j|j|jdƒdS)z‚ Calculate the closest linear position to pref_col given a line layout structure. Returns None if no position found. Nrr"r$r1)rGrKrMrr5ÚabsrIrL)rÚ line_layoutÚpref_colZ closest_scZ closest_posZ current_scrNrTrrrÚ calc_line_pos˜s`        ÿþþ  ÿ  r\cCsÄ|dks|t|ƒkrtdƒ‚t||||ƒ}|dur8|Stt|dddƒƒ}tt|dt|ƒƒƒ}|rÀ|rÀ|r”| d¡}t||||ƒ}|dur”|S|rb| d¡}t||||ƒ}|durb|SqbdS)za Calculate the closest linear position to pref_col and row given a layout structure. rz&calculate_pos: out of layout row rangeNr1r8)r;Ú Exceptionr\Úlistr Úpop)rrr[ÚrowrDZ rows_aboveZ rows_belowÚrrrrÚcalc_posÒs"   rbr1c Cs d}d}|D]ì}d}|D]Ö}t|ƒ} | jdur:|| j7}q| j|krT||fS| jdur”| j|kr”| j|kr”|t|| j|ƒ7}||fSt| j|ƒ} | jdurÄ| j|krÄ|| jd} |dusØ| |dkrä| ||ff}|| j7}q|d7}q |�r|dSdS)zî Calculate the coordinates closest to position pos in text with layout. text -- raw string or unicode string layout -- layout structure applied to text pos -- integer position into text clamp -- ignored right now Nrr1)rr)rGrKr5rMrrY) rrrDZclampZclosestÚyrZrWrNrTZdistancerrrÚ calc_coordsís0       rdN)r1)Z __future__rrZ urwid.utilrrrrrr Z urwid.compatr r r r rr]rr Zdefault_layoutrGr-rVrXr\rbrdrrrrÚs  P@#: