Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
canvas.cpython-313.pyc450 linesDownload Raw Back to __pycache__
1�

2��j���Z�SSKJr SSKrSSKrSSKrSSKrSSKJr SSKJrJ	r	 SSK3JrJr SSK
JrJrJrJrJrJrJr \R*(aSSKJrJrJrJr SSKJr S	S4KJr "SS5r"S
S\ 5r!"SS5r""SS\"5r#"SS\"5r$\$"5r%"SS\"5r&"SS\"5r'Sr(S,Sjr)Sr*Sr+S-S.Sjjr,S/Sjr-S0Sjr.S1S jr/S!r0S2S"jr1S3S#jr2S3S$jr3S4S%jr4S5S&jr5S6S'jr6S7S(jr7\Rp"S)S*55r9S8S+jr:g)9�)�annotationsN)�suppress)�
calc_text_pos�5calc_width)�
LayoutSegment�	trim_line)�apply_target_encoding�get_encoding�rle_append_modify�rle_join_modify�rle_len�rle_product�trim_text_attr_cs)�Hashable�Iterable�Iterator�Sequence)�Literal�)�Widgetc��\rSrSr%Sr0rS\S'0rS\S'0rS\S'S	r	S	r6S	r\SS7j5r
\SSj5r\SSj5r\SS
j5r\SSj5rSrg)�CanvasCache�1a08Cache for rendered canvases.  Automatically populated and9accessed by Widget render() MetaClass magic, cleared by10Widget._invalidate().11 12Stores weakrefs to the canvas objects, so an external class13must maintain a reference for this cache to be effective.14At present the Screen classes store the last topmost canvas15after redrawing the screen, keeping the canvases from being16garbage collected.17 18_widgets[widget] = {(wcls, size, focus): weakref.ref(canvas), ...}19_refs[weakref.ref(canvas)] = (widget, wcls, size, focus)20_deps[widget} = [dependent_widget, ...]21ztyping.ClassVar[dict[Widget, dict[tuple[type[Widget], tuple[int, int] | tuple[int] | tuple[()], bool], weakref.ReferenceType]]]�_widgetszytyping.ClassVar[dict[weakref.ReferenceType, tuple[Widget, type[Widget], tuple[int, int] | tuple[int] | tuple[()], bool]]]�_refsz+typing.ClassVar[dict[Widget, list[Widget]]]�_depsrc�.^	�UR(dgUR(d[S5eURup4nSU	4Sjjm	[USS5nUc[	US5(aT	"U5nU(aNUHnXpR22;dM g UH.nURRU/5RU5 M0 [R"X R5nX1XE4URU'X�R23RU05XU4'g)z�24Store a weakref to canvas in the cache.25 26wcls -- widget class that contains render() function27canvas -- rendered canvas with widget_info (widget, size, focus)28Nz&Can't store canvas without widget_infoc��>�/nURHaup#pEUR(a URURS5 M7[US5(dMJUR	T"U55 Mc U$)z=29Collect all child widgets for determining who we30depend on.31r�children)r�widget_info�append�hasattr�extend)�canv�depends�_x�_y�c�_pos�walk_dependss      ��RD:\code\apps\devtools\python\user_packages\Python313\site-packages\urwid/canvas.pyr*�'CanvasCache.store.<locals>.walk_dependses\����G�#'�=�=�����=�=��N�N�1�=�=��#3�4��Q�32�+�+��N�N�<��?�3�	$1�33�N��34depends_onr)r$�Canvas�returnzlist[Widget])
�	cacheabler �	TypeError�getattrr"rr�35setdefaultr!�weakref�ref�cleanupr)36�cls�wcls�canvas�widget�size�focusr.�wr6r*s37         @r+�store�CanvasCache.storeVs���������!�!��D�E�E�$�0�0���e�	��V�\�4�8�38���'�&�*�"=�"=�%�f�-�J�����L�L�(�� � ���	�	�$�$�Q��+�2�2�6�:� ��k�k�&�+�+�.�� ��4��	�	�#��AD�������+�D��,=�>r-c���U=RS-
slURRUS5nU(dgURX#U4S5nU(dgU"5nU(aU=RS-
slU$)z�39Return the cached canvas or None.40 41widget -- widget object requested42wcls -- widget class that contains render() function43size, focus -- render() parameters44rN)�fetchesr�get�hits)r8r;r9r<r=�sizesr6r$s        r+�fetch�CanvasCache.fetch�se��	���q������ � ���.�����i�i��U�+�T�2�����u����H�H��M�H��r-c�4�[R"[5 URUR	5H(n[[5 UR45U	SSS5 M* URU	SSS5 XR;agURRU/5n[[5 URU	SSS5 UHnURU5 M g!,(df   M�=f!,(df   N�=f!,(df   NL=f)z(46Remove all canvases cached for widget.47N)	�48contextlibr�KeyErrorr�valuesrrrC�49invalidate)r8r;r6�50dependantsr>s     r+rL�CanvasCache.invalidate�s���51�
 �
 ��
*��|�|�F�+�2�2�4���h�'��	�	�#��(�'�5����V�$�	+����"���Y�Y�]�]�6�2�.�52�
�h�
��	�	�&�!� ��A��N�N�1���(�'��+�
*�� �
�s/�0C8�C&�C8�5D	�&53C5�0C8�854D�	55Dc���U=RS-
slURRUS5nURU	U(dgUup4pVURRUS5nU(dg[	[565 XtXV4	SSS5 U(d>[R"[575 URU	URU	SSS5 gg!,(df   NT=f!,(df   g=f�Nr)�cleanupsrrCrrrJrIr)r8r6r>r;r9r<r=rEs        r+r7�CanvasCache.cleanup�s����������I�I�M�M�#�t�$���I�I�c�N���$%�!��d���� � ���.����
�h�
��D�'�(� ���$�$�X�.��L�L��(��I�I�f�%�/�.�� �
��/�.�s�?C�-C#�58C �#59C1c�.�0Ul0Ul0Ulg)z60Empty the cache.61N)rrr)r8s r+�clear�CanvasCache.clear�s��62�����	���	r-�N)r9�type[Widget]r:r/r0�None)r;rr9rWr=�boolr0z
Canvas | None)r;rr0rX)r6zweakref.ReferenceTyper0rX�r0rX)�__name__�63__module__�__qualname__�__firstlineno__�__doc__r�__annotations__rrrDrBrQ�classmethodr?rFrLr7rT�__static_attributes__rVr-r+rr1s����0	�
���	�64���:<�E�6�;��D��G��H��)E��)E�V����*����$�&��&�$���r-rc��\rSrSrSrg)�CanvasError��rVN)r[r\r]r^rbrVr-r+rdrd�s��r-rdc�,�\rSrSrSrSr\"S5rSSjrSSjr	\65SSj5r\66SSj5r\67SS	j5r
SSSjjrSSjrSS
jrSSjrS SjrS!Sjr\68"\\5rS"SjrS#SjrS$SjrS%SjrS%SjrSrg69)&r/��z70base class for canvases71TzdThis canvas has been finalized. Use CompositeCanvas to wrap this canvas if you need to make changes.c�.�SUl0Ul0Ulg)zBase Canvas classN��_widget_info�coords�	shortcuts��selfs r+�__init__�Canvas.__init__�s��bf���ce���)+��r-c�P�UR(aUReXU4Ulg)a�72Mark this canvas as finalized (should not be any future73changes to its content). This is required before caching74the canvas.  This happens automatically after a widget's75'render call returns the canvas thanks to some metaclass76magic.77 78widget -- widget that rendered this canvas79size -- size parameter passed to widget's render method80focus -- focus parameter passed to widget's render method81N)r �_finalized_errorrj)rnr;r<r=s    r+�finalize�Canvas.finalize�s&��"����'�'�'�"�%�/��r-c��UR$�N)rjrms r+r �Canvas.widget_info�s��� � � r-c��UR5VVVVs/sH+nSRUVVVs/sHup#oDPM	 snnn5PM- snnnn$s snnnfs snnnnf)zO82Return the text content of the canvas as a list of strings, one for each row.83r-)�content�join)rn�row�attr�cs�texts     r+r~�Canvas.text�sD��84IM����W������s�;�s�#3�D�d�$�s�;�<��W�W��;��Ws�A85�A�
A86�A87c�V^�[5m[U4SjUR55$)zNDecoded text content of the canvas as a sequence of strings, one for each row.c3�D># �UHoRT5v� M g7frv)�decode)�.0�line�encodings  �r+�	<genexpr>�&Canvas.decoded_text.<locals>.<genexpr>s����A�y�t�[�[��*�*�y�s� )r88�tupler~)rnr�s @r+�decoded_text�Canvas.decoded_text�s!��� �>���A�t�y�y�A�A�Ar-Nc��[5erv��NotImplementedError)rn�	trim_left�trim_top�cols�rowsr|s      r+ry�Canvas.contents
��"�#�#r-c��[5ervr�rms r+r��Canvas.cols
���!�#�#r-c��[5ervr�rms r+r��Canvas.rowsr�r-c��[5ervr��rn�others  r+�
content_delta�Canvas.content_deltar�r-c�T�URRSS5=n(aUSS$g)N�cursor��rkrC�rnr(s  r+�89get_cursor�Canvas.get_cursors*��������$�/�/�1�/��R�a�5�L�r-c���UR(aUR(aUReUc&[[5 UR90S	SSS5 g/UQSP7UR91S'g!,(df   g=f)Nr�)r r1rrrrJrkr�s  r+�92set_cursor�Canvas.set_cursors`���������'�'�'��9��(�#��K�K��)�$�� *�!�93�T�94����H��$�#��s�A-�-95A;c�N�URRSS5=n(aU$g)N�pop upr�r�s  r+�96get_pop_up�Canvas.get_pop_up's$��������$�/�/�1�/��H�r-c��UR(aUR(aUReX#XU44URS'g)aB97This method adds pop-up information to the canvas.  This information98is intercepted by a PopUpTarget widget higher in the chain to99display a pop-up at the given (left, top) position relative to the100current canvas.101 102:param w: widget to use for the pop-up103:type w: widget104:param left: x position for left edge of pop-up >= 0105:type left: int106:param top: y position for top edge of pop-up >= 0107:type top: int108:param overlay_width: width of overlay in screen columns > 0109:type overlay_width: int110:param overlay_height: height of overlay in screen rows > 0111:type overlay_height: int112r�N)r r1rrrk)rnr>�left�top�
overlay_width�overlay_heights      r+�113set_pop_up�Canvas.set_pop_up-s7��$�������'�'�'�!%�Q�~�,N� O����H�r-c�n�0nURR5HunupVnXQ-Xb-U4X4'M U$)z$114Return coords shifted by (dx, dy).115)rk�items)rn�dx�dy�d�name�x�y�datas        r+�translate_coords�Canvas.translate_coordsDs@��
��"&�+�+�"3�"3�"5��D�,�1���v�q�v�t�,�A�G�#6��r-c	�Z�S/n[R"[5 URSUR	535 SSS5 [R"[5 URSUR535 SSS5 UR(aURSUR35 SURRS[UR5SRU5S[U5S	S1163$!,(df   N�=f!,(df   N�=f)N��cols=�rows=�cursor=�<� finalized=� � at 0x�X�>)
rIr�
BaseExceptionr!r�r�r��	__class__r[rYr rz�id�rn�extras  r+�__repr__�Canvas.__repr__Ms������
�
 �
 ��
/��L�L�5�����
�.�/�0��
 �
 ��
/��L�L�5�����
�.�/�0��;�;��L�L�7�4�;�;�-�0�1��4�>�>�*�*�+�;�t�D�<L�<L�7M�6N�s�x�x�X]��N_�_e�fh�im�fn�op�eq�qr�s�s�0�
/��0�
/�s�#D�##D�117D�118D*c��[R"[5 SRUR5sSSS5 $!,(df   O=f[U5$)N�119)rIrr�rzr��reprrms r+�__str__�Canvas.__str__Zs:��
�
 �
 ��
/��9�9�T�.�.�/�0�
/�
/���D�z�s�A�120ArirZ)r;rr<z(tuple[()] | tuple[int] | tuple[int, int]r=rYr0rX)r0zDtuple[Widget, tuple[[]] | tuple[int] | tuple[int, int], bool] | None)r0zlist[bytes])r0z
Sequence[str]�rrNNN�121r��intr�r�r��122int | Noner�r�r0z>Iterator[list[tuple[object, Literal['0', 'U'] | None, bytes]]]�r0r��r�r/)r0�tuple[int, int] | None)r(r�r0rX)r0z/tuple[int, int, tuple[Widget, int, int]] | None)r>rr�r�r�r�r�r�r�r�r0rX)r�r�r�r�r0z3dict[str, tuple[int, int, tuple[Widget, int, int]]]�r0�str)r[r\r]r^r_r1rdrrrors�propertyr r~r�ryr�r�r�r�r�r�r�r�r�r�r�rbrVr-r+r/r/�s����I�"�n���,�0��0�7�0��	0�123124�0�*�!��!��X��X��B��B�����
�
$��$��$��	$�125�$�126H�$�$�$�$��+��j�*�
-�F��P�.�t�r-r/c�^�\rSrSrSrS127SU4SjjjrSSjrSSjrS
SjrSSSjjr	SSjr128S	rU=r$)�129TextCanvasiaz0130class for storing rendered text and attributes131c�z>�[TU]5 Uc/nU(a[/nUHRn[U[5(d[	S[U55eUR
[US[U555 MT O/[U[5(d[U5eU/[U5-nUcU(a[U5nOSnUc$[[U55V	s/sHn	/PM nn	Uc$[[U55V	s/sHn	/PM nn	[[U55H�n132XznX�:�a"[	SU<SU<SU<S[535eX�:aX==SRX[-1335-
ss'[X5[X*5-134nUS:a[	S	X<S135X*<35eU(a[!X*SU45 [X5[X:5-136n
U
S:a[	SX<S137X:<35eU
(dM�[!X:SU
45 M� X lX0lX@lXlXPlgs sn	fs sn	f)a#138text -- list of strings, one for each line139attr -- list of run length encoded attributes for text140cs -- list of run length encoded character set for text141cursor -- (x,y) of cursor or None142maxcol -- screen columns taken by this canvas143check_width -- check and fix width of all lines in text144NzBCanvas text must be plain strings encoded in the screen's encodingrz7Canvas text is wider than the maxcol specified:145maxcol=z146widths=z147text=z148urwid target encoding=r-zAttribute extends beyond text 149r�z#Character Set extends beyond text 150)�superro�151isinstance�bytesrdr�r!r�lenr�r2�max�ranger152�rjustr
r�_attr�_csr��_text�_maxcol)rnr~r|r}r��maxcol�check_width�widths�t�_�ir>�a_gap�cs_gapr�s              �r+ro�TextCanvas.__init__fs7���"	�����<��D���F���!�!�U�+�+�%�\��T�153����
�
�j��A�s�1�v�6�7�
��f�c�*�*���'�'��X��D�	�)�F��>���V������<� %�c�$�i� 0�1� 0�1�B� 0�D�1�
�:�#�C��I�.�/�.��"�.�B�/��s�4�y�!�A��	�A��z�!��$�Z�(�$�Z�(� �8�$-�-9�^�,<�	>����z���3�9�9�V�Z�0�0�����L�7�4�7�#3�3�E��q�y�!�$D�T�W�K�r�RV�RY�Q\�"]�^�^��!�$�'�D�%�=�9����\�G�B�E�N�2�F���z�!�$H����SU�VX�V[�U^�"_�`�`��v�!�"�%�$���8�-"�0�154������155����C2��/s�H3�>H8c�,�[UR5$)z)Return the number of rows in this canvas.)r�r�rms r+r��TextCanvas.rows�s���4�:�:��r-c��UR$)z.Return the screen column width of this canvas.)r�rms r+r��TextCanvas.cols�s���|�|�r-c�R�UR(aURup4X1-XB-4$g)zJ156Return cursor coords shifted by (dx, dy), or None if there157is no cursor.158N)r�)rnr�r�r�r�s     r+�translated_coords�TextCanvas.translated_coords�s'��159�;�;��;�;�D�A��6�1�6�>�!�r-c160#�161# �UR5UR5pvU(dXa-162nU(dXr-163nSUs=::aU:aO OUS:�aX-U::d[U5eSUs=::aU:aO OUS:�aX$-U::d[U5eU(dXG:a;[URX"U-UR164X"U-URX"U-5nO+[URUR165UR5nUH�up�nU(dX0R:a[U	U166UUX-5up�n[X�5nSn
/nUH7uunnnU(a	X�;aX_nURUUX�U
U-45 U
U-
n
M9 Uv� M� g7f)z�167Return the canvas content as a list of rows where each row168is a list of (attr, cs, text) tuples.169 170trim_left, trim_top, cols, rows may be set by171CompositeCanvas when rendering a partially obscured172canvas.173rN)r�r��174ValueError�zipr�r�r�r�rrr!)rnr�r�r�r�r|r��maxrow�text_attr_csr~�a_row�cs_row�attr_csr�r{�ar}�runs                  r+ry�TextCanvas.content�s{��� ����d�i�i�k����%�D���$�D��i�(�&�(�t�a�x�I�<L�PV�<V��Y�'�'��h�'��'�d�Q�h�8�?�f�;T��X�&�&��t�}���175�176�8��o�6��177�178�8��o�6�����t�O�4��L��t�z�z�4�:�:�t�x�x�@�L�#/��D���D�<�<�/�&7������$�'�#��V�"�%�0�G��A��C� '����B���A�I���A��179�180�A�r�4�A��G�#4�5�6��S���	!(�181�I�#$0�s�FFc�n�XLa"UR5/UR5-$UR5$)z�182Return the differences between other and this canvas.183 184If other is the same object as self this will return no185differences, otherwise this is the same as calling186content().187�r�r�ryr�s  r+r��TextCanvas.content_delta�s.���=��I�I�K�=�4�9�9�;�.�.��|�|�~�r-)r�r�r�r�r�)NNNNNT)r~zlist[bytes] | Noner|z.list[list[tuple[Hashable | None, int]]] | Noner}z7list[list[tuple[Literal['0', 'U'] | None, int]]] | Noner�r�r�r�r�rYr0rXr�)r�r�r�r�r0r��rrrrN)188r�r�r�r�r�r�r�r�r0z8Iterator[tuple[object, Literal['0', 'U'] | None, bytes]]r�)
r[r\r]r^r_ror�r�r�ryr�rb�
__classcell__�r�s@r+r�r�as�����$(�?C�FJ�)-�!� �L� �L�=�L�
D�	L�189'�L��
L��L�190�L�L�\�������
�
5��5��5��	5�191�5�192B�5�n193�194r-r�c�`�\rSrSrSrS	S195SjjrSSjrSSjrSSjrSr	g)
�BlankCanvasi196zj197a canvas with nothing on it, only works as part of a composite canvas198since it doesn't know its own size199Nc#�# �SnU(aSU;aUSnUSSRU54/n[U5HnUv� M	 g7f)z8200return (cols, rows) of spaces with default attributes.201Nr-)r�r��	rnr�r�r�r�r|�def_attrr�r�s	         r+ry�BlankCanvas.contentsH������D�D�L��D�z�H��4����4��1�2���t��A��J��s�AAc��[S5e�Nz&BlankCanvas doesn't know its own size!r�rms r+r��BlankCanvas.cols"���!�"J�K�Kr-c��[S5err�rms r+r��BlankCanvas.rows%rr-c��[S5err�r�s  r+r��BlankCanvas.content_delta(rr-rVr202r�)r0�typing.NoReturn)r�r/r0r)203r[r\r]r^r_ryr�r�r�rbrVr-r+rr204s`�������
�
������	�205��206H��$L�L�Lr-rc�t^�\rSrSrSrS	U4SjjrS207SjrS208SjrSSSjjrSr	Sr209U=r$)
�SolidCanvasi/z5210A canvas filled completely with a single character.211c��>�[TU]5 [US[U5S5upEUS:wa[	SU<35e[USU5uUlnUSSUlX#4UlSUl	g)NrrzInvalid fill_char: )212r�rorr�r�r	r�r�r<r�)rn�	fill_charr�r��end�colr}r�s       �r+ro�SolidCanvas.__init__4ss���
���� ��A�s�9�~�q�A����!�8��2�9�-�@�A�A�.�y��#��?���213�B��a�5��8����J��	���r-c� �URS$)Nr�r<rms r+r��SolidCanvas.cols>����y�y��|�r-c� �URS$rPr$rms r+r��SolidCanvas.rowsAr&r-c#��# �UcURSnUcURSnSnU(aSU;aUSnX`RURU-4/n[U5HnUv� M	 g7f)Nrr)r<r�r�r�rs	         r+ry�SolidCanvas.contentDso����<��9�9�Q�<�D��<��9�9�Q�<�D����D�D�L��D�z�H��8�8�T�Z�Z�$�%6�7�8���t��A��J��s�A,A.c�n�XLa"UR5/UR5-$UR5$)�7214Return the differences between other and this canvas.215rr�s  r+r��SolidCanvas.content_deltaXs.���=��I�I�K�=�4�9�9�;�.�.��|�|�~�r-)r�r�r�r<)r�str | bytesr�r�r�r�r0rXr�r�r�)r[r\r]r^r_ror�r�ryr�rbrrs@r+rr/sh�������216����
�
������	�217��218H��(�r-rc��^�\rSrSrSrSSU4SjjjrSSjrSSjrSSjrSSSjjr	SSjr219SSS	jjrSS220jrSSjr
SSjrSS
jrSSjrSSjrS SjrSrU=r$)!�CompositeCanvasiaz-221class for storing a combination of canvases222c�>�[TU]5 Uc/Ul/Ulg[	US5(aURUlO;UR5SSUR
5UR5SU4/4/UlSSUS4/UlURRUR5 URHnSURU'M g)zy223canv -- a Canvas object to wrap this CompositeCanvas around.224 225if canv is a CompositeCanvas, make a copy of its contents226N�shardsr�wrap)227r�ror2rr"r�r�rk�updaterl)rnr$�shortcutr�s   �r+ro�CompositeCanvas.__init__fs����"	�����<��
�K�HJ�D�M��t�X�&�&�"�k�k��� $�	�	��q�!�T�Y�Y�[�$�)�)�+�t�UY�.Z�-[�\�]�����D�$�/�0�D�M��K�K���t�{�{�+� �N�N��+1����x�(�+r-c	���S/n[R"[5 URSUR	535 SSS5 [R"[5 URSUR535 SSS5 UR(aURSUR35 UR(a5URSSRSUR55S35 S	URRS228[UR5SRU5S[U5S
S3$!,(df   GN=f!,(df   N�=f)Nr�r�r�r�z229children=(z, c3�@# �UHu pn[U5v� M g7frv)r�)r�r�r$s   r+r��+CompositeCanvas.__repr__.<locals>.<genexpr>�s���/^�P]�}�q�!�1��T�230�231�P]�s��)r�r�r�r�r�r�)rIrr�r!r�r�r�rrzr�r[rYr r�r�s  r+r��CompositeCanvas.__repr__�s�����
�
 �
 ��
/��L�L�5�����
�.�/�0��
 �
 ��
/��L�L�5�����
�.�/�0��;�;��L�L�7�4�;�;�-�0�1��=�=��L�L�:�d�i�i�/^�PT�P]�P]�/^�&^�%_�_`�a�b��4�>�>�*�*�+�;�t�D�<L�<L�7M�6N�s�x�x�X]��N_�_e�fh�im�fn�op�eq�qr�s�s�0�
/��0�
/�s�#E�##E#�232E �#233E1c��URH%up[U[5(aM[X5e [	SUR55$)Nc3�*# �UH	upUv� M g7frvrV�r��r�cvs   r+r��'CompositeCanvas.rows.<locals>.<genexpr>�s���.�+���1�+���)r2r�r�r2�sum)rnr?r@s   r+r��CompositeCanvas.rows�sA���[�[�E�A��a��%�%���&�&�!��.�$�+�+�.�.�.r-c��UR(dg[SURSS55n[U[5(d[	U5eU$)Nrc3�*# �UH	oSv� M g7f)r�NrV)r�r@s  r+r��'CompositeCanvas.cols.<locals>.<genexpr>�s���5�#4�R�a�5�#4�rBr)r2rCr�r�r2)rnr�s  r+r��CompositeCanvas.cols�sE���{�{���5�4�;�;�q�>�!�#4�5�5���$��$�$��D�/�!��r-c#�# �/nURH:upx[X�5n	[U5Hn234[U	5v� M [	Xy5nM< g7f)zb235Return the canvas content as a list of rows where each row236is a list of (attr, cs, text) tuples.237N)r2�238shard_bodyr��shard_body_row�shard_body_tail)rnr�r�r�r�r|�239shard_tail�num_rows�cviews�sbodyr�s           r+ry�CompositeCanvas.content�sN����240� $����H��v�2�E��8�_��$�U�+�+�%�)��9�J�!,�s�AAc#�z# �[US5(dUR5Shv�N g/n[URUR5Heup4[	XB5n/n[U5H9n[
U5S:wd[US[5(d[U5nUv� M; [X55nMg gN�7f)r,r2Nrr)r"ry�shards_deltar2rJr�r�r�r�rKrL)rnr�rMrNrOrPr{r�s        r+r��CompositeCanvas.content_delta�s�����u�h�'�'��|�|�~�%�%���241� ,�T�[�[�%�,�,� G��H��v�2�E��C��8�_���s�8�q�=�242�3�q�6�3�(?�(?�(��/�C��	�%�)��9�J�!H�	
&�s�%B;�B9�BB;c��US:a[SUSS35eXR5:�a"[SUSSUR5SS35eUR(aUReU(a[	UR243U5UlUS:Xa/UlOUb[
UR244U5UlURSU*5Ulg)z�Trim lines from the top and/or bottom of canvas.245 246top -- number of lines to remove from top247count -- number of lines to keep, or None for all the rest248r�invalid trim amount r��!�cannot trim � lines from N)	r�r�r rr�shards_trim_topr2�shards_trim_rowsr�rk)rnr��counts   r+�trim�CompositeCanvas.trim�s�����7��3�C��7�!�<�=�=��)�)�+���|�C��7�,�t�y�y�{�1�o�Q�O�P�P�����'�'�'��)�$�+�+�s�;�D�K��A�:��D�K�
�
�*�4�;�;��>�D�K��+�+�A��t�4��r-c�,�US::a[SUSS35eXR5:�a"[SUSSUR5SS35eUR(aURe[	UR249UR5U-2505Ulg)zYTrim lines from the bottom of the canvas.251 252end -- number of lines to remove from the end253rrVr�rWrXrYN)r�r�r rrr[r2)rnr s  r+�trim_end�CompositeCanvas.trim_end�s���254�!�8��3�C��7�!�<�=�=�������|�C��7�,�t�y�y�{�1�o�Q�O�P�P�����'�'�'�&�t�{�{�D�I�I�K�#�4E�F��r-c���UR(aUReURnUS:dUS:a:[SU*5nUR	5U-255[SU*5-256n[X4U5nUR
5nUS:�dUS:�aUUSupxUS:�aSSXS[4/UQn	OUR5n	US:�aU	RSSX&S[45 Xy4/USSQnURUS5UlX0lg)z�257Pad or trim this canvas on the left and right258 259values > 0 indicate screen columns to pad260values < 0 indicate screen columns to trim261rNr)r rrr2r�r��shards_trim_sidesr��blank_canvas�copyr!r�rk)262rnr��rightr2r�r�r��top_rows�263top_cviews�new_top_cviewss264          r+�pad_trim_left_right�#CompositeCanvas.pad_trim_left_right�s������'�'�'������!�8�u�q�y��A��u�
�I��9�9�;��*�S��U�F�^�;�D�&�v�$�?�F��y�y�{���!�8�u�q�y�#)�!�9� �H��a�x�#$�a��T�<�"H�!V�:�!V��!+���!2���q�y��%�%�q�!�U�$��&M�N��0�>�6�!�"�:�>�F��+�+�D�!�4����r-c	�<�UR(aUReURnUS:dUS:a?[SU*5nUR	5U-265[SU*5-266nURXE5 UR
5nUS:�a7USSXaS[4/4/URQUlURSU5Ul	US:�aUX0RLaURR5UlURRUSSXbS[4/45 gg)z0267Pad or trim this canvas on the top and bottom.268rN)r rrr2r�r�r]r�rdr�rkrer!)rnr��bottom�orig_shardsr�r�r�s       r+�pad_trim_top_bottom�#CompositeCanvas.pad_trim_top_bottoms������'�'�'��k�k����7�f�q�j��1�s�d�|�H��9�9�;��)�C��F�7�O�;�D��I�I�h�%��y�y�{����7��1�a��D�,�"G�!H�I�X�D�K�K�X�D�K��/�/��3�7�D�K��A�:��k�k�)�"�k�k�.�.�0����K�K����!�Q��d�L�)Q�(R�S�T�r-c��UR(aUReUR5nUR5nUR5U-269U-270nUR5U-271U-272nUS:a [	SUR5X&U4<35eUS:a [	SUR5X7U4<35eUR273n/n	UR274n275/nU(a[
X�5n276[X�5n	U(a[
X�5n[X�5n277/n/n
US:�a[U278SU5/nUS:�a[U279[SX$-5U5/n
UR5(d/nO7U(dU(a[/UQUR280PU
Q75nOUR281nX�-U-UlURRURX#55 g)zOverlay other onto this canvas.rz,top canvas of overlay not the size expected!N)r rrr�r�r�r2rZr[rcr��shards_joinrkr4r�)rnr�r�r��width�heightrfrmr2�282top_shards�side_shards�
bottom_shards�left_shards�right_shards�
middle_shardss               r+�overlay�CompositeCanvas.overlay4s�������'�'�'��283�284���������	�	��d�"�U�*������s�"�V�+���1�9��K�U�Z�Z�\�[_�hm�Ln�Kq�r�s�s��A�:��K�U�Z�Z�\�[^�hn�Lo�Kr�s�t�t������285��k�k���
��)�&�6�K�)�&�6�J��+�K�@�M�*�;�?�K������!�8�,�[�!�T�B�C�K��1�9�-�k�3�q�$�,�;O�QV�W�X�L��y�y�{�{��M�
�U�'�(S�+�(S�u�|�|�(S�l�(S�T�M�!�L�L�M� �0�=�@��������5�1�1�$�<�=r-c�*�URSU05 g)z~286Apply attribute a to all areas of this canvas with default attribute currently set to None,287leaving other attributes intact.288N)�fill_attr_apply)rnrs  r+�	fill_attr�CompositeCanvas.fill_attr`s��289	
���d�A�Y�'r-c
���UR(aURe/nURH�up4/nUH�nUSc UR/USSQUPUSSQ75 M)UR	5nURUSR
5VV	s/sHup�X�RX�54PM sn	n5 UR/USSQUPUSSQ75 M� URX545 M� X lgs sn	nf)zw290Apply an attribute-mapping dictionary to the canvas.291 292mapping -- dictionary of original-attribute:new-attribute items293�N�)r rrr2r!rer4r�rC)294rn�mappingr2rN�original_cviews�295new_cviewsr@�combined�k�vs296          r+r~�CompositeCanvas.fill_attr_applygs�������'�'�'���)-���%�H��J�%���a�5�=��%�%�&A��2�A��&A��&A�"�Q�R�&�&A�B�&�|�|�~�H��O�O��1����
�$V�
���a���Q�):�%;�
�$V�W��%�%�&B��2�A��&B��&B�2�a�b�6�&B�C�&�
�M�M�8�0�1�*5����%Ws�C4c�J�UR(aUReXlg)z�297Explicitly specify the list of widgets that this canvas298depends on.  If any of these widgets change this canvas299will have to be updated.300N)r rrr.)rn�widget_lists  r+�set_depends�CompositeCanvas.set_depends~s������'�'�'�%�r-)rrkr.r2rv)r$r/r0rXr�r�r�r�r�)r�r�r\r�r0rX)r r�r0rX)r�r�rfr�r0rX)r�r�rmr�r0rX)r�r0r�r�r�r�r0rX)rrr0rX)r�zdict[Hashable | None, Hashable]r0rX)r�zSequence[Widget]r0rX)r[r\r]r^r_ror�r�r�ryr�r]r`rjror{rr~r�rbrrs@r+r0r0as�����#2�#2�J
t�/������
�
:��:��:��	:�301�:�302H�:�0:�25�.G��<U�.*>�X(��.	&�	&r-r0c���/nUHnup#nU(aUR[U55 M)U(a*[US[5(aUS==US-
ss'MZUR	US5 Mp U$)zl303Return one row, advancing the iterators in sbody.304 305** MODIFIES sbody by calling next() on its iterators **306�����r�)r#�nextr�r�r!)rPr{�307_done_rows�content_iter�cviews     r+rKrK�sj��
�C�+0�'�308�%���J�J�t�L�)�*��z�#�b�'�3�/�/��B��5��8�#���309�310�5��8�$�,1��Jr-c�|�/nSnUH1upEnUSSupxX@-
nXH:XaX7-
nMURX4XV45 SnM3 U$)z7311Return a new shard tail that follows this shard body.312rr�r�)r!)	rNrPrM�col_gap�	done_rowsr�r�r�r�s	         r+rLrL�sb���J��G�*/�&�	���1�Q�Z�313����	����O�G�����7�|�C�D���+0��r-c#��# �[U5nS=p4S=pVUH[upxUc
[U5up4Xe:aXc-
n[U5up4Xe:aMXe:�aXx4v� XW-
nMBU[X�54v� Xc-
nSnXW-
nM] g7f)zL314Yield shards1 with cviews that are the same as shards2 having canv = None.315Nr)�iterr��shard_cviews_delta)	r2�other_shards�other_shards_iter�other_num_rows�other_cviews�done�316other_donerNrOs	         r+rSrS�s����317�\�*��$(�(�N���D�"����!�+/�0A�+B�(�N����(�J�+/�0A�+B�(�N������$�$���D���+�F�A�B�B��$�318������#�s�AA6�.A6c#�4# �[U5nSnS=pEUH~nUc[U5nXT:aXSS-
n[U5nXT:aMXT:�a
Uv� XFS-
nMAUSUSLaUSSUSS:Xa/USSQSPUSSQ7v� OUv� XSS-
nSnXFS-
nM� g7f)Nrr�r��)r�r�)rOr��other_cviews_iter�other_cvr��319other_colsr@s       r+r�r��s�����\�*���H���D������-�.�H����1�+�%�J��-�.�H������H��q�E�M�D��
�a�5�H�Q�K��B�r��F�h�r��l�$:�*�B�r��F�*�D�*�2�a�b�6�*�*��H��q�k�!�320����1��
��#�s
�AB�ABc��Sn/n[U5nUH�upxp�U(ap[U5nUSSup�p�nnXN-
nX~-nUS:a[S5eU(aU(aUR	X�X�U5nOUnURSUU45 U(aMpURX�U32145 M� UHEnUSSup�p�nnU(aU(aUR	X�X�U5nOUnURSUU45 MG U$![a Mqf=f)a>322Return a list of (done_rows, content_iter, cview) tuples for323this shard and shard tail.324 325If a canvas in cviews is None (eg. when unchanged from326shard_cviews_delta()) or if create_iter is False then no327iterator is created for content_iter.328 329iter_default is the value used for content_iter when no iterator330is created.331rNr�z#cviews overflow gaps in shard_tail!)r�r��
StopIterationrdryr!)rOrM�create_iter�iter_defaultr!�body�cviews_iterr�r�r��332tail_cviewr�r�r�r�r��attr_mapr$�new_iters                   r+rJrJ�s%���C�
�D��v�,�K�8B�4��L��
��[�)��AF�b�q�	�=�Y�$�h���K�C��O�G���{�!�"G�H�H��t��<�<�	�T��R��'���K�K��H�e�,�-��g�	
���Y�j�9�:�!9C�"��<A�"�1�I�9��d�(�D��4��|�|�I��X�N�H�#�H����Q��%�(�)�
��K��)!�
��
�s�C3�3333D�Dc��US::a[U5e[U5n/nUH'upEX:a O*[XSS5n[XF5nX-nM) [	S5e[XSS5n[XF5nUVVV	s/sHupxn	SU[X�U-54PM n334nnn	U335nXA-336UVVV	s/sHupxo�PM	 sn	nn4/nUR
U5 U$s sn	nnfs sn	nnf)z&337Return shards with top rows removed.338rFz%tried to trim shards out of existence)r�r�rJrLrd�cview_trim_topr#)r2r��339shard_iterrMrNrOrPr�r�r@�	new_sbody�340new_shardss            r+rZrZs����a�x���o���f��J��J�&����>���6�u�5��$�X�5�341����'��A�B�B��v�5�1�E� ��1�J�kp�q�kp�Lg�I�eg�!�\�>�"�#�o�#F�G�kp�I�q��E��>�%�#P�%�+F�9�B�B�%�#P�Q�R�J����j�!����r��$Qs�4C	�!C342c	�L�US:a[U5e/nSnUH�upEX1:�a U$/nUH?nUSU-U:�aUR[XqU-34355 M.URU5 MA XC-U:�aURX-344U45 OURXF45 X4-
nM� U$)z0345Return the topmost keep_rows rows from shards.346r�)r�r!�cview_trim_rows)r2�	keep_rowsr�r�rNrOr�r@s        r+r[r[.s����1�}���#�#��J��I�"����!�����347��B��!�u�y� �9�,��!�!�/�"�)�6K�"L�M��!�!�"�%�	���)�+����y�4�j�A�B����x�4�5���	�#� �r-c���US:a[U5eUS::a[U5e/n/nX-nUH�upg[XsS5n[Xh5n/n	Sn348UH_up�n
U
SnX�-nU(d349X�::dX�:�aUn350M$X�:a[X�U351-3525n
Un353X�:�a[	X�U354-3555n
U	RU
5 Un356Ma U	(dUSunnUU-U4US'M�URXi45 M� U$)zD357Return shards with starting from column left and cols total width.358rFr�r�)r�rJrL�cview_trim_left�cview_trim_colsr!)r2r�r�rMr�rfrNrOrPr�r!r��
_content_iterr@�cv_cols�next_col�
prev_num_rows�prev_cviewss                  r+rcrcJs���a�x������q�y������J��J��K�E�"����6�u�5��$�X�5�359��360���,1�(�I�b���e�G��}�H��H�,�������z�$�R���4������$�R���5�����b�!��C�-2��)3�B��&�M�;�+�h�6��D�J�r�N����x�4�5�-#�.�r-c���UVs/sHn[U5PM nnUVs/sHn[U5PM nn/n/n[SU55n/nUH2up�U361(aURU3625 UR	X�-363S45 M4 UnUR	Xv45 [[
U55HnXCSS:�aM[X#5XC'M! M�s snfs snf![a U$f=f)zl364Return the result of joining shard lists horizontally.365All shards lists must have the same number of rows.366c3�*# �UH	upUv� M g7frvrVr>s   r+r��shards_join.<locals>.<genexpr>zs���5�n�U�Q�q�n�rBNr)r�r��minr#r!r�r�r�)�shard_lists�sl�shards_itersr��shards_currentr�r�rN�shards_nextr�rOs           r+rrrros��367(3�3�{��D��H�{�L�3�'3�4�|�!�d�1�g�|�N�4��J�368��369��5�n�5�5����*�L�D���!�!�&�)�������6�7�+�370%�����8�0�1�	��3�~�.�/��!�$�Q�'�!�+��$(���$9��!�0���	4��4��,�	����	�s�C�C�7C � 371C.�-C.c� �/USSQUPUSSQ7$)Nr�r�rV)r@r�s  r+r�r���#��#�R���V�#�T�#�B�q�r�F�#�#r-c�<�USXS-USUSU-372/USSQ7$)Nrrr�r�r�rV�r@r]s  r+r�r��s2���q�E�4�Q�%�<��A���1����>�r�!�"�v�>�>r-c�6�USU-USUSU-373/USSQ7$)Nrrr�r�rVr�s  r+r�r��s.���q�E�D�L�"�Q�%��A����7��1�2��7�7r-c� �/USSQUPUSSQ7$)Nr�r�rV)r@r�s  r+r�r��r�r-c�$�UVVVs/sHupn[U5X#4PM nnnn[5n/n/nSnSn	[U5H�un374up�n
U
(aU375n	URSX�U45 URUR5 UR376R
URSU55 URHnX�RU'M X�R5-
nM� U	(aXy/USU	QXyS-SQnXelXul377U$s snnnf)azStack canvases in l vertically and return resulting canvas.378 379:param canvas_info: list of (canvas, position, focus) tuples:380 381                    position382                        a value that widget.set_focus will accept or None if not allowed383                    focus384                        True if this canvas is the one that would be in focus if the whole widget is in focus385rNr)r0�	enumerater!r#r2rkr4r�rlr�r)�canvas_infor(�p�f�clist�combined_canvasr2rr{�focus_index�nr$�posr=r5s               r+�
CanvasCombiner��s��8C�C�{�G�A�!�o�a� �!�
'�{�E�C�%�'�O�
�F��H�386�C��K�!*�5�!1����D�u���K�����C�s�+�,��
�
�d�k�k�"����%�%�d�&;�&;�A�s�&C�D����H�25�%�%�h�/�'��y�y�{���"2���)�a�H�\�k�,B�a�X�\]�o�N_�E`�a��#��'�����/
Ds�Dc��[U5nURXU5 X#US4SSUS4/Ul0UlURHnSURU'M U$)z=387Overlay canvas top_c onto bottom_c at position (left, top).388Nr�fg)r0r{rrl)�top_c�bottom_cr�r��overlayed_canvasr5s      r+�
CanvasOverlayr��sk��'�x�0�����U�#�.�"&�U�D�!9�A�q�(�D�;Q� R���!#����O�O��/3��"�"�8�,�$��r-c���/nSnSn[U5HRunupVpxUR5n	X�R5-389n390U(aUn[X95nUR	XVX�45 MT /n/n[5n
SnUH�upVp�[U5nU391(aUR
SU3925 X�:aURSX9-3935 U
RRURUS55 URHnXmRU'M UR	UR5 UR	USX�45 X�R5-
nM� U(aX�/USUQX�S-SQn[U5U
lX�lU
$)ao394Join canvases in l horizontally. Return result.395 396:param canvas_info: list of (canvas, position, focus, cols) tuples:397 398                    position399                        value that widget.set_focus will accept or None if not allowed400                    focus401                        True if this canvas is the one that would be in focus if the whole widget is in focus402                    cols403                        is the number of screen columns that this widget will require,404                        if larger than the actual canvas.cols() value then this widget405                        will be padded on the right.406rNr)r�r�r�r�r!r0rjrorkr4r�rlr2rrr)r��l2�407focus_itemr�r�r$r�r=r�r��	pad_rightr�r�
joined_canvasr!�composite_canvasr5s                 r+�408CanvasJoinr��s��� 409�B��J�
�F�'0��'=�#��#�D�u��y�y�{���9�9�;�&�	���J��V�"��410�	�	�4�i�.�/�
(>��K��H�#�%�M�411�C�&(�"��9�*�4�0����0�0��I�>��=��0�0��F�M�B����#�#�$4�$E�$E�c�1�$M�N�(�2�2�H�03�#�#�H�-�3����+�2�2�3�����a�!1�7�8��$�$�&�&��')���(�^�8�K�Z�+@�^�8�YZ�N�L\�C]�^��&�{�3�M��%���r-c�2�\rSrSr%SrS\S'SrS\S'Srg)�	_AttrWalkirr��counter�offsetrVN)r[r\r]r^r�r`r�rbrVr-r+r�r�s���G�S���F�C�Or-r�c	��^^^^^�/n/n/n[5mSUU4SjjmUGH?n[UTSU5n/n/m/n	SUUU4Sjjn412UGH�n[U5nUR(ai[	TUR413UR5up�UR
U
5 U414"UR415UR[U55 [X�5 M�UR(a\[	UR5up�UR
U
5 U416"UR417UR418[U
55 [X�5 M�UR419(aiUR(aUUR
SRUR55 U420"UR421UR422UR5 GMmGMpUR
SRUR55 TR
SUR45 U	R
SUR45 GM� UR
SRU55 UR
T5 UR
U	5 GMB [XEXcS9$)Nc��>�UTR:aSTlSTl/nTRU::GaI[T5TR::a-URSU[	UTR5-42345 U$TTRup4TRU-U::a,T=RS-
slT=RU-
slM�UTRU-::a,URX1[	UTR5-42445 U$URUTRU-[	UTR5-42545 T=RS-
slT=RU-
slTRU::aGMIU$)z9Return an attribute list for the range of text specified.rNr)r�r�r�r!r�)�426start_offs�end_offs�o�atrr|�aws     ��r+�arange�!apply_text_layout.<locals>.aranges=�����	�	�!��B�J��B�I����i�i�8�#��4�y�B�J�J�&����$��3�z�2�9�9�+E� E�F�G�����2�:�:�&�G�B��y�y�3��*�,��427�428�a��429��	�	�S� �	���2�9�9�s�?�*����"��Z����)C�C�D�E����
�H�H�b�"�)�)�c�/�C�430�B�I�I�,F�F�G�H��J�J�!�O�J��I�I���I�!�i�i�8�#�"�r-rc�N>�X:XaT	"X5uup4[T431X245 gX!U-432:XaT	"X5Hup4[T433X445 M gUnT	"X5HPup4XT-U:Xa[T434X245  gTXUU-n[U5upg[U5n[T435X845 XT-
nX(-nMR g)zE436Add attributes based on attributes between437start_offs and end_offs.438N)rr	r
)r�r��destwr�rr��tsegr}�segwr��linear~s         ���r+�	attrrange�$apply_text_layout.<locals>.attrrange:s�����%�$�Z�:���"�!�%�"��5���:�-�-�%�j�;�G�B�%�e�b�Y�7� <���A�!�*�7����7�h�&�%�e�b�[�9���A�C��(��0��6����r�{��!�%�"��4�����
��8r-r-)r�)r�r�r�r�r0z!list[tuple[Hashable | None, int]])r�r�r�r�r�r�r0rX)r�rrr r	�offsr!r
rr~r��scr�rzr�)r~r|�lsr�r�rr(�line_layoutr��linecr��seg�sr�r}r�r�r�s``             @@@r+�apply_text_layoutrs�����A�13�A�:<�A�	��B���4����T�1�f�=��������	�	�8�C��c�"�A��u�u�0��a�f�f�q�u�u�1E�F������D�!��!�&�&�!�%�%����5���*����0����8������D�!��!�&�&�!�&�&�#�d�)�4���*�����4�4��K�K��	�	�!�$�$��0��a�f�f�a�f�f�a�d�d�3�����C�I�I�a�d�d�O�,����d�A�D�D�\�*����d�A�D�D�\�*�)�,	439������$�� �	�����	�����y�|�a�A�-�-r-)rNr�)TN)r�rY)r�r�)r�r�)r�r�r�r�)r�r�)r]r�)r�r�)r�z)Iterable[tuple[Canvas, typing.Any, bool]]r0r0)440r�r/r�r/r�r�r�r�r0r0)r�z.Iterable[tuple[Canvas, typing.Any, bool, int]]r0r0)441r~r.r|zlist[tuple[Hashable, int]]r�zAlist[list[tuple[int, int, int | bytes] | tuple[int, int | None]]]r�r�r0r�);�442__future__rrI�dataclasses�typingr5r�urwid.str_utilrr�urwid.text_layoutrr�443urwid.utilr	r444rrr
rr�
TYPE_CHECKING�collections.abcrrrr�typing_extensionsrr;rr�	Exceptionrdr/r�rrdrr0rKrLrSr�rJrZr[rcrrr�r�r�r�r�r�r��	dataclassr�rrVr-r+�<module>rs]��*#���
���4�6����445���F�F�)��T�T�n	�)�	�R�R�jf��f�RL�&�L�D�}��/�&�/�df&�f�f&�R	�(�$�2�2'�T�D�8"�J�B$�?�8�$�!�H446�2�j
�������447d.�448�d.�449$�d.�	J�d.�
�	d.�450�d.r-
codekingpro/portable-devtools · Team Ai