Uname: Linux web3.us.cloudlogin.co 5.10.226-xeon-hst #2 SMP Fri Sep 13 12:28:44 UTC 2024 x86_64
Software: Apache
PHP version: 8.1.31 [ PHP INFO ] PHP os: Linux
Server Ip: 162.210.96.117
Your Ip: 3.140.253.240
User: edustar (269686) | Group: tty (888)
Safe Mode: OFF
Disable Function:
NONE

name : replace.cpython-311.pyc
�

Tfq&����dZddlZeje_ddlmZmZddlmZddl	m
Z
dd�ZGd�de��Zd	�Z
ed
kr'ddlmZedd
d���ddlmZee
��dSdS)z�Replace dialog for IDLE. Inherits SearchDialogBase for GUI.
Uses idlelib.searchengine.SearchEngine for search capability.
Defines various replace related functions like replace, replace all,
and replace+find.
�N)�	StringVar�TclError)�SearchDialogBase)�searchenginec�
�|���}tj|��}t|d��st	||��|_|j}|�dd��}|�|||���dS)z�Create or reuse a singleton ReplaceDialog instance.

    The singleton dialog saves user entries and preferences
    across instances.

    Args:
        text: Text widget containing the text to be searched.
    �_replacedialog�	sel.first�sel.last��insert_tagsN)�_rootr�get�hasattr�
ReplaceDialogr�open)�textr�root�engine�dialog�searchphrases      �8/usr/local/python-3.11/lib/python3.11/idlelib/replace.py�replacers���:�:�<�<�D�
�
�d�
#�
#�F��6�+�,�,�<� -�d�F� ;� ;���
�
"�F��8�8�K��4�4�L�
�K�K��l��K�<�<�<�<�<�c���eZdZdZdZdZ�fd�Zddd�d�Zd�Zd	�Z	dd
�Z
dd�Zdd�Zd
�Z
dd�Zdd�Zd�Zd�Zdd�Z�xZS)rz3Dialog for finding and replacing a pattern in text.zReplace Dialog�Replacec���t���||��t|��|_d|_dS)a�Create search dialog for finding and replacing text.

        Uses SearchDialogBase as the basis for the GUI and a
        searchengine instance to prepare the search.

        Attributes:
            replvar: StringVar containing 'Replace with:' value.
            replent: Entry widget for replvar.  Created in
                create_entries().
            ok: Boolean used in searchengine.search_text to indicate
                whether the search includes the selection.
        N)�super�__init__r�replvarr)�selfrr�	__class__s   �rrzReplaceDialog.__init__'s:���	������v�&�&�&� ����������rNrc�N�tj|||��d|_||_dS)aMake dialog visible on top of others and ready to use.

        Also, set the search to include the current selection
        (self.ok).

        Args:
            text: Text widget being searched.
            searchphrase: String phrase to search.
        TN)rr�okr)r rrrs    rrzReplaceDialog.open8s.��	��d�D�,�7�7�7����&����rc�z�tj|��|�d|j��d|_dS)z8Create base and additional label and text entry widgets.z
Replace with:rN)r�create_entries�
make_entryr�replent�r s rr%zReplaceDialog.create_entriesFs3���'��-�-�-�������E�E�a�H����rc�
�tj|��|�d|j��|�d|j��|�d|jd���|�d|j��dS)z�Create base and additional command buttons.

        The additional buttons are for Find, Replace,
        Replace+Find, and Replace All.
        �FindrzReplace+FindT)�isdefzReplace AllN)r�create_command_buttons�make_button�find_it�
replace_it�default_command�replace_allr(s rr,z$ReplaceDialog.create_command_buttonsKs���	�/��5�5�5�������.�.�.�����D�O�4�4�4������)=�T��J�J�J������(8�9�9�9�9�9rc�0�|�d��dS)zHandle the Find button.FN)�do_find�r �events  rr.zReplaceDialog.find_itWs�����U�����rc�f�|�|j��r|���dSdS)z]Handle the Replace button.

        If the find is successful, then perform replace.
        N�r3r#�
do_replacer4s  rr/zReplaceDialog.replace_it[s:��
�<�<��� � �	��O�O������	�	rc��|�|j��r+|���r|�d��dSdSdS)z�Handle the Replace+Find button as the default command.

        First performs a replace and then, if the replace was
        successful, a find next.
        FNr7r4s  rr0zReplaceDialog.default_commandcsX���<�<��� � �	$���� � �
$����U�#�#�#�#�#�	$�	$�
$�
$rc���|j���rI	|�|��}n4#tj$r |j�|d��d}YnwxYw|}|S)z.Expand replacement text if regular expression.zInvalid Replace ExpressionN)r�isre�expand�re�PatternError�report_error)r �m�repl�news    r�_replace_expandzReplaceDialog._replace_expandnsy���;�����	�
��h�h�t�n�n�����?�
�
�
���(�(��/K�L�L�L�����
�����C��
s�1�,A �A c���|j���}|sdS|j���}|j}|j�||��}|s|���dS|�ddd��|�ddd��|d}|d���}|j�	��rd}d}d}dx}	}
|�
��|j�||||d	|�
��x}�r|\}}|�d|zd|dzz��}|���}
|�
||��}|�n�|���\}}d||fz}	d||fz}
||
kr|�d
|
��nP|�d
|	��|	|
kr|�|	|
��|r|�|	||j��|t'|��z}d	}|j�||||d	|�
��x}��|���|	r|
r|�|	|
��|���dS)a�Handle the Replace All button.

        Search text for occurrences of the Find value and replace
        each of them.  The 'wrap around' value controls the start
        point for searching.  If wrap isn't set, then the searching
        starts at the first occurrence after the current selection;
        if wrap is set, the replacement starts at the first line.
        The replacement is always done top-to-bottom in the text.
        N�sel�1.0�end�hitr�TF)�wrapr#�%d.0�%d.%d�insert)r�getprogrrr�search_text�bell�
tag_remove�start�iswrap�undo_block_start�search_forward�grouprC�span�mark_set�deleterMr�len�undo_block_stop�show_hit�close)r r5�progrAr�res�line�colr#�first�lastr@�chars�origrB�i�js                 rr1zReplaceDialog.replace_all{s����{�"�"�$�$���	��F��|���!�!���y���k�%�%�d�D�1�1���	��I�I�K�K�K��F�����u�e�,�,�,�����u�e�,�,�,��1�v���!�f�l�l�n�n���;�����	��D��C�
�������������[�/�/��d�D�#�E�b�0�:�:�:�c�	��G�D�!��H�H�V�d�]�F�d�1�f�,=�>�>�E��7�7�9�9�D��&�&�q�$�/�/�C��{���6�6�8�8�D�A�q��t�Q�i�'�E��d�A�Y�&�D��d�{�{��
�
�h��-�-�-�-��
�
�h��.�.�.��D�=�=��K�K��t�,�,�,��>��K�K��s�D�,<�=�=�=��c�#�h�h�,�C��B�)�[�/�/��d�D�#�E�b�0�:�:�:�c�	�*	
�������	'�T�	'��M�M�%��&�&�&��
�
�����rFc�@�|j���sdS|j}|j�|d|��}|s|���dS|\}}|���\}}d||fz}d||fz}	|�||	��d|_dS)z|Search for and highlight next occurrence of pattern in text.

        No text replacement is done with this option.
        FNrLT)rrNrrOrPrWr\r#)
r r#rr_r`r@rfrgrbrcs
          rr3zReplaceDialog.do_find�s���
�{�"�"�$�$�	��5��y���k�%�%�d�D�"�5�5���	��I�I�K�K�K��5����a��v�v�x�x���1��4��)�#���$���"���
�
�e�T�"�"�"�����trc�r�|j���}|sdS|j}	|�d��x}}|�d��}n#t$rd}YnwxYw|s|�d��x}x}}tj|��\}}|�d|zd|dzz��}|�||��}	|sdS|�	|	|j
�����}
|
�dS|�d|��|���|	�
��r|�||��|
r|�||
|j��|���|�||�d����d|_dS)	z6Replace search pattern in text with replacement value.Fr	r
NrMrKrIT)rrNr�indexrr�get_line_colr�matchrCrrXrTrVrYrMrr[r\r#)r r^rrb�posrcr`rardr@rBs           rr8zReplaceDialog.do_replace�s����{�"�"�$�$���	��5��y��	��*�*�[�1�1�1�E�C��:�:�j�)�)�D�D���	�	�	��C�C�C�	�����	6�!%���H�!5�!5�5�E�5�D�3� �-�c�2�2�	��c�����$���$�q�&�(9�:�:���J�J�u�c�"�"���	��5��"�"�1�d�l�&6�&6�&8�&8�9�9���;��5��
�
�h��&�&�&��������7�7�9�9�	%��K�K��t�$�$�$��	6��K�K��s�D�$4�5�5�5��������
�
�e�T�Z�Z��1�1�2�2�2�����ts�,A�A"�!A"c��|j}|�d|��|�ddd��|�d||��|�ddd��||kr|�d|��n|�d||��|�d��|���dS)a�Highlight text between first and last indices.

        Text is highlighted via the 'hit' tag and the marked
        section is brought into view.

        The colors from the 'hit' tag aren't currently shown
        when the text is displayed.  This is due to the 'sel'
        tag being added first, so the colors in the 'sel'
        config are seen instead of the colors for 'hit'.
        rMrErFrGrHN)rrXrQ�tag_add�see�update_idletasks)r rbrcrs    rr\zReplaceDialog.show_hit�s����y���
�
�h��&�&�&�����u�e�,�,�,����U�E�4�(�(�(�����u�e�,�,�,��D�=�=��L�L���&�&�&�&��L�L���t�,�,�,���������������rc�v�tj||��|j�ddd��d|_dS)z%Close the dialog and remove hit tags.rHrFrGN)rr]rrQrr4s  rr]zReplaceDialog.close�s=����t�U�+�+�+��	���U�E�5�1�1�1�����r�N)F)�__name__�
__module__�__qualname__�__doc__�title�iconrrr%r,r.r/r0rCr1r3r8r\r]�
__classcell__)r!s@rrr!s0�������9�9��E��D� � � � � �"'�4�'�'�'�'�'�I�I�I�

:�
:�
:���������	$�	$�	$�	$����6�6�6�6�p����(���@ � � �. � � � � � � � rrc��
���ddlm}m}m�
m�ddlm}m}||��}|�d��tt|����d��dd���\}}|�d||dzfz��d	�}d
�}	||��}
|
�
��||
d����|�_|	�_��
����d
d�������
��fd�}||
d|���}|�
��dS)Nr)�Toplevel�Text�END�SEL)�Frame�ButtonzTest ReplaceDialog�+rIz+%d+%d�c��dSrs�r�rrrTz)_replace_dialog.<locals>.undo_block_start����rc��dSrsr�r�rrr[z(_replace_dialog.<locals>.undo_block_stopr�r�gray)�inactiveselectbackgroundrMz"This is a sample sTring
Plus MORE.c������d���t������d���dS)NrF)rorrQ)r~rrs���r�show_replacez%_replace_dialog.<locals>.show_replaces@������S�%��%�%�%���
�
�
�����U�C�(�(�(�(�(rr)r�command)�tkinterr|r}r~r�tkinter.ttkr�r�rx�map�int�geometry�split�packrTr[rM�	focus_set)�parentr|r}r�r��top�x�yrTr[�framer��buttonr~rrs             @@@r�_replace_dialogr�s������0�0�0�0�0�0�0�0�0�0�0�0�)�)�)�)�)�)�)�)�
�(�6�
�
�C��I�I�"�#�#�#��s�F�O�O�%�%�+�+�C�0�0����4�5�5�D�A�q��L�L��Q��C��L�(�)�)�)�
�
�
�
�
�
�
�E�#�J�J�E�	�J�J�L�L�L��4���7�7�7�D�,�D��*�D���I�I�K�K�K��K�K��>�?�?�?��N�N����)�)�)�)�)�)�)�
�V�E�	�<�
@�
@�
@�F�
�K�K�M�M�M�M�Mr�__main__)�mainzidlelib.idle_test.test_replace�F)�	verbosity�exit)�runrs)rwr=�errorr>r�rr�idlelib.searchbaser�idlelibrrrr�rt�unittestr��idlelib.idle_test.htestr�r�rr�<module>r�s����

�	�	�	��(���'�'�'�'�'�'�'�'�/�/�/�/�/�/� � � � � � �=�=�=�=�$a �a �a �a �a �$�a �a �a �H���D�z����������D�	)�Q�U�C�C�C�C�+�+�+�+�+�+��C��������r
© 2025 GrazzMean