f ž _0ã@s~dZddlZddlmZmZmZddlmZdd„Z Gdd„dƒZ dd „Z d d „Z d d „Z edkrzddlmZeddddS)z'Define SearchEngine for search dialogs.éN)Ú StringVarÚ BooleanVarÚTclErrorcCst|dƒst|ƒ|_|jS)z¼Return 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)Úroot©r ú-/usr/lib64/python3.10/idlelib/searchengine.pyÚgets  r c@seZdZdZdd„Zdd„Zdd„Zdd „Zd d „Zd d „Z dd„Z dd„Z dd„Z dd„Z dd„Zd#dd„Zd$dd„Zd%dd „Zd&d!d"„ZdS)'rzÚindexÚmapÚintÚsplitr-) rr9r/r?r1r;r:rErFrGrHÚposr r r r7§s*  zSearchEngine.search_backward)r')Nr)r)r)Ú__name__Ú __module__Ú __qualname__Ú__doc__rrrrrrrr r#r$r2r(rAr8r7r r r r rs  ( rcCsj| |¡}|sdSd}| ¡\}}||krf||krf|}||krF|d}| ||¡}|sXqf| ¡\}}q"|S)a&Search 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(). Nr&)rCÚspan)r/rGr1rHÚfoundÚiÚjr r r rJÀs   rJcCsRz| d¡}| d¡}Wnty2d}}Yn0|sB| d¡}|sJ|}||fS)zFReturn tuple of 'line.col' indexes from selection or insert mark. z sel.firstzsel.lastNÚinsert)rKr)r9r<r=r r r r5×s   r5cCstt| d¡ƒ\}}||fS)z8Return (line, col) tuple of ints from 'line.col' string.rI)rLrMrN)rKr?r1r r r r6åsr6Ú__main__)Úmainz#idlelib.idle_test.test_searchenginer%)Ú verbosity)rSr!ÚtkinterrrrZtkinter.messageboxZ messageboxr4r rrJr5r6rPZunittestrZr r r r Ús  .