f ž _0c@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)ZhasattrÚ 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)'rzr?Zposrrrr0§s*  zSearchEngine.search_backward)r%)Nr©rrF)Ú__name__Z __module__Z __qualname__Ú__doc__rrrrrrrrr!r"r,r&r9r1r0rrrrrs  ( 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$)r;Zspan)r)r>r+r?ZfoundZiZjrrrrAÀs   rAcCsRz| d¡}| d¡}Wnty2d}}Yn0|sB| d¡}|sJ|}||fS)zFReturn tuple of 'line.col' indexes from selection or insert mark. z sel.firstzsel.lastNZinsert)rBr)r2r5r6rrrr.×s   r.cCstt| d¡ƒ\}}||fS)z8Return (line, col) tuple of ints from 'line.col' string.r@)rCrDrE)rBr8r+rrrr/åsr/Z__main__)Úmainz#idlelib.idle_test.test_searchenginer#)Z verbosity)rHrZtkinterrrrZtkinter.messageboxZ messageboxr-r rrAr.r/rGZunittestrIrrrrZs  .