Hacked By AnonymousFox

Current Path : /opt/alt/python36/lib64/python3.6/idlelib/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib64/python3.6/idlelib/__pycache__/autocomplete_w.cpython-36.pyc

3

� fuM�
@s�dZddlZddlTddlmZddlmZmZddlm	Z	dZ
dZed	fZd
Z
d"ZdZdZdZdZdZGdd�d�Zedkr�ddlmZeddd d!�dS)#zH
An auto-completion window for IDLE, used by the autocomplete extension
�N)�*)�	Scrollbar)�COMPLETE_FILES�COMPLETE_ATTRIBUTES)�MC_SHIFTz<<autocompletewindow-hide>>z
<FocusOut>z
<ButtonPress>z<<autocompletewindow-keypress>>�<Key>�<Key-BackSpace>�<Key-Return>�	<Key-Tab>�<Key-Up>�
<Key-Down>�
<Key-Home>�	<Key-End>�<Key-Prior>�
<Key-Next>z!<<autocompletewindow-keyrelease>>z<KeyRelease>z<B1-ButtonRelease>z<Configure>z<B1-Double-ButtonRelease>c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!S)"�AutoCompleteWindowcCs|||_d|_|_|_d|_|_d|_d|_d|_d|_	d|_
d|_d|_d|_
|_|_|_|_|_d|_dS)NF)�widget�autocompletewindow�listbox�	scrollbar�origselforeground�origselbackground�completions�morecompletions�mode�start�
startindex�lasttypedstart�userwantswindowZhideid�
keypressid�listupdateid�winconfigid�keyreleaseid�
doubleclickid�lastkey_was_tab)�selfr�r&�;/opt/alt/python36/lib64/python3.6/idlelib/autocomplete_w.py�__init__s$zAutoCompleteWindow.__init__cCs�tt|j�t|��}d}x&||kr>|j|||kr>|d7}qW|t|j�krv|jjd|j|fd|jt|j�f�|t|�kr�|jjd|j|f||d��||_dS)Nr�z%s+%dc)�min�lenrr�deleter�insert)r%�newstart�min_len�ir&r&r'�
_change_start=sz AutoCompleteWindow._change_startcCsXd}t|j�}x4||krB||d}|j||kr8|}q|d}qWt|t|j�d�S)z�Find the first index in self.completions where completions[i] is
        greater or equal to s, or the last index if there is no such
        one.r�r))r+rr*)r%�sr0�j�mr&r&r'�_binary_searchJs

z!AutoCompleteWindow._binary_searchc
Cs�|j|�}|j|dt|��|kr(|S|d}t|j�}x@||krz||d}|j|dt|��|krp|}q<|d}q<W|d}||kr�|j|S|j|}|j|}tt|�t|��}	t|�}x$||	kr�||||kr�|d7}q�W|d|�S)z�Assuming that s is the prefix of a string in self.completions,
        return the longest string which is a prefix of all the strings which
        s is a prefix of them. If s is not a prefix of a string, return s.Nr)r2)r6rr+r*)
r%r3�firstr0r4r5ZlastZ
first_compZ	last_compr/r&r&r'�_complete_stringWs(





z#AutoCompleteWindow._complete_stringcCsLt|jj�d�}|jj|�|j}|j|}|j|�|krB|}nHtt|�t|��}d}x$||kr|||||kr||d7}qZW|d|�}|j	|�|j|dt|j
��|j
kr�|jj|j|j
d�n�|jj|jjd�|jjd�d�|j�rH|j|_d|_|jjdt�x|jD]}|jjt|��qW|jj|j|j
��|j�dS)z|Should be called when the selection of the Listbox has changed.
        Updates the Listbox display and calls _change_start.rr)N)�selectbackground�selectforeground�bgZfg)�intr�curselection�seerrr6r*r+r1rZ	configurerr�cgetrr,�ENDr-�
select_set�_selection_changed)r%�curselZltsZselstartr.r/r0�itemr&r&r'rBvs2


z%AutoCompleteWindow._selection_changedcCs�|\|_|_||_|jj|�|_|jj|jd�|_|r�|j|j�}|j}|j	|�|j
|�}|j||kr�|t|j�dks�|j|ddt|��|kr�||kS||_|j|_
t|j�|_}	|	jd�|	jd�y|	jjdd|	jdd�Wntk
�rYnXt|	td	�|_}
t|	|
jd
dd�|_}x|jD]}|jt|��q8W|jd
�|_|jd�|_ |
j!|j"d�|
j#t$t%d�|j#t&t'dd�|	j(�|jj)|j
|j��|j*�|	j+t,|j-�|_.|jj+t,|j-�|_/|	j0t,t1�xt2D]}
|jj0t,|
��q�W|jj+t3|j4�|_5xt6D]}
|jj0t3|
��qW|jj+t7|j8�|_9|jj0t7t:�|j+t;|j<�|_=|	j+t>|j?�|_@|j+tA|jB�|_CdS)z�Show the autocomplete list, bind events.
        If complete is True, complete the text, and if there is exactly one
        matching completion, don't open a list.r-r)Nz+10000+10000z!::tk::unsupported::MacWindowStyleZstyle�helpZnoActivates)ZorientFZwhite)ZyscrollcommandZexportselectionr;r:r9)Zcommand)�side�fillT)rFrG�expand)Drrrr�indexr�getrr8r1r6r+rrZToplevelr�wm_geometryZwm_overrideredirectZtkZcallZ_wZTclErrorrZVERTICALrZListbox�setrr-r@r?rr�configZyviewZpackZRIGHT�YZLEFTZBOTHZliftrArBZbind�HIDE_VIRTUAL_EVENT_NAME�
hide_event�hideaid�hidewidZ	event_add�HIDE_FOCUS_OUT_SEQUENCE�HIDE_SEQUENCES�KEYPRESS_VIRTUAL_EVENT_NAME�keypress_eventr�KEYPRESS_SEQUENCES�KEYRELEASE_VIRTUAL_EVENT_NAME�keyrelease_eventr"�KEYRELEASE_SEQUENCE�LISTUPDATE_SEQUENCE�listselect_eventr �WINCONFIG_SEQUENCE�winconfig_eventr!�DOUBLECLICK_SEQUENCE�doubleclick_eventr#)r%Z
comp_listsrI�completerZuserWantsWinZ	completedrr0�acwrrrD�seqr&r&r'�show_window�sl









zAutoCompleteWindow.show_windowcCs�|j�sdS|j}|j|j�|j|j�\}}}}|j}|j�|j�}}	|j�|j�}
}|j�t	|t
d|
|��}|j�|}
||||	ks�||	kr�|
|7}
n|
|	8}
|jd||
f�t
j�jd�r�|jt|j�d|_dS)Nrz+%d+%dZWindows)�	is_activerr>rZbboxrZwinfo_width�winfo_heightZwinfo_rootxr*�maxZwinfo_rootyrK�platform�system�
startswith�unbindr]r!)r%�event�text�x�yZcxZcyrbZ	acw_widthZ
acw_heightZ
text_widthZtext_heightZnew_xZnew_yr&r&r'r^�s$
z"AutoCompleteWindow.winconfig_eventcCsB|js
dSy|jj�s|j�Wntk
r<|j�YnXdS)N)rZ	focus_get�hide_window�KeyError)r%r&r&r'�_hide_event_check�s
z$AutoCompleteWindow._hide_event_checkcCs>|j�r:|jtjkr&|jjd|j�n|jtjkr:|j�dS)Nr))	re�typeZ	EventTypeZFocusOutr�afterrrZButtonPressrp)r%rlr&r&r'rPs
zAutoCompleteWindow.hide_eventcCs4|j�r0d|_t|jj�d�}|j|j|�dS)NTr)rerr<rr=r1r)r%rlrCr&r&r'r\sz#AutoCompleteWindow.listselect_eventcCs.t|jj�d�}|j|j|�|j�dS)Nr)r<rr=r1rrp)r%rlrCr&r&r'r`sz$AutoCompleteWindow.doubleclick_eventcs$|j�sdS|j�t|d�r$|j}nd}�dkr6d|_t��dks\�d(ks\|jtkof�d)kof|t@�rHt��dkr�|j	|j
��n|�dkr�|j	|j
d
�nb�dkr�|j	|j
d�nH�d	kr�|j	|j
d�n.t|j
�dkr�|j�dS|j	|j
dd*��|j
|_|j
jdt|j
j�d��|j
j|j|j
��|j�d
S�dk�rf|j�|j�d
S|jtk�r|�d+k�s�|jtk�r�d,k�r|t@�rt|j
j�d�}|j|dt|j
��|j
k�r�|jtk�s�|j
�r�|j	|j|�|j�dS�d-k�r4|�r4d|_t|j
j�d�}�dk�r<d}nĈdk�rVt|j�d}n��d.k�r�|j
j|j
j��|j
jd�}�dk�r�td||�}n&�dk�s�t�tt|j�d||�}n@�dk�r�td|d�}n&�dk�s�t�tt|j�d|d�}|j
j|�|j
j|�|j�|j	|j|�d
S�dk�r�|�r�|j�r|t|j
j�d�}|j	|j|�|j�d
Sd|_d|_dSn�t�fdd �d/D���r�dS|j�r|jd'k�r|j	|j
|j�|j
|_|j
jdt|j
j�d��|j
j|j|j
��|j�d
S|j�dSdS)0N�mc_staterZTabFr)�
underscore�	BackSpace�period�minus�_�.�-�breakZReturn�space�	parenleft�
parenright�bracketleft�bracketright�slash�	backslash�quotedbl�
apostrophe�Home�End�Prior�Next�Up�DownTc3s|]}|�kVqdS)Nr&)�.0r3)�keysymr&r'�	<genexpr>�sz4AutoCompleteWindow.keypress_event.<locals>.<genexpr>�Shift�Control�Alt�Meta�Command�Option� )rvrw)rxry���)rxr~rr�r�r�)r�r�r�r�)r�r�r�r�r�r�)r�r�)r�r�r�r�r�r�)rer��hasattrrur$r+rrrr1rrprrZselect_clearr<r=rAr6rBrarrrZnearestrfrg�AssertionErrorr*�any�char)r%rl�staterCZnewselZjumpr&)r�r'rV$s�

 





z!AutoCompleteWindow.keypress_eventcCs@|j�sdS|jjd�|jjd|jt|j�f�kr<|j�dS)Nr-z%s+%dc)rerrIrr+rrp)r%rlr&r&r'rY�s

z#AutoCompleteWindow.keyrelease_eventcCs
|jdk	S)N)r)r%r&r&r're�szAutoCompleteWindow.is_activecCs|j|j|j��dS)N)r1r8r)r%r&r&r'ra�szAutoCompleteWindow.completecCs(|j�sdS|jjtt�xtD]}|jjt|�q W|jjt|j�|jjt|j	�d|_d|_	xt
D]}|jjt|�qhW|jjt|j�d|_|jjt
t�|jjt
|j�d|_|jjt|j�d|_|jr�|jjt|j�d|_|jj�|jj�d|_|jj�d|_|jj�d|_dS)N)rerZevent_deleterOrSrTrrkrQrRrWrUrrXrZr"rr[r r!r]Z	focus_setrZdestroy)r%rcr&r&r'rp�s<





zAutoCompleteWindow.hide_windowN)�__name__�
__module__�__qualname__r(r1r6r8rBrdr^rrrPr\r`rVrYrerarpr&r&r&r'rs  

$I
tr�__main__)�mainz%idlelib.idle_test.test_autocomplete_wr2F)�	verbosity�exit)
rrr	r
rrr
rrr)�__doc__rhZtkinterZtkinter.ttkrZidlelib.autocompleterrZidlelib.multicallrrOrSrTrUrWrXrZr[r]r_rr�Zunittestr�r&r&r&r'�<module>s07

Hacked By AnonymousFox1.0, Coded By AnonymousFox