Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.9/idlelib/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.9/idlelib/__pycache__/replace.cpython-39.opt-2.pyc

a

��gG&�@s�ddlZddlmZmZddlmZddlmZdd�ZGdd�de�Z	d	d
�Z
edkr�ddlm
Z
e
d
ddd�ddlmZee
�dS)�N)�	StringVar�TclError)�SearchDialogBase)�searchenginecCs<|��}t�|�}t|d�s(t||�|_|j}|�|�dS)N�_replacedialog)�_rootr�get�hasattr�
ReplaceDialogr�open)�text�root�engineZdialog�r�+/usr/local/lib/python3.9/idlelib/replace.py�replaces	

rcs�eZdZdZdZ�fdd�Zdd�Zdd�Zd	d
�Zddd
�Z	d dd�Z
d!dd�Zdd�Zd"dd�Z
d#dd�Zdd�Zdd�Zd$dd�Z�ZS)%r
zReplace Dialog�Replacecst��||�t|�|_dS�N)�super�__init__r�replvar)�selfr
r��	__class__rrr%s
zReplaceDialog.__init__cCs�t�||�z|�d�}Wnty0d}Yn0z|�d�}WntyVd}Yn0|pd|�d�}|pl|}|�||�d|_dS)N�	sel.first�sel.last�insertT)rr�indexr�show_hit�ok)rr�first�lastrrrr5s	

zReplaceDialog.opencCs"t�|�|�d|j�d|_dS)Nz
Replace with:r)r�create_entriesZ
make_entryrZreplent�rrrrr"Ls
zReplaceDialog.create_entriescCsJt�|�|�d|j�|�d|j�|jd|jdd�|�d|j�dS)NZFindrzReplace+FindT)ZisdefzReplace All)r�create_command_buttonsZmake_button�find_it�
replace_it�default_command�replace_allr#rrrr$Qs

z$ReplaceDialog.create_command_buttonsNcCs|�d�dS�NF)�do_find�r�eventrrrr%]szReplaceDialog.find_itcCs|�|j�r|��dSr�r*r�
do_replacer+rrrr&aszReplaceDialog.replace_itcCs"|�|j�r|��r|�d�dSr)r-r+rrrr'iszReplaceDialog.default_commandcCsJ|j��rBz|�|�}WqFtjy>|j�|d�d}YqF0n|}|S)NzInvalid Replace Expression)rZisre�expand�re�errorZreport_error)r�m�repl�newrrr�_replace_expandts
zReplaceDialog._replace_expandcCs�|j��}|sdS|j��}|j}|j�||�}|s@|��dS|�ddd�|�ddd�|d}|d��}|j�	�r�d}d}d}d}	}
|�
�|jj||||d|d	�}�rv|\}}|�d
|d
|d�}|��}
|�
||�}|dur�qv|��\}}d||f}	d||f}
||
k�r0|�d|
�n4|�d|	�|	|
k�rR|�|	|
�|�rd|�|	|�|t|�}d}q�|��|	�r�|
�r�|�|	|
�|��dS)
N�sel�1.0�end�hitr�TF)�wrapr�%d.0�%d.%dr)r�getprogrrr�search_text�bell�
tag_remove�startZiswrap�undo_block_startZsearch_forward�groupr5�span�mark_set�deleter�len�undo_block_stopr�close)rr,�progr3r�res�line�colrr r!r2�charsZorigr4�i�jrrrr(�sX



�

zReplaceDialog.replace_allFc
Csv|j��sdS|j}|j�|d|�}|s4|��dS|\}}|��\}}d||f}d||f}	|�||	�d|_dS)NFr=T)rr>rr?r@rErr)
rrrrLrMr2rPrQr r!rrrr*�s
zReplaceDialog.do_findcCs|j��}|sdS|j}z|�d�}}|�d�}WntyJd}Yn0|sb|�d�}}}t�|�\}}|�d|d|d�}|�||�}	|s�dS|�	|	|j
���}
|
dur�dS|�d|�|��|	�
�r�|�||�|
r�|�||
�|��|�||�d��d|_dS)NFrrrr<r:T)rr>rrrrZget_line_colr�matchr5rrFrCrDrGrrIrr)rrKrr �posr!rMrNrOr2r4rrrr.�s:

zReplaceDialog.do_replacecCsv|j}|�d|�|�ddd�|�d||�|�ddd�||krR|�d|�n|�d||�|�d�|��dS)Nrr6r7r8r9)rrFrA�tag_addZseeZupdate_idletasks)rr r!rrrrr�s
zReplaceDialog.show_hitcCs t�||�|j�ddd�dS)Nr9r7r8)rrJrrAr+rrrrJszReplaceDialog.close)N)N)N)N)F)N)�__name__�
__module__�__qualname__�titleZiconrrr"r$r%r&r'r5r(r*r.rrJ�
__classcell__rrrrr
s



8
 r
c
s�ddlm}m}m�m�ddlm}m}||�}|�d�t	t
|���d�dd��\}}|�d||df�d	d
�}dd�}	||�}
|
�
�||
d
d��|�_|	�_��
���dd�������fdd�}||
d|d�}|�
�dS)Nr)�Toplevel�Text�END�SEL)�Frame�ButtonzTest ReplaceDialog�+r:z+%d+%d�cSsdSrrrrrrrCsz)_replace_dialog.<locals>.undo_block_startcSsdSrrrrrrrIsz(_replace_dialog.<locals>.undo_block_stopZgray)Zinactiveselectbackgroundrz"This is a sample sTring
Plus MORE.cs(���d��t�����d��dS)Nr7)rTrrAr�r\r]rrr�show_replace#sz%_replace_dialog.<locals>.show_replacer)rZcommand)�tkinterrZr[r\r]Ztkinter.ttkr^r_rX�map�intZgeometry�split�packrCrIrZ	focus_set)
�parentrZr[r^r_�top�x�yrCrI�framercZbuttonrrbr�_replace_dialog
s&
 rn�__main__)�mainzidlelib.idle_test.test_replace�F)�	verbosity�exit)�run)r0rdrrZidlelib.searchbaserZidlelibrrr
rnrUZunittestrpZidlelib.idle_test.htestrtrrrr�<module>sl!

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