Hacked By AnonymousFox

Current Path : /opt/alt/python37/lib64/python3.7/idlelib/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/idlelib/__pycache__/autocomplete_w.cpython-37.pyc

B

� f�N�@s�dZddlZddlTddlmZddlmZmZddlm	Z	dZ
dZed	fZd
Z
dZdZd
ZdZdZdZGdd�d�Zedkr�ddlmZedddd�dS)zH
An auto-completion window for IDLE, used by the autocomplete extension
�N)�*)�	Scrollbar)�FILES�ATTRS)�MC_SHIFTz<<autocompletewindow-hide>>z
<FocusOut>z
<ButtonPress>z<<autocompletewindow-keypress>>)z<Key>z<Key-BackSpace>z<Key-Return>z	<Key-Tab>z<Key-Up>z
<Key-Down>z
<Key-Home>z	<Key-End>z<Key-Prior>z
<Key-Next>z<Key-Escape>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|_d|_dS)NF)�widget�autocompletewindow�listbox�	scrollbar�origselforeground�origselbackground�completions�morecompletions�mode�start�
startindex�lasttypedstart�userwantswindowZhideid�
keypressid�listupdateid�winconfigid�keyreleaseid�
doubleclickid�lastkey_was_tab�is_configuring)�selfr�r�;/opt/alt/python37/lib64/python3.7/idlelib/autocomplete_w.py�__init__s$zAutoCompleteWindow.__init__cCs�tt|j�t|��}d}x&||kr>|j|||kr>|d7}qW|t|j�krv|j�d|j|fd|jt|j�f�|t|�kr�|j�d|j|f||d��||_dS)Nr�z%s+%dc)�min�lenrr�deleter�insert)r�newstart�min_len�irrr�
_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.
        r�r )r"rr!)r�sr'�j�mrrr�_binary_searchKs

z!AutoCompleteWindow._binary_searchc
Cs�|�|�}|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 r))r-rr"r!)
rr*�firstr'r+r,ZlastZ
first_compZ	last_compr&rrr�_complete_stringXs(





z#AutoCompleteWindow._complete_stringcCsLt|j��d�}|j�|�|j}|j|}|�|�|krB|}nHtt|�t|��}d}x$||kr|||||kr||d7}qZW|d|�}|�	|�|j|dt|j
��|j
kr�|jj|j|j
d�n�|jj|j�d�|j�d�d�|j�rH|j|_d|_|j�dt�x|jD]}|j�t|��qW|j�|�|j
��|��dS)zzCall when the selection of the Listbox has changed.

        Updates the Listbox display and calls _change_start.
        rr N)�selectbackground�selectforegroundZbgZfg)�intr
�curselection�seerrr-r!r"r(rZ	configurer
r�cgetrr#�ENDr$�
select_set�_selection_changed)r�curselZltsZselstartr%r&r'�itemrrrr8xs2


z%AutoCompleteWindow._selection_changedcCs�|\|_|_||_|j�|�|_|j�|jd�|_|r�|�|j�}|j}|�	|�|�
|�}|j||kr�|t|j�dks�|j|ddt|��|kr�||kS||_|j|_
t|j�|_}	|	�d�|	�d�y|	j�dd|	jdd�Wntk
�rYnXt|	td	�|_}
t|	|
jd
d�|_}x|jD]}|�t|��q6W|�d�|_|�d
�|_ |
j!|j"d�|
j#t$t%d�|j#t&t'dd�|	�(�|j�)|�
|j��|�*�|	�+t,|j-�|_.|j�+t,|j-�|_/|	�0t,t1�xt2D]}
|j�0t,|
��q�W|j�+t3|j4�|_5xt6D]}
|j�0t3|
��qW|j�+t7|j8�|_9|j�0t7t:�|�+t;|j<�|_=d
|_>|	�+t?|j@�|_A|�+tB|jC�|_DdS)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)ZorientF)ZyscrollcommandZexportselectionr1r0)Zcommand)�side�fillT)r<r=�expand)Errrr�indexr�getrr/r(r-r"rrZToplevelr	�wm_geometryZwm_overrideredirectZtkZcallZ_wZTclErrorrZVERTICALrZListbox�setr
r$r6r5rr
ZconfigZyviewZpackZRIGHT�YZLEFTZBOTHZliftr7r8Zbind�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_eventrr�WINCONFIG_SEQUENCE�winconfig_eventr�DOUBLECLICK_SEQUENCE�doubleclick_eventr)rZ
comp_listsr?�completerZuserWantsWinZ	completedrr'�acwrr
r:�seqrrr�show_window�sn









zAutoCompleteWindow.show_windowcCs|jr
dSd|_|��sdS|j}|�|j�|�|j�\}}}}|j}|��|��|�	�}}	|��|�	�}
}|�
�t|td|
|��}|�
�|}
||||	ks�||	kr�|
|7}
n|
|	8}
|�d||
f�|��t���d��r|�t|j�d|_d|_dS)NTrz+%d+%dZWindowsF)r�	is_activerr4rZbboxr	�updateZwinfo_width�winfo_heightZwinfo_rootxr!�maxZwinfo_rootyrAZupdate_idletasks�platform�system�
startswith�unbindrRr)r�event�text�x�yZcxZcyrWZ	acw_widthZ
acw_heightZ
text_widthZtext_heightZnew_xZnew_yrrrrS�s0
z"AutoCompleteWindow.winconfig_eventcCsB|js
dSy|j��s|��Wntk
r<|��YnXdS)N)r	Z	focus_get�hide_window�KeyError)rrrr�_hide_event_checks
z$AutoCompleteWindow._hide_event_checkcCs>|��r:|jtjkr&|j�d|j�n|jtjkr:|��dS)Nr )	rZ�typeZ	EventTypeZFocusOutrZafterrhZButtonPressrf)rrbrrrrEs
zAutoCompleteWindow.hide_eventcCs4|��r0d|_t|j��d�}|�|j|�dS)NTr)rZrr2r
r3r(r)rrbr9rrrrQ(sz#AutoCompleteWindow.listselect_eventcCs.t|j��d�}|�|j|�|��dS)Nr)r2r
r3r(rrf)rrbr9rrrrU.sz$AutoCompleteWindow.doubleclick_eventcs |��sdS|j�t|d�r$|j}nd}�dkr6d|_t��dks`�dks`|jtk�rJ�dk�rJ|t@�sJt��dkr�|�	|j
��n|�dkr�|�	|j
d	�nb�d
kr�|�	|j
d�nH�dkr�|�	|j
d
�n.t|j
�dkr�|��dS|�	|j
dd��|j
|_|j
�dt|j
��d��|j
�|�|j
��|��dS�dk�rh|��|��dS|jtk�r~�dk�s�|jtk�r�dk�r|t@�st|j
��d�}|j|dt|j
��|j
k�r�|jtk�s�|j
�r�|�	|j|�|��dS�dk�r2|�s2d|_t|j
��d�}�dk�r:d}nĈdk�rTt|j�d}n��dk�r�|j
�|j
���|j
�d�}�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|�dS�dk�r�|�s�|j�rxt|j
��d�}|�	|j|�|��dSd|_d|_dSn�t�fdd�dD���r�dS|j�r|jdk�r|�	|j
|j�|j
|_|j
�dt|j
��d��|j
�|�|j
��|��dS|��dSdS) N�mc_staterZTabFr )�
underscoreZ	BackSpace)�period�minusrk�_rl�.rm�-����breakZReturn)rlZspaceZ	parenleftZ
parenrightZbracketleftZbracketright)ZslashZ	backslashZquotedblZ
apostrophe)�Home�End�Prior�Next�Up�DownTrsrt)rurvrurvrwrxc3s|]}|�kVqdS)Nr)�.0r*)�keysymrr�	<genexpr>�sz4AutoCompleteWindow.keypress_event.<locals>.<genexpr>)ZShiftZControlZAltZMetaZCommandZOption� )rZrz�hasattrrjrr"rrrr(rrfrr
Zselect_clearr2r3r7r-r8rVrrrZnearestr\r]�AssertionErrorr!�any�char)rrb�stater9ZnewselZjumpr)rzrrK4s�

 





z!AutoCompleteWindow.keypress_eventcCs@|��sdS|j�d�|j�d|jt|j�f�kr<|��dS)Nr$z%s+%dc)rZrr?rr"rrf)rrbrrrrN�s

z#AutoCompleteWindow.keyrelease_eventcCs
|jdk	S)N)r	)rrrrrZ�szAutoCompleteWindow.is_activecCs|�|�|j��dS)N)r(r/r)rrrrrV�szAutoCompleteWindow.completecCs(|��sdS|j�tt�xtD]}|j�t|�q W|j�t|j�|j�t|j	�d|_d|_	xt
D]}|j�t|�qhW|j�t|j�d|_|j�t
t�|j�t
|j�d|_|j�t|j�d|_|jr�|j�t|j�d|_|j��|j��d|_|j��d|_|j��d|_dS)N)rZr	Zevent_deleterDrHrIrrarFrGrLrJrrMrOrr
rPrrrRZ	focus_setrZdestroy)rrXrrrrf�s<





zAutoCompleteWindow.hide_windowN)�__name__�
__module__�__qualname__rr(r-r/r8rYrSrhrErQrUrKrNrZrVrfrrrrrs !

 &L%
tr�__main__)�mainz%idlelib.idle_test.test_autocomplete_wr)F)�	verbosity�exit)�__doc__r^ZtkinterZtkinter.ttkrZidlelib.autocompleterrZidlelib.multicallrrDrHrIrJrLrMrOrPrRrTrr�Zunittestr�rrrr�<module>s,G

Hacked By AnonymousFox1.0, Coded By AnonymousFox