f f=@sdZddlZddlmZmZmZddljZddZ GdddZ dd Z d d Z d d Z edkrddlZejdddddndS)z'Define SearchEngine for search dialogs.N) StringVar BooleanVarTclErrorcCs(t|ds!t||_n|jS)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)rootr 9/opt/alt/python34/lib64/python3.4/idlelib/SearchEngine.pygetsr c@seZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZd#ddZddddZddd Zdd!d"ZdS)$rzr5r4r r r r rs             (rcCs|j|}|sdSd}|j\}}xi||kr||kr|}||krk|d}n|j||}|sPn|j\}}q4W|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?span)r,rCr.rDfoundijr r r rFs  rFc Csry"|jd}|jd}Wntk r@d}}YnX|sY|jd}n|sh|}n||fS)zFReturn tuple of 'line.col' indexes from selection or insert mark. z sel.firstzsel.lastNinsert)rGr)r6r9r:r r r r2s  r2cCs(tt|jd\}}||fS)z8Return (line, col) tuple of ints from 'line.col' string.rE)rHrIrJ)rGr<r.r r r r3sr3__main__z#idlelib.idle_test.test_searchengine verbosityr"exitF)rOrZtkinterrrrZtkinter.messageboxZ messageboxr1r rrFr2r3rLZunittestmainr r r r s