Team Ai
Datasetpublic

codekingpro/portable-devtools

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

2�j/0���%SSKJr SSKJr SSKJr SSKJrJrJ	r	J3r4 SSKJr
 \5\\\4r\"S5r/SQrS\S	'\"\VVVs/sH!up\"\\"XS6-55HnUPM M# snnn5r\R0rS\S'"S
S\5r\"SS9SSSjj5r\"S5SSSjj5rSSSjjrSSjrSSSjjrSSSjjr SSSjjr!SS Sjjr"SS!Sjjr#gs snnnf)"�)�annotations)�	lru_cache)�7itemgetter)�Callable�8NamedTuple�Sequence�Tuple)�load�))� �~)��)�i�)ipi�)i%i�%)i(i�(zlist[tuple[int, int]]�_SINGLE_CELL_UNICODE_RANGES�zCallable[[str], bool]�_is_single_cell_widthsc�8�\rSrSr%SrS\S'S\S'S\S'S	rg9)�	CellTable�&zDContains unicode data required to measure the cell widths of glyphs.�str�unicode_versionzSequence[tuple[int, int, int]]�widthszfrozenset[str]�narrow_to_wide�N)�__name__�10__module__�__qualname__�__firstlineno__�__doc__�__annotations__�__static_attributes__r��PD:\code\apps\devtools\python\user_packages\Python313\site-packages\rich/cells.pyrr&s��N���*�*�"�"r#ri)�maxsizec�"�[U5nU(aUS:dSUs=::aS:ag Og[U5RnUSnX$S:�agSn[U5S-11nXV::a-XV-S-	nX7up�n12X(:aUS-13nO
X):�aUS-nOU14$XV::aM-g)aGet the cell size of a character.15 16Args:17    character (str): A single character.18    unicode_version: Unicode version, `"auto"` to auto detect, `"latest"` for the latest unicode version.19 20Returns:21    int: Number of cells (0, 1 or 2) occupied by that character.22r�rr�����r)�ord�load_cell_tabler�len)�	characterr�	codepoint�table�23last_entry�lower_bound�upper_bound�index�start�end�widths           r$�get_character_cell_sizer6.s����I��I��Y��^�u�	�'A�E�'A��(B���O�,�3�3�E��r��J��a�=� ���K��e�*�q�.�K�24�25$��*�q�0��!�L���E����!�)�K�
�_��!�)�K��L��26$�
r#c��[X5$)a}Get the number of cells required to display text.27 28This method always caches, which may use up a lot of memory. It is recommended to use29`cell_len` over this method.30 31Args:32    text (str): Text to display.33    unicode_version: Unicode version, `"auto"` to auto detect, `"latest"` for the latest unicode version.34 35Returns:36    int: Get the number of cells required to display text.37)�	_cell_len��textrs  r$�cached_cell_lenr;Qs���T�+�+r#c�L�[U5S:a[X5$[X5$)�Get the cell length of a string (length as it appears in the terminal).38 39Args:40    text: String to measure.41    unicode_version: Unicode version, `"auto"` to auto detect, `"latest"` for the latest unicode version.42 43Returns:44    Length of string in terminal cells.45i)r+r;r8r9s  r$�cell_lenr>bs%���4�y�3���t�5�5��T�+�+r#c�t^�[U5(a[U5$SU;aSU;a[U4SjU55$[T5nSnSnSS1nSn[U5nXg:aUXnX�;a'US:XaUS-
nO4U(aX4UR;-
nSnO[UT5=n	(aUnX9-
nUS-
nXg:aMUU$)r=�‍�️c3�<># �UHn[UT5v� M g7f)N)r6)�.0r,rs  �r$�	<genexpr>�_cell_len.<locals>.<genexpr>�s ����46�QU�I�#�I��?�?�QU�s�rNr)rr+�sumr*rr6)47r:r�48cell_table�total_width�last_measured_character�SPECIALr2�character_countr,�character_widths49 `        r$r8r8qs�����d�#�#��4�y���t���� 4��50�QU�51�52�	53�!��1�J��K�*.����"�G�
�E��$�i�O�54�55!��K�	����H�$���56��(��*�:S�:S�S�S��*.�'��"9�)�_�"U�U��U�*3�'��.��
��57���58!��r#c�\�[U5n[U5nSnSnSn/nSS1nXC:GaX=o�;a�U(dURXDS-=nS45 M0U	S:XaXDUS-59:aSOS-
nUSup�nX�U4US'OFUS-
nU(a+USup�nXRR;aSnUS-
nUS-
nX�U4US'OUSup�nX�U4US'M�[	X�5=n
(aU	nURXDS-=oM45 Xm-
nO3U(aUSup�nX�S-=oL4US'OURXDS-=nS45 XC:aGMXv4$)a,Divide text into spans that define a single grapheme, and additionally return the cell length of the whole string.60 61The returned spans will cover every index in the string, with no gaps. It is possible for some graphemes to have a cell length of zero.62This can occur for nonsense strings like two zero width joiners, or for control codes that don't contribute to the grapheme size.63 64Args:65    text: String to split.66    unicode_version: Unicode version, `"auto"` to auto detect, `"latest"` for the latest unicode version.67 68Returns:69    A tuple of a list of *spans* and the cell length of the entire string. A span is a list of tuples70        of three values consisting of (<START>, <END>, <CELL LENGTH>), where START and END are string indices,71        and CELL LENGTH is the cell length of the single grapheme.72rNr@rArrr()r*r+�appendrr6)r:rrG�codepoint_countr2rIrH�spansrJr,r3�_end�cell_lengthrLs              r$�split_graphemesrS�s���$!��1�J��$�i�O�
�E�*.���K�(*�E���"�G�73�74!���$�I�0�����e�a�i�%7�U��;�<���H�$����':�;���B��+0��9�(��[�"�;�7��b�	���75��*�/4�R�y�,�E��.�2K�2K�K�26�/�#�q�(��#�q�(��!&�{� ;�E�"�I�7605�R�y�,�E��!&�{� ;�E�"�I��5�i�Q�Q�?�Q�&/�#��L�L�%�!�)�!3��E�F��*�K��+0��9�(��[�"�Q�Y�$6�E�D��b�	����e�a�i�%7�U��;�<�W�77!�Z
��r#c��US::aSU4$[X5up4[X-[U5-5n[[	[78USU55nXa:Xa#U[U5:�aUS4$X5SnUSUXS4$Xa:a(X5up�n79Xj-U:�aUSUS-SX	S-4$US-
nXj-
nO*X5S-80up�n81Xj-82U:aUSUS-SX	S-4$US-nXj-nM�)�PSplit text by cell position.83 84If the cell position falls within a double width character, it is converted to two spaces.85 86Args:87    text: Text to split.88    cell_position Offset in cells.89    unicode_version: Unicode version, `"auto"` to auto detect, `"latest"` for the latest unicode version.90 91Returns:92    Tuple to two split strings.93r�N� r)rS�intr+rF�map�_span_get_cell_len)r:�
cell_positionrrPrR�offset�	left_size�split_indexr3r4�	cell_sizes           r$�_split_textr`�s1������4�x��(��?��E��-�-��U��;�
<�F��C�*�E�'�6�N�;�<�I�94��%���U��#��R�x���-��*�K����%�t�L�'9�9�9��$�$)�M�!�E�	��$�}�4��F�U�|�c�)�3��d��+;�;�;��a�K�F��"�I�$)�1�*�$5�!�E�	��$�}�4��F�U�|�c�)�3��d��+;�;�;��a�K�F��"�I�#r#c�L�[U5(a	USUXS4$[XU5$)rUN)rr`)r:r[rs   r$�95split_textrbs3���d�#�#��N�]�#�T�.�%9�9�9��t�O�<�<r#c���[U5(a[U5nX1:a96USX-97--$USU$US::ag[U5nXA:XaU$XA:a98USX-99--$[XU5upU$)aAdjust a string by cropping or padding with spaces such that it fits within the given number of cells.100 101Args:102    text: String to adjust.103    total: Desired size in cells.104    unicode_version: Unicode version.105 106Returns:107    A string with cell size equal to total.108rWNrrV)rr+r>r`)r:�totalr�sizer_�_s      r$�
set_cell_sizerg+s����d�#�#��4�y���<��#���.�.�.��F�U�|����z�����I��������c�U�.�/�/�/��$��7�G�D��Kr#c�>�[U5(a+[S[U5U5Vs/sH	o0X3U-PM sn$[X5upESn/nSnUH)up�nXk-U:�aUR	XU	5 U	nSnXk-
nM+ U(aUR	XS5 U$s snf)aLSplit text into lines such that each line fits within the available (cell) width.109 110Args:111    text: The text to fold such that it fits in the given width.112    width: The width available (number of cells).113 114Returns:115    A list of strings such that each string in the list has cell width116    less than or equal to the available width.117rN)r�ranger+rSrN)r:r5rr2rPrf�	line_size�lines�line_offsetr3r4r_s            r$�118chop_cellsrmFs����d�#�#�9>�q�#�d�)�U�9S�T�9S��U�U�]�+�9S�T�T��t�5�H�E��I��E��K�!&���I�� �5�(��L�L��%�0�1��K��I���	�"'��
���T�,�'�(��L��Us�BN)�auto)r,rrr�returnrX)r:rrrrorX)r:rrrroz'tuple[list[CellSpan], int]')r:rr[rXrrroztuple[str, str])r:rrdrXrrror)r:rr5rXrrroz	list[str])$�119__future__r�	functoolsr�operatorr�typingrrrr	�rich._unicode_datar120r*rX�CellSpanrZrr!�	frozensetrY�chrri�
_SINGLE_CELLS�121issupersetrrr6r;r>r8rSr`rbrgrm)�_startrQr,s000r$�<module>r{st��"���8�8�6���c�3������]��6��2���8��7�L�F��S�%��q��"9�:�I�	�:�	�7���
�1>�0H�0H��-�H�#�122�#��4��
��
�D�4��
,��
,� ,�-�b'-�G �123
�G � #�G �!�G �V;A�)#�124
�)#�!�)#�47�)#��)#�Z;A�=�125
�=�!�=�47�=��=�(�6��Y	s�(C<
codekingpro/portable-devtools · Team Ai