eF&SrSSKrSSKJrJr SSKJr SSKJr SSjr "SS\5r S r \ S :XaSS K Jr \"S S SS9 SSKJr \"\ 5 gg)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) searchenginecUR5n[R"U5n[US5(d[ X#5UlUR nURSS5nUR XUS9 g)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 sel.firstsel.last insert_tagsN)_rootrgethasattr ReplaceDialogropen)textr rootenginedialog searchphrases 5/opt/imh/python3.13/lib/python3.13/idlelib/replace.pyreplacerse ::[TU]X5 [U5UlSUlg)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 rrReplaceDialog.__init__&s% &  rNr cL[R"XU5 SUlX0lg)zMake dialog visible on top of others and ready to use. Also, set the search to include the current selection (self.ok). Args: text: Text widget being searched. searchphrase: String phrase to search. TN)rrokr )r!rrr s rrReplaceDialog.open7s! d,7&rcx[R"U5 URSUR5SUlg)z8Create base and additional label and text entry widgets.z Replace with:rN)rcreate_entries make_entryr replentr!s rr(ReplaceDialog.create_entriesEs+''- EaH rc[R"U5 URSUR5 URSUR5 URSUR SS9 URSUR 5 g)zzCreate base and additional command buttons. The additional buttons are for Find, Replace, Replace+Find, and Replace All. Findrz Replace+FindT)isdefz Replace AllN)rcreate_command_buttons make_buttonfind_it replace_itdefault_command replace_allr+s rr0$ReplaceDialog.create_command_buttonsJsk //5 . DOO4 )=)=TJ (8(89rc&URS5 g)zHandle the Find button.FN)do_findr!events rr2ReplaceDialog.find_itVs UrcfURUR5(aUR5 gg)zMHandle the Replace button. If the find is successful, then perform replace. Nr8r% do_replacer9s rr3ReplaceDialog.replace_itZs& << OO  !rcURUR5(a(UR5(aURS5 ggg)zHandle the Replace+Find button as the default command. First performs a replace and then, if the replace was successful, a find next. FNr=r9s rr4ReplaceDialog.default_commandbs: <<    U#! !rcURR5(aURU5nU$UnU$![Ra" URR US5 SnU$f=f)z.Expand replacement text if regular expression.zInvalid Replace ExpressionN)risreexpandre PatternError report_error)r!mreplnews r_replace_expandReplaceDialog._replace_expandmsp ;;     hhtn C ??  ((/KL  s82A.-A.c URR5nU(dgURR5nURnURR XB5nU(dUR 5 gURSSS5 URSSS5 USnUSR5nURR5(aSnSnSnS=pUR5 URRXBXgS US 9=n(aUupkURS U-S US--5n U R5n URX5nUcOU R5unnS Xo4-n S UU4-n X:XaURS U 5 OKURS U 5 X:waUR!X5 U(aUR#XUR$5 U['U5-nS nURRXBXgS US 9=n(aMUR)5 U (aU (aUR+X5 UR-5 g)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.%dinsert)rgetprogr rr search_textbell tag_removestartiswrapundo_block_startsearch_forwardgrouprKspanmark_setdeleterVr lenundo_block_stopshow_hitclose)r!r:progrIrreslinecolr%firstlastrHcharsorigrJijs rr5ReplaceDialog.replace_allzs{{""$ ||!yykk%%d1 IIK  ue, ue,1v!flln ;;    DC  [[//DEb0::c:GDHHVd]Fd1f,=>E779D&&q/C{668DAqti'EdAY&D{ h- h.=KK,KKD,<,<=c#h,CB)[[//DEb0::c:*  T MM% & rc:URR5(dgURnURRUSU5nU(dUR 5 gUupEUR 5upgSXF4-nSXG4-n UR X5 SUlg)zlSearch for and highlight next occurrence of pattern in text. No text replacement is done with this option. FNrUT)rrWrrXrYr`rer%) r!r%rrhrirHrorprkrls rr8ReplaceDialog.do_finds {{""$$yykk%%dD"5 IIKvvx4)#$" e"rc<URR5nU(dgURnURS5=p4URS5nU(dURS5=n=pT[ R "U5upgURSU-SUS--5nURX5n U(dgURXRR55n U cgURSW5 UR5 U R5(aURUW5 U (aURX:UR 5 UR#5 UR%X2RS55 SUlg![a SnGNGf=f) z6Replace search pattern in text with replacement value.Fr r NrVrTrRT)rrWrindexrr get_line_colrmatchrKr rar]r_rbrVr rdrer%) r!rgrrkposrlrirjrmrHrJs rr>ReplaceDialog.do_replacesU{{""$yy **[1 1E::j)D!%H!5 5E 5D --c2 $$q&(9: JJu """1ll&6&6&89 ; h&  7799 KKt $  KKD$4$4 5  eZZ12+ C s#F FFcFURnURSU5 URSSS5 URSX5 URSSS5 X:XaURSU5 OURSX5 UR S5 UR 5 g)aRHighlight 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'. rVrNrOrPrQN)rrarZtag_addseeupdate_idletasks)r!rkrlrs rreReplaceDialog.show_hitsyy h& ue, UE( ue, = LL & LL ,  rcx[R"X5 URRSSS5 SUlg)z%Close the dialog and remove hit tags.rQrOrPN)rrfrrZr r9s rrfReplaceDialog.closes.t+ UE51r)r r%r*r N)F)__name__ __module__ __qualname____firstlineno____doc__titleiconrrr(r0r2r3r4rKr5r8r>rerf__static_attributes__ __classcell__)r"s@rrr s`9 E D " '4 'I : $ 6p(@ .  rrc^ ^^SSKJnJnJm Jm SSKJnJn U"U5nURS5 [[UR5RS5SS5upgURSXgS-4-5 S nS n U"U5n U R5 U"U S S 9mUTlU TlTR5 TR!S S5 TR#5 U UU4Sjn U"U SU S9n U R5 g)Nr)ToplevelTextENDSEL)FrameButtonzTest ReplaceDialog+rRz+%d+%dcgrrrrr])_replace_dialog..undo_block_start rcgrrrrrrd(_replace_dialog..undo_block_stoprrgray)inactiveselectbackgroundrVz"This is a sample sTring Plus MORE.ch>TRTST5 [T5 TRTST5 g)NrO)r{rrZ)rrrsr show_replace%_replace_dialog..show_replaces* S%%  UC(rr)rcommand)tkinterrrrr tkinter.ttkrrrmapintgeometrysplitpackr]rdrV focus_set)parentrrrrtopxyr]rdframerbuttonrrrs @@@r_replace_dialogrs00) 6 CII"# sFOO%++C04 5DALLQCL()   #JE JJL  7D,D*DIIKKK>?NN) E < @F KKMr__main__)mainzidlelib.idle_test.test_replaceF) verbosityexit)runr)rrErrridlelib.searchbaseridlelibrrrrrunittestridlelib.idle_test.htestrrrrrs]  '/ =$a $a HD z )QUC+ r