HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.10/idlelib/__pycache__/replace.cpython-310.opt-2.pyc
o

�i'�@s�	ddlZddlmZmZddlmZddlmZddd�ZGdd�de�Z	d	d
�Z
edkrGddlm
Z
e
d
ddd�ddlmZee
�dSdS)�N)�	StringVar�TclError)�SearchDialogBase)�searchenginecCsB	|��}t�|�}t|d�st||�|_|j}|j||d�dS)N�_replacedialog)�insert_tags)�_rootr�get�hasattr�
ReplaceDialogr�open)�textr�root�engineZdialog�r�,/usr/local/lib/python3.10/idlelib/replace.py�replaces

rcs�eZdZ	dZdZ�fdd�Zddd�Zdd	�Zd
d�Zddd
�Z	ddd�Z
ddd�Zdd�Zddd�Z
d dd�Zdd�Zdd�Zddd�Z�ZS)!rzReplace Dialog�Replacecs$	t��||�t|�|_d|_dS�N)�super�__init__r�replvarr)�selfrr��	__class__rrr%s

zReplaceDialog.__init__NcCs�	t�||�z|�d�}Wntyd}Ynwz|�d�}Wnty,d}Ynw|p3|�d�}|p7|}|�||�d|_||_dS)N�	sel.first�sel.last�insertT)rr�indexr�show_hit�okr)rr
r�first�lastrrrr6s"��
zReplaceDialog.opencCs$	t�|�|�d|j�d|_dS)Nz
Replace with:r)r�create_entriesZ
make_entryrZreplent�rrrrr#Ns
zReplaceDialog.create_entriescCsL	t�|�|�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%Ss
z$ReplaceDialog.create_command_buttonscCs	|�d�dS�NF)�do_find�r�eventrrrr&_szReplaceDialog.find_itcCs	|�|j�r
|��dSdSr�r+r �
do_replacer,rrrr'cs�zReplaceDialog.replace_itcCs,	|�|j�r|��r|�d�dSdSdSr*r.r,rrrr(ks�zReplaceDialog.default_commandcCsN	|j��r#z|�|�}W|Stjy"|j�|d�d}Y|Sw|}|S)NzInvalid Replace Expression)rZisre�expand�re�errorZreport_error)r�m�repl�newrrr�_replace_expandvs
��zReplaceDialog._replace_expandcCs�	|j��}|s
dS|j��}|j}|j�||�}|s!|��dS|�ddd�|�ddd�|d}|d��}|j�	�rBd}d}d}d}	}
|�
�|jj||||d|d	�}r�|\}}|�d
|d
|d�}|��}
|�
||�}|durynM|��\}}d||f}	d||f}
||
kr�|�d|
�n|�d|	�|	|
kr�|�|	|
�|r�|�|	||j�|t|�}d}|jj||||d|d	�}sZ|��|	r�|
r�|�|	|
�|��dS)
N�sel�1.0�end�hitr�TF)�wrapr �%d.0�%d.%dr)r�getprogrr	r
�search_text�bell�
tag_remove�startZiswrap�undo_block_startZsearch_forward�groupr6�span�mark_set�deleterr�len�undo_block_stopr�close)rr-�progr4r
�res�line�colr r!r"r3�charsZorigr5�i�jrrrr)�s`
	


��
�zReplaceDialog.replace_allFc
Csx	|j��sdS|j}|j�|d|�}|s|��dS|\}}|��\}}d||f}d||f}	|�||	�d|_dS)NFr>T)rr?r
r@rArFrr )
rr r
rMrNr3rQrRr!r"rrrr+�s
zReplaceDialog.do_findcCs	|j��}|s
dS|j}z|�d�}}|�d�}Wnty&d}Ynw|s2|�d�}}}t�|�\}}|�d|d|d�}|�||�}	|sOdS|�	|	|j
���}
|
dur^dS|�d|�|��|	�
�rr|�||�|
r||�||
|j�|��|�||�d��d|_dS)NFrrrr=r;T)rr?r
rrrZget_line_colr	�matchr6rrGrDrErHrrrJrr )rrLr
r!�posr"rNrOrPr3r5rrrr/�s>
�zReplaceDialog.do_replacecCsx	|j}|�d|�|�ddd�|�d||�|�ddd�||kr*|�d|�n|�d||�|�d�|��dS)Nrr7r8r9r:)r
rGrB�tag_addZseeZupdate_idletasks)rr!r"r
rrrr�s

zReplaceDialog.show_hitcCs(	t�||�|j�ddd�d|_dS)Nr:r8r9)rrKr
rBrr,rrrrKs
zReplaceDialog.closer)F)�__name__�
__module__�__qualname__�titleZiconrrr#r%r&r'r(r6r)r+r/rrK�
__classcell__rrrrrs"





8 rc
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�cS�dSrrrrrrrD�z)_replace_dialog.<locals>.undo_block_startcSrcrrrrrrrJrdz(_replace_dialog.<locals>.undo_block_stopZgray)Zinactiveselectbackgroundrz"This is a sample sTring
Plus MORE.cs(���d��t�����d��dS)Nr8)rUrrBr�r]r^r
rr�show_replace&sz%_replace_dialog.<locals>.show_replacer)r
Zcommand)�tkinterr[r\r]r^Ztkinter.ttkr_r`rY�map�intZgeometry�split�packrDrJrZ	focus_set)
�parentr[r\r_r`�top�x�yrDrJ�framerfZbuttonrrer�_replace_dialog
s&
 rq�__main__)�mainzidlelib.idle_test.test_replace�F)�	verbosity�exit)�runr)r1rgrrZidlelib.searchbaserZidlelibrrrrqrVZunittestrsZidlelib.idle_test.htestrwrrrr�<module>s
o!�