Plan 9 from Bell Labs’s /usr/web/sources/contrib/stallion/root/sys/lib/python2.7/idlelib/AutoExpand.pyo

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


�`^c@scdZddlZddlZdd	d��YZedkr_ddlZejddd�ndS(
s[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.
i�Nt
AutoExpandcBsReZddgfgZejejdZd�Zd�Zd�Z	d�Z
RS(	teditsE_xpand Words<<expand-word>>t_cCs|j|_d|_dS(N(ttexttNonetstate(tselfteditwin((s(/sys/lib/python2.7/idlelib/AutoExpand.pyt__init__ sc
CsT|jjd�}|jjdd�}|jsE|j�}d}nB|j\}}}}||ksr||kr�|j�}d}n|s�|jj�dS|j�}|jjdt|�d�||}	|dt|�}|dkr|jj�n|jj	d|	�|jjd�}|jjdd�}||||f|_dS(s1Replace the current word with the next expansion.tinsertsinsert linestartsinsert lineenditbreaksinsert - %d charsi(
RtindextgetRtgetwordstbelltgetprevwordtdeletetlenR	(
Rteventt	curinserttcurlinetwordsRR	tlinetwordtnewword((s(/sys/lib/python2.7/idlelib/AutoExpand.pytexpand_word_event$s.			

c	Cs-|j�}|sgS|jjdd�}tjd|d|�}~|jjdd�}tjd|d|�}~|r�|r�gSg}i}|j�x:|D]2}|j|�r�q�n|j|�|||<q�Wx:|D]2}|j|�rq�|j|�|||<q�|j|�|S(s?Return a list of words that match the prefix before the cursor.s1.0sinsert wordstarts\bs\w+\bsinsert wordendtend(RRRtretfindalltreversetappend(	RRtbeforetwbeforetaftertwafterRtdicttw((s(/sys/lib/python2.7/idlelib/AutoExpand.pyR
?s4





cCs]|jjdd�}t|�}x1|dkrT||d|jkrT|d}q$W||S(s)Return the word prefix before the cursor.sinsert linestartR	ii(RRRt	wordchars(RRti((s(/sys/lib/python2.7/idlelib/AutoExpand.pyR^s
&(sE_xpand Words<<expand-word>>(t__name__t
__module__tmenudefststringt
ascii_letterstdigitsR%RRR
R(((s(/sys/lib/python2.7/idlelib/AutoExpand.pyRs			t__main__s!idlelib.idle_test.test_autoexpandt	verbosityi((t__doc__R*RRR'tunittesttmain(((s(/sys/lib/python2.7/idlelib/AutoExpand.pyt<module>sP

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].