Team Ai
Datasetpublic

codekingpro/portable-devtools

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

2��j�1����SSKJr SSKrSSKJr SSKJr SSKJr SSK	J3r4 SSKJrJ
r
 SS	KJrJrJr SS5KJrJr \R*(aSSKJr SSKJr SS
KJr "SS\5r"SS\5rg)�)�annotationsN)�text_layout)�apply_text_layout)�remove_defaults)�6calc_width)�decompose_tagmarkup�get_encoding�)�Align�Sizing�WrapMode)�Widget�WidgetError)�Hashable)�Literal)�7TextCanvasc��\rSrSrSrg)�	TextError��N)�__name__�8__module__�__qualname__�__firstlineno__�__static_attributes__r��WD:\code\apps\devtools\python\user_packages\Python313\site-packages\urwid/widget/text.pyrrs��rrc�^�\rSrSrSr\"\R\R/5r	Sr9Sr\R\RS4SU4SjjjrSU4SjjrSU4SjjrSU4S	jjrSS10jrSSjr\S Sj5r\S!S
j5rS"SjrS#SjrS$S%Sjjr\"S\5r\"S\5r\S5rS&S'SjjrS&S(Sjjr S$S)Sjjr!S*Sjr"S+S,Sjjr#Sr$U=r%$)-�Text�z'11a horizontally resizeable text widget12T�Nc�>�[TU]5 SUlU=(d [RUlUR
U5 URX#U5 g)a�13:param markup: content of text widget, one of:14 15    bytes or unicode16      text to be displayed17 18    (*display attribute*, *text markup*)19      *text markup* with *display attribute* applied to all parts20      of *text markup* with no display attribute already applied21 22    [*text markup*, *text markup*, ... ]23      all *text markup* in the list joined together24 25:type markup: :ref:`text-markup`26:param align: typically ``'left'``, ``'center'`` or ``'right'``27:type align: text alignment mode28:param wrap: typically ``'space'``, ``'any'``, ``'clip'`` or ``'ellipsis'``29:type wrap: text wrapping mode30:param layout: defaults to a shared :class:`StandardTextLayout` instance31:type layout: text layout instance32 33>>> Text("Hello")34<Text fixed/flow widget 'Hello'>35>>> t = Text(("bold", "stuff"), "right", "any")36>>> t37<Text fixed/flow widget 'stuff' align='right' wrap='any'>38>>> print(t.text)39stuff40>>> t.attrib41[('bold', 5)]42N)�super�__init__�
_cache_maxcolr�default_layout�_layout�set_text�43set_layout)�self�markup�align�wrap�layout�	__class__s     �rr$�
Text.__init__$sE���L	����)-���/5�/S��9S�9S����
�
�f������V�,rc��>�[TU]5nUR5Sn[U5n[	U5UR44:�a.USUR45S-S-S-46S-X0R47*S-S-n/UQUP$)zg48Show the text in the repr in python3 format (b prefix for byte strings) and truncate if it's too long49rN��z...)r#�_repr_words�get_text�repr�len�_repr_content_length_max)r*�first�text�restr/s    �rr4�Text._repr_wordsPs������#�%���}�}��q�!���D�z���t�9�t�4�4�4��A�t�4�4�q�8�A�=��A�B�U�J�T�Sp�Sp�Rp�tu�Ru�Rw�Mx�x�
���~��~�rc�>�0[TU]5EURURS.En[	U[50R5$)N)r,r-)r#�_repr_attrs�_align_mode�51_wrap_moderrr$)r*�attrsr/s  �rr>�Text._repr_attrs]sB���52��g�!�#�53��%�%��O�O�54��55�u�d�m�m�4�4rc�0>�SUl[TU]	5 g�N)r%r#�_invalidate)r*r/s �rrE�Text._invalidatees���!���
���rc�T�[U5uUlUlUR5 g)aa56Set content of text widget.57 58:param markup: see :class:`Text` for description.59:type markup: text markup60 61>>> t = Text("foo")62>>> print(t.text)63foo64>>> t.set_text("bar")65>>> print(t.text)66bar67>>> t.text = "baz"  # not supported because text stores text but set_text() takes markup68Traceback (most recent call last):69AttributeError: can't set attribute70N)r�_text�_attribrE)r*r+s  rr(�
Text.set_textis#��"$7�v�#>� ��71�D�L����rc�2�URUR4$)a�72:returns: (*text*, *display attributes*)73 74    *text*75      complete bytes/unicode content of text widget76 77    *display attributes*78      run length encoded display attributes for *text*, eg.79      ``[('attr1', 10), ('attr2', 5)]``80 81>>> Text("Hello").get_text()  # ... = u in Python 282(...'Hello', [])83>>> Text(("bright", "Headline")).get_text()84(...'Headline', [('bright', 8)])85>>> Text([("a", "one"), "two", ("b", "three")]).get_text()86(...'onetwothree', [('a', 3), (None, 3), ('b', 5)])87)rHrI�r*s rr5�
Text.get_text}s��$�z�z�4�<�<�'�'rc�(�UR5S$)zP88Read-only property returning the complete bytes/unicode content89of this widget90r�r5rLs rr:�	Text.text�����}�}��q�!�!rc�(�UR5S$)zW91Read-only property returning the run-length encoded display92attributes of this widget93r94rOrLs r�attrib�Text.attrib�rQrc��URRU5(d[SU<S35eXlUR	5 g)a#95Set text alignment mode. Supported modes depend on text layout96object in use but defaults to a :class:`StandardTextLayout` instance97 98:param mode: typically ``'left'``, ``'center'`` or ``'right'``99:type mode: text alignment mode100 101>>> t = Text("word")102>>> t.set_align_mode("right")103>>> t.align104'right'105>>> t.render((10,)).text  # ... = b in Python 3106[...'      word']107>>> t.align = "center"108>>> t.render((10,)).text109[...'   word   ']110>>> t.align = "somewhere"111Traceback (most recent call last):112TextError: Alignment mode 'somewhere' not supported.113zAlignment mode � not supported.N)r.�supports_align_moderr?rE�r*�modes  r�set_align_mode�Text.set_align_mode�s?��*�{�{�.�.�t�4�4��o�d�X�_�E�F�F������rc��URRU5(d[SU<S35eXlUR	5 g)ap114Set text wrapping mode. Supported modes depend on text layout115object in use but defaults to a :class:`StandardTextLayout` instance116 117:param mode: typically ``'space'``, ``'any'``, ``'clip'`` or ``'ellipsis'``118:type mode: text wrapping mode119 120>>> t = Text("some words")121>>> t.render((6,)).text  # ... = b in Python 3122[...'some  ', ...'words ']123>>> t.set_wrap_mode("clip")124>>> t.wrap125'clip'126>>> t.render((6,)).text127[...'some w']128>>> t.wrap = "any"  # Urwid 0.9.9 or later129>>> t.render((6,)).text130[...'some w', ...'ords  ']131>>> t.wrap = "somehow"132Traceback (most recent call last):133TextError: Wrap mode 'somehow' not supported.134z135Wrap mode rVN)r.�supports_wrap_moderr@rErXs  r�
set_wrap_mode�Text.set_wrap_mode�s>��.�{�{�-�-�d�3�3��j����@�A�A������rc�z�Uc[RnX0lURU5 UR	U5 g)a�136Set the text layout object, alignment and wrapping modes at137the same time.138 139:type align: text alignment mode140:param wrap: typically 'space', 'any', 'clip' or 'ellipsis'141:type wrap: text wrapping mode142:param layout: defaults to a shared :class:`StandardTextLayout` instance143:type layout: text layout instance144 145>>> t = Text("hi")146>>> t.set_layout("right", "clip")147>>> t148<Text fixed/flow widget 'hi' align='right' wrap='clip'>149N)rr&r'rZr^)r*r,r-r.s    rr)�Text.set_layout�s5��*�>� �/�/�F������E�"����4� rc��UR$rD)r?rLs r�<lambda>�
Text.<lambda>�s150��$�"2�"2rc��UR$rD)r@rLs rrcrd�s����rc��UR$rD)r'rLs rr.�Text.layout�s���|�|�rc��UR5up4U(aUunOURUS9upVURXSU45n[X4Xu5$)a?151Render contents with wrapping and alignment.  Return canvas.152 153See :meth:`Widget.render` for parameter details.154 155>>> Text("important things").render((18,)).text156[b'important things  ']157>>> Text("important things").render((11,)).text158[b'important  ', b'things     ']159>>> Text("demo text").render(()).text160[b'demo text']161)�focus)r5�pack�get_line_translationr)r*�sizerir:�attr�maxcol�_�transs        r�render�Text.render�sN��"�]�]�_�162����I�V��	�	��	�.�I�F��)�)�&��,�?�� ��U�;�;rc�>�Uun[URU55$)z�163Return the number of rows the rendered text requires.164 165See :meth:`Widget.rows` for parameter details.166 167>>> Text("important things").rows((18,))1681169>>> Text("important things").rows((11,))1702171)r7rk)r*rlrirns    r�rows�	Text.rowss!���	���4�,�,�V�4�5�5rc�~�UR(aURU:waURX5 UR$)ad172Return layout structure used to map self.text to a canvas.173This method is used internally, but may be useful for debugging custom layout classes.174 175:param maxcol: columns available for display176:type maxcol: int177:param ta: ``None`` or the (*text*, *display attributes*) tuple178           returned from :meth:`.get_text`179:type ta: text and display attributes180)r%�_update_cache_translation�_cache_translation)r*rn�tas   rrk�Text.get_line_translation!s4���!�!�T�%7�%7�6�%A��*�*�6�6��&�&�&rc��U(aUup4OUR5up4XlURRX1URUR5UlgrD)r5r%r.r?r@rx)r*rnryr:�_attrs     rrw�Text._update_cache_translation4sK��181��K�D�%��-�-�/�K�D�#��"&�+�+�"4�"4�T�4�CS�CS�UY�Ud�Ud�"e��rc���UR5up4U(alUun[URS5(dXPRX54$UR	XSU45nURRXV5nU[
U54$U(a\[U[5(aUR[55nURS5n[SU55[
U54$g)u�182Return the number of screen columns and rows required for183this Text widget to be displayed without wrapping or184clipping, as a single element tuple.185 186:param size: ``None`` or ``()`` for unlimited screen columns (like FIXED sizing)187             or (*maxcol*,) to specify a maximum column size188:type size: widget size189:param focus: widget is focused on190:type focus: bool191 192>>> Text("important things").pack()193(16, 1)194>>> Text("important things").pack((15,))195(9, 2)196>>> Text("important things").pack((8,))197(8, 2)198>>> Text("important things").pack(())199(16, 1)200>>> not_common_separated_text = "Line feed\nLine Separator\u2028Paragraph Separator\u2029"201>>> # 
 (Line Separator) and 
 (Paragraph Separator) are not splitted by StandardTextLayout202>>> not_common_separated = Text(not_common_separated_text)203 204>>> not_common_separated.pack()205(33, 2)206>>> not_common_separated_canv = not_common_separated.render(())207>>> not_common_separated_canv.cols()20833209>>> not_common_separated_canv.rows()2102211rj�212c3�N# �UHn[US[U55v� M g7f)rN)rr7)�.0�lines  r�	<genexpr>�Text.pack.<locals>.<genexpr>vs ���J�z�t�J�t�Q��D�	�2�2�z�s�#%)rr213)
r5�hasattrr.rtrkrjr7�214isinstance�bytes�decoder	�split�max)	r*rlrir:rmrnrp�cols�215split_texts	         rrj�	Text.pack@s���H�]�]�_�216����I�V��4�;�;��/�/��y�y��5�5�5��-�-�f�T�l�C�E��;�;�#�#�F�2�D��#�e�*�%�%���$��&�&��{�{�<�>�2�����D�)�J��J�z�J�J��J���
�r)r?rIr%rxr'rHr@)217r+�=str | tuple[Hashable, str] | list[str | tuple[Hashable, str]]r,�*Literal['left', 'center', 'right'] | Alignr-�6Literal['space', 'any', 'clip', 'ellipsis'] | WrapModer.�text_layout.TextLayout | None�return�None)r�z	list[str])r�zdict[str, typing.Any])r�r�)r+r�r�r�)r�z.tuple[str | bytes, list[tuple[Hashable, int]]])r�zstr | bytes)r�zlist[tuple[Hashable, int]])rYr�r�r�)rYr�r�r�rD)r,r�r-r�r.r�r�r�)F)rlztuple[int] | tuple[()]ri�boolr�r)rlz218tuple[int]rir�r��int)rnr�ry�5tuple[str | bytes, list[tuple[Hashable, int]]] | Noner�zAlist[list[tuple[int, int, int | bytes] | tuple[int, int | None]]])rnr�ryr�r�r�)NF)rlztuple[()] | tuple[int] | Nonerir�r�ztuple[int, int])&rrrr�__doc__�	frozensetr�FLOW�FIXED�_sizing�ignore_focusr8r�LEFTr
�SPACEr$r4r>rEr(r5�propertyr:rSrZr^r)r,r-r.rqrtrkrwrjr�
__classcell__)r/s@rrrs���������f�l�l�3�4�G��L�"��219=B�J�J�GO�~�~�04�*-�M�*-�:�*-�E�	*-�220.�*-�221�
*-�*-�X�5���((�(�"��"��"��"��4�@15�	!�9�!�E�!�.�	!�222223�!�6
�2�N�C�E��0�-�@�D�
�����<�$�<��<�224�	<�46�"EI�'��'�
B�'�225K�	'�&226f��227f�
B�228f�229�	230f�/3��9�+�9��9�231�	9�9rr)�232__future__r�typing�urwidr�urwid.canvasr�urwid.split_reprr�urwid.str_utilr�233urwid.utilrr	�	constantsrrr
�widgetrr�
TYPE_CHECKING�collections.abcr�typing_extensionsrrrrrrr�<module>r�sO��"�
��*�,�%�8�.�.�'�	���(�)�'�	��	�_�6�_r
codekingpro/portable-devtools · Team Ai