Hacked By AnonymousFox

Current Path : /proc/thread-self/root/proc/self/root/opt/alt/python36/lib64/python3.6/idlelib/__pycache__/
Upload File :
Current File : //proc/thread-self/root/proc/self/root/opt/alt/python36/lib64/python3.6/idlelib/__pycache__/multicall.cpython-36.pyc

3

� f�H�@s&dZddlZddlZddlZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZdZdZdZdZdZdZdZdZdZdZdUZdVZdWZdXZdYZdZZ ej!dkr�d_Z"eeee fZ#nddZ"eeeefZ#e$d!d"�e%e&e"��D��Z'd#Z(Gd$d%�d%�Z)e%de&e"�>�Z*d&d"�e*D�Z+d'd(�Z,e,e*�Z-gZ.xNe*D]FZ/dZ0x0e%e&e"��D] Z1de1>e/@�r6e0e#e1OZ0�q6We.j2e0��q WGd)d*�d*�Z3d|Z4e3fde)fe&e4�dZ5e$dDd"�e%e&e4��D��Z6ej7dE�Z8ej7dF�Z9dGdH�Z:dIdJ�Z;iZ<dKdL�Z=dMdN�Z>e?dOk�r"ddPl@mAZAeAdQddRdS�ddTlBmCZCeCe>�dS)}a�
MultiCall - a class which inherits its methods from a Tkinter widget (Text, for
example), but enables multiple calls of functions per virtual event - all
matching events will be called, not only the most specific one. This is done
by wrapping the event functions - event_add, event_delete and event_info.
MultiCall recognizes only a subset of legal event sequences. Sequences which
are not recognized are treated by the original Tk handling mechanism. A
more-specific event will be called before a less-specific event.

The recognized sequences are complete one-event sequences (no emacs-style
Ctrl-X Ctrl-C, no shortcuts like <3>), for all types of events.
Key/Button Press/Release events can have modifiers.
The recognized modifiers are Shift, Control, Option and Command for Mac, and
Control, Alt, Shift, Meta/M for other platforms.

For all events which were handled by MultiCall, a new member is added to the
event instance passed to the binded functions - mc_type. This is one of the
event type constants defined in this module (such as MC_KEYPRESS).
For Key/Button events (which are handled by MultiCall and may receive
modifiers), another member is added - mc_state. This member gives the state
of the recognized modifiers, as a combination of the modifier constants
also defined in this module (for example, MC_SHIFT).
Using these members is absolutely portable.

The order by which events are called is defined by these rules:
1. A more-specific event will be called before a less-specific event.
2. A recently-binded event will be called before a previously-binded event,
   unless this conflicts with the first rule.
Each function will be called at most once for each event.
�N���������	�
���
����������darwin�Shift�Control�Option�Command�Alt�Meta�McCs"g|]}t|D]}||f�qqS�)�
_modifiers)�.0�number�namer r �6/opt/alt/python36/lib64/python3.6/idlelib/multicall.py�
<listcomp>7sr&zapplication has been destroyedc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�
_SimpleBindercCs8||_dt|dd|_||_||_g|_d|_dS)N�<r�>)�type�_types�sequence�widget�
widgetinst�bindedfuncs�	handlerid)�selfr*r-r.r r r%�__init__Jsz_SimpleBinder.__init__cCs>|js.|j|jfdd�}|jj|j|j|�|_|jj|�dS)NcSsT||_i}xDtt|�ddd�D],}||}||kr d||<||�}|r |Sq WdS)NrT���r3)�mc_type�range�len)�event�lr4�	wascalled�i�func�rr r r%�handlerTsz#_SimpleBinder.bind.<locals>.handler)r0r/r*r-�bindr.r,�append)r1�tripletr;r=r r r%r>Rs


z_SimpleBinder.bindcCs2|jj|�|js.|jj|j|j|j�d|_dS)N)r/�remover-�unbindr.r,r0)r1r@r;r r r%rBbsz_SimpleBinder.unbindcCsZ|jrVy|jj|j|j|j�Wn4tjk
rT}zt|jdkrD�WYdd}~XnXdS)Nr)	r0r-rBr.r,�tkinter�TclError�APPLICATION_GONE�args)r1�er r r%�__del__hsz_SimpleBinder.__del__N)�__name__�
__module__�__qualname__r2r>rBrHr r r r%r'Isr'cs(g|] �dj�fdd�tt�D���qS)�c3s*|]"\}}d|>�@r|ddVqdS)rr�-Nr )r"r:�m)�sr r%�	<genexpr>wsz<listcomp>.<genexpr>)�join�	enumerater!)r"r )rOr%r&wscsPdd�}g}x>|D]6�tt�fdd�|D���}|j|dd�|j|�qW|S)z�For each item of states return a list containing all combinations of
    that item with individual bits reset, sorted by the number of set bits.
    cSs(d}x|r"t|d�\}}||7}qW|S)znumber of bits set in n base 2rr)�divmod)�nZnbZremr r r%�nbits�s
zexpand_substates.<locals>.nbitsc3s|]}�|@VqdS)Nr )r"�x)�stater r%rP�sz#expand_substates.<locals>.<genexpr>T)�key�reverse)�list�set�sortr?)ZstatesrUZ	statelistZ	substatesr )rWr%�expand_substates|s
r]c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�_ComplexBindercCs||||j|jfdd�}|S)NcSs�dg|dd�<||_||_i}d}xZ|D]R}xFtt|�ddd�D].}	||	}
|
|krBd||
<||	|�}|rBPqBW|r(Pq(Wg|dd�<x|D]
}|�q�Wg|dd�<|r�|SdS)NTrr3r3)r4�mc_stater5r6)r7�listsr4r_�ishandlerrunning�doafterhandlerr9r<r8r:r;�fr r r%r=�s*


z0_ComplexBinder.__create_handler.<locals>.handler)rarb)r1r`r4r_r=r r r%Z__create_handler�s
z_ComplexBinder.__create_handlercs�|�_t|d�_|�_|�_ddd�tD�i�_g�_g�_g�_	xhtD]`}�fdd�t
|D�}�j||t|�}dt
|�jd}�jj|�jj�j||�f�qLWdS)NrcSsg|]}g�qSr r )r"rOr r r%r&�sz+_ComplexBinder.__init__.<locals>.<listcomp>csg|]}�jd|�qS)N)r/)r"r:)r1r r%r&�sr(r))r*r+�typenamer-r.�_statesr/�
handleridsrarb�_state_subsets�_ComplexBinder__create_handler�_state_codes�_state_namesr?r>)r1r*r-r.rOr`r=�seqr )r1r%r2�s
z_ComplexBinder.__init__cs��d�jkr�dd�tD��j�d<xrtD]j���fdd��ddfD�}�j|�jt��}dt��j�df}�jj|�j	j
�j||�f�q,W���fdd�}�js�|�n�j
j|�dS)NrcSsg|]}g�qSr r )r"rOr r r%r&�sz'_ComplexBinder.bind.<locals>.<listcomp>cs(g|] }t�D]}�j||�qqSr )rgr/)r"�detailr:)rOr1r r%r&�sz	<%s%s-%s>cs�j�d�dj��S)Nrr)r/r?r )r;r1r@r r%�<lambda>�sz%_ComplexBinder.bind.<locals>.<lambda>)r/rerhr*rirjrdrfr?r-r>r.rarb)r1r@r;r`r=rk�doitr )r;rOr1r@r%r>�s


z_ComplexBinder.bindcs.���fdd�}�js|�n�jj|�dS)Ncs�j�d�dj��S)Nrr)r/rAr )r;r1r@r r%rm�sz'_ComplexBinder.unbind.<locals>.<lambda>)rarbr?)r1r@r;rnr )r;r1r@r%rB�sz_ComplexBinder.unbindcCsdx^|jD]T\}}y|jj|j||�Wqtjk
rZ}zt|jdkrJ�WYdd}~XqXqWdS)Nr)rfr-rBr.rCrDrErF)r1rk�idrGr r r%rH�sz_ComplexBinder.__del__N)rIrJrKrhr2r>rBrHr r r r%r^�s
r^�KeyPress�Key�
KeyRelease�ButtonPress�Button�
ButtonRelease�Activate�	Circulate�Colormap�	Configure�
Deactivate�Destroy�Enter�Expose�FocusIn�FocusOut�Gravity�Leave�Map�Motion�
MouseWheel�Property�Reparent�Unmap�
VisibilitycCs"g|]}t|D]}||f�qqSr )r+)r"r#r$r r r%r&sz^\w+$z^[1-5]$cCs|s|ddks|ddkr"dS|dd�jd�}d}x.|rf|dtkrf|dt|d>O}|d=q:W|r�|dtkr�t|d}|d=ndSt|tkr�|s�|r�dSd}nP|dd�d
D�kr�t}nt}|s�d}n*t|�dko�|j|d��r�|d}ndS|||fS)a-Get a string which should describe an event sequence. If it is
    successfully parsed as one, return a tuple containing the state (as an int),
    the event type (as an index of _types), and the detail - None if none, or a
    string if there is one. If the parsing is unsuccessful, return None.
    rr(rr)NrMcSsg|]}t|�qSr )�_type_names)r"rOr r r%r&$sz#_parse_sequence.<locals>.<listcomp>rprrr3r3)rprr)	�split�_modifier_namesr��_binder_classesr'�
_keysym_re�
_button_rer6�match)r,ZwordsZ	modifiersr*rlZtype_rer r r%�_parse_sequences0

r�cCs`|dr8dt|dt|ddd|ddSdt|dt|dddSdS)Nrr(rrrMr))rjr+)r@r r r%�_triplet_to_sequence2s0r�cs0�tkrt�SG�fdd�d��}|t�<|S)z�Return a MultiCall class which inherits its methods from the
    given widget class (for example, Tkinter.Text). This is used
    instead of a templating mechanism.
    csreZdZe�ej�st��fdd�Zd�fdd�	Zd�fdd�	Z	�fdd	�Z
�fd
d�Zd�fdd
�	Zdd�Z
dS)z#MultiCallCreator.<locals>.MultiCallcs:�j�f|�|�i�_��fdd�ttt��D��_dS)Ncsg|]}t||����qSr )r�)r"r:)r1r-r r%r&Ksz@MultiCallCreator.<locals>.MultiCall.__init__.<locals>.<listcomp>)r2�_MultiCall__eventinfor5r6r+�_MultiCall__binders)r1rF�kwargs)r-)r1r%r2Esz,MultiCallCreator.<locals>.MultiCall.__init__Ncs�t|�tkr�t|�dkr�|dd�dkr�|dd�dkr�||jkr�|j|}|ddk	r�x*|dD]}|j|dj||d�qbW||d<|ddk	r�x6|dD]}|j|dj||�q�Wn|gg|j|<�j||||�S)Nrz<<z>>rr���)r*�strr6r�r�rBr>)r1r,r;�addZeir@)r-r r%r>Ns 

z(MultiCallCreator.<locals>.MultiCall.bindcs�t|�tkr�t|�dkr�|dd�dkr�|dd�dkr�||jkr�|j|\}}|dk	r�x"|D]}|j|dj||�q^Wd|j|d<�j|||�S)Nrz<<z>>rrr�)r*r�r6r�r�rB)r1r,Zfuncidr;�tripletsr@)r-r r%rB`s 

z*MultiCallCreator.<locals>.MultiCall.unbindcs�||jkrdgg|j|<|j|\}}xT|D]L}t|�}|dkrP�j|||�q,|dk	rn|j|dj||�|j|�q,WdS)Nr)r�r��	event_addr�r>r?)r1�virtual�	sequencesr;r�rkr@)r-r r%r�ks

z-MultiCallCreator.<locals>.MultiCall.event_addcsv||jkrdS|j|\}}xT|D]L}t|�}|dkrF�j|||�q"|dk	rd|j|dj||�|j|�q"WdS)Nr)r�r��event_deleter�rBrA)r1r�r�r;r�rkr@)r-r r%r�|s

z0MultiCallCreator.<locals>.MultiCall.event_deletecsF|dks||jkr�j||�Sttt|j|d���j||�SdS)Nr)r��
event_info�tuple�mapr�)r1r�)r-r r%r��s
z.MultiCallCreator.<locals>.MultiCall.event_infocSs�x~|jD]t}|j|\}}|rx\|D]T}y|j|dj||�Wq$tjk
rv}zt|jdkrf�WYdd}~Xq$Xq$WqWdS)Nrr)r�r�rBrCrDrErF)r1r�r;r�r@rGr r r%rH�s
z+MultiCallCreator.<locals>.MultiCall.__del__)NNN)N)N)rIrJrK�
issubclassrCZMisc�AssertionErrorr2r>rBr�r�r�rHr )r-r r%�	MultiCallBs	r�)�_multicall_dict)r-r�r )r-r%�MultiCallCreator:s
[r�cs�tj|�}|jd�tt|j�jd�dd��\}}|jd||df�ttj�|���j	�dgf�fdd�	}|d	�|d
�|d�|d�|d
�|d�|d�|d�|d�|d�|d�|d�dS)NzTest MultiCall�+rz+%d+%d�rcsH�fdd�}�jd|d|��jd|d��|dd7<dS)Ncst��dS)N)�print)r7)rkr r%r=�sz-_multi_call.<locals>.bindseq.<locals>.handlerz
<<handler%d>>rr)r>r�)rkrTr=)�text)rkr%�bindseq�sz_multi_call.<locals>.bindseqz<Key>z
<Control-Key>z<Alt-Key-a>z<Control-Key-a>z<Alt-Control-Key-a>z<Key-b>z<Control-Button-1>z
<Button-2>z<Alt-Button-1>z
<FocusOut>z<Enter>z<Leave>)
rCZToplevel�titler��intZgeometryr�r�ZTextZpack)�parent�toprV�yr�r )r�r%�_multi_call�s&

 r��__main__)�mainzidlelib.idle_test.test_mainmenuF)�	verbosity�exit)�runrrr	� �@��r�r�r�r)r�r�r�r��r�r�r�rr)r�r�r�r��rprq�rr�rsrt�ru�rv�rw�rx�ry�rz�r{�r|�r}�r~�r�r��r��r��r��r��r��r��r��r�)r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�)D�__doc__�re�sysrCZMC_KEYPRESSZ
MC_KEYRELEASEZMC_BUTTONPRESSZMC_BUTTONRELEASEZMC_ACTIVATEZMC_CIRCULATEZMC_COLORMAPZMC_CONFIGUREZ
MC_DEACTIVATEZ
MC_DESTROYZMC_ENTERZ	MC_EXPOSEZ
MC_FOCUSINZMC_FOCUSOUTZ
MC_GRAVITYZMC_LEAVEZMC_MAPZ	MC_MOTIONZ
MC_MOUSEWHEELZMC_PROPERTYZMC_REPARENTZMC_UNMAPZ
MC_VISIBILITYZMC_SHIFTZ
MC_CONTROLZMC_ALTZMC_METAZ	MC_OPTIONZ
MC_COMMAND�platformr!Z_modifier_masks�dictr5r6r�rEr'rerjr]rgrirOr<r:r?r^r+r�r��compiler�r�r�r�r�r�r�rIZunittestr�Zidlelib.idle_test.htestr�r r r r%�<module>s�

-
`

'g


Hacked By AnonymousFox1.0, Coded By AnonymousFox