Your IP : 18.117.94.221
��YfC
� @ 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 �7/opt/alt/python35/lib64/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 ZbeforeZwbefore�afterZwafterr �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"