Sindbad~EG File Manager
�
&Μg����dZddlmZddlmZddlmZd�Zd�Zd�Z d�Z
Gd �d
e�Zd�Ze
dk(r dd
lmZeddd��ddlmZee�yy)z�Search dialog for Find, Find Again, and Find Selection
functionality.
Inherits from SearchDialogBase for GUI and uses searchengine
to prepare search pattern.
�)�TclError)�searchengine)�SearchDialogBasec��|j�}tj|�}t|d�st ||�|_|j
S)z�Return the new or existing singleton SearchDialog instance.
The singleton dialog saves user entries and preferences
across instances.
Args:
text: Text widget containing the text to be searched.
�
_searchdialog)�_rootr�get�hasattr�SearchDialogr)�text�root�engines �+/usr/local/lib/python3.12/idlelib/search.py�_setuprsD���:�:�<�D�
�
�
�d�
#�F��6�?�+�+�D�&�9�������c�\�|jdd�}t|�j||�S)a
Open the search dialog.
Module-level function to access the singleton SearchDialog
instance and open the dialog. If text is selected, it is
used as the search phrase; otherwise, the previous entry
is used. No search is done with this command.
� sel.first�sel.last)r r�open)r�pats r�findrs+���(�(�;�
�
+�C��$�<���T�3�'�'rc�6�t|�j|�S)aSRepeat the search for the last pattern and preferences.
Module-level function to access the singleton SearchDialog
instance to search again using the user entries and preferences
from the last dialog. If there was no prior search, open the
search dialog; otherwise, perform the search without showing the
dialog.
)r�
find_again�rs rrr&s���$�<�"�"�4�(�(rc�6�t|�j|�S)a�Search for the selected pattern in the text.
Module-level function to access the singleton SearchDialog
instance to search using the selected text. With a text
selection, perform the search without displaying the dialog.
Without a selection, use the prior entry as the search phrase
and don't display the dialog. If there has been no prior
search, open the search dialog.
)r�find_selectionrs rrr1s���$�<�&�&�t�,�,rc�*�eZdZdZd�Zdd�Zd�Zd�Zy)rz%Dialog for finding a pattern in text.c�j�tj|�|jd|jd��y)z=Create the base search dialog and add a button for Find Next.z Find NextT)�isdefN)r�create_widgets�make_button�default_command)�selfs rr zSearchDialog.create_widgetsAs+���'�'��-�����d�&:�&:�$��GrNc�p�|jj�sy|j|j�y)z3Handle the Find Next button as the default command.N)r�getprogrr)r#�events rr"zSearchDialog.default_commandGs%���{�{�"�"�$������ � �"rc��|jj�s|j|�y|jj�sy|jj |�}|r�|\}}|j�\}}d||fz}d||fz} |j
d�} |j
d�}
| |k(r|
|k(r|j�y|jddd�|jd||�|jd|jj�xr|xs|�|jd�y |j�y#t$rY��wxYw)
a2Repeat the last search.
If no search was previously run, open a new search dialog. In
this case, no search is done.
If a search was previously run, the search dialog won't be
shown and the options from the previous search (including the
search pattern) will be used to find the next occurrence
of the pattern. Next is relative based on direction.
Position the window to display the located occurrence in the
text.
Return True if the search was successful and False otherwise.
Fz%d.%drr�sel�1.0�end�insertT)r�getpatrr%�search_text�span�index�bellr�
tag_remove�tag_add�mark_set�isback�see)r#r�res�line�m�i�j�first�last�selfirst�sellasts rrzSearchDialog.find_againMs1�� �{�{�!�!�#��I�I�d�O���{�{�"�"�$���k�k�%�%�d�+����G�D�!��6�6�8�D�A�q��t�Q�i�'�E��d�A�Y�&�D�
��:�:�k�2���*�*�Z�0���u�$��D���I�I�K� �
�O�O�E�5�%�0��L�L���t�,��M�M�(�D�K�K�$6�$6�$8�$B�U�$J�d�K��H�H�X����I�I�K����
��
�s�<E� E�Ec��|jdd�}|r|jj|�|j|�S)a/Search for selected text with previous dialog preferences.
Instead of using the same pattern for searching (as Find
Again does), this first resets the pattern to the currently
selected text. If the selected text isn't changed, then use
the prior search phrase.
rr)r r�setcookedpatr)r#rrs rrzSearchDialog.find_selectionys8���h�h�{�J�/����K�K�$�$�S�)����t�$�$r)N)�__name__�
__module__�__qualname__�__doc__r r"rr�rrrr>s��+�H�#�*�X%rrc���ddlm}m}ddlm}m}||�}|j
d�tt|j�jd�dd�\}}|jd||d zfz�||�}|j�||d
����j��jdd
��fd�} ||d| ��}
|
j�y)zDisplay search test box.r)�Toplevel�Text)�Frame�ButtonzTest SearchDialog�+�Nz+%d+%d��gray)�inactiveselectbackgroundr+z}This is a sample string.
This is a sample string.
This is a sample string.
This is a sample string.
This is a sample string.
c����jddd�t��j���jddd�y)Nr(r)r*)r2rrr1rs�r� show_findz!_search_dialog.<locals>.show_find�s5������U�E�5�)��t����$������u�e�,rzSearch (selection ignored))r�command)
�tkinterrGrH�tkinter.ttkrIrJ�title�map�int�geometry�split�packr+)�parentrGrHrIrJ�top�x�y�framerQ�buttonrs @r�_search_dialogra�s����&�)�
�6�
�C��I�I�!�"��s�F�O�O�%�+�+�C�0���4�5�D�A�q��L�L��Q��C��L�(�)��#�J�E� �J�J�L����7�D��I�I�K��K�K��7�8�-�
�E� <�i�
P�F�
�K�K�Mr�__main__)�mainzidlelib.idle_test.test_search�F)� verbosity�exit)�runN)rDrSr�idlelibr�idlelib.searchbaserrrrrrrarA�unittestrc�idlelib.idle_test.htestrgrErr�<module>rlsh���� �/�
� (� )�
-�F%�#�F%�R�2�z���� (�A�E�B�+����r
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists