Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.12/idlelib/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.12/idlelib/__pycache__/colorizer.cpython-312.pyc

�

%Μg�9���ddlZddlZddlZddlZddlmZddlmZdZd�Z	d�Z
e
�Zejd�Z
ddddd	�Zd
�Zd�ZGd�d
e�Zd�Zedk(r ddlmZeddd��ddlmZee�yy)�N)�idleConf)�	DelegatorFc�6�d|zdj|�zdzS)z9Return a named group pattern matching list of alternates.z(?P<%s>�|�))�join)�name�
alternatess  �./usr/local/lib/python3.12/idlelib/colorizer.py�anyrs ���t��c�h�h�z�2�2�S�8�8�c��dtdtj�zdz}ddjdddjtj�zdzg�zdz}d	}d
djddddjtj�zdzg�zdz}t	t
�D�cgc]0}|j
d�s|tjvrt|���2}}d
td|�zdz}tddg�}d}|dz}	|dz}
|dz}|dz}td|||	|
g�}
tjdj|||
||||tddg�g�tjtjz�}|Scc}w)Nz\b�KEYWORDz,^[ \t]*(?P<MATCH_SOFTKW>match)\b(?![ \t]*(?:rz[:,;=^&|@~)\]}]z\b(?:z)\bz))zB^[ \t]*(?P<CASE_SOFTKW>case)[ \t]+(?P<CASE_DEFAULT_UNDERSCORE>_\b)z+^[ \t]*(?P<CASE_SOFTKW2>case)\b(?![ \t]*(?:z_\b�_z([^.'\"\\#]\b|^)�BUILTIN�COMMENTz#[^\n]*z(?i:r|u|f|fr|rf|b|br|rb)?z'[^'\\\n]*(\\.[^'\\\n]*)*'?z"[^"\\\n]*(\\.[^"\\\n]*)*"?z''''[^'\\]*((\\.|'(?!''))[^'\\]*)*(''')?z'"""[^"\\]*((\\.|"(?!""))[^"\\]*)*(""")?�STRING�SYNCz\n)r�keyword�kwlistr�dir�builtins�
startswith�str�re�compile�DOTALL�	MULTILINE)�kw�match_softkw�case_default�case_softkw_and_patternr	�builtinlist�builtin�comment�stringprefix�sqstring�dqstring�	sq3string�	dq3string�string�progs               r�make_patr-s���	��Y����/�	/�%�	7�B�	��(�(���t�y�y����0�0�6�9�$
��	�	�	��	2��	��(�(����t�y�y����0�0�6�9�	$
��	�	�	��*-�X��/����/�/�#�.��w�~�~�-��t�9��K�/�"�C�	�;�$?�?�%�G�G��)�j�\�*�G�/�L��<�<�H��<�<�H��I�I�I��I�I�I�
��I�y�(�H�E�
F�F�
�:�:�c�h�h� '��&�"� ,�l� 7� #�F�U�G� 4�	 !�"��i�i�"�,�,�.�
0�D��K��%/s�-5Fz\s+(\w+)r)�MATCH_SOFTKW�CASE_SOFTKW�CASE_DEFAULT_UNDERSCORE�CASE_SOFTKW2c�L�d�|j�j�D�S)z<Get only the non-empty named groups from an re.Match object.c3�0K�|]\}}|s�	||f���y�w�N�)�.0�k�vs   r�	<genexpr>z'matched_named_groups.<locals>.<genexpr>Ns����C�!=�v��1��Q��F�!=�s�
�	)�	groupdict�items)�re_matchs r�matched_named_groupsr=Ls��C��!3�!3�!5�!;�!;�!=�C�Cr
c	��tj�}tj|d�}tj|d�d}tj|d�}|j|d|d||d|d|d��y)zcSet color options of Text widget.

    If ColorDelegator is used, this should be called first.
    �normal�cursor�
foreground�hilite�
background)rArC�insertbackground�selectforeground�selectbackground�inactiveselectbackgroundN)r�CurrentTheme�GetHighlight�config)�text�theme�
normal_colors�cursor_color�
select_colorss     r�color_configrPQs���
�!�!�#�E��)�)�%��:�M��(�(���9�,�G�L��)�)�%��:�M��K�K� ��.� ��.�%�&�|�4�&�|�4�!.�|�!<�
�
r
c�r�eZdZdZd�Zd�Zd�Zd�Zd�Zdd�Z	dd	�Z
dd
�Zd�Zdd�Z
d
�Zd�Zd�Zd�Zd�Zy)�ColorDelegatora-Delegator for syntax highlighting (text coloring).

    Instance variables:
        delegate: Delegator below this one in the stack, meaning the
                one this one delegates to.

        Used to track state:
        after_id: Identifier for scheduled after event, which is a
                timer for colorizing the text.
        allow_colorizing: Boolean toggle for applying colorizing.
        colorizing: Boolean flag when colorizing is in process.
        stop_colorizing: Boolean flag to end an active colorizing
                process.
    c��tj|�|j�t|_t|_|j�yr4)r�__init__�
init_stater,�idprog�LoadTagDefs��selfs rrTzColorDelegator.__init__vs4�����4� �������	�������r
c�<�d|_d|_d|_d|_y)z1Initialize variables that track colorizing state.NTF)�after_id�allow_colorizing�stop_colorizing�
colorizingrXs rrUzColorDelegator.init_state}s ����
� $���$�����r
c��|j�|jd�tj||�|�?|j	�|jd|j�|jdd�yd|_d|_	y)a�Set the delegate for this instance.

        A delegate is an instance of a Delegator class and each
        delegate points to the next delegator in the stack.  This
        allows multiple delegators to be chained together for a
        widget.  The bottom delegate for a colorizer is a Text
        widget.

        If there is a delegate, also start the colorizing process.
        Nz<<toggle-auto-coloring>>�1.0�endTF)
�delegate�unbindr�setdelegate�
config_colors�bind�toggle_colorize_event�notify_ranger]r\)rYrbs  rrdzColorDelegator.setdelegate�st���=�=�$��K�K�2�3����d�H�-������ ��I�I�0�$�2L�2L�M����e�U�+�$(�D� �$)�D�!r
c��|jj�D]\}}|j|fi|���|jd�y)z4Configure text widget tags with colors from tagdefs.�selN)�tagdefsr;�
tag_configure�	tag_raise)rY�tag�cnfs   rrezColorDelegator.config_colors�s>�����*�*�,�H�C���D���s�*�c�*�-����u�r
c��tj�}tj|d�tj|d�tj|d�tj|d�tj|d�ddd�ddd�tj|d�tj|d	�d
�	|_trtd|j�yy)z.Create dictionary of tag names to text colors.r%rr$r+�
definitionN)rCrA�error�hit)	rrrr�
DEFINITIONr�TODO�ERRORrsrk)rrHrIrk�DEBUG�print)rYrLs  rrWzColorDelegator.LoadTagDefs�s����%�%�'���,�,�U�I�>��,�,�U�I�>��,�,�U�I�>��+�+�E�8�<�"�/�/��|�D�#'�t�<�#'�t�<��*�*�5�'�:�
�(�(���6�����%�	�4�<�<�0�5r
Nc��|j|�}|jj|||�|j||dt	|�zz�y)z:Insert chars into widget at index and mark for colorizing.z+%dcN)�indexrb�insertrh�len)rYrz�chars�tagss    rr{zColorDelegator.insert�sD���
�
�5�!���
�
���U�E�4�0����%���#�e�*�)<�!<�=r
c��|j|�}|jj||�|j|�y)z5Delete chars between indexes and mark for colorizing.N)rzrb�deleterh�rY�index1�index2s   rr�zColorDelegator.delete�s2�����F�#���
�
���V�V�,����&�!r
c�*�|jd||�|jrtrtd�y|jrd|_trtd�|jr2trtd�|jd|j�|_y)zCMark text changes for processing and restart colorizing, if active.ruzcolorizing already scheduledNT�stop colorizingzschedule colorizing�)	�tag_addr[rwrxr^r]r\�after�
recolorizer�s   rrhzColorDelegator.notify_range�sn�����V�V�V�,��=�=��e�:�;���?�?�#'�D� ��e�-�.�� � ��e�1�2� �J�J�q�$�/�/�:�D�M�r
c��|jr5|j}d|_trtd�|j|�d|_d|_y)N�cancel scheduled recolorizerFT)r[rwrx�after_cancelr\r])rYr[s  r�closezColorDelegator.close�sB���=�=��}�}�H� �D�M��e�:�;����h�'� %���#��r
c��|jr5|j}d|_trtd�|j|�|jr$|j
rtrtd�d|_|j|_|jr-|j
s!|jd|j�|_trtd|jrdnd�y	)
z�Toggle colorizing on and off.

        When toggling off, if colorizing is scheduled or is in
        process, it will be cancelled and/or stopped.

        When toggling on, colorizing will be scheduled.
        Nr�r�Tr�zauto colorizing turned�on�off�break)	r[rwrxr�r\r^r]r�r�)rY�eventr[s   rrgz$ColorDelegator.toggle_colorize_event�s����=�=��}�}�H� �D�M��e�:�;����h�'�� � �T�_�_��e�-�.�#'�D� �$(�$9�$9� 9���� � ���� �J�J�q�$�/�/�:�D�M���*��/�/�$�U�
<�r
c�n�d|_|jstrtd�y|jstrtd�y|j
rtrtd�y	d|_d|_trtd�tj�}|j�tj�}trtd||z
z�d|_|jrF|jd	d
�r3trtd�|jd|j�|_yyy#d|_wxYw)
aSTimer event (every 1ms) to colorize text.

        Colorizing is only attempted when the text widget exists,
        when colorizing is toggled on, and when the colorizing
        process is not already running.

        After colorizing is complete, some cleanup is done to
        make sure that all the text has been colorized.
        Nzno delegatezauto colorizing is offzalready colorizingFTz
colorizing...z%.3f secondsrur`zreschedule colorizingr�)
r[rbrwrxr\r^r]�time�perf_counter�recolorize_main�
tag_nextranger�r�)rY�t0�t1s   rr�zColorDelegator.recolorize�s�����
��}�}��e�M�*���$�$��e�4�5���?�?��e�0�1��		$�#(�D� �"�D�O��e�O�,��"�"�$�B�� � �"��"�"�$�B��e�N�b��e�4�5�#�D�O�� � �T�%7�%7���%F��e�3�4� �J�J�q�$�/�/�:�D�M�&G� ��$�D�O�s
�#A.D+�+	D4c���d}|jd|�x}�rH|jd|d|d�|jd|d�}|r|dnd}d}|}d}d}|s�|}|j|d|zz�}t	|d	zd
�}d|j|dz�v}|j
||�}	|	sy|jD]}
|j|
||��||	z
}|j||�d|j|dz�vr|}d}nd}|s|jd|�|j�|jrtrtd
�y|s��|jd|�x}r��Gyy)z(Evaluate text and apply colorizing tags.r`rurrr��Fz+%d lines linestart��dz-1cNzcolorizing stopped)r��
tag_remove�
tag_prevrangerz�min�	tag_names�getrk�_add_tags_in_sectionr��update_idletasksr]rwrx)rY�next�todo_tag_range�sync_tag_range�headr}�lines_to_get�ok�mark�linerns           rr�zColorDelegator.recolorize_mains����� $� 2� 2�6�4� @�@�n�@��O�O�F�N�1�$5�~�a�7H�I�!�/�/���q�8I�J�N�(6�>�!�$�E�D��E��D��L��B�����z�z�$�)>�)5�*6�#6�7��"�<�!�#3�S�9���t�~�~�d�U�l�;�;���x�x��d�+�����<�<�C��O�O�C��t�4�(���
���)�)�%��6��T�^�^�D�5�L�9�9��D��E��B���L�L���.��%�%�'��'�'��e�$8�9��=�!%� 2� 2�6�4� @�@�n�@r
c�r�tj||�}|j||�d|d�d�|�d|d�d��y)a�Add a tag to a given range in the text widget.

        This is a utility function, receiving the range as `start` and
        `end` positions, each of which is a number of characters
        relative to the given `head` index in the text widget.

        The tag to add is determined by `matched_group_name`, which is
        the name of a regular expression "named group" as matched by
        by the relevant highlighting regexps.
        �+�d�cN)�prog_group_name_to_tagr�r�)rY�startrar��matched_group_namerns      r�_add_tagzColorDelegator._add_tag>sL��%�(�(�);�);�=�����S��v�Q�u�Q�i�q�)��v�Q�s�1�g�Q�'�	)r
c�R�|jj|�D]�}t|�D]y\}}|j|�\}}|j	||||�|dvs�3|j
j
||�x}s�R|jd�\}}|j	|||d��{��y)z�Parse and add highlighting tags to a given part of the text.

        `chars` is a string with the text to parse and to which
        highlighting is to be applied.

            `head` is the index in the text widget where the text is found.
        )�def�classr�rtN)r,�finditerr=�spanr�rV�match)	rYr}r��mr	�matched_text�a�b�m1s	         rr�z#ColorDelegator._add_tags_in_sectionOs������#�#�E�*�A�&:�1�&=�"��l��v�v�d�|���1��
�
�a��D�$�/��#3�3�!�[�[�.�.�u�a�8�8�r�8�!�w�w�q�z���1��
�
�a��D�,�?�
'>�+r
c�L�|jD]}|j|dd��y)zRemove all colorizing tags.r`raN)rkr�)rYrns  r�removecolorszColorDelegator.removecolors`s ���<�<�C��O�O�C���.� r
r4)�__name__�
__module__�__qualname__�__doc__rTrUrdrerWr{r�rhr�rgr�r�r�r�r�r5r
rrRrRfsU��
�� �*�.�1�(>�"��$��0 ;�D*�X)�"@�"/r
rRc���ddlm}m}ddlm}ddlm}||�}|jd�tt|j�jd�dd�\}}|jd|d	z|d
zfz�||d��}|jdd
��|jd|�|j�t|�||�}	t!�}
|	j#|
�y)Nr)�Toplevel�Text)�source)�
PercolatorzTest ColorDelegatorr�r�z
700x550+%d+%d���white)rC�both)�expand�fillr{)�tkinterr�r�� idlelib.idle_test.test_colorizerr��idlelib.percolatorr��title�map�int�geometry�split�packr{�	focus_setrPrR�insertfilter)�parentr�r�r�r��top�x�yrK�pr�s           r�_color_delegatorr�fs���&�7�-�
�6�
�C��I�I�#�$��s�F�O�O�%�+�+�C�0���4�5�D�A�q��L�L��A��F�A��G�#4�4�5����(�D��I�I�Q�V�I�$��K�K��&�!��N�N������4��A���A��N�N�1�r
�__main__)�mainz idlelib.idle_test.test_colorizerr�)�	verbosity�exit)�run)rrrr��idlelib.configr�idlelib.delegatorrrwrr-r,rrVr�r=rPrRr�r��unittestr��idlelib.idle_test.htestr�r5r
r�<module>r�s�����	��#�'�
��9�
.�b�z��	����K�	 ����(��	��D�

�*}/�Y�}/�@�*�z����	+�q�u�E�+����r

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists