Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
_width.cpython-313.pyc115 linesDownload Raw Back to __pycache__
1�

2��j�9���SrSSKJr SSKJr SSKJr SSKJr SSKJ	r	J3r4JrJrJ
r
 SSKJr SS	KJrJr SS5KJrJrJrJr SSKJr SSKJrJrJrJrJr S
r \!RESSSRGS\$"SS555S-SRGS\$"SS555-5r%S!S\!S\&S\&4Sjjr'SSSS.S\!S\SS\&S\&S\&46Sjjr(g )"z8This is a high-level width() supporting terminal output.�)�Literal���wcwidth)�bisearch)�wcswidth)�_EMOJI_ZWJ_SET�_ISC_VIRAMA_SET�_CATEGORY_MC_TABLE�_FITZPATRICK_RANGE�_REGIONAL_INDICATOR_SET)�VS16_NARROW_TO_WIDE)�7TextSizing�TextSizingParams)�ILLEGAL_CTRL�
VERTICAL_CTRL�HORIZONTAL_CTRL�ZERO_WIDTH_CTRL)�
ISC_CONSONANT)�_SEQUENCE_CLASSIFY�TEXT_SIZING_PATTERN�CURSOR_MOVEMENT_SEQUENCE�INDETERMINATE_EFFECT_SEQUENCE�strip_sequences��c#�8# �UHn[U5v� M g7f�N��chr��.0�cs  �TD:\code\apps\devtools\python\user_packages\Python313\site-packages\wcwidth/_width.py�	<genexpr>r% ����.�-�q�C��F�F�-���� �c#�8# �UHn[U5v� M g7frrr!s  r$r%r%"r&r'���text�ambiguous_width�returnc�N�[[U5R[5US9$)z�8Fast path for width() with control_codes='ignore'.9 10Strips escape sequences and control characters, then measures remaining text.11)r.)rr�	translate�_CONTROL_CHAR_TABLE)r-r.s  r$�_width_ignored_codesr3&s(������'�'�(;�<�'����parse�)�
control_codes�tabsizer.r7)r5�strict�ignorer8c	�^�UR5(a UR5(a[U5$US:Xac[U5[:�aPSU;aJSU;aDSU;a>SU;d6[R12"U5(d[R13"U5(dSnUS:Xa[UT5$US:HnSnSnSn[U5nTS	:Xa[OU4S14jn	Sn15SnS
nS
n
Xx:Ga�XnUS:XGa�[R"X5nU(dUS	-
nGO�UR5nU(a-[R"U5(a[SUSU<35eURS5=nb4U(a[U5OS	nU(a[SUSU<S35eUS	-16nO�URS5=nbUU(a[U5OS	-
nO�URS5=nbFU(a[U5OS	nU(aUU:�a[SUSUSUS35e[SUU-175nOrURS5=nb^URS5nURS5nUbUce[!["R$"UUS9UU5nUUR'T5-
nUR)5nSn18Sn[Xe5nGM�U[*;a.U(a[S[-U5SSU35eUS	-
nSn19SnGMU[.;a.U(a[S [-U5SSU35eUS	-
nSn20SnGMKU[0;a]US:XaUS:�a21XRXR--22-
nO0US:XaUS:�aUS	-nOUS:XaU(a[S!US"35eSn[Xe5nUS	-
nSn23SnGM�U[2;aUS	-
nSn24SnGM�[-U5nUS#:Xa(U(aUS	-
nOUS	-U:aS
nUS$-
nOS
nUS	-
nGMUS%:XaCU25S:�a=[5[-X265[6S&5(aUS	-
n[Xe5nSn27US	-
nGMJUS':�a�U[8;a_SnUS	-28nUS:�a>[-UU5[8;a(US	-
nUS	-nUS:�a[-UU5[8;aM(US$-S	:Xa29UnUS	-
nGM�O0[:SUs=::a
[:S	::aO OU[<;aUS	-
nGM�U(a%[5U[>5(aUn30UnS
nS(n
US	-
nGMU	"U5nUS:�a%U
(aUS	-
nS
n
UU-
n[Xe5nUn31UnS
nO;U32S:�a,[5U[@5(aUS	-
n[Xe5nSn33S
nS
n
O	U[B;nUS	-
nXx:aGM�U
(aUS	-
n[Xe5nU$))u�34Return printable width of text containing many kinds of control codes and sequences.35 36Unlike :func:`wcswidth`, this function handles most control characters and many popular terminal37output sequences.  Never returns -1.38 39:param text: String to measure.40:param control_codes: How to handle control characters and sequences:41 42    - ``'parse'`` (default): Track horizontal cursor movement like BS ``\b``, CR ``\r``, TAB43      ``\t``, cursor left and right movement sequences.  Vertical movement (LF, VT, FF) and44      indeterminate terminal sequences are zero-width. OSC 66 Kitty Text Sizing protocol, OSC 845      Hyperlink, and many other kinds of output sequences are parsed for displayed measurements.46    - ``'strict'``: Like parse, but raises :exc:`ValueError` on control characters with47      indeterminate results of the screen or cursor, like clear or vertical movement. Generally,48      these should be handled with a virtual terminal emulator (like 'pyte').49    - ``'ignore'``: All C0 and C1 control characters and escape sequences are measured as50      width 0. This is the fastest measurement for text already filtered or known not to contain51      any kinds of control codes or sequences. TAB ``\t`` is zero-width; to ensure52      tab expansion, pre-process text using :func:`str.expandtabs`.53 54:param tabsize: Tab stop width for ``'parse'`` and ``'strict'`` modes. Default is 8.55    Must be positive. Has no effect when ``control_codes='ignore'``.56:param ambiguous_width: Width to use for East Asian Ambiguous (A)57    characters. Default is ``1`` (narrow). Set to ``2`` for CJK contexts.58:returns: Maximum cursor position reached, "extent", accounting for cursor movement sequences59    present in ``text`` according to given parameters.  This represents the rightmost column the60    cursor reaches.  Always a non-negative integer.61 62:raises ValueError: If ``control_codes='strict'`` and control characters with indeterminate63    effects, such as vertical movement or clear sequences are encountered, or on unexpected64    C0 or C1 control code. Also raised when ``control_codes`` is not one of the valid values.65 66.. versionadded:: 0.3.067 68.. versionchanged:: 0.7.069   Expanded strict-mode to raise :exc:`ValueError` when cursor-left movement70   (CSI D) would move beyond the beginning of the string. Previously, cursor-left71   was silently clamped to column 0 in all modes.72 73   Support horizontal cursor sequences (``cub``, ``cuf``, ``hpa``). Cursor-left (``cub``) or74   backspace (``\b``) now overwrites text.  ``column_address`` (``hpa``) and carriage return75   (``\r``) are now parsed, and some values conditionally raise ``ValueError`` when76   ``control_codes='parse'``.77 78Examples::79 80    >>> width('hello')81    582    >>> width('コンニチハ')83    1084    >>> width('\x1b[31mred\x1b[0m')85    386    >>> width('\x1b[31mred\x1b[0m', control_codes='ignore')  # same result (ignored)87    388    >>> width('123\b4')     # backspace overwrites previous cell (outputs '124')89    390    >>> width('abc\t')      # tab caused cursor to move to column 891    892    >>> width('1\x1b[10C')  # '1' + cursor right 10, cursor ends on column 1193    1194    >>> width('1\x1b[10C', control_codes='ignore')   # faster but wrong in this case95    196r5��	�
�r:r9rrc�>�[UST5$)N�autor)r#r.s �r$�<lambda>�width.<locals>.<lambda>�s���g�a��Q`�>ar4����������Fz*Indeterminate cursor sequence at position z, �hpa_nz.Indeterminate horizontal position at position z (absolute column unknown)�97cforward_n�cbackward_nz!Cursor left movement at position z would move z cells left from column z, exceeding string start�ts_meta�ts_text�ts_term)r7zIllegal control character z#xz
 at position zVertical movement character z-Horizontal movement character \r at position z: indeterminate starting columni
 �i�z9.0.0i��T)"�isascii�isprintable�len�_WIDTH_FAST_PATH_MIN_LENr�searchrr3rr�match�groupr�98ValueError�int�maxrr�from_params�
display_width�endr�ordrrrrrr
rr	rrr99)r-r7r8r.r9�current_col�100max_extent�idx�text_len�_wcwidth�last_measured_idx�last_measured_ucs�last_was_virama�conjunct_pending�char�m�seqrF�101target_colrGrH�102n_backwardrIrJrK�	text_size�ucs�	ri_before�j�ws   `                          r$�widthrn2s_���Z�|�|�~�~�$�*�*�,�,��4�y�����C��I�0H�$H��t���D� 0�T��5E��T�!�,�3�3�D�9�9�+�2�2�4�8�8� (�
��� �#�D�/�:�:�
�h�
&�F��K��J�103�C��4�y�H�104*�Q�.�w�4a�H������O���105
�.��y���6�>�"�(�(��3�A���q����g�g�i���;�A�A�#�F�F�$�'Q�RU�QV�VX�Y\�X_�%`�a�a��W�W�W�-�-�E�:�/4��U��!�J��(�L�S�E�QS�"�g�%?�A���#-�q�.�K�$%�G�G�L�$9�9�j�F��j�3�z�?�a�G�K�%&�W�W�]�%;�;�k�H�5@��[�!1�a�J��*�{�":�(�?��u�L�)�l�*B�;�-�P5�6���106#&�a��z�)A�"B�K�!"����!3�3�g�@��g�g�i�0�G��g�g�i�0�G�"�.�7�3F�F�F� *�(�4�4�W�M�Z���!*�I� �9�#:�#:�?�#K�K�K��e�e�g�� "�� "���Z�5�J���<��� �#=�c�$�i��^�=�Y\�X]�!^�_�_��1�H�C� "�� "����=� �� �#?��D�	�"�~�]�[^�Z_�!`�a�a��1�H�C� "�� "����?�"��t�|��!���+�*?�@�@�������?��1�$�K������$�H���N8�8��� ���Z�5�J��1�H�C� "�� "����?�"��1�H�C� "�� "����$�i���&�=���q����q��8�#�"'���q���"'���q�����&�=�.�!�3���D�3�4�6I�'�6R�S�S��q� �� ��9�107� "���1�H�C����<��-�-��	��!�G���1�f��T�!�W��1H�!H���N�I���F�A��1�f��T�!�W��1H�!H��q�=�A�%�(+�%��1�H�C��&�%�Q�'�3�G�2D�Q�2G�G�'�>�9��q�����x��]�;�;� #�� #��#�O�#���1�H�C��
�T�N���q�5���q� ��#(� ��1��K��Z�5�J� #�� #��#�O�
�!�
#���6H�(I�(I��1��K��Z�5�J� "��#�O�$��!�_�4�O��q���Q�.�T��q�����1�108��r4N)r))�__doc__�typingrr_rr�	_wcswidthr�109_constantsr	r110rrr
�111table_vs16r�text_sizingrrr7rrrr�table_graphemer�escape_sequencesrrrrrrP�str�	maketrans�join�ranger2rUr3rn�r4r$�<module>r|s���>�����2�2�112,�5�X�X�)�0�0����m�m�B���G�G�.�E�$��-�.�.�113���G�G�.�E�$��-�.�.�/���	�s�	�S�	��	�;B���a�114
�a��6�7�a��	a�115�a�	�
ar4
codekingpro/portable-devtools · Team Ai