Hacked By AnonymousFox

Current Path : /proc/thread-self/root/proc/self/root/opt/alt/python35/lib64/python3.5/idlelib/__pycache__/
Upload File :
Current File : //proc/thread-self/root/proc/self/root/opt/alt/python35/lib64/python3.5/idlelib/__pycache__/ReplaceDialog.cpython-35.pyc



��Yf9�@s�dZddlTddlmZddlmZddlZdd�ZGdd	�d	e�Zd
d�Z	e
dkr�ddlZejd
dddd�ddl
mZee	�dS)z�Replace dialog for IDLE. Inherits SearchDialogBase for GUI.
Uses idlelib.SearchEngine for search capability.
Defines various replace related functions like replace, replace all,
replace+find.
�)�*)�SearchEngine)�SearchDialogBaseNcCsV|j�}tj|�}t|d�s<t||�|_|j}|j|�dS)zvReturns a singleton ReplaceDialog instance.The single dialog
     saves user entries and preferences across instances.�_replacedialogN)Z_rootr�get�hasattr�
ReplaceDialogr�open)�text�root�engineZdialog�r
�:/opt/alt/python35/lib64/python3.5/idlelib/ReplaceDialog.py�replace
s	rc@s�eZdZdZdZdd�Zdd�Zdd�Zd	d
�Zddd
�Z	ddd�Z
ddd�Zdd�Zddd�Z
ddd�Zdd�Zdd�Zddd�ZdS)rzReplace Dialog�ReplacecCs&tj|||�t|�|_dS)N)r�__init__Z	StringVar�replvar)�selfrrr
r
rrszReplaceDialog.__init__cCs�tj||�y|jd�}Wntk
r=d}YnXy|jd�}Wntk
rkd}YnX|p~|jd�}|p�|}|j||�d|_dS)zDisplay the replace dialogz	sel.firstNzsel.last�insert�)rr	�index�TclError�show_hit�ok)rr
�first�lastr
r
rr	!s

zReplaceDialog.opencCs-tj|�|jd|j�d|_dS)z#Create label and text entry widgetsz
Replace with:rN)r�create_entriesZ
make_entryrZreplent)rr
r
rr1s
zReplaceDialog.create_entriescCs`tj|�|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)rr
r
rr6s

z$ReplaceDialog.create_command_buttonsNcCs|jd�dS)Nr)�do_find)r�eventr
r
rr=szReplaceDialog.find_itcCs |j|j�r|j�dS)N)r"r�
do_replace)rr#r
r
rr@szReplaceDialog.replace_itcCs/|j|j�r+|j�r+|jd�dS)zReplace and find next.rN)r"rr$)rr#r
r
rr DszReplaceDialog.default_commandcCs`|jj�rVy|j|�}Wq\tjk
rR|jj|d�d}Yq\Xn|}|S)za Helper function for expanding a regular expression
            in the replace field, if needed. zInvalid Replace ExpressionN)rZisre�expand�re�errorZreport_error)r�m�repl�newr
r
r�_replace_expandKszReplaceDialog._replace_expandcCs0|jj�}|sdS|jj�}|j}|jj||�}|sZ|j�dS|jddd�|jddd�|d}|dj�}|jj	�r�d}d}d}d}	}
|j
�x*|jj||||d|�}|s�P|\}}|jd|d|d�}|j�}
|j
||�}|dkrOP|j�\}}d	||f}	d	||f}
||
kr�|jd
|
�nB|jd
|	�|	|
kr�|j|	|
�|r�|j|	|�|t|�}d}q�W|j�|	r"|
r"|j|	|
�|j�dS)z4Replace all instances of patvar with replvar in textN�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�jr
r
rr!YsZ	



!

zReplaceDialog.replace_allrc
Cs�|jj�sdS|j}|jj|d|�}|sH|j�dS|\}}|j�\}}d||f}d||f}	|j||	�d|_dS)NFz%d.%drT)rr/r
r0r1r6rr)
rrr
r=r>r(rArBrrr
r
rr"�s	
	zReplaceDialog.do_findc
Csv|jj�}|sdS|j}y&|jd�}}|jd�}Wntk
rbd}YnX|s�|jd�}}}tj|�\}}|jd|d|d�}|j||�}	|s�dS|j	|	|j
j��}
|
dkr�dS|jd|�|j�|	j
�r0|j||�|
rF|j||
�|j�|j||jd��d|_dS)	NFz	sel.firstzsel.lastrz%d.0rrT)rr/r
rrrZget_line_colr�matchr+rr7r4r5r8rr:rr)rr<r
r�posrr>r?r@r(r*r
r
rr$�s:	


	zReplaceDialog.do_replacecCs�|j}|jd|�|jddd�|jd||�|jddd�||krq|jd|�n|jd||�|jd�|j�dS)zMHighlight text from 'first' to 'last'.
        'first', 'last' - Text indicesrr,z1.0r-r.N)r
r7r2�tag_addZseeZupdate_idletasks)rrrr
r
r
rr�s	
zReplaceDialog.show_hitcCs*tj||�|jjddd�dS)Nr.z1.0r-)rr;r
r2)rr#r
r
rr;�szReplaceDialog.close)�__name__�
__module__�__qualname__�titleZiconrr	rrrrr r+r!r"r$rr;r
r
r
rrs2rc
s�t|�}|jd�ttttjd|j����\}}}}|jd||df�dd�}dd�}t|d	d
��|�_	|�_
�j��jdd��j
��fd
d�}t|ddd|�}	|	j�dS)zhtest wrapper functionzTest ReplaceDialogz[x+]z+%d+%d�cSsdS)Nr
r
r
r
rr4�sz)_replace_dialog.<locals>.undo_block_startcSsdS)Nr
r
r
r
rr:�sz(_replace_dialog.<locals>.undo_block_stopZinactiveselectbackgroundZgrayrz"This is a sample sTring
Plus MORE.cs4�jtdt�t���jtdt�dS)Nz1.0)rEZSELZENDrr2r
)r
r
r�show_replace�s
z%_replace_dialog.<locals>.show_replacer
rZcommandN)ZToplevelrI�list�map�intr&�splitZgeometryZTextr4r:ZpackrZ	focus_setZButton)
�parentZbox�widthZheight�x�yr4r:rKZbuttonr
)r
r�_replace_dialog�s
3		

rT�__main__z$idlelib.idle_test.test_replacedialog�	verbosity��exitF)�run)�__doc__ZtkinterZidlelibrZidlelib.SearchDialogBaserr&rrrTrFZunittest�mainZidlelib.idle_test.htestrYr
r
r
r�<module>s
�


Hacked By AnonymousFox1.0, Coded By AnonymousFox