python (3.11.7)

(root)/
lib/
python3.11/
idlelib/
__pycache__/
replace.cpython-311.opt-1.pyc

e'dZddlZddlmZmZddlmZddlmZddZ	GddeZ
d	Zed
kr'ddl
mZedd
dddlmZeedSdS)zReplace dialog for IDLE. Inherits SearchDialogBase for GUI.
Uses idlelib.searchengine.SearchEngine for search capability.
Defines various replace related functions like replace, replace all,
and replace+find.
N)	StringVarTclError)SearchDialogBase)searchenginec|}tj|}t|dst	|||_|j}|||dS)zCreate or reuse a singleton ReplaceDialog instance.

    The singleton dialog saves user entries and preferences
    across instances.

    Args:
        text: Text widget containing the text to be searched.
    _replacedialog)insert_tagsN)_rootrgethasattr
ReplaceDialogropen)textr	rootenginedialogs     C/BuggyBox/python/3.11.7/bootstrap/lib/python3.11/idlelib/replace.pyreplacersj::<<D

d
#
#F6+,,< -dF ; ;

"F
KK+K.....ceZdZdZdZdZfdZddZdZdZ	dd	Z
dd
ZddZdZ
dd
ZddZdZdZddZxZS)r
z3Dialog for finding and replacing a pattern in text.zReplace DialogReplacect||t||_d|_dS)aCreate search dialog for finding and replacing text.

        Uses SearchDialogBase as the basis for the GUI and a
        searchengine instance to prepare the search.

        Attributes:
            replvar: StringVar containing 'Replace with:' value.
            replent: Entry widget for replvar.  Created in
                create_entries().
            ok: Boolean used in searchengine.search_text to indicate
                whether the search includes the selection.
        N)super__init__rreplvarr	)selfrr	__class__s   rrzReplaceDialog.__init__%s:	v&&& rNcRtj||	|d}n#t$rd}YnwxYw	|d}n#t$rd}YnwxYw|p|d}|p|}|||d|_||_dS)zMake dialog visible on top of others and ready to use.

        Also, highlight the currently selected text and set the
        search to include the current selection (self.ok).

        Args:
            text: Text widget being searched.
        	sel.firstNsel.lastinsertT)rrindexrshow_hitokr	)rrr	firstlasts     rrzReplaceDialog.open6s	dD)))	JJ{++EE			EEE		::j))DD			DDD	-H--}u

eT"""&s-<<AA%$A%cztj||d|jd|_dS)z8Create base and additional label and text entry widgets.z
Replace with:rN)rcreate_entries
make_entryrreplentrs rr(zReplaceDialog.create_entriesNs3'---EEaHrc
tj||d|j|d|j|d|jd|d|jdS)zCreate base and additional command buttons.

        The additional buttons are for Find, Replace,
        Replace+Find, and Replace All.
        FindrzReplace+FindT)isdefzReplace AllN)rcreate_command_buttonsmake_buttonfind_it
replace_itdefault_commandreplace_allr+s rr/z$ReplaceDialog.create_command_buttonsSs	/555...DO444)=TJJJ(899999rc0|ddS)zHandle the Find button.FN)do_findrevents  rr1zReplaceDialog.find_it_sUrcf||jr|dSdS)z]Handle the Replace button.

        If the find is successful, then perform replace.
        Nr6r$
do_replacer7s  rr2zReplaceDialog.replace_itcs:
<<  	OO		rc||jr+|r|ddSdSdS)zHandle the Replace+Find button as the default command.

        First performs a replace and then, if the replace was
        successful, a find next.
        FNr:r7s  rr3zReplaceDialog.default_commandksX<<  	$  
$U#####	$	$
$
$rc|jrI	||}n4#tj$r |j|dd}YnwxYw|}|S)z.Expand replacement text if regular expression.zInvalid Replace ExpressionN)risreexpandreerrorreport_error)rmreplnews    r_replace_expandzReplaceDialog._replace_expandvsy;	
hhtnn8


((/KLLL
C
s1,A A c|j}|sdS|j}|j}|j||}|s|dS|ddd|ddd|d}|d}|j	rd}d}d}dx}	}
|
|j||||d	|
x}r|\}}|d|zd|dzz}|}
|
||}|n|\}}d||fz}	d||fz}
||
kr|d
|
nP|d
|	|	|
kr||	|
|r||	||j|t'|z}d	}|j||||d	|
x}||	r|
r||	|
|dS)aHandle the Replace All button.

        Search text for occurrences of the Find value and replace
        each of them.  The 'wrap around' value controls the start
        point for searching.  If wrap isn't set, then the searching
        starts at the first occurrence after the current selection;
        if wrap is set, the replacement starts at the first line.
        The replacement is always done top-to-bottom in the text.
        Nsel1.0endhitrTF)wrapr$%d.0%d.%dr!)rgetprogrrrsearch_textbell
tag_removestartiswrapundo_block_startsearch_forwardgrouprFspanmark_setdeleter!r	lenundo_block_stopr#close)rr8progrDrreslinecolr$r%r&rCcharsorigrEijs                 rr4zReplaceDialog.replace_alls{""$$	F|!!yk%%dD11	IIKKKFue,,,ue,,,1v!fllnn;	DC
[//dD#Eb0:::c	GD!HHVd]Fd1f,=>>E7799D&&q$//C{6688DAqtQi'EdAY&Dd{{

h----

h...D==KKt,,,>KKsD,<===c#hh,CB)[//dD#Eb0:::c	*	
	'T	'MM%&&&

rFc@|jsdS|j}|j|d|}|s|dS|\}}|\}}d||fz}d||fz}	|||	d|_dS)z|Search for and highlight next occurrence of pattern in text.

        No text replacement is done with this option.
        FNrOT)rrPrrQrRrYr#r$)
rr$rr`rarCrerfr%r&s
          rr6zReplaceDialog.do_finds
{""$$	5yk%%dD"55	IIKKK5avvxx14)#$"

eT"""trcr|j}|sdS|j}	|dx}}|d}n#t$rd}YnwxYw|s|dx}x}}tj|\}}|d|zd|dzz}|||}	|sdS|	|	|j
}
|
dS|d|||	
r||||
r|||
|j||||dd|_dS)	z6Replace search pattern in text with replacement value.Frr Nr!rNrLT)rrPrr"rrget_line_colrmatchrFrrZrVrXr[r!r	r]r#r$)rr_rr%posr&rarbrcrCrEs           rr;zReplaceDialog.do_replaces{""$$	5y	**[111EC::j))DD			CCC		6!%H!5!55E5D3 -c22	c$$q&(9::JJuc""	5""1dl&6&6&8&899;5

h&&&7799	%KKt$$$	6KKsD$4555

eTZZ11222ts,AA"!A"c|j}|d||ddd|d|||ddd||kr|d|n|d|||d|dS)aHighlight text between first and last indices.

        Text is highlighted via the 'hit' tag and the marked
        section is brought into view.

        The colors from the 'hit' tag aren't currently shown
        when the text is displayed.  This is due to the 'sel'
        tag being added first, so the colors in the 'sel'
        config are seen instead of the colors for 'hit'.
        r!rHrIrJrKN)rrZrStag_addseeupdate_idletasks)rr%r&rs    rr#zReplaceDialog.show_hitsy

h&&&ue,,,UE4(((ue,,,D==LL&&&&LLt,,,rcvtj|||jdddd|_dS)z%Close the dialog and remove hit tags.rKrIrJN)rr^rrSr	r7s  rr^zReplaceDialog.closes=tU+++	UE5111rN)F)__name__
__module____qualname____doc__titleiconrrr(r/r1r2r3rFr4r6r;r#r^
__classcell__)rs@rr
r
s$99ED     "''''0III

:
:
:	$	$	$	$6666p(@   .        rr
c
ddlm}m}m
mddlm}m}||}|dtt|ddd\}}|d||dzfzd	}d
}	||}
|

||
d|_|	_
d
d
fd}||
d|}|
dS)Nr)ToplevelTextENDSEL)FrameButtonzTest ReplaceDialog+rLz+%d+%dcdSrqrrrrVz)_replace_dialog.<locals>.undo_block_startrcdSrqrrrrr]z(_replace_dialog.<locals>.undo_block_stoprrgray)inactiveselectbackgroundr!z"This is a sample sTring
Plus MORE.cdtddS)NrI)rmrrS)r|r}rsrshow_replacez%_replace_dialog.<locals>.show_replace&s@S%%%%


UC(((((rr)rcommand)tkinterrzr{r|r}tkinter.ttkr~rrvmapintgeometrysplitpackrVr]r!	focus_set)parentrzr{r~rtopxyrVr]framerbuttonr|r}rs             @@@r_replace_dialogr
s000000000000))))))))
(6

CII"###sFOO%%++C00455DAqLLQCL()))






E#JJE	JJLLL4777D,D*DIIKKKKK>???NN)))))))
VE	<
@
@
@F
KKMMMMMr__main__)mainzidlelib.idle_test.test_replaceF)	verbosityexit)runrq)rur@rrridlelib.searchbaseridlelibrrr
rrrunittestridlelib.idle_test.htestrrrr<module>rs

			''''''''//////      ////"k k k k k $k k k \DzD	)QUCCCC++++++Cr