eSrSSKrSSKJrJrJr SSKJr Sr"SS5rSr S r S r \ S :XaSS K Jr \"S SS9 gg)z'Define SearchEngine for search dialogs.N) StringVar BooleanVarTclError) messageboxc\[US5(d[U5UlUR$)zReturn the singleton SearchEngine instance for the process. The single SearchEngine saves settings between dialog instances. If there is not a SearchEngine already, make one. _searchengine)hasattr SearchEnginer)roots :/opt/imh/python3.13/lib/python3.13/idlelib/searchengine.pygetr s* 4 ) ))$/   c\rSrSrSrSrSrSrSrSr Sr S r S r S r S rS rSSjrSSjrSSjrSSjrSrg)r zkkmyy{{))C.C ;;==c/C rcUR5nU(dURUS5 gUR5nSnUR5(dU[R -n[R "X5nU$![Ra0nURXRUR5 SnAgSnAff=f)z&Return compiled cooked search pattern.zEmpty regular expressionNr) r report_errorr=r+r8 IGNORECASEcompile PatternErrormsgpos)rr$flagsproges r getprogSearchEngine.getprogKskkm   c#= >!{{}}BMM)E ::c)D     c55!%% 0 s&A>>C&B==CNcS[U5-nU(aUS-[U5-nUbUS-[U5-n[R"SX RS9 g)NzError: z Pattern: z Offset: zRegular expression error)master)strr showerrorr )rr$rDcols r r@SearchEngine.report_error\sV#c("  %C0C ? $s3x/C7"99 6rcpU(dUR5nU(dgURR5n[U5upVUR 5(a.U(aUnOUn[ U5upUR XXXC5n U $U(aUnOUn[ U5upURXXXC5n U $)a^Return (lineno, matchobj) or None for forward/backward search. This function calls the right function with the right arguments. It directly return the result of that call. Text is a text widget. Prog is a precompiled pattern. The ok parameter is a bit complicated as it has two effects. If there is a selection, the search begin at either end, depending on the direction setting and ok, with ok meaning that the search starts with the selection. Otherwise, search begins at the insert mark. To aid progress, the search functions do not return an empty match at the starting position unless ok is True. N)rIrr get_selectionr5 get_line_colsearch_backwardsearch_forward) rtextrGokwrapfirstlaststartlinerOress r search_textSearchEngine.search_textfs$<<>D||!#D)  ;;==$U+ID&&t4dGC $U+ID%%d$TFC rcSnUnURSU-SUS--5n U (aURU SSU5n U (aU(dU R5U:aX:4$US-nU(aX8:agSnSnURSU-SUS--5n U (dU(aSnSnSnURSS5n U (aMg)Nr%d.0z1.0z2.0)r searchend) rrVrGr\rOrXrWwrapped startlinecharsms r rUSearchEngine.search_forwards $$q&(9: E#2J,A37N!8D4+CBHHVd]Fd1f,=>ET.e rcSnUnURSU-SUS--5n [X)SSU5n U (aU(dU R5U:aX:4$US- nU(aX8:agSnUS::a?U(dgSnSnURS5n [ [ U R S55up4URSU-SUS--5n [U 5S- nM)Nrrarbrczend-1c.)r search_reverser[indexmapintsplitlen) rrVrGr\rOrXrWrfrgrhrirEs r rTSearchEngine.search_backwards $$q&(9:t3BZ5AS7N!8D4+Bqy jj*SYYs^4 HHVd]Fd1f,=>Ee*q.C#r)rrrrr rrr)Nr)r)__name__ __module__ __qualname____firstlineno____doc__rrr%r(r+r/r2r5r:r=rIr@r^rUrT__static_attributes__rr r r sQF /! """" "6&P,rr cURU5nU(dgSnUR5upVXR:aJXb::aEUnXV:XaUS-nURX5nU(dU$UR5upVXR:aXb::aMEU$)aSearch backwards and return an re match object or None. This is done by searching forwards until there is no match. Prog: compiled re object with a search method returning a match. Chars: line of text, without \n. Col: stop index for the search; the limit for match.end(). Nrb)rdspan)rGrhrOrifoundijs r rmrms EA  E 668DA 'ah 6!A KK !  Lvvx 'ah LrcURS5nURS5nU(dURS5nU(dUnX4$![a S=pN3f=f)zFReturn tuple of 'line.col' indexes from selection or insert mark. z sel.firstzsel.lastNinsert)rnr)rVrYrZs r rRrRsa ;'zz*%  8$  ; s"A AAcJ[[URS55upX4$)z8Return (line, col) tuple of ints from 'line.col' string.rl)rorprq)rnr\rOs r rSrSs!CS)*ID 9r__main__)mainz#idlelib.idle_test.test_searchengine) verbosity)rxr8tkinterrrrrr r rmrRrSrtunittestrrzrr rsR- 33 ggT.   z .!<r