Team Ai
Datasetpublic

codekingpro/portable-devtools

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

2��j���$�SrSSKrSSKrSSKJr \R3"S5r\R4"S5r\R5"S5r\R6"S5r	\R7"S	5r8\R9"S105r\R11"S5r\R12"\RRSS
S5S-\13RRSSS5-S-\RRSSS5-S-\	RRSSS5-S-S-S-S-\R-S-5r\R14"SR!SS555rS\S\R&\R(\\44SjrS\S\4Sjrg)aA15Terminal escape sequence patterns.16 17This module provides regex patterns for matching terminal escape sequences. All patterns match18sequences that begin with ESC (``\x1b``). Before calling re.match with these patterns, callers19should first check that the character at the current position is ESC for optimal performance.20�N�)�_SGR_PATTERNz4\x1b\]66;([^;\x07\x1b]*);([^\x07\x1b]*)(\x07|\x1b\\)a\x1b\[[\x30-\x3f]*[\x20-\x2f]*[\x40-\x7e]|\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)|\x1b_[^\x1b\x07]*(?:\x07|\x1b\\)|\x1bP[^\x1b\x07]*(?:\x07|\x1b\\)|\x1b\^[^\x1b\x07]*(?:\x07|\x1b\\)|\x1b[()].|\x1b[\x20-\x2f]+[\x30-\x7e]|\x1b[\x40-\x5f]|\x1b[\x30-\x3f]|\x1b[\x60-\x7e]z\x1b\[(\d*)Cz\x1b\[(\d*)Dz\x1b\[(\d*)Gz\x1b\[(\d*)[CDG]z[\x08\r]|\x1b\[(\d*)[CDG]�(z(?P<sgr_params>�|z21(?P<hpa_n>z(?P<cforward_n>z(?P<cbackward_n>zU\x1b\]66;(?P<ts_meta>[^;\x07\x1b]*);(?P<ts_text>[^\x07\x1b]*)(?P<ts_term>\x07|\x1b\\)z(?P<other_seq>(?:z))c#�.# �UHnSUS3v� M
 g7f)z(?:�)N�)�.0�_patterns  �^D:\code\apps\devtools\python\user_packages\Python313\site-packages\wcwidth/escape_sequences.py�	<genexpr>r
Ws!���
�0�8�s�8�*�A�
�0�s�)z\x1b\[\d+;\d+rz22\x1b\[\d*Kz23\x1b\[\d*Jz\x1b\[\d+;\d+Hz24\x1b\[\d*Hz25\x1b\[\d*Az26\x1b\[\d*Bz27\x1b\[\d*Pz28\x1b\[\d*Mz29\x1b\[\d*Lz30\x1b\[\d*@z31\x1b\[\d+Xz32\x1b\[\d*Sz33\x1b\[\d*Tz34\x1b\[\d*dz\x1b\[\?1049[hl]z\x1b\[\?47[hl]z\x1b8z\x1bDz\x1bMz\x1bc�text�returnc#�4# �Sn[U5nSnX:arXnUS:Xa\X:�aXUS4v� [RX5nU(a%UR5S4v� UR	5nOUS4v� US-
nUnOUS-
nX:aMrX2:a	XSS4v� gg7f)ap35Iterate through text, yielding segments with sequence identification.36 37This generator yields tuples of ``(segment, is_sequence)`` for each part38of the input text, where ``is_sequence`` is ``True`` if the segment is39a recognized terminal escape sequence.40 41:param text: String to iterate through.42:returns: Iterator of (segment, is_sequence) tuples.43 44.. versionadded:: 0.3.045 46Example::47 48    >>> list(iter_sequences('hello'))49    [('hello', False)]50    >>> list(iter_sequences('\x1b[31mred'))51    [('\x1b[31m', True), ('red', False)]52    >>> list(iter_sequences('\x1b[1m\x1b[31m'))53    [('\x1b[1m', True), ('\x1b[31m', True)]54r�FTrN)�len�ZERO_WIDTH_PATTERN�match�group�end)r�idx�text_len�
segment_start�charrs      r�iter_sequencesrqs����,�C��4�y�H��M�55
�.��y���6�>��"��#�.��6�6�'�,�,�T�7�E���{�{�}�d�+�+��i�i�k���T�l�"��q����M��1�H�C�'�.�,���N�#�U�+�+� �s�BB�	Bc�f�SU;a[RSU5n[RSU5$)a�56Return text with all terminal escape sequences removed.57 58Unknown or incomplete ESC sequences are preserved.59 60:param text: String that may contain terminal escape sequences.61:returns: The input text with all escape sequences stripped.62 63.. versionadded:: 0.3.064 65.. versionchanged:: 0.7.066   Inner text of OSC 66 (Text sizing protocol) is preserved.67 68Example::69 70    >>> strip_sequences('\x1b[31mred\x1b[0m')71    'red'72    >>> strip_sequences('hello')73    'hello'74    >>> strip_sequences('\x1b[1m\x1b[31mbold red\x1b[0m text')75    'bold red text'76    >>> strip_sequences('\x1b]66;s=2;hello\x07')77    'hello'78    >>> strip_sequences('\x1b]8;id=34;https://example.com\x1b\\[view]\x1b]8;;\x1b\\')79    '[view]'80z]66;z\2�)�TEXT_SIZING_PATTERN�subr)rs r�strip_sequencesr �s1��6�T��"�&�&�u�d�3���!�!�"�d�+�+�)�__doc__�re�typing�	sgr_stater�compilerr�CURSOR_RIGHT_SEQUENCE�CURSOR_LEFT_SEQUENCE�CURSOR_HPA_SEQUENCE�CURSOR_MOVEMENT_SEQUENCE�_HORIZONTAL_CURSOR_MOVEMENT�pattern�replace�_SEQUENCE_CLASSIFY�join�INDETERMINATE_EFFECT_SEQUENCE�str�Iterator�Tuple�boolrr r	r!r�<module>r5s����81�
�$��j�j�;����Z�Z����2�82�83�?�3���z�z�/�2���j�j��1��84�:�:�&9�:��85!�j�j�)E�F��86�Z�Z���� � ��&7��;�	�87��'�'�/�/��\�1�E�F�	�88�!�)�)�1�1�#�7H�!�L�M�89�90�
!�(�(�0�0��6H�!�L�M�91�	92�
e�	e�9394�95�96
!�!�97$6�#=�#=�>�98AE�E��� !#�99�100��H�H�
�0�
��!��61,��1,�������c�4�i�1H�!I�1,�h,�#�,�#�,r!
codekingpro/portable-devtools · Team Ai