Your IP : 18.190.253.224


Current Path : /opt/alt/python36/lib64/python3.6/idlelib/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib64/python3.6/idlelib/__pycache__/replace.cpython-36.opt-2.pyc

3

��2aN�@s�ddlZddlmZmZddlmZddlmZdd�ZGdd�de�Z	d	d
�Z
edkr�ddlm
Z
e
d
ddd�ddlmZee
�dS)�N)�	StringVar�TclError)�SearchDialogBase)�searchenginecCs<|j�}tj|�}t|d�s(t||�|_|j}|j|�dS)N�_replacedialog)Z_rootr�get�hasattr�
ReplaceDialogr�open)�text�root�engineZdialog�r�,/opt/alt/python36/lib64/python3.6/replace.py�replace
s

rc@s�eZdZdZdZdd�Zdd�Zdd�Zd	d
�Zddd
�Z	d dd�Z
d!dd�Zdd�Zd"dd�Z
d#dd�Zdd�Zdd�Zd$dd�ZdS)%r	zReplace Dialog�ReplacecCstj|||�t|�|_dS)N)r�__init__r�replvar)�selfrr
rrrrszReplaceDialog.__init__cCs�tj||�y|jd�}Wntk
r2d}YnXy|jd�}Wntk
rZd}YnX|ph|jd�}|pp|}|j||�d|_dS)Nz	sel.firstzsel.last�insert�)rr
�indexr�show_hit�ok)rr�first�lastrrrr
!s

zReplaceDialog.opencCs"tj|�|jd|j�d|_dS)Nz
Replace with:r)r�create_entriesZ
make_entryrZreplent)rrrrr1s
zReplaceDialog.create_entriescCsHtj|�|jd|j�|jd|j�|jd|jd�|jd|j�dS)NZFindrzReplace+FindrzReplace All)r�create_command_buttonsZmake_button�find_it�
replace_it�default_command�replace_all)rrrrr6s

z$ReplaceDialog.create_command_buttonsNcCs|jd�dS)Nr)�do_find)r�eventrrrr=szReplaceDialog.find_itcCs|j|j�r|j�dS)N)r"r�
do_replace)rr#rrrr@szReplaceDialog.replace_itcCs"|j|j�r|j�r|jd�dS)Nr)r"rr$)rr#rrrr DszReplaceDialog.default_commandcCsL|jj�rDy|j|�}WqHtjk
r@|jj|d�d}YqHXn|}|S)NzInvalid Replace Expression)r
Zisre�expand�re�errorZreport_error)r�m�repl�newrrr�_replace_expandKs
zReplaceDialog._replace_expandcCs�|jj�}|sdS|jj�}|j}|jj||�}|s@|j�dS|jddd�|jddd�|d}|dj�}|jj	�r�d}d}d}d}	}
|j
�x�|jj||||d|�}|s�P|\}}|jd|d|d�}|j�}
|j
||�}|dkr�P|j�\}}d||f}	d||f}
||
k�r.|jd	|
�n4|jd	|	�|	|
k�rP|j|	|
�|�rb|j|	|�|t|�}d}q�W|j�|	�r�|
�r�|j|	|
�|j�dS)
N�selz1.0�end�hitrrz%d.0z%d.%dr)r
�getprogrrr�search_text�bell�
tag_remove�startZiswrap�undo_block_startZsearch_forward�groupr+�span�mark_set�deleter�len�undo_block_stopr�close)rr#�progr)r�res�line�colrrrr(�charsZorigr*�i�jrrrr!YsZ




zReplaceDialog.replace_allrc
Csv|jj�sdS|j}|jj|d|�}|s4|j�dS|\}}|j�\}}d||f}d||f}	|j||	�d|_dS)NFz%d.%drT)r
r/rr0r1r6rr)
rrrr=r>r(rArBrrrrrr"�s
zReplaceDialog.do_findc
Cs|jj�}|sdS|j}y|jd�}}|jd�}Wntk
rLd}YnX|sd|jd�}}}tj|�\}}|jd|d|d�}|j||�}	|s�dS|j	|	|j
j��}
|
dkr�dS|jd|�|j�|	j
�r�|j||�|
r�|j||
�|j�|j||jd��d|_dS)	NFz	sel.firstzsel.lastrz%d.0rrT)r
r/rrrrZget_line_colr�matchr+rr7r4r5r8rr:rr)rr<rr�posrr>r?r@r(r*rrrr$�s:

zReplaceDialog.do_replacecCsv|j}|jd|�|jddd�|jd||�|jddd�||krR|jd|�n|jd||�|jd�|j�dS)Nrr,z1.0r-r.)rr7r2�tag_addZseeZupdate_idletasks)rrrrrrrr�s
zReplaceDialog.show_hitcCs tj||�|jjddd�dS)Nr.z1.0r-)rr;rr2)rr#rrrr;�szReplaceDialog.close)N)N)N)N)r)N)�__name__�
__module__�__qualname__�titleZiconrr
rrrrr r+r!r"r$rr;rrrrr	s



2
r	cs�ddlm}m}m�m�ddlm}||�}|jd�tt	|j
�jd�dd��\}}|j
d||df�d	d
�}dd�}||d
d��|�_|�_
�j��jdd��j����fdd�}	||d|	d�}
|
j�dS)Nr)�Toplevel�Text�END�SEL)�ButtonzTest ReplaceDialog�+rz+%d+%d�cSsdS)Nrrrrrr4�sz)_replace_dialog.<locals>.undo_block_startcSsdS)Nrrrrrr:�sz(_replace_dialog.<locals>.undo_block_stopZgray)Zinactiveselectbackgroundrz"This is a sample sTring
Plus MORE.cs(�j�d��t���j�d��dS)Nz1.0)rErr2r)rLrMrrr�show_replace�sz%_replace_dialog.<locals>.show_replacer)rZcommand)�tkinterrJrKrLrMZtkinter.ttkrNrI�map�intZgeometry�splitr4r:�packrZ	focus_set)�parentrJrKrNZbox�x�yr4r:rQZbuttonr)rLrMrr�_replace_dialog�s"
 rZ�__main__)�mainzidlelib.idle_test.test_replace�F)�	verbosity�exit)�run)r&rRrrZidlelib.searchbaserZidlelibrrr	rZrFZunittestr\Zidlelib.idle_test.htestr`rrrr�<module>s7

?>