AlkantarClanX12

Your IP : 18.116.86.132


Current Path : /opt/alt/python35/lib64/python3.5/idlelib/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/idlelib/__pycache__/AutoExpand.cpython-35.opt-1.pyc



��YfC
�@s`dZddlZddlZGdd�d�Zedkr\ddlZejddd�dS)	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@sfeZdZddgfgZejejdZdd�Zdd�Z	d	d
�Z
dd�Zd
S)�
AutoExpandZedit�E_xpand Word�<<expand-word>>�_cCs|j|_d|_dS)N)�text�state)�selfZeditwin�r	�7/opt/alt/python35/lib64/python3.5/idlelib/AutoExpand.py�__init__ szAutoExpand.__init__c
CsN|jjd�}|jjdd�}|jsE|j�}d}n?|j\}}}}||ksr||kr�|j�}d}|s�|jj�dS|j�}|jjdt|�d�||}	|dt|�}|dkr�|jj�|jj	d|	�|jjd�}|jjdd�}||||f|_dS)z1Replace the current word with the next expansion.�insertzinsert linestartzinsert lineendr�breakzinsert - %d chars�)
r�index�getr�getwordsZbell�getprevwordZdelete�lenr)
rZeventZ	curinsertZcurline�wordsrr�line�wordZnewwordr	r	r
�expand_word_event$s.		


zAutoExpand.expand_word_eventc	Cs'|j�}|sgS|jjdd�}tjd|d|�}~|jjdd�}tjd|d|�}~|r�|r�gSg}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)rrr�re�findall�reverse�append)	rrZbeforeZwbefore�afterZwafterr�dict�wr	r	r
r?s4





zAutoExpand.getwordscCsc|jjdd�}t|�}x1|dkrT||d|jkrT|d}q$W||d�S)z)Return the word prefix before the cursor.zinsert linestartrrrN)rrr�	wordchars)rr�ir	r	r
r^s
&zAutoExpand.getprevwordN)rr)�__name__�
__module__�__qualname__Zmenudefs�stringZ
ascii_lettersZdigitsr rrrrr	r	r	r
rsr�__main__z!idlelib.idle_test.test_autoexpand�	verbosity�)�__doc__r%rrr"Zunittest�mainr	r	r	r
�<module>sP