mò &U²Ic@sTdkZdkTdkZd„Zdfd„ƒYZd„Zd„Zd„ZdS(N(t*cCs*t|dƒpt|ƒ|_n|iS(Nt _searchengine(thasattrtroott SearchEngineR(R((t1/data/zmath/lib/python2.4/idlelib/SearchEngine.pytgetsRcBsžtZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z d „Z d „Z d d „Z d „Z ddd„Zdd„Zdd„ZRS(NcCsw||_t|ƒ|_t|ƒ|_t|ƒ|_t|ƒ|_t|ƒ|_|ii dƒt|ƒ|_ dS(Ni( Rtselft StringVartpatvart BooleanVartrevartcasevartwordvartwrapvartsettbackvar(RR((Rt__init__ s cCs |iiƒS(N(RR R(R((RtgetpatscCs|ii|ƒdS(N(RR Rtpat(RR((RtsetpatscCs |iiƒS(N(RR R(R((Rtisre!scCs |iiƒS(N(RR R(R((Rtiscase$scCs |iiƒS(N(RR R(R((Rtisword'scCs |iiƒS(N(RRR(R((Rtiswrap*scCs |iiƒS(N(RRR(R((Rtisback-scCsK|iƒ}|iƒpti|ƒ}n|iƒod|}n|S(Ns\b%s\b(RRRRtretescapeR(RR((Rt getcookedpat2s    cCsÓ|iƒ}|p|i|dƒdSn|iƒ}d}|iƒp|ti B}nyti ||ƒ}Wn[ti j oL}y|\}}Wnt|ƒ}d}nX|i|||ƒdSnX|S(NsEmpty regular expressioniiÿÿÿÿ(RRRt report_errortNoneRtflagsRRt IGNORECASEtcompiletprogterrortwhattmsgtcoltstr(RRR$RR"R&R%((Rtgetprog:s&      iÿÿÿÿcCsqdt|ƒ}|o|dt|ƒ}n|djo|dt|ƒ}ntid|d|iƒdS(NsError: s p\Pattern: is Offset: sRegular expression errortmaster(R'R%RR&t tkMessageBoxt showerrorRR(RRR%R&((RROs  cCs1|iƒoti|ƒ}n|i|ƒdS(N(RRRRRR(RR((Rt setcookedpatYs ic Csê|p|iƒ}|pdSq&n|iiƒ}t|ƒ\} }|i ƒoK|o |}n| }t|ƒ\}} |i|||| ||ƒ}nH|o | }n|}t|ƒ\}} |i|||| ||ƒ}|S(s.Search a text widget for the pattern. If prog is given, it should be the precompiled pattern. Return a tuple (lineno, matchobj); None if not found. This obeys the wrap and direction (back) settings. The search starts at the selection (if there is one) or at the insert mark (otherwise). If the search is forward, it starts at the right of the selection; for a backward search, it starts at the left end. An empty match exactly at either end of the selection (or at the insert mark if there is no selection) is ignored unless the ok flag is true -- this is done to guarantee progress. If the search is allowed to wrap around, it will return the original selection if (and only if) it is the only match. N(R"RR(RRRtwrapt get_selectionttexttfirsttlastRtoktstartt get_line_coltlineR&tsearch_backwardtrestsearch_forward( RR/R"R2R3R-R7R1R5R&R0((Rt search_text^s&    " c Cs d} |}|id|d|dƒ} xÙ| oÑ|i| d |ƒ}|o,|p|i ƒ|jo||fSq}n|d}| o||joPnd}d}|id|d|dƒ} | o/|o(d} d}d}|iddƒ} q-q-WdS(Nis%d.0iiÿÿÿÿs1.0s2.0(twrappedR5t startlineR/RtcharsR"tsearchR&tmR2tendR-R( RR/R"R5R&R-R2R;R>R:R<((RR8ˆs* c Cs,d} |}|id|d|dƒ} xût|| d |ƒ}|o,|p|i ƒ|jo||fSqvn|d}| o||joPnd}|djoI|pPnd} d}|i dƒ} tt| idƒƒ\}}n|id|d|dƒ} t| ƒd}q-WdS(Nis%d.0iiÿÿÿÿsend-1ct.(R:R5R;R/RR<tsearch_reverseR"R&R>R2R3R-tindextpostmaptinttsplittlenR( RR/R"R5R&R-R2R;R>RCR:R<((RR6žs.  "(t__name__t __module__RRRRRRRRRR(RR,RR9R8R6(((RR s           * cCs­|i|ƒ}|pdSnd}|iƒ\}}xp||job||joU|}||jo|d}n|i||ƒ}|pPn|iƒ\}}q9W|S(Ni( R"R=R<R>RtfoundtspantitjR&(R"R<R&RLRMR>RJ((RRA¹s cCswy"|idƒ}|idƒ}Wntj od}}nX|p|idƒ}n|p |}n||fS(Ns sel.firstssel.lasttinsert(R/RBR0R1tTclErrorR(R/R1R0((RR.Ìs cCs(tt|idƒƒ\}}||fS(NR@(RDRERBRFR5R&(RBR5R&((RR4Ús(RtTkinterR*RRRAR.R4(R.RRRR*RAR4((Rt?s   ®