Ë ÒB˜Uh‰i+ãóÈ—dZddlZeje_ddlmZmZddlmZddl m Z dd„Z Gd„de«Z d „Z ed k(r dd lmZed d d¬«ddlmZee «yy)zÑReplace 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)Ú StringVarÚTclError)ÚSearchDialogBase)Ú searchenginecóì—|j«}tj|«}t|d«st ||«|_|j }|jdd«}|j |||¬«y)zÔCreate 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.firstúsel.last©Ú insert_tagsN)Ú_rootrÚgetÚhasattrÚ ReplaceDialogrÚopen)Útextr ÚrootÚengineÚdialogÚ searchphrases ú&/usr/lib/python3.12/idlelib/replace.pyÚreplacersf€ð �:‰:‹<€DÜ × Ñ ˜dÓ #€FÜ �6Ð+Ô ,Ü -¨d°FÓ ;ˆÔØ × "Ñ "€FØ—8‘8˜K¨Ó4€LØ ‡K�K��l° €KÕ<óc󆇗eZdZdZdZdZˆfd„Zdddœd„Zd„Zd „Z dd „Z dd „Z dd „Z d „Z dd„Zdd„Zd„Zd„Zdd„ZˆxZS)rz3Dialog for finding and replacing a pattern in text.zReplace DialogÚReplacecóT•—t‰|�||«t|«|_d|_y)aãCreate 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__rÚreplvarr )ÚselfrrÚ __class__s €rrzReplaceDialog.__init__'s'ø€ô ‰Ñ˜˜vÔ&Ü  “ˆŒ ؈ÕrNr cóN—tj|||«d|_||_y)aMake 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)rrÚokr )r rrr s rrzReplaceDialog.open8s%€ô ×јd D¨,Ô7؈ŒØ&ˆÕrcóv—tj|«|jd|j«d|_y)z8Create base and additional label and text entry widgets.z Replace with:rN)rÚcreate_entriesÚ make_entryrÚreplent©r s rr%zReplaceDialog.create_entriesFs+€ä×'Ñ'¨Ô-Ø—‘ ¸¿ ¹ ÓEÀaÑHˆ� rcó—tj|«|jd|j«|jd|j«|jd|j d¬«|jd|j «y)z’Create base and additional command buttons. The additional buttons are for Find, Replace, Replace+Find, and Replace All. ÚFindrz Replace+FindT)Úisdefz Replace AllN)rÚcreate_command_buttonsÚ make_buttonÚfind_itÚ replace_itÚdefault_commandÚ replace_allr(s rr,z$ReplaceDialog.create_command_buttonsKsk€ô ×/Ñ/°Ô5Ø ×ј §¡Ô.Ø ×ј D§O¡OÔ4Ø ×ј¨×)=Ñ)=ÀTÐÔJØ ×ј¨×(8Ñ(8Õ9rcó&—|jd«y)zHandle the Find button.FN)Údo_find©r Úevents rr.zReplaceDialog.find_itWs€à � ‰ �UÕrcó\—|j|j«r|j«yy)z]Handle the Replace button. If the find is successful, then perform replace. N©r3r#Ú do_replacer4s rr/zReplaceDialog.replace_it[s#€ð �<‰<˜Ÿ™Ô Ø �O‰OÕ ð !rcó€—|j|j«r#|j«r|jd«yyy)zŸHandle the Replace+Find button as the default command. First performs a replace and then, if the replace was successful, a find next. FNr7r4s rr0zReplaceDialog.default_commandcs4€ð �<‰<˜Ÿ™Ô Ø�‰Ô à— ‘ ˜UÕ#ð!ð !rcóÖ—|jj«r |j|«}|S|}|S#tj$r"|jj |d«d}Y|SwxYw)z.Expand replacement text if regular expression.zInvalid Replace ExpressionN)rÚisreÚexpandÚreÚ PatternErrorÚ report_error)r ÚmÚreplÚnews rÚ_replace_expandzReplaceDialog._replace_expandnsm€à �;‰;× Ñ Ô ð Ø—h‘h˜t“n�ðˆ ðˆCàˆ øô —?‘?ò Ø— ‘ ×(Ñ(¨Ð/KÔLØ‘ðˆ ð  úsœ3³1A(Á'A(cór—|jj«}|sy|jj«}|j}|jj ||«}|s|j «y|jddd«|jddd«|d}|dj«}|jj«rd}d}d}dx} } |j«|jj||||d |¬ «x}rú|\}} |jd |zd |dzz«} | j«} |j| |«}|€nµ| j«\}}d ||fz} d ||fz} || k(r|jd | «nH|jd | «| | k7r|j!| | «|r|j#| ||j$«|t'|«z}d }|jj||||d |¬ «x}rŒú|j)«| r| r|j+| | «|j-«y)a¸Handle 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. NÚselú1.0ÚendÚhitréTF)Úwrapr#ú%d.0ú%d.%dÚinsert)rÚgetprogrrrÚ search_textÚbellÚ tag_removeÚstartÚiswrapÚundo_block_startÚsearch_forwardÚgrouprCÚspanÚmark_setÚdeleterMr ÚlenÚundo_block_stopÚshow_hitÚclose)r r5ÚprogrArÚresÚlineÚcolr#ÚfirstÚlastr@ÚcharsÚorigrBÚiÚjs rr1zReplaceDialog.replace_all{s.€ð�{‰{×"Ñ"Ó$ˆÙØ Ø�|‰|×ÑÓ!ˆØ�y‰yˆØ�k‰k×%Ñ% d¨DÓ1ˆÙØ �I‰IŒKØ Ø �‰˜˜u eÔ,Ø �‰˜˜u eÔ,Ø�1‰vˆØ�!‰f�l‰l‹nˆØ �;‰;× Ñ Ô ØˆD؈CØ ˆØÐˆ�à ×ÑÔØ—[‘[×/Ñ/Ø�d˜D #¨E°bð0ó:ð:ˆcð:à‰GˆD�!Ø—H‘H˜V d™]¨F°d¸1±fÑ,=Ó>ˆEØ—7‘7“9ˆDØ×&Ñ& q¨$Ó/ˆC؈{ØØ—6‘6“8‰DˆAˆqؘt Q˜iÑ'ˆEؘd A˜YÑ&ˆDØ�dŠ{Ø— ‘ ˜h¨Õ-à— ‘ ˜h¨Ô.ؘD’=Ø—K‘K  tÔ,ÙØ—K‘K  s¨D×,<Ñ,<Ô=Ø”c˜#“h‘,ˆC؈Bð)—[‘[×/Ñ/Ø�d˜D #¨E°bð0ó:ð:ˆcñ:ð* ×ÑÔÙ ‘TØ �M‰M˜% Ô &Ø � ‰ � rcó0—|jj«sy|j}|jj|d|«}|s|j «y|\}}|j «\}}d||fz}d||fz} |j || «d|_y)z|Search for and highlight next occurrence of pattern in text. No text replacement is done with this option. FNrLT)rrNrrOrPrWr\r#) r r#rr_r`r@rfrgrbrcs rr3zReplaceDialog.do_find³s“€ð �{‰{×"Ñ"Ô$ØØ�y‰yˆØ�k‰k×%Ñ% d¨D°"Ó5ˆÙØ �I‰IŒKØØ‰ˆˆaØ�v‰v‹x‰ˆˆ1ؘ4 ˜)Ñ#ˆØ˜$ ˜Ñ"ˆØ � ‰ �e˜TÔ"؈ŒØrcó—|jj«}|sy|j} |jd«x}}|jd«}|s|jd«x}x}}t j |«\}}|jd|zd|dzz«}|j||«} |sy|j| |jj««} | €y|jd«|j«| j«r|j|«| r|j|| |j «|j#«|j%||jd««d|_y#t$rd}Y�Œ6wxYw) z6Replace search pattern in text with replacement value.Fr r NrMrKrIT)rrNrÚindexrrÚ get_line_colrÚmatchrCrrXrTrVrYrMr r[r\r#) r r^rrbÚposrcr`rardr@rBs rr8zReplaceDialog.do_replaceÇsa€à�{‰{×"Ñ"Ó$ˆÙØØ�y‰yˆð ØŸ*™* [Ó1Ð 1ˆE�CØ—:‘:˜jÓ)ˆDñØ!%§¡¨HÓ!5Ð 5ˆEÐ 5�D˜3Ü ×-Ñ-¨cÓ2‰ ˆˆcØ—‘˜ $™¨°$°q±&Ñ(9Ó:ˆØ �J‰J�u˜cÓ "ˆÙØØ×"Ñ" 1 d§l¡l×&6Ñ&6Ó&8Ó9ˆØ ˆ;ØØ � ‰ �h Ô&Ø ×ÑÔØ �7‰7Œ9Ø �K‰K˜˜tÔ $Ù Ø �K‰K˜˜s D×$4Ñ$4Ô 5Ø ×ÑÔØ � ‰ �e˜TŸZ™Z¨Ó1Ô2؈ŒØøô+ò Ø‹Cð ús«$E7Å7 FÆFcóJ—|j}|jd|«|jddd«|jd||«|jddd«||k(r|jd|«n|jd||«|j d«|j «y)aŠHighlight 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'. rMrErFrGrHN)rrXrQÚtag_addÚseeÚupdate_idletasks)r rbrcrs rr\zReplaceDialog.show_hitçsˆ€ð�y‰yˆØ � ‰ �h Ô&Ø �‰˜˜u eÔ,Ø � ‰ �U˜E 4Ô(Ø �‰˜˜u eÔ,Ø �DŠ=Ø �L‰L˜ Õ &à �L‰L˜  tÔ ,Ø �‰�ÔØ ×ÑÕrcóx—tj||«|jjddd«d|_y)z%Close the dialog and remove hit tags.rHrFrGN)rr]rrQr r4s rr]zReplaceDialog.closeþs0€ä×јt UÔ+Ø � ‰ ×јU E¨5Ô1؈Õr©N)F)Ú__name__Ú __module__Ú __qualname__Ú__doc__ÚtitleÚiconrrr%r,r.r/r0rCr1r3r8r\r]Ú __classcell__)r!s@rrr!s[ø„Ù9à €EØ €Dô ð" '¸4ô 'òIò :óóó $ò ó6ópò(ò@ ÷. rrcó‡ ‡‡—ddlm}m}mŠ mŠddlm}m}||«}|jd«tt|j«jd«dd«\}}|jd||dzfz«d „}d „} ||«} | j«|| d ¬ «Š|‰_| ‰_‰j«‰j!d d«‰j#«ˆ ˆˆfd„} || d| ¬«} | j«y)Nr)ÚToplevelÚTextÚENDÚSEL)ÚFrameÚButtonzTest ReplaceDialogÚ+rIz+%d+%dé¯có—yrs©r…rrrTz)_replace_dialog..undo_block_startó€Ø rcó—yrsr…r…rrr[z(_replace_dialog..undo_block_stopr†rÚgray)ÚinactiveselectbackgroundrMz"This is a sample sTring Plus MORE.cóh•—‰j‰d‰«t‰«‰j‰d‰«y)NrF)rorrQ)r~rrs€€€rÚ show_replacez%_replace_dialog..show_replaces*ø€Ø � ‰ �S˜% Ô%Ü�Œ Ø �‰˜˜U CÕ(rr)rÚcommand)Útkinterr|r}r~rÚ tkinter.ttkr€r�rxÚmapÚintÚgeometryÚsplitÚpackrTr[rMÚ focus_set)Úparentr|r}r€r�ÚtopÚxÚyrTr[Úframer‹Úbuttonr~rrs @@@rÚ_replace_dialogr›sßú€ß0Ó0ß)á �6Ó €C؇I�IÐ"Ô#Ü Œs�F—O‘OÓ%×+Ñ+¨CÓ0°°Ð4Ó 5�D€A€q؇L�L�˜Q  C¡˜LÑ(Ô)ò ò ñ �#‹J€EØ ‡J�J„LÙ �°Ô 7€DØ,€DÔØ*€DÔØ‡I�I„K؇K�K�Ð>Ô?؇N�NÔö)ñ �E  °<Ô @€FØ ‡K�K…MrÚ__main__)Úmainzidlelib.idle_test.test_replaceéF)Ú verbosityÚexit)Úrunrs)rwr=Úerrorr>r�rrÚidlelib.searchbaserÚidlelibrrrr›rtÚunittestr�Úidlelib.idle_test.htestr¡r…rrÚr§shðñó  Ø—(‘(€„ç'å/Ý ó=ô$a Ð$ôa òHðD ˆzÒÝÙÐ )°Q¸UÕCå+ÙˆÕð r