Mini Shell

Direktori : /lib/python3.6/site-packages/orca/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/orca/__pycache__/keybindings.cpython-36.pyc

3

�2[�A�@s�dZdZdZdZdZdZddlmZddlZddl	Z	d	d
l
mZd	dl
mZd	dl
mZiZiZd
ZdZd	e	j>Zd	e	j>Zd	e>Zd	e>d	e	j>BZd	e>d	e	j>BZd	e>d	e	j>Bd	e	j>BZd	e>d	e	j>BZd	e	j>Zd	e	j>d	e	j>BZd	e	j>d	e	j>BZd	e	j>d	e	j>Bd	e	j >Bd	e	j!>BZ"d	e	j>d	e	j>Bd	e	j>Bd	e	j >Bd	e	j!>Bd	e>BZ#e#Z$dd�Z%dd�Z&dd�Z'Gdd�d�Z(Gdd�d�Z)dS)zLProvides support for defining keybindings and matching them to input
events.z$Id$z
$Revision$z$Date$z-Copyright (c) 2005-2008 Sun Microsystems Inc.ZLGPL�)�GdkN�)�debug)�settings)�_�cCs�|sdS|tkr�tjj�}tj|�}|dkr0dSdt|<|j|�\}}x<|D]4}|jdkrf|jt|<Pt|dkrL|djt|<qLWt|S)a�Converts an XKeysym string (e.g., 'KP_Enter') to a keycode that
    should match the event.hw_code for key events.

    This whole situation is caused by the fact that Solaris chooses
    to give us different keycodes for the same key, and the keypad
    is the primary place where this happens: if NumLock is not on,
    there is no telling the difference between keypad keys and the
    other navigation keys (e.g., arrows, page up/down, etc.).  One,
    for example, would expect to get KP_End for the '1' key on the
    keypad if NumLock were not on.  Instead, we get 'End' and the
    keycode for it matches the keycode for the other 'End' key.  Odd.
    If NumLock is on, we at least get KP_* keys.

    So...when setting up keybindings, we say we're interested in
    KeySyms, but those keysyms are carefully chosen so as to result
    in a keycode that matches the actual key on the keyboard.  This
    is why we use KP_1 instead of KP_End and so on in our keybindings.

    Arguments:
    - keysym: a string that is a valid representation of an XKeysym.

    Returns an integer representing a key code that should match the
    event.hw_code for key events.
    r)�
_keycodeCacherZKeymapZget_defaultZkeyval_from_nameZget_entries_for_keyval�group�keycode)�keysym�keymapZkeyval�successZentries�entry�r�!/usr/lib/python3.6/keybindings.py�
getKeycodeIs 




rcCs�d}|t@r<tjtjkr*|td�d7}qZ|td�d7}n|dtj>@rZ|td�d7}|d@rr|td�d7}|dtj>@r�|td�d7}|dtj>@r�|td	�d7}|t	@r�|td
�d7}|t
@r�|td�d7}|t@r�|td�d7}|S)
zYGets the modifier names of a numeric modifier mask as a human
    consumable string.
    �ZInsert�+Z	Caps_Lockr�ZAlt_RZSuperZMeta2ZAlt_LZCtrlZShift)�ORCA_MODIFIER_MASKrZkeyboardLayoutZGENERAL_KEYBOARD_LAYOUT_DESKTOPr�pyatspiZMODIFIER_SHIFTLOCK�MODIFIER_META3�MODIFIER_META2�ALT_MODIFIER_MASK�CTRL_MODIFIER_MASK�SHIFT_MODIFIER_MASK)�mods�textrrr�getModifierNames�s(rcCs$|dkrtd�S|dkr td�SdS)zsReturns a human-consumable string representing the number of
    clicks, such as 'double click' and 'triple click'.�zdouble click�ztriple clickr)r)�countrrr�getClickCountString�s
r"c@s2eZdZdZddd�Zdd�Zdd�Zd	d
�ZdS)
�
KeyBindingzcA single key binding, consisting of a keycode, a modifier mask,
    and the InputEventHandler.
    rcCs(||_||_||_||_||_d|_dS)aeCreates a new key binding.

        Arguments:
        - keysymstring: the keysymstring - this is typically a string
          from /usr/include/X11/keysymdef.h with the preceding 'XK_'
          removed (e.g., XK_KP_Enter becomes the string 'KP_Enter').
        - modifier_mask: bit mask where a set bit tells us what modifiers
          we care about (see pyatspi.MODIFIER_*)
        - modifiers: the state the modifiers we care about must be in for
          this key binding to match an input event (see also
          pyatspi.MODIFIER_*)
        - handler: the InputEventHandler for this key binding
        N)�keysymstring�
modifier_mask�	modifiers�handler�click_countr
)�selfr$r%r&r'r(rrr�__init__�szKeyBinding.__init__cCs8|jst|j�|_|j|kr0||j@}||jkSdSdS)z_Returns true if this key binding matches the given keycode and
        modifier state.
        FN)r
rr$r%r&)r)r
r&�resultrrr�matches�s	


zKeyBinding.matchesc	Csy|jjSdSdS)z8Returns the description of this binding's functionality.rN)r'�description)r)rrrr-�szKeyBinding.descriptioncCs0t|j�}t|j�}|j}d|||f}|j�S)zAReturns a more human-consumable string representing this binding.z%s%s %s)rr&r"r(r$�strip)r)r�
clickCountr�stringrrr�asStrings


zKeyBinding.asStringN)r)�__name__�
__module__�__qualname__�__doc__r*r,r-r1rrrrr#�s

r#c@sdeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
d�Z	ddd�Z
dd�Zdd�Zdd�Z
dS)�KeyBindingsz<Structure that maintains a set of KeyBinding instances.
    cCs
g|_dS)N)�keyBindings)r)rrrr*szKeyBindings.__init__cCsBd}x0|jD]&}|d|j|j|j|j|jjf7}qW|d7}|S)Nz[
z  [%x %x %s %d %s]
�])r7r%r&r$r(r'r-)r)r+�
keyBindingrrr�__str__szKeyBindings.__str__cCs|jj|�dS)zGAdds the given KeyBinding instance to this set of keybindings.
        N)r7�append)r)r9rrr�addszKeyBindings.addc	Cs*y|jj|�}WnYn
X|j|=dS)zLRemoves the given KeyBinding instance from this set of keybindings.
        N)r7�index)r)r9�irrr�remove%s
zKeyBindings.removecCsDt|j�}x4|dkr>|j|dj|kr4|j|d=|d}qWdS)zLRemoves the given KeyBinding instance from this set of keybindings.
        rrN)�lenr7r')r)r'r>rrr�removeByHandler0s


zKeyBindings.removeByHandler�strictcCs�d}x�|jD]�}|dkr^|jj|jjkr�|j|jkr�|j|jkr�|j|jkr�|j|jkr�d}q|dkr||jj|jjkr�d}q|dkr�|j|jkr�|j|jkr�|j|jkr�|j|jkr�d}q|dkr|j|jkr|j|jkr|j|jkrd}qW|S)a�Return True if keyBinding is already in self.keyBindings.

           The typeOfSearch can be:
              "strict":      matches description, modifiers, key, and
                             click count
              "description": matches only description.
              "keys":        matches the modifiers, key, and modifier mask,
                             and click count
              "keysNoMask":  matches the modifiers, key, and click count
        FrBTr-�keysZ
keysNoMask)r7r'r-r$r%r&r()r)Z
newKeyBindingZtypeOfSearchZhasItr9rrr�
hasKeyBinding9sJ

zKeyBindings.hasKeyBindingFcsDdd�|jD��|r@dd��D�}�fdd�t|jt|��D���S)z�Returns the KeyBinding instances which are bound to a keystroke.

        Arguments:
        - uniqueOnly: Should alternative bindings for the same handler be
          filtered out (default: False)
        cSsg|]}|jr|�qSr)r$)�.0�kbrrr�
<listcomp>usz0KeyBindings.getBoundBindings.<locals>.<listcomp>cSsg|]}|jj�qSr)r'r-)rErFrrrrGwscsg|]}�|�qSrr)rEr>)�boundrrrGxs)r7�mapr=�set)r)Z
uniqueOnly�handlersr)rHr�getBoundBindingsms
zKeyBindings.getBoundBindingscs�fdd�|jD�S)z9Returns the KeyBinding instances associated with handler.csg|]}|j�kr|�qSr)r')rErF)r'rrrGsz5KeyBindings.getBindingsForHandler.<locals>.<listcomp>)r7)r)r'r)r'r�getBindingsForHandler|sz!KeyBindings.getBindingsForHandlercCs�g}|j�}xJ|jD]@}|j|j|j�r|j|jkrD|j|krD|jS|jr|j	|�qW|jdt
j>@rx|jj
d�rxdSdd�}|jtj|�d�x|D]}|j|kr�|jSq�WdS)z�Returns the input handler of the key binding that matches the
        given keycode and modifiers, or None if no match exists.
        rZKPNcSs|j|jS)N)r()�x�yrrr�<lambda>�sz-KeyBindings.getInputHandler.<locals>.<lambda>)�key)Z
getClickCountr7r,Zhw_coder&r%r(r'r$r;rZMODIFIER_NUMLOCKZkeyval_name�
startswith�sort�	functools�
cmp_to_key)r)Z
keyboardEventZ
candidatesr/r9Z
comparison�	candidaterrr�getInputHandler�s&



zKeyBindings.getInputHandlerc	Cs�x�|D]x}|d}|d}|d}|d}y|d}Wnd}YnX||krl|jt||||||��qtjtjd|�qWdS)a4 Takes the keymappings and tries to find a matching named
           function in handlers.
           keymap is a list of lists, each list contains 5 elements
           If addUnbound is set to true, then at the end of loading all the
           keybindings, any remaining functions will be unbound.
        rrrr �z@WARNING: could not find %s handler to associate with keybinding.N)r<r#rZprintlnZ
LEVEL_WARNING)	r)rrKr>r$ZmodifierMaskr&r'r/rrr�load�s 	

zKeyBindings.loadN)rB)F)r2r3r4r5r*r:r<r?rArDrLrMrWrYrrrrr6s	
4
#r6)*r5Z__id__�__version__Z__date__Z
__copyright__Z__license__Z
gi.repositoryrrTrrrrZ	orca_i18nrZ
_keysymsCacherZ
MODIFIER_ORCAZNO_MODIFIER_MASKZMODIFIER_ALTrZMODIFIER_CONTROLrrZORCA_ALT_MODIFIER_MASKZORCA_CTRL_MODIFIER_MASKZORCA_CTRL_ALT_MODIFIER_MASKZMODIFIER_SHIFTZORCA_SHIFT_MODIFIER_MASKrZSHIFT_ALT_MODIFIER_MASKZCTRL_ALT_MODIFIER_MASKrrZCOMMAND_MODIFIER_MASKZNON_LOCKING_MODIFIER_MASKZdefaultModifierMaskrrr"r#r6rrrr�<module>sR


0
98@