File: //usr/lib/python3.5/idlelib/__pycache__/AutoExpand.cpython-35.pyc
FüƒaC
ã @ s` d Z d d l Z d d l Z Gd d „ d ƒ Z e d k r\ d d l Z e j d d d ƒd S) a[ Complete the current word before the cursor with words in the editor.
Each menu selection or shortcut key selection replaces the word with a
different word with the same prefix. The search for matches begins
before the target and moves toward the top of the editor. It then starts
after the cursor and moves down. It then returns to the original word and
the cycle starts again.
Changing the current text line or leaving the cursor in a different
place before requesting the next selection causes AutoExpand to reset
its state.
This is an extension file and there is only one instance of AutoExpand.
é Nc @ sf e Z d Z d d g f g Z e j e j d Z d d „ Z d d „ Z d d
„ Z
d d „ Z d
S)Ú
AutoExpandZeditúE_xpand Wordú<<expand-word>>Ú_c C s | j | _ d | _ d S)N)ÚtextÚstate)ÚselfZeditwin© r ú(/usr/lib/python3.5/idlelib/AutoExpand.pyÚ__init__ s zAutoExpand.__init__c
C sN | j j d ƒ } | j j d d ƒ } | j sE | j ƒ } d } n? | j \ } } } } | | k sr | | k r„ | j ƒ } d } | s› | j j ƒ d S| j ƒ } | j j d t | ƒ d ƒ | | } | d t | ƒ } | d k rû | j j ƒ | j j d | ƒ | j j d ƒ } | j j d d ƒ } | | | | f | _ d S)z1Replace the current word with the next expansion.Úinsertzinsert linestartzinsert lineendr Úbreakzinsert - %d charsé )
r ÚindexÚgetr ÚgetwordsZbellÚgetprevwordZdeleteÚlenr )
r ZeventZ curinsertZcurlineÚwordsr r ÚlineÚwordZnewwordr r r
Úexpand_word_event$ s.
zAutoExpand.expand_word_eventc C s' | j ƒ } | s g S| j j d d ƒ } t j d | d | ƒ } ~ | j j d d ƒ } t j d | d | ƒ } ~ | rŒ | rŒ g Sg } i } | j ƒ x7 | D]/ } | j | ƒ rÁ q© | j | ƒ | | | <q© Wx7 | D]/ } | j | ƒ rû qã | j | ƒ | | | <qã W| j | ƒ | S)z?Return a list of words that match the prefix before the cursor.z1.0zinsert wordstartz\bz\w+\bzinsert wordendÚend)r r r ÚreÚfindallÚreverseÚappend) r r ZbeforeZwbeforeZafterZwafterr ÚdictÚwr r r
r ? s4
zAutoExpand.getwordsc C sc | j j d d ƒ } t | ƒ } x1 | d k rT | | d | j k rT | d } q$ W| | d … S)z)Return the word prefix before the cursor.zinsert linestartr r r N)r r r Ú wordchars)r r Úir r r
r ^ s
&zAutoExpand.getprevwordN)r r )Ú__name__Ú
__module__Ú__qualname__ZmenudefsÚstringZ
ascii_lettersZdigitsr r r r r r r r r
r s r Ú__main__z!idlelib.idle_test.test_autoexpandÚ verbosityé )Ú__doc__r$ r r r! ZunittestÚmainr r r r
Ú<module> s P