403Webshell
Server IP : 93.86.61.54  /  Your IP : 216.73.216.60
Web Server : Apache/2.4.62 (Ubuntu)
System : Linux rasin.ddns.net 6.8.0-124-generic #124~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 21:05:19 UTC x86_64
User : www-data ( 33)
PHP Version : 8.4.22
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3/dist-packages/orca/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3/dist-packages/orca/__pycache__/script_utilities.cpython-310.pyc
o

S�b&�@s>dZdZdZdZdZdZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlmZdd	lmZd
dlmZd
dlmZd
d
lmZd
dlmZd
dlmZd
dlmZd
dlmZd
dlmZd
dlmZd
dlmZd
dlmZd
dlmZd
dlmZd
dlmZd
dlm Z e�!�Z"Gdd�d�Z#dS)z�Commonly-required utility methods needed by -- and potentially
   customized by -- application and toolkit scripts. They have
   been pulled out from the scripts because certain scripts had
   gotten way too large as a result of including these methods.z$Id$z
$Revision$z$Date$z#Copyright (c) 2010 Joanmarie Diggs.�LGPL�N)�Gdk��Gtk�)�chnames)�
colornames)�debug)�keynames)�keybindings)�input_event)�mathsymbols)�messages)�orca)�
orca_state)�object_properties)�pronunciation_dict)�settings)�settings_manager)�text_attribute_namesc@s�eZdZej�d�Ze��ZdZ	dZ
gd�Zgd�Ze
jZe
�de�Ze
�dd�e�e�Ze
�dd�e�e�Ze
�d	e�Zd
ZdZdZd
ZdZdZdd�Zdd�Zedd��Z�dYdd�Z dd�Z!edd��Z"�dZdd�Z#d d!�Z$d"d#�Z%d$d%�Z&d&d'�Z'd(d)�Z(d*d+�Z)d,d-�Z*d.d/�Z+�dZd0d1�Z,d2d3�Z-d4d5�Z.�d[d7d8�Z/d9d:�Z0ed;d<��Z1d=d>�Z2d?d@�Z3dAdB�Z4dCdD�Z5�d[dEdF�Z6�d[dGdH�Z7dIdJ�Z8dKdL�Z9dMdN�Z:dOdP�Z;dQdR�Z<dSdT�Z=dUdV�Z>dWdX�Z?dYdZ�Z@d[d\�ZAd]d^�ZBd_d`�ZCdadb�ZDdcdd�ZEdedf�ZFdgdh�ZGdidj�ZHdkdl�ZIdmdn�ZJdodp�ZKdqdr�ZLdsdt�ZMdudv�ZNdwdx�ZOdydz�ZPd{d|�ZQd}d~�ZRdd��ZSd�d��ZTd�d��ZUd�d��ZVd�d��ZWd�d��ZXd�d��ZYd�d��ZZd�d��Z[d�d��Z\d�d��Z]d�d��Z^d�d��Z_d�d��Z`d�d��Zad�d��Zbd�d��Zcd�d��Zdd�d��Zed�d��Zfd�d��Zgd�d��Zhd�d��Zid�d��Zjd�d��Zkd�d��Zld�d��Zmd�d��Znd�d��Zod�d��Zpd�d��Zqd�d��Zrd�d��Zsd�d„Ztd�dĄZud�dƄZvd�dȄZwd�dʄZxd�d̄Zyd�d΄Zzd�dЄZ{d�d҄Z|d�dԄZ}d�dքZ~d�d؄Z�d[d�dڄZ�d�d܄Z�d�dބZ�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d��Z�d�d��Z�d�d��Z�d�d��Z�d�d��Z�d��d�Z��d�d�Z��d�d�Z��d�d�Z��d�d�Z��d	�d
�Z��d�d�Z��d
�d�Z��d�d�Z��d�d�Z��d�d�Z��d�d�Z��d�d�Z��d[�d�d�Z��d�d�Z��d�d�Z��d�d �Z��d!�d"�Z��d#�d$�Z��d%�d&�Z��d'�d(�Z��d)�d*�Z��d[�d+�d,�Z��d[�d-�d.�Z��d/�d0�Z��d1�d2�Z��d3�d4�Z��d5�d6�Z��d7�d8�Z��d9�d:�Z��d;�d<�Z��d=�d>�Z��d?�d@�Z��dA�dB�Z��dC�dD�Z��dE�dF�Z��dG�dH�Z��dI�dJ�Z��dK�dL�Z��dM�dN�Z��dY�dO�dP�Z��dQ�dR�Z��dS�dT�Z��dU�dV�Z��dW�dX�Z��dY�dZ�Z�e�d[�d\��Z��d]�d^�Zd_�d`�ZÐda�db�ZĐdc�dd�ZŐde�df�ZƐd\�dg�dh�Zǐdi�dj�Z�e�dk�dl��Zɐdm�dn�Zʐdo�dp�Z�e�dq�dr��Z�e�ds�dt��Z͐du�dv�Zΐdw�dx�Zϐd[�dy�dz�ZАd{�d|�Zѐd}�d~�ZҐd�d��ZӐd��d��ZԐd��d��ZՐd[�d��d��Z�e�d��d���Zאd��d��Zؐd��d��Zِd��d��Zڐd��d��Zېd��d��Zܐd��d��Zݐd��d��Zސd��d��Zߐd��d��Z�d[�d��d��Z�e�d]�d��d���Z�e�d��d���Z�e�d��d���Z�e�d��d���Z�d��d��Z�d��d��Z�d��d��Z�d��d��Z�d^�d��d��Z�d_�d��d��Z�d��d��Z�d��d��Z�d��d��Z�d��d��Z�e�d��d���Z�d��d��Z�d��d��Z�d��d��Z�e�ddÄ�Z�dĐdńZ��dƐdDŽZ��dȐdɄZ��dʐd˄Z��d`�d͐d΄Z��dϐdЄZ��dѐd҄Z��dӐdԄZ��dՐdքZ��d[�dאd؄Z��dِdڄZ��dېd܄�Z�dݐdބ�Z�dߐd��Z�d�d��Z�d�d��Z�d[�d�d��Z�d�d��Z�d�d��Z�d�d��Z�d�d��Z	�d`�d�d��Z
�da�d�d��Z�d�d��Z�d��d���Z
�d��d���Z�d`�d��d���Z�d��d���Z�dZ�d��d���Z�d��d��Z�d�d��Z�d�d��Ze�d�d���Ze�d�d���Z�d	�d
��Z�d�d��Z�d
�d��Z�d�d��Ze�d�d���Ze�db�d�d���Z�d�d��Z�d�d��Z�d�d��Z�d�d��Z �d[�d�d��Z!�d �d!��Z"�d"�d#��Z#e�d$�d%���Z$e�d&�d'���Z%e�d(�d)���Z&e�d*�d+���Z'�d,�d-��Z(e�d.�d/���Z)�d0�d1��Z*e�d2�d3���Z+�dc�d4�d5��Z,�dd�d6�d7��Z-�de�d8�d9��Z.�de�d:�d;��Z/�d<�d=��Z0�d>�d?��Z1�d@�dA��Z2�dB�dC��Z3�dD�dE��Z4�dF�dG��Z5�dH�dI��Z6�dJ�dK��Z7�dL�dM��Z8�dN�dO��Z9�dP�dQ��Z:�d[�dR�dS��Z;�d[�dT�dU��Z<�dV�dW��Z=�dX�dY��Z>�dZ�d[��Z?�d\�d]��Z@�d^�d_��ZA�d`�da��ZB�db�dc��ZC�dd�de��ZD�df�dg��ZE�dh�di��ZF�dj�dk��ZG�dl�dm��ZH�dn�do��ZI�dp�dq��ZJ�dr�ds��ZK�dt�du��ZL�dv�dw��ZM�dx�dy��ZN�dz�d{��ZO�d|�d}��ZP�d~�d��ZQ�d��d���ZR�d��d���ZS�d��d���ZT�d��d���ZU�d��d���ZV�d��d���ZW�dZ�d��d���ZX�d��d���ZY�dZ�d��d���ZZ�d��d���Z[�d��d���Z\�df�d��d���Z]�d��d���Z^�d��d���Z_�d��d���Z`�d[�d��d���Za�d[�d��d���Zb�d��d���Zc�d��d���Zd�d[�d��d���Ze�d[�d��d���Zf�d^�d��d���Zg�d��d���Zh�d��d���Zi�d��d���Zj�dY�d��d���Zk�dY�d��d���Zl�d��d���Zm�d��d���Zn�d��d���Zo�d��d���Zp�d��d���Zq�d��d„�Zr�dÐdĄ�Zs�dŐdƄ�Zt�dǐdȄ�Zu�dɐdʄ�Zv�dːd̄�Zw�dY�d͐d΄�Zx�dϐdЄ�Zy�dѐd҄�Zze�dӐdԄ��Z{�dՐdք�Z|�dאd؄�Z}�dِdڄ�Z~�dېd܄�Z�dݐdބ�Z��dg�d�d��Z��d�d��Z��d�d��Z��d�d��Z��d�d��Z��d�d��Z��d�d��Z��d�d��Z��d�d��Z��d�d��Z��d�d���Z��d��d���Z��d��d���Z��d��d���Z��d��d���Z��d��d���Z��d�d��Z��d�d��Z��d�d��Z��d�d��Z��d�d	��Z��d
�d��Z��d�d
��Z��d�d��Z��d�d��Z��d�d��Z��d�d��Z��d�d��Z��d�d��Z��d�d��Z��d�d��Z��dh�d�d ��Z��d!�d"��Z��d#�d$��Z��d%�d&��Z��d'�d(��Z��d)�d*��Z��d+�d,��Z��d-�d.��Z��d/�d0��Z��d1�d2��Z��d3�d4��Z��d5�d6��Z��d7�d8��Z��d[�d9�d:��Z��d;�d<��Z��d=�d>��Z��d?�d@��Z��dA�dB��Z��dC�dD��Z��dE�dF��Z��dG�dH��Z��dI�dJ��Z��dK�dL��Z��dZ�dM�dN��Z��dO�dP��Z��dQ�dR��Z��dZ�dS�dT��Z��dU�dV��Z��dW�dX��Z�d6S(i�	Utilitiesruu)
u⁰�¹�²�³u⁴u⁵u⁶u⁷u⁸u⁹)
u₀u₁u₂u₃u₄u₅u₆u₇u₈u₉z(\W+)z[%s]+�z[^\w\s]�displayedDescription�displayedLabel�
displayedText�
keyBinding�nestingLevel�	nodeLevelcCs||_d|_i|_dS)z�Creates an instance of the Utilities class.

        Arguments:
        - script: the script with which this instance is associated.
        N)�_script�_clipboardHandlerId�_selectedMenuBarMenu)�self�script�r&�7/usr/lib/python3/dist-packages/orca/script_utilities.py�__init___s
zUtilities.__init__cCs�z|��}Wnd|}t�tj|d�YdS|�tj�s-d|}t�tj|d�dS|�tj�rAd|}t�tj|d�dS|�tj�sUd|}t�tj|d�dSdS)N�$ERROR: Exception getting state of %sTFzINFO: %s lacks state activezINFO: %s has state iconifiedzINFO: %s lacks state showing)	�getStater	�println�
LEVEL_INFO�contains�pyatspi�STATE_ACTIVE�STATE_ICONIFIED�
STATE_SHOWING�r$�obj�state�msgr&r&r'�"_isActiveAndShowingAndNotIconifiedps&z,Utilities._isActiveAndShowingAndNotIconifiedcCsf|sdSz|��}Wnd|}t�tj|d�YdSz	t�d|�}WnYdS|�dd�S)Nrz:ERROR: Exception getting process id of %s. May be defunct.Tzcat /proc/%s/cmdline�� )�get_process_idr	r+r,�
subprocess�	getoutput�replace)�app�pidr5�cmdliner&r&r'�_getAppCommandLine�szUtilities._getAppCommandLineFcCs�|sdSz|��}Wnd}Yd|||�|�f}t�tj|d�|r)|��|�|�s<d|}t�tj|d�dSd|}t�tj|d�dS)NFzINFO: Looking at %s from %s %sTz3INFO: %s is not active and showing, or is iconifiedzINFO: %s can be active window)�getApplicationr@r	r+r,�
clearCacher6)r$�windowrBr=r5r&r&r'�canBeActiveWindow�s"
zUtilities.canBeActiveWindowc	sg}|p���}|D]!}z|��fdd�|D��Wq
d|}t�tj|d�Yq
|sAdttt|��}t�tj|d�dSt|�dkrYd|d	}t�tj|d�|d	St	|t
��j�d
�}dttt|��}t�tj|d�d|d	}t�tj|d�|d	S)
z:Tries to locate the active window; may or may not succeed.c�g|]	}��|�r|�qSr&�rD��.0�child�r$r&r'�
<listcomp>��z*Utilities.activeWindow.<locals>.<listcomp>z)ERROR: Exception examining children of %sTz+ERROR: Unable to find active window from %sNrzINFO: Active window is %sr��keyz1WARNING: These windows all claim to be active: %sz%INFO: Active window is (hopefully) %s)
�knownApplications�extendr	r+r,�list�map�str�len�sorted�	functools�
cmp_to_key�sizeComparison)r$�apps�
candidatesr=r5r&rJr'�activeWindow�s,zUtilities.activeWindowcCs�|sdSt|gj�s
|g}t|gj�s|g}d}|j}|rI||jkrIz|��}WnY|S||vr8|}	|S||vr?	|S|j}|rI||jks"|S)acReturns the object of the specified roles which contains the
        given object, or None if the given object is not contained within
        an object the specified roles.

        Arguments:
        - obj: the Accessible object
        - ancestorRoles: the list of roles to look for
        - stopRoles: the list of roles to stop the search at
        N)�
isinstance�	__class__�parent�getRole)r3�
ancestorRoles�	stopRoles�ancestor�roler&r&r'�ancestorWithRole�s0	����
zUtilities.ancestorWithRoleTcCs.ztdd�|��D��}W|Si}Y|S)NcS�g|]}|�dd��qS��:r��split�rH�attrr&r&r'rK�z.Utilities.objectAttributes.<locals>.<listcomp>)�dict�
getAttributes)r$r3�useCache�rvr&r&r'�objectAttributes�s�zUtilities.objectAttributescsD��|�}|�d�}|rt|�S�fdd�}t�||�p|}|��S)aReturns the index of the cell which should be used with the
        table interface.  This is necessary because in some apps we
        cannot count on getIndexInParent() returning the index we need.

        Arguments:
        -obj: the table cell whose index we need.
        ztable-cell-indexcs|o	|�����vS�N)r_�getCellRoles��xrJr&r'�<lambda>�z%Utilities.cellIndex.<locals>.<lambda>)rq�get�intr.�findAncestor�getIndexInParent)r$r3�attrs�index�isCellr&rJr'�	cellIndexs
	
zUtilities.cellIndexcCsbz|j��}WngYS|���tj�sgSg}|��}z.|D])}|��tjkrKt	|�
��D]}|�|�}|rE|��dkrE|�
|�q1|WSq"WnY|�|�}|�|�}	|�|�}
|�|�}d}t	|	d|j�D]>}
|�|
|
�}|s{qp|��}|D]'}|��tjkr�|�d�}|�||�r�|�
|�n|�|�}||kr�d}nq�|r�|Sqp|S)z�Gets all of the children that have RELATION_NODE_CHILD_OF pointing
        to this expanded table cell.

        Arguments:
        -obj: the Accessible Object

        Returns: a list of all the child nodes
        ���FrrT)r^�
queryTabler*r-r.�STATE_EXPANDED�getRelationSet�getRelationType�RELATION_NODE_PARENT_OF�range�getNTargets�	getTargetr{�appendr�
getRowAtIndex�getColumnAtIndexr �nRows�getAccessibleAt�RELATION_NODE_CHILD_OF�isSameObject)r$r3�table�nodes�	relations�relation�target�noder}�row�colr �done�i�cell�nodeOf�currentLevelr&r&r'�
childNodessd
�

�
��



�

�
�zUtilities.childNodesc
Cs\d||f}t�tj|d�|r|sdS||kr|S|g}z|j}|r7|j|kr7|�|�|j}|r7|j|ks(|��Wn
t�tj�Y|g}z|j}|rd|j|krd|�|�|j}|rd|j|ksU|��Wn
t�tj�Yd}tt	|�t	|��}d}	|	|kr�|�
||	||	�r�||	}|	d7}	nn|	|ks�d|||f}t�tj|d�|S)z�Finds the common ancestor between Accessible a and Accessible b.

        Arguments:
        - a: Accessible
        - b: Accessible
        z.INFO: Looking for common ancestor of %s and %sTNrrz(INFO: Common ancestor of %s and %s is %s)r	r+r,r^r��reverse�printException�LEVEL_FINEST�minrTr�)
r$�a�br5�aParentsr^�bParents�commonAncestor�	maxSearchr�r&r&r'r�]sL
�
�
�zUtilities.commonAncestorcCs�tjtjtjg}|���tj�s|��|vrdSd}t|j	ddd�D].}||��tj
kr=||���tj�r=||}n||��|vrL|�||�}|rQ|Sq#|S)z�Returns the default button in the dialog which contains obj.

        Arguments:
        - obj: the top-level object (e.g. window, frame, dialog) for
          which the status bar is sought.
        Nrr�)
r.�	ROLE_TREE�ROLE_TREE_TABLE�
ROLE_TABLEr*r-�STATE_MANAGES_DESCENDANTSr_r��
childCount�ROLE_PUSH_BUTTON�STATE_IS_DEFAULT�
defaultButton)r$r3�	skipRolesr�r�r&r&r'r��s(
��
�zUtilities.defaultButtoncCs�z
|jj|j|WS|j|jjvri|jj|j<d}Y|�|�}|D]}|�||�|��}q&||jj|j|<|jj|j|S)aXIf there is an object labelling the given object, return the
        text being displayed for the object labelling this object.
        Otherwise, return None.

        Argument:
        - obj: the object in question

        Returns the string of the object labelling this object, or None
        if there is nothing of interest here.
        N)r!�generatorCache�DISPLAYED_LABEL�labelsForObject�appendStringr)r$r3�labelString�labels�labelr&r&r'r�s
�zUtilities.displayedLabelcC�dS�NFr&�r$r3r&r&r'�preferDescriptionOverName��z#Utilities.preferDescriptionOverNamec	Cs`z|��}Wnttfyd|}t�tj|d�gYSwdd�}t||�}dd�|D�S)z(Return a list of objects describing obj.�+ERROR: Exception getting relationset for %sTcS�|��tjkSrr)r�r.�RELATION_DESCRIBED_BYrtr&r&r'rv��z1Utilities.descriptionsForObject.<locals>.<lambda>cS�(g|]}t|���D]}|�|��q
qSr&�r�r�r��rH�rr�r&r&r'rK��(z3Utilities.descriptionsForObject.<locals>.<listcomp>)r��LookupError�RuntimeErrorr	r+r,�filter)r$r3r�r5�describedByr�r&r&r'�descriptionsForObject�s�
zUtilities.descriptionsForObjectcCs|�|�}tt|j|��Srr)�detailsForObjectrQrRr)r$r3�detailsr&r&r'�detailsContentForObject�s
z!Utilities.detailsContentForObjectc	Cs�z|��}|��}|��}Wnttfy'd|}t�tj|d�gYSwdd�}t||�}dd�|D�}	|	sL|t	j
krL|�t	j�rLdd�|D�}	|sP|	Sg}
|	D]}|
�
|�||j��qT|
S)z4Return a list of objects containing details for obj.z<ERROR: Exception getting relationset, role, and state for %sTcSr�rr)r�r.�RELATION_DETAILSrtr&r&r'rv�r�z,Utilities.detailsForObject.<locals>.<lambda>cSr�r&r�r�r&r&r'rK�r�z.Utilities.detailsForObject.<locals>.<listcomp>cS�g|]}|�qSr&r&rGr&r&r'rK��)r�r_r*r�r�r	r+r,r�r.�ROLE_TOGGLE_BUTTONr-r�rP�findAllDescendants�queryNonEmptyText)r$r3�textOnlyr�rcr4r5�
hasDetailsr�r��textObjects�detailr&r&r'r��s(�
zUtilities.detailsForObjectcCsvz
|jj|j|WS|j|jjvri|jj|j<Yd�t|j|�|���}||jj|j|<|jj|j|S)z?Returns the text being displayed for the object describing obj.r8)r!r��DISPLAYED_DESCRIPTION�joinrRrr��r$r3�stringr&r&r'r�s�zUtilities.displayedDescriptionc	Csfz
|jj|j|WSd}Yz	|��}|j}Wnd|}t�tj|d�d}d}Y|tj	tj
fvr;|r;|Sdt�|�vrT|��}|�
d|j�}|j|vrTd}|so|tjtjfvroz|j}WnttfynYnw|s�|tj	tjfvr�|j|dd�}|s�|j|d	dd
�}d�t|j|��}|j|jjvr�i|jj|j<||jj|j|<|jj|j|S)z�Returns the text being displayed for an object.

        Arguments:
        - obj: the object

        Returns the text being displayed for an object or None if there isn't
        any text being shown.
        Nz,ERROR: Exception getting role and name of %sTr�Textrr)�minimumWordsF)�onlyShowingr�r8)r!r��DISPLAYED_TEXTr_�namer	r+r,r.r��
ROLE_LABEL�listInterfaces�	queryText�getText�characterCount�EMBEDDED_OBJECT_CHARACTER�ROLE_COMBO_BOX�ROLE_SPIN_BUTTONr�r��ROLE_LIST_ITEM�unrelatedLabelsr�rRr)r$r3rrcr�r5�textr�r&r&r'rsD



�zUtilities.displayedTextNcCsh|s|��\}}tjtjtjtjtjtjg}tjtj	g}|�
|||�}|s2tjr2tj�
�|vr2tjS|S)zyReturns the document frame which is displaying the content.
        Note that this is intended primarily for web content.)�getCaretContextr.�ROLE_DOCUMENT_EMAIL�ROLE_DOCUMENT_FRAME�ROLE_DOCUMENT_PRESENTATION�ROLE_DOCUMENT_SPREADSHEET�ROLE_DOCUMENT_TEXT�ROLE_DOCUMENT_WEB�
ROLE_FRAME�ROLE_SCROLL_PANErdr�locusOfFocusr_)r$r3�offset�docRolesra�documentr&r&r'�
documentFrameCs�
zUtilities.documentFramecCr�)z5Returns the URI of the document frame that is active.Nr&rJr&r&r'�documentFrameURIWszUtilities.documentFrameURIcCsP|sdS|���tj�r|S|D]}zt�|�}|r|WSWqYqdS)a*Returns the accessible that has focus under or including the
        given root.

        TODO: This will currently traverse all children, whether they are
        visible or not and/or whether they are children of parents that
        manage their descendants.  At some point, this method should be
        optimized to take such things into account.

        Arguments:
        - root: the root object where to start searching

        Returns the object with the FOCUSED state or None if no object with
        the FOCUSED state can be found.
        N)r*r-r.�
STATE_FOCUSEDr�
focusedObject)�rootrI�	candidater&r&r'r�\s

�zUtilities.focusedObjectcCs�ddg}|ptj}|sd}t�tj|d�|S|��tjkr"||d<|j}|rO|j|krO|��tjkr7||d<|��tj	tj
fvrE||d<|j}|rO|j|ks,|S)z;Returns the frame and (possibly) the dialog containing obj.Nz3ERROR: frameAndDialog() called without valid objectTrr)rr�r	r+r,r_r.r�r^�ROLE_DIALOG�ROLE_FILE_CHOOSER)r$r3�resultsr5r^r&r&r'�frameAndDialog}s&

��zUtilities.frameAndDialogcCs|jtjkrdSdS�NTF)�sourcerr��r$�eventr&r&r'� presentEventFromNonShowingObject�sz*Utilities.presentEventFromNonShowingObjectcCs(|r|��tjkr|�|tj�sdSdS)ayWhether or not we should perform a grabFocus before routing
        the cursor via the braille cursor routing keys.

        Arguments:
        - obj: the accessible object where the cursor should be routed
        - offset: the offset to which it should be routed

        Returns True if we should do an explicit grabFocus on obj prior
        to routing the cursor.
        TF)r_r.r�r�rr��r$r3r�r&r&r'�grabFocusBeforeRouting�s
�z Utilities.grabFocusBeforeRoutingcCsz|}|D]6}|dur
dSt|t�s|g}zt|dt�r"|��}n|��}Wnd}Y||vr5dS|�|�}qdS)a�Called to determine if the given object and it's hierarchy of
        parent objects, each have the desired roles. Please note: You
        should strongly consider an alternative means for determining
        that a given object is the desired item. Failing that, you should
        include only enough of the hierarchy to make the determination.
        If the developer of the application you are providing access to
        does so much as add an Adjustment to reposition a widget, this
        method can fail. You have been warned.

        Arguments:
        - obj: the accessible object to check.
        - rolesList: the list of desired roles for the components and the
          hierarchy of its parents.

        Returns True if all roles match.
        NFrT)r\rQrS�getRoleNamer_�validParent)r$r3�	rolesList�currentrc�current_roler&r&r'�hasMatchingHierarchy�s"

�zUtilities.hasMatchingHierarchycCsN|stj}z|��}WnYdS|tjkrdSdd�}t�||�}|duS)NFcS�|o|��tjkSrr)r_r.�
ROLE_TOOL_BARrtr&r&r'rv��z+Utilities.inFindContainer.<locals>.<lambda>)rr�r_r.�
ROLE_ENTRYrz)r$r3rc�	isToolbar�toolbarr&r&r'�inFindContainer�s
zUtilities.inFindContainercCr��Nrr&�r$r�r&r&r'�getFindResultsCount�r�zUtilities.getFindResultsCountcCr�r�r&r�r&r&r'�isAnchor�r�zUtilities.isAnchorcCr�r�r&r�r&r&r'�isCode�r�zUtilities.isCodecCr�r�r&r�r&r&r'�isCodeDescendant�r�zUtilities.isCodeDescendantcCsXz|��}Wnd|}t�tj|d�YdS|tjkr dS|�|�}|�d�dkS)N�#ERROR: Exception getting role of %sTFz
is-desktop�true)r_r	r+r,r.r�rqrx)r$r3rcr5r|r&r&r'�	isDesktop�s

zUtilities.isDesktopcCr�r�r&r�r&r&r'�isComboBoxWithToggleDescendantr�z(Utilities.isComboBoxWithToggleDescendantcCr�r�r&r�r&r&r'�isToggleDescendantOfComboBoxr�z&Utilities.isToggleDescendantOfComboBoxcCr�r�r&r�r&r&r'�isTypeaheadr�zUtilities.isTypeaheadcs |�krdSt�|�fdd��S)NTcs|o|�kSrrr&rt�rbr&r'rv�z,Utilities.isOrDescendsFrom.<locals>.<lambda>�r.rz�r$r3rbr&r#r'�isOrDescendsFromszUtilities.isOrDescendsFromcCr�)z�Returns True if the window is a functioning as a dialog.
        This method should be subclassed by application scripts as
        needed.
        Fr&r�r&r&r'�isFunctionalDialogszUtilities.isFunctionalDialogcCr�r�r&r�r&r&r'�	isCommentr�zUtilities.isCommentcCr�r�r&r�r&r&r'�isContentDeletionr�zUtilities.isContentDeletioncCr�r�r&r�r&r&r'�isContentErrorr�zUtilities.isContentErrorcCr�r�r&r�r&r&r'�isContentInsertion"r�zUtilities.isContentInsertioncCr�r�r&r�r&r&r'�isContentMarked%r�zUtilities.isContentMarkedcCr�r�r&r�r&r&r'�isContentSuggestion(r�zUtilities.isContentSuggestioncCr�r�r&r�r&r&r'�isInlineSuggestion+r�zUtilities.isInlineSuggestioncCr�r�r&r�r&r&r'�$isFirstItemInInlineContentSuggestion.r�z.Utilities.isFirstItemInInlineContentSuggestioncCr�r�r&r�r&r&r'�#isLastItemInInlineContentSuggestion1r�z-Utilities.isLastItemInInlineContentSuggestioncCr�r�r&r�r&r&r'�isEmpty4r�zUtilities.isEmptycCr�r�r&r�r&r&r'�isHidden7r�zUtilities.isHiddencCr�r�r&r�r&r&r'�isDPub:r�zUtilities.isDPubcCr�r�r&r�r&r&r'�isDPubAbstract=r�zUtilities.isDPubAbstractcCr�r�r&r�r&r&r'�isDPubAcknowledgments@r�zUtilities.isDPubAcknowledgmentscCr�r�r&r�r&r&r'�isDPubAfterwordCr�zUtilities.isDPubAfterwordcCr�r�r&r�r&r&r'�isDPubAppendixFr�zUtilities.isDPubAppendixcCr�r�r&r�r&r&r'�isDPubBibliographyIr�zUtilities.isDPubBibliographycCr�r�r&r�r&r&r'�isDPubBacklinkLr�zUtilities.isDPubBacklinkcCr�r�r&r�r&r&r'�isDPubBibliorefOr�zUtilities.isDPubBibliorefcCr�r�r&r�r&r&r'�
isDPubChapterRr�zUtilities.isDPubChaptercCr�r�r&r�r&r&r'�isDPubColophonUr�zUtilities.isDPubColophoncCr�r�r&r�r&r&r'�isDPubConclusionXr�zUtilities.isDPubConclusioncCr�r�r&r�r&r&r'�isDPubCover[r�zUtilities.isDPubCovercCr�r�r&r�r&r&r'�isDPubCredit^r�zUtilities.isDPubCreditcCr�r�r&r�r&r&r'�
isDPubCreditsar�zUtilities.isDPubCreditscCr�r�r&r�r&r&r'�isDPubDedicationdr�zUtilities.isDPubDedicationcCr�r�r&r�r&r&r'�
isDPubEndnotegr�zUtilities.isDPubEndnotecCr�r�r&r�r&r&r'�isDPubEndnotesjr�zUtilities.isDPubEndnotescCr�r�r&r�r&r&r'�isDPubEpigraphmr�zUtilities.isDPubEpigraphcCr�r�r&r�r&r&r'�isDPubEpiloguepr�zUtilities.isDPubEpiloguecCr�r�r&r�r&r&r'�isDPubErratasr�zUtilities.isDPubErratacCr�r�r&r�r&r&r'�
isDPubExamplevr�zUtilities.isDPubExamplecCr�r�r&r�r&r&r'�isDPubFootnoteyr�zUtilities.isDPubFootnotecCr�r�r&r�r&r&r'�isDPubForeword|r�zUtilities.isDPubForewordcCr�r�r&r�r&r&r'�isDPubGlossaryr�zUtilities.isDPubGlossarycCr�r�r&r�r&r&r'�isDPubGlossref�r�zUtilities.isDPubGlossrefcCr�r�r&r�r&r&r'�isDPubIndex�r�zUtilities.isDPubIndexcCr�r�r&r�r&r&r'�isDPubIntroduction�r�zUtilities.isDPubIntroductioncCr�r�r&r�r&r&r'�isDPubPagelist�r�zUtilities.isDPubPagelistcCr�r�r&r�r&r&r'�isDPubPagebreak�r�zUtilities.isDPubPagebreakcCr�r�r&r�r&r&r'�
isDPubPart�r�zUtilities.isDPubPartcCr�r�r&r�r&r&r'�
isDPubPreface�r�zUtilities.isDPubPrefacecCr�r�r&r�r&r&r'�isDPubPrologue�r�zUtilities.isDPubProloguecCr�r�r&r�r&r&r'�isDPubPullquote�r�zUtilities.isDPubPullquotecCr�r�r&r�r&r&r'�	isDPubQna�r�zUtilities.isDPubQnacCr�r�r&r�r&r&r'�isDPubSubtitle�r�zUtilities.isDPubSubtitlecCr�r�r&r�r&r&r'�	isDPubToc�r�zUtilities.isDPubToccCr�r�r&r�r&r&r'�isFeed�r�zUtilities.isFeedcCr�r�r&r�r&r&r'�isFigure�r�zUtilities.isFigurecCr�r�r&r�r&r&r'�isGrid�r�zUtilities.isGridcCr�r�r&r�r&r&r'�
isGridCell�r�zUtilities.isGridCellcCr�r�r&rJr&r&r'�supportsLandmarkRole�r�zUtilities.supportsLandmarkRolecCr�r�r&r�r&r&r'�
isLandmark�r�zUtilities.isLandmarkcCr�r�r&r�r&r&r'�isLandmarkWithoutType�r�zUtilities.isLandmarkWithoutTypecCr�r�r&r�r&r&r'�isLandmarkBanner�r�zUtilities.isLandmarkBannercCr�r�r&r�r&r&r'�isLandmarkComplementary�r�z!Utilities.isLandmarkComplementarycCr�r�r&r�r&r&r'�isLandmarkContentInfo�r�zUtilities.isLandmarkContentInfocCr�r�r&r�r&r&r'�isLandmarkForm�r�zUtilities.isLandmarkFormcCr�r�r&r�r&r&r'�isLandmarkMain�r�zUtilities.isLandmarkMaincCr�r�r&r�r&r&r'�isLandmarkNavigation�r�zUtilities.isLandmarkNavigationcCr�r�r&r�r&r&r'�
isDPubNoteref�r�zUtilities.isDPubNoterefcCr�r�r&r�r&r&r'�isLandmarkRegion�r�zUtilities.isLandmarkRegioncCr�r�r&r�r&r&r'�isLandmarkSearch�r�zUtilities.isLandmarkSearchcCr�r�r&r�r&r&r'�speakMathSymbolNames�r�zUtilities.speakMathSymbolNamescCr�r�r&rJr&r&r'�isInMath�r�zUtilities.isInMathcCr�r�r&r�r&r&r'�isMath�r�zUtilities.isMathcCr�r�r&r�r&r&r'�isMathLayoutOnly�r�zUtilities.isMathLayoutOnlycCr�r�r&r�r&r&r'�isMathMultiline�r�zUtilities.isMathMultilinecCr�r�r&r�r&r&r'�isMathEnclosed�r�zUtilities.isMathEnclosedcCr�r�r&r�r&r&r'�isMathFenced�r�zUtilities.isMathFencedcCr�r�r&r�r&r&r'�isMathFractionWithoutBar�r�z"Utilities.isMathFractionWithoutBarcCr�r�r&r�r&r&r'�
isMathPhantom�r�zUtilities.isMathPhantomcCr�r�r&r�r&r&r'�isMathMultiScript�r�zUtilities.isMathMultiScriptcCr�r�r&r�r&r&r'�isMathSubOrSuperScript�r�z Utilities.isMathSubOrSuperScriptcCr�r�r&r�r&r&r'�isMathUnderOrOverScript�r�z!Utilities.isMathUnderOrOverScriptcCr�r�r&r�r&r&r'�isMathSquareRoot�r�zUtilities.isMathSquareRootcCr�r�r&r�r&r&r'�isMathTable�r�zUtilities.isMathTablecCr�r�r&r�r&r&r'�isMathTableRowr�zUtilities.isMathTableRowcCr�r�r&r�r&r&r'�isMathTableCellr�zUtilities.isMathTableCellcCr�r�r&r�r&r&r'�isMathTokenr�zUtilities.isMathTokencCr�r�r&r�r&r&r'�isMathTopLevel	r�zUtilities.isMathTopLevelcC�dSrrr&r�r&r&r'�getMathDenominatorr�zUtilities.getMathDenominatorcCrzrrr&r�r&r&r'�getMathNumeratorr�zUtilities.getMathNumeratorcCrzrrr&r�r&r&r'�getMathRootBaser�zUtilities.getMathRootBasecCrzrrr&r�r&r&r'�getMathRootIndexr�zUtilities.getMathRootIndexcCrzrrr&r�r&r&r'�getMathScriptBaser�zUtilities.getMathScriptBasecCrzrrr&r�r&r&r'�getMathScriptSubscriptr�z Utilities.getMathScriptSubscriptcCrzrrr&r�r&r&r'�getMathScriptSuperscriptr�z"Utilities.getMathScriptSuperscriptcCrzrrr&r�r&r&r'�getMathScriptUnderscript!r�z"Utilities.getMathScriptUnderscriptcCrzrrr&r�r&r&r'�getMathScriptOverscript$r�z!Utilities.getMathScriptOverscriptcC�gSrrr&r�r&r&r'�getMathPrescripts'r�zUtilities.getMathPrescriptscCr�rrr&r�r&r&r'�getMathPostscripts*r�zUtilities.getMathPostscriptscCr�rrr&r�r&r&r'�getMathEnclosures-r�zUtilities.getMathEnclosurescCsdgSrr&r�r&r&r'�getMathFencedSeparators0�z!Utilities.getMathFencedSeparatorscCsddgSrr&r�r&r&r'�
getMathFences3�zUtilities.getMathFencescCr��Nrr&)r$r3�testr&r&r'�getMathNestingLevel6r�zUtilities.getMathNestingLevelcCsgd�S)N)�banner�
complementary�contentinfozdoc-acknowledgmentsz
doc-afterwordzdoc-appendixzdoc-bibliographyzdoc-chapterzdoc-conclusionzdoc-creditszdoc-endnoteszdoc-epiloguez
doc-erratazdoc-forewordzdoc-glossaryz	doc-indexzdoc-introductionzdoc-pagelistzdoc-partzdoc-prefacezdoc-prologuezdoc-toc�form�main�
navigation�region�searchr&rJr&r&r'�getLandmarkTypes9r�zUtilities.getLandmarkTypescCs�|r	|��tjksdSz|��}Wn'ty'd|}t�tj|d�YdSd|}t�tj|d�YdSz|j|j	krOd|}t�tj|d�WdSWdSd|}t�tj|d�YdS)NF�&ERROR: %s doesn't implement AtspiValueT�%ERROR: Exception getting value for %szINFO: %s is busy indicatorz+INFO: %s is either busy indicator or broken)
r_r.�ROLE_PROGRESS_BAR�
queryValue�NotImplementedErrorr	r+r,�maximumValue�minimumValue)r$r3�valuer5r&r&r'�
isProgressBarVs.�	�zUtilities.isProgressBarcCs�t�d�st�d�st�d�sdS|�|�sdS|�|�rdSt�d�r0dd	�}t�||�r0d
St�d�}|tjkr<dS|tjkrV|�	|�}|t
jkrMd
Sdd|t
jffS|tjkrw|ra|j
}n|��}|t
jjkrmdSdd|t
jjffSdS)N�speakProgressBarUpdates�brailleProgressBarUpdates�beepProgressBarUpdates)FzUpdates not enabled)FzIs not progress bar)FzHas no size�ignoreStatusBarProgressBarscSrrr�r_r.�ROLE_STATUS_BARrtr&r&r'rv~rz/Utilities.isProgressBarUpdate.<locals>.<lambda>)FzIs status bar descendant�progressBarVerbosity)TzVerbosity is all)TzVerbosity is windowFzWindow %s is not %s)TzVerbosity is appzApp %s is not %s)TzNot handled by any other case)�_settingsManager�
getSettingr��	hasNoSizer.rzr�PROGRESS_BAR_ALL�PROGRESS_BAR_WINDOW�topLevelObjectrr[�PROGRESS_BAR_APPLICATION�host_applicationrA�activeScriptr=)r$r3r�isStatusBar�	verbosity�topLevelr=r&r&r'�isProgressBarUpdateqs<
��








zUtilities.isProgressBarUpdatecCs�z|��}|j|j|j}}}Wn'ty'd|}t�tj|d�YdSd|}t�tj|d�YdS|���	t
j�rUd||f}t�tj|d�|dkrUdS||kr_|krsnnd|krndkrqt|�SdSdSt|||d�S)Nr�Tr�z0INFO: %s has state indeterminate and value of %srr�d)
r�r��currentValuer�r�r	r+r,r*r-r.�STATE_INDETERMINATEry)r$r3r��minval�val�maxvalr5r&r&r'�getValueAsPercent�s,�zUtilities.getValueAsPercentcCs|o|��tjkSrr)r_r.�ROLE_BLOCK_QUOTEr�r&r&r'�isBlockquote�szUtilities.isBlockquotecC�R|r	|��tjksdSzt�||j�}W|duSd|}t�tj|�YdS�NF�'ERROR: Exception finding ancestor of %s)r_r.�	ROLE_LISTrz�
isDocumentr	r+r,�r$r3r�r5r&r&r'�isDocumentList���zUtilities.isDocumentListcCr�r�)r_r.�
ROLE_PANELrzr�r	r+r,r�r&r&r'�isDocumentPanel�r�zUtilities.isDocumentPanelcCs,tjtjtjtjtjtjg}|o|��|vSrr)r.r�r�r�r�r�r�r_)r$r3�
documentRolesr&r&r'r��s�zUtilities.isDocumentcCs|ptj}|�|�duSrr)rr��getDocumentForObjectr�r&r&r'�inDocumentContent�s
zUtilities.inDocumentContentcCs|�tj�Srr)�getTopLevelDocumentForObjectrr�)r$rCr&r&r'�activeDocument��zUtilities.activeDocumentcCs|�|�ot�||j�Srr)r�r.rzr�r&r&r'�isTopLevelDocument�szUtilities.isTopLevelDocumentcCs|�|�r|St�||j�Srr)r�r.rzr�r&r&r'r��s
z&Utilities.getTopLevelDocumentForObjectcCsP|sdS|�|�r|Sz
t�||j�}W|Sd|}t�tj|d�YdS)Nr�T)r�r.rzr	r+r,)r$r3�docr5r&r&r'r��s
�zUtilities.getDocumentForObjectcsh|sdStjtjtjg��fdd�}||�r|Sz	t�||�}W|Sd|}t�tj|d�YdS)Ncs|o|���vodt�|�vS�N�Table)r_r.r�rt��
tableRolesr&r'rv��z$Utilities.getTable.<locals>.<lambda>r�T)r.r�r�r�rzr	r+r,)r$r3�isTabler�r5r&r�r'�getTable�s�zUtilities.getTablecCs6|r	|��tjksdS|�|�}|sdS|��tjkSr�)r_r.r�r�r�)r$r3r�r&r&r'�isTextDocumentTable	s
zUtilities.isTextDocumentTablecCs$|r	|��tjksdS|�|�duSr�)r_r.r�r�r�r&r&r'�
isGUITableszUtilities.isGUITablecCs�|sdSz|��}Wnd|}t�tj|d�YdS|tjks$dS|�|�}|s-dS|��tjkr6dSz|��}Wn't	yRd|}t�tj|d�YdSd|}t�tj|d�YdS|j
dkS)NFrT�2ERROR: Table %s does not implement table interface�/ERROR: Exception querying table interface of %si)r_r	r+r,r.r�r�r�r�r�r�)r$r3rcr5r�r�r&r&r'�isSpreadSheetTables4

�
�zUtilities.isSpreadSheetTablecCstjtjtjtjtjgSrr)r.�ROLE_TABLE_CELL�ROLE_TABLE_COLUMN_HEADER�ROLE_TABLE_ROW_HEADER�ROLE_COLUMN_HEADER�ROLE_ROW_HEADERrJr&r&r'rs;s�zUtilities.getCellRolescC�X|sdSz|��}Wnd|}t�tj|d�YdS||��vr%dSt�||j�S�NFrT)r_r	r+r,rsr.rzr��r$r3rcr5r&r&r'�isTextDocumentCellB�zUtilities.isTextDocumentCellcCr�r�)r_r	r+r,rsr.rzr�r�r&r&r'�isSpreadSheetCellRr�zUtilities.isSpreadSheetCellcCs0|�|�\}}|dkr
dS|jj�d�}||kS)Nr�F�
lastColumn��coordinatesForCellr!�pointOfReferencerx)r$r�r��columnr�r&r&r'�cellColumnChangedb�
zUtilities.cellColumnChangedcCs0|�|�\}}|dkr
dS|jj�d�}||kS)Nr�F�lastRowr�)r$r�r�r�r�r&r&r'�cellRowChangedjr�zUtilities.cellRowChangedcCs`|j��rdS|�|�sdS|�|�}|sdS|�|�s!t�d�S|�|�r+t�d�St�d�S)NF�readFullRowInGUITable�readFullRowInSpreadSheet�readFullRowInDocumentTable)r!�inSayAllr�r�r�r�r�r�)r$r3r�r&r&r'�shouldReadFullRowrs







zUtilities.shouldReadFullRowcCr�r�r&r�r&r&r'�isSorted�r�zUtilities.isSortedcCr�r�r&r�r&r&r'�isAscending�r�zUtilities.isAscendingcCr�r�r&r�r&r&r'�isDescending�r�zUtilities.isDescendingcCsX|r|�|�s	dS|�|�rtj}n|�|�rtj}ntj}|r*|jr*d|j|f}|S)Nrz%s. %s)r�r�r�SORT_ORDER_ASCENDINGr��SORT_ORDER_DESCENDING�SORT_ORDER_OTHERr�)r$r3�includeName�resultr&r&r'�getSortOrderDescription�s


z!Utilities.getSortOrderDescriptioncCslz
|��}|��}WnYdS|tjkrdS|�tj�r dS|�tj�r4d|}t�tj	|d�dSdS)NFT�-INFO: %s is focused but lacks state focusable)
r_r*r.r�r-�STATE_FOCUSABLEr�r	r+r,�r$r3rcr4r5r&r&r'�isFocusableLabel��
zUtilities.isFocusableLabelcCslz
|��}|��}WnYdS|tjkrdS|�tj�r dS|�tj�r4d|}t�tj	|d�dSdS)NFr�T)
r_r*r.r�r-r�r�r	r+r,rr&r&r'�isNonFocusableList�rzUtilities.isNonFocusableListcCs2|r	|��tjksdSdd�}t�||�rdSdS)NFcSrrrr�rtr&r&r'rv�rz3Utilities.isStatusBarNotification.<locals>.<lambda>T)r_r.�ROLE_NOTIFICATIONrz�r$r3r�r&r&r'�isStatusBarNotification�sz!Utilities.isStatusBarNotificationcCsL|sdSz|��}WnYdS|tjkrdSdd�}t�||�r$dSdS)NFTcS�|o|��tjtjfvSrr)r_r.r�r�rtr&r&r'rv�rlz,Utilities.isTreeDescendant.<locals>.<lambda>)r_r.�ROLE_TREE_ITEMrz)r$r3rc�isTreer&r&r'�isTreeDescendant�s
zUtilities.isTreeDescendantcCsHd}|�|�s|�|�rdS|�|�}z|��}Wnd}Yz|j��}Wnd}Yz|d}Wnd}Y|��}tjtjtj	tj
g}|tjkr�|�d�dkr�z|�
�}	Wn+tysd|}
t�tj|
d�d}Y�n�d|}
t�tj|
d�d}Y�n�|	jr�|	js�|���tj�}�n{|�d	�d
ks�|�d�d
kr�d}�ni|js�|�|�s�|	�d�p�|	�d�}�nT|tjkr�|jr�|tjkr�d}�nC|��tjkr�d}�n8|tjkr�|�|j�}�n+|tjkr�|� |�}�n|tj!kr�d}�n|tj"k�rd}�n|tj#k�rd}�n|tj$k�r!|�%|�&|��}n�|tj'k�r*d}n�|tj(tj)fv�r6d}n�|tj*tjfv�rBd}n�||v�rJd}n�|tjk�rV|tj+k}n�|tj+k�r_d}n�|tj,k�rhd}n�|tj-k�rqd}n�|tj.tj/fv�r}d}n�|tj0tj1tj2fv�r�d}n�|tj	k�r�|tj*k�r�d}ny|tj3tj4fv�r�d}nm|�5|��r�|��}|�tj6��p�|�tj7�}nT|tj8k�r�|j�r�|�r�|��|v�r�d}n=|tj8k�r�|j|�9�jk�r�d}n+|jdk�r�|j�r�|j|jk�r�d}n|�:|��rd}n|�;|��s|�|��sd}|�r"d
|}
t�tj|
d�|S)z�Returns True if the given object is a container which has
        no presentable information (label, name, displayed text, etc.).FTNrzlayout-guessrr�r�z	xml-rolesr��tagrz$INFO: %s is deemed to be layout only)<�isDead�isZombierqr_r^�_topLevelRolesr.�	ROLE_MENU�ROLE_MENU_ITEMr�rr�rxr�r�r	r+r,r��nColumnsr*r-r�r�r�getColumnHeader�getRowHeaderr�r�r��isLayoutOnly�ROLE_SECTIONr�r��ROLE_FILLERr��ROLE_LAYERED_PANErr��ROLE_AUTOCOMPLETE�ROLE_TEAROFF_MENU_ITEM�ROLE_SEPARATOR�
ROLE_LIST_BOXr�r��	ROLE_FORMr�r��	ROLE_TEXT�ROLE_PASSWORD_TEXTr�ROLE_REDUNDANT_OBJECT�ROLE_UNKNOWN�
isTableRowr��STATE_SELECTABLEr�rAr3r)r$r3�
layoutOnlyr|rc�
parentRole�
firstChild�
topLevelRoles�ignorePanelParentr�r5r4r&r&r'r�s�
�

�

�



�"zUtilities.isLayoutOnlycCs |rtjsdStj��|��kS)z�Returns True if the given object is from the same application that
        currently has keyboard focus.

        Arguments:
        - obj: an Accessible object
        F)rr�rA�r3r&r&r'�
isInActiveAppTs
	zUtilities.isInActiveAppc	CsP|sdSz|��}Wnttfy"d|}t�tj|d�YdSw|tjkS)zReturns True if obj is a link.F�$ERROR: Exception getting role for %sT)r_r�r�r	r+r,r.�	ROLE_LINKr�r&r&r'�isLinkbs�
zUtilities.isLinkcCs4|�|�sdS|��}|�tj�o|�tj�}|S)z;Returns True if obj is a text entry area that is read only.F)�
isTextArear*r-r.r��STATE_EDITABLE)r$r3r4�readOnlyr&r&r'�isReadOnlyTextAreaqs
�zUtilities.isReadOnlyTextAreacCr�r�r&r�r&r&r'�isSwitch|r�zUtilities.isSwitchcCsB|jj}d}|D]}|dkrqz||}WqY|S|}|S�Nr�)r!r=)r$�path�startrp�pr&r&r'�getObjectFromPaths�zUtilities.getObjectFromPathcCs�tj�|�}tj�|�}t|�t|�krdS|dd�}|dd�}|�d�r.|�d�r.dSz|�d�}WntySz|�d�}Wn
tyPt|�}YnwYnw|d|�|d|�kS)NFrr�r)r.�utils�getPathrT�countr}�
ValueError)r$�obj1�obj2�path1�path2r}r&r&r'�_hasSamePath�s&���zUtilities._hasSamePathcCs�||krdS|r
|sdSz[|��|��krWdS|j|jkr#|s#WdS|r.|�||�r.WdS|���tj�}|���tj�}||krEWdS|jdkr\|jdkr_|j	dkrb|j
dkreWdSWdSWdSWdSWdSYdS)NTFr)r_r�r?�queryComponent�
getExtentsr.�DESKTOP_COORDSru�y�width�height)r$r;r<�comparePaths�ignoreNames�extents1�extents2r&r&r'r��s>��
�����zUtilities.isSameObjectcCs*|�|�rdS|o|��tjtjtjfvS)z{Returns True if obj is a GUI component that is for entering text.

        Arguments:
        - obj: an accessible
        F)r,r_r.rr�ROLE_PARAGRAPHr�r&r&r'r-�s
�zUtilities.isTextAreacCsdd�tjD�S)znRetrieves the list of currently running apps for the desktop
        as a list of Accessible objects.
        cSsg|]}|dur|�qSrrr&�rHrur&r&r'rK�rlz/Utilities.knownApplications.<locals>.<listcomp>)r�_desktopr&r&r&r'rO�szUtilities.knownApplicationsc	s�z���}Wnttfyd�}t�tj|d�gYSwdd�}tt|�����}|s1gS|d�t�fdd�t	��
��D��}�|vrYd�}t�tj|d�|����fd	d
�}tt||��S)z,Return a list of the labels for this object.r�TcSr�rr)r�r.�RELATION_LABELLED_BY�r�r&r&r'rv�r�z+Utilities.labelsForObject.<locals>.<lambda>rc�g|]}��|��qSr&�r��rHr�rNr&r'rK��z-Utilities.labelsForObject.<locals>.<listcomp>z+WARNING: %s claims to be labelled by itselfcst���fdd��S)Nc�|�kSrrr&rt��accr&r'rv��zBUtilities.labelsForObject.<locals>.isNotAncestor.<locals>.<lambda>r%rTr(rTr'�
isNotAncestor�sz0Utilities.labelsForObject.<locals>.isNotAncestor)r�r�r�r	r+r,rQr��setr�r��remove)r$r3r�r5�predr�rWr&)r3r�r'r��s&�
zUtilities.labelsForObjectcCsD|�|�}|s	dSt�dd|�}|��}|D]	}|��sdSq|S)Nrz[-_]r8)�linkBasename�re�subri�isalpha)r$r3�basename�tokens�tokenr&r&r'�linkBasenameToName�s
�zUtilities.linkBasenameToNamecCsNd}z|��}WnY|S|�d�}|r�t|�r�|�d�}t|�dkrM|D]%}|�d�dkrL|d��s<|dd�}|d��sH|dd�}|}nq'|�d�d}|sX|S|ddkrm|dd�}|�d�d}|S|�d�sv|}|S|�d�d}|�d	�r�|�d�d}|�d
�d}|�d�d}|�d�d}|�d
�d}|S)z�Returns the relevant information from the URI.  The idea is
        to attempt to strip off all prefix and suffix, much like the
        basename command in a shell.Nr�,rz://r�����/r}�.�?�#�%)�queryHyperlink�getURIrTri�find�isalnumr9�
startswith)r3r_�	hyperlink�uri�
expression�itemr&r&r'r[
sJ/
�
�
�
�
zUtilities.linkBasenamecCs�|sdSz|��Wn
tyYdSwz|��}Wn
ty%YdSwt|���D]}|�|�}||jkrA||jkrA|Sq,dS)a�A brute force method to see if an offset is a link.  This
        is provided because not all Accessible Hypertext implementations
        properly support the getLinkIndex method.  Returns an index of
        0 or greater of the characterIndex is on a hyperlink.

        Arguments:
        -obj: the object with the Accessible Hypertext specialization
        -characterIndex: the text position to check
        r�)r�r��queryHypertextr��	getNLinks�getLink�
startIndex�endIndex)r3�characterIndex�	hypertextr��linkr&r&r'�	linkIndexFs&��


�zUtilities.linkIndexcs�|sdSz
�jj�j|WS�j�jjvr i�jj�j<Y��|�r-�fdd�}n|��tjkr9dd�}n
|����fdd�}g}t�||�}|rZ|�|�t�||�}|sMt	|�}|�jj�j|<�jj�j|S)zmDetermines the nesting level of this object.

        Arguments:
        -obj: the Accessible object
        rcs
��|�Srr)r�rtrJr&r'rvxs
z(Utilities.nestingLevel.<locals>.<lambda>cSs|o|jo|j��tjkSrr)r^r_r.r�rtr&r&r'rvzrLcs|o|���kSrr�r_rt)rcr&r'rv}r�)
r!r��
NESTING_LEVELr�r_r.r�rzr�rT)r$r3rZ�	ancestorsrbrr&)rcr$r'rgs.�


�zUtilities.nestingLevelc	CsX|�|�sdSz
|jj|j|WS|j|jjvr#i|jj|j<Yg}|}d}|s�z|��}WnttfyJd|}t�tj	|d�YdSwd}|D]}|�
�tjkr_|�
d�}nqO|�|�rud||f}t�tj	|d�d}t|�dkr�d	|}t�tj	|d�d}n
|r�|�|�nd}|r,t|�d
|jj|j|<|jj|j|S)z�Determines the node level of this object if it is in a tree
        relation, with 0 being the top level node.  If this object is
        not in a tree relation, then -1 will be returned.

        Arguments:
        -obj: the Accessible object
        r�Fr�TNrz0ERROR: %s is already in the list of nodes for %sr�z&INFO: More than 100 nodes found for %sr)r
r!r��
NODE_LEVELr�r�r�r	r+r,r�r.r�r�r9rTr�)r$r3r�r�r�r�r5r�r&r&r'r �sR
	���
�
�zUtilities.nodeLevelcCs�|�|�rdS|�|�rdS|�|�s!d|}t�tj|d�dSz
|���tj	�}Wnd|}t�tj|d�YdSd||f}t�tj|d�|j
dksV|jdkrdd|}t�tj|d�dS|j
dkr�|jdkr�t|�d	kr�d
|}t�tj|d�dS|j
s�|js�|js�d|}t�tj|d�dS|��tjkr�d|}t�tj|d�dSdS|dus�|�|j�s�dS|�||�s�t|�d	kr�d
|||f}t�tj|d�dSdS)NFz#INFO: %s is not showing and visibleT�'ERROR: Exception getting extents for %szINFO: Extents for %s are: %si'z(INFO: %s seems to have bogus coordinatesr)r�r�r�r�z!INFO: %s has negative coordinatesz$INFO: %s has no size and no childrenzINFO: %s has no sizezINFO: %s %s not in %s)rr3�isShowingAndVisibler	r+r,r@rAr.rBrurC�tuplerDrEr�r_r�_boundsIncludeChildrenr^�containsRegion)r$r3�boundingboxr5�boxr&r&r'�
isOnScreen�sR


 zUtilities.isOnScreenc	Cs�z|��}Wnd|}t�tj|d�YdS|tjkr dSdt�|�vr4|�|�}|r2|dSdS|D].}z
|��|�	�}Wnd|}t�tj|d�Yq6|�
tj�s`|�
tj�rd|Sq6dS)NrT�	Selectionrr))
r_r	r+r,r.�
ROLE_MENU_BARr��selectedChildrenrBr*r-r��STATE_SELECTED)r$�menubarrcr5�selected�menur4r&r&r'�selectedMenuBarMenu�s6


��zUtilities.selectedMenuBarMenucsz|sdSdd�}t�||�}|durdS|j�t|����dur%|�|���s)dS�fdd�}||�r5dSt�||�duS)NFcSrrr)r_r.r�rtr&r&r'rvrz/Utilities.isInOpenMenuBarMenu.<locals>.<lambda>crSrrr&rt��selectedMenur&r'rv%rVT)r.rzr#rx�hashr�)r$r3�	isMenuBarr��inSelectedMenur&r�r'�isInOpenMenuBarMenus
zUtilities.isInOpenMenuBarMenucCr�r�r&r�r&r&r'�isStaticTextLeaf+r�zUtilities.isStaticTextLeafcCr�r�r&r�r&r&r'�isListItemMarker.r�zUtilities.isListItemMarkercCs8|�|�rdS|�|�}|sdStt�d|�dd���S)NFz\w+rr�)r�r��boolr\r�r�)r$r3r�r&r&r'�hasPresentableText1s

zUtilities.hasPresentableTextc	Csz|�||�sgSz|��}Wnd|}t�tj|d�gYS|tjkr)gS|tjkr1|gS|tjkr9|gS|tj	krA|gS|tj
krP|�|�|jt
|�<|jrc|j��tj
krc|�|�sc|gS|tjkr�|js�d|}t�tj|d�|��d||jf}t�tj|d�|dur�z|��}|�tj�}Wnd|}t�tj|d�d}Yt�|�}d|vr�d|vr�|�|�}|r�|Sg}|jp�|j}	|tjtjfvr�|	r�|�|�n
|�|�r�|�|�|D]}
|�|
�s�|�|� |
|��q�|tj
k�rd|jt
|�<|�r
|S|tj!k�r|j�s|�"|��sgStj#tjtjtj$tj%tj&tj'tj(tj)g	}||v�r:|	�s:gS|gS)	NrTz)INFO: %s is empty filler. Clearing cache.zINFO: %s reports %i children�&ERROR: Exception getting extents of %s�rrrrr�r�)*r�r_r	r+r,r.�ROLE_INVALIDr�r�r�r�r�r#r�r^r�rr�rBr@rArBr��getVisibleTableCellsr��description�
ROLE_PAGE_TAB�
ROLE_IMAGEr�r�r�rP�getOnScreenObjectsr�r��ROLE_CANVASr+rr�rr��
ROLE_VIEWPORT)r$r��extentsrcr5�	component�
interfaces�visibleCells�objects�hasNameOrDescriptionrI�
containersr&r&r'r�;s�




�




� �	zUtilities.getOnScreenObjectscCs�z
|r	|jr	|jsWdSWnd|}t�tj|d�YdS|��}|tjkr+dS|tjkr2dS|j��tj	ks<dSdd�}t
t|dd�|D���}t|�|jkrUdSdS)z9Determines if obj is a table row -- real or functionally.Fz5ERROR: Exception getting parent and childCount for %sTcSs$|o|��tjtjtjtjtjfvSrr)r_r.r�r�r�r�r�rtr&r&r'rv�s�z&Utilities.isTableRow.<locals>.<lambda>cSr�r&r&rKr&r&r'rK�r�z(Utilities.isTableRow.<locals>.<listcomp>)
r^r�r	r+r,r_r.�ROLE_TABLE_ROWr�r�rQr�rT)r3r5rcr~�cellChildrenr&r&r'r!�s(�

zUtilities.isTableRowcs`|���tj�r
|Stjtjtjtjtjtj	g�t�
|�fdd��}|r.|jj�
|j�s.|}|S)Nc�|o|���vSrrr|rt��rolesr&r'rv�r�z.Utilities.realActiveAncestor.<locals>.<lambda>)r*r-r.r�r�r�r�r�r�r�rzr!�	utilitiesrr^r&r&r�r'�realActiveAncestor�s�zUtilities.realActiveAncestorcs\��|�rdS|��tjkr|S�fdd�|D�}�fdd�|D�}t|�dkr,|dS|S)a2Given an object that should be a child of an object that
        manages its descendants, return the child that is the real
        active descendant carrying useful information.

        Arguments:
        - obj: an object that should be a child of an object that
        manages its descendants.
        Ncsg|]	}��|�s|�qSr&)r�rKrJr&r'rK�rLz2Utilities.realActiveDescendant.<locals>.<listcomp>csg|]}��|���r|�qSr&)r�striprKrJr&r'rK�r�rr)rr_r.r�rT)r$r3�children�
hasContentr&rJr'�realActiveDescendant�s

zUtilities.realActiveDescendantcCs |sdSdd�}t�||�duS)NFcSrrrr�rtr&r&r'rv�rz1Utilities.isStatusBarDescendant.<locals>.<lambda>r%rr&r&r'�isStatusBarDescendant�szUtilities.isStatusBarDescendantcCs�|r	|��tjksgSt��}|jj�d�}|s,dd�}tt||�	|���}||jjd<t��}d||}t
�t
j|d�|S)N�statusBarItemscSs|o|��tjkSrrr�rtr&r&r'rv�rz*Utilities.statusBarItems.<locals>.<lambda>z)INFO: Time getting status bar items: %.4fT)
r_r.r��timer!r�rxrQr�r�r	r+r,)r$r3r4�items�include�endr5r&r&r'r��szUtilities.statusBarItemscCs�|��tjkr	|Stjtjtjg}|���tj�s|��|vr!dSd}t	|j
ddd�D])}||��tjkr<||}n||��|vrK|�||�}|rU|�|�rU|Sq,|S)z�Returns the status bar in the window which contains obj.

        Arguments:
        - obj: the top-level object (e.g. window, frame, dialog) for which
          the status bar is sought.
        Nrr�)
r_r.r�r�r�r�r*r-r�r�r��	statusBarr�)r$r3r�r�r�r&r&r'r��s(�
�zUtilities.statusBarcCrzrrr&rr&r&r'�infoBar	r�zUtilities.infoBarcC�tjtjtjtjgSrr)r.�
ROLE_ALERTr�r��ROLE_WINDOWrJr&r&r'r	s
�zUtilities._topLevelRolescCsntjsdSztj��}Wndtj}t�tj|d�YdS||��v}dtj|f}t�tj|d�|S)NFr*Tz INFO: %s is top-level object: %s)rr�r_r	r+r,r)r$rcr5rpr&r&r'�_locusOfFocusIsTopLevelObject	s
z'Utilities._locusOfFocusIsTopLevelObjectcCsz|sdS|��}|r;|jr;||jkr;|��|vr;|j��tjks;|j}|r;|jr;||jkr;|��|vr;|j��tjkr |S)z�Returns the top-level object (frame, dialog ...) containing obj,
        or None if obj is not inside a top-level object.

        Arguments:
        - obj: the Accessible object
        N)rr^r_r.�ROLE_APPLICATION)r$r3�stopAtRolesr&r&r'r�/	s�zUtilities.topLevelObjectcCs�|ptj}|�|�}|sdS|��z|��}Wnd|}t�tj|d�YdS|�t	j
�r7|�t	j�r9dS|�|tj
�sBdSdS)NFz-ERROR: Exception getting state of topLevel %sT)rr�r�rBr*r	r+r,r-r.r/�
STATE_DEFUNCTr�r[)r$r3r�r4r5r&r&r'� topLevelObjectIsActiveAndCurrentC	s$


�z*Utilities.topLevelObjectIsActiveAndCurrentcCsbz|���tj�}|���tj�}WnYdS|j|jd}|j|jd}t||�|kS)z1Determines if obj1 and obj2 are on the same line.F�)r@rAr.rBrCrE�abs)r;r<�delta�bbox1�bbox2�center1�center2r&r&r'�
onSameLine[	szUtilities.onSameLinecCs�||krdStt|�t|��}|dg|d|�}|dg|d|�}ttt|�t|���D]}||||kr=dS||||krHdSq0dS)zpCompares the two paths and returns -1, 0, or 1 to indicate if path1
        is before, the same, or after path2.rr�Nr)�maxrTr�r�)r=r>�sizerur&r&r'�pathComparisonj	s�zUtilities.pathComparisoncCsxz|���tj�}|j|j}}Wnd\}}Yz|���tj�}|j|j}}Wnd\}}Y||||S�N�rr)r@rAr.rBrDrE)r;r<�bbox�width1�height1�width2�height2r&r&r'rX~	s

zUtilities.sizeComparisoncCs�z|���tj�}|j|j}}Wnd\}}Yz|���tj�}|j|j}}Wnd\}}Y||p;||}|sL|j|jkrL|��|��}t|d�}t	|d�}|S)z�Compares the physical locations of obj1 and obj2 and returns -1,
        0, or 1 to indicate if obj1 physically is before, is in the same
        place as, or is after obj2.r�r�r)
r@rAr.rBrurCr^r{r�r�)r;r<r��x1�y1�x2�y2rpr&r&r'�spatialComparison�	s 



zUtilities.spatialComparisoncCs@z
|���||tj�}W|Sd|}t�tj|d�YdS)Nz,ERROR: Exception getting range extents of %sT�r�r�rr)r��getRangeExtentsr.rBr	r+r,)r$r3r4r�r�r5r&r&r'�getTextBoundingBox�	s�zUtilities.getTextBoundingBoxcCsNz
|���tj�}Wnd|}t�tj|d�YdS|j|j|j	|j
fS)Nr�Tr�)r@rAr.rBr	r+r,rurCrDrE�r$r3r�r5r&r&r'�getBoundingBox�	szUtilities.getBoundingBoxcCsb|sdS|��tjkr
dSz
|���tj�}Wnd|}t�tj|d�YdS|j	o/|j
S)NFr�T)r_r.r�r@rArBr	r+r,rDrEr�r&r&r'r��	szUtilities.hasNoSizec		Cs�|sdSz|j}Wnd|}t�tj|d�YdSt|�D]8}z||}Wnd||f}t�tj|d�YdS|rE||�rEq |rP||�rP|�|�|�||||�q dS)N�*ERROR: Exception getting childCount for %sTz(ERROR: Exception getting %i child for %s)r�r	r+r,r�r��_findAllDescendants)	r$r��	includeIf�	excludeIf�matchesr�r5r�rIr&r&r'r��	s*

�zUtilities._findAllDescendantscCsg}|�||||�|Srr)r�)r$r�r�r�r�r&r&r'r��	szUtilities.findAllDescendants�c	s|jjr
|jj�|�r
gStjtjg�tjtjtjtj	tj
tjtjtj
tjg	���fdd�}��fdd�}�fdd�}|�|||�}|j}i}	|D]*}
|
jpR|�|
�}|r^|||
jjfvr^qIt|���|krgqI|�|�dkroqI|
|	|<qIt|	���}t|t�|j�d�S)	a�Returns a list containing all the unrelated (i.e., have no
        relations to anything and are not a fundamental element of a
        more atomic component like a combo box) labels under the given
        root.  Note that the labels must also be showing on the display.

        Arguments:
        - root: the Accessible object to traverse
        - onlyShowing: if True, only return labels with STATE_SHOWING

        Returns a list of unrelated labels under the given root.
        cs<|r|���vs
dS|��rdS�r|���tj�sdSdS�NFT)r_r�r*r-r.r1rt)�
labelRolesr�r&r'�_include
sz+Utilities.unrelatedLabels.<locals>._includecs0|r|���vr
dS�r|���tj�sdSdSr)r_r*r-r.r1rt)r�r�r&r'�_exclude
s
z+Utilities.unrelatedLabels.<locals>._excludecr�rrr|rt)r�r&r'rv
r�z+Utilities.unrelatedLabels.<locals>.<lambda>rrM)r!�
spellcheck�
isCheckWindowr.r��ROLE_STATICr�rrr�r��ROLE_SPLIT_PANEr�r�r�r�r�rr^rTrirlrQ�valuesrUrVrWr�)r$r�r�r�r�r�r�r��rootName�dr�r�r&)r�r�r�r'r��	s<
�
	
zUtilities.unrelatedLabelscCr�)NTr&rJr&r&r'�_treatAlertsAsDialogs/
r�zUtilities._treatAlertsAsDialogscs�tjg����r��tj���fdd���fdd�|��D�}|��fdd���|�D���fdd�}tt	|t
|���}tt	�fdd�|��}t|�S)acIf the current application has one or more alert or dialog
        windows and the currently focused window is not an alert or a dialog,
        return a count of the number of alert and dialog windows, otherwise
        return a count of zero.

        Arguments:
        - obj: the Accessible object

        Returns the alert and dialog count.
        cs|r|���vp��|�Srr)r_r(rt)r�r$r&r'rvB
rLz8Utilities.unfocusedAlertAndDialogCount.<locals>.<lambda>c�g|]}�|�r|�qSr&r&rK��isDialogr&r'rKC
rlz:Utilities.unfocusedAlertAndDialogCount.<locals>.<listcomp>cr�r&r&rKr�r&r'rKD
rlcs��|�o
|jp
|jSrr)r�r�r�rtrJr&r'rvF
rRcs��|�SrrrFrtrJr&r'rvI
r$)r.r�r�r�r�rArPr�rQr�rXrT)r$r3�dialogs�
isPresentable�presentable�	unfocusedr&)r�r�r$r'�unfocusedAlertAndDialogCount2
sz&Utilities.unfocusedAlertAndDialogCountcCsz|���d�WSYdS)zjReturn the URI for a given link object.

        Arguments:
        - obj: the Accessible object.
        rN)rjrkr�r&r&r'rpL
sz
Utilities.uricCs|sdS|jS)z�Returns the first valid parent/ancestor of obj. We need to do
        this in some applications and toolkits due to bogus hierarchies.

        Arguments:
        - obj: the Accessible object
        N)r^r�r&r&r'rX
szUtilities.validParentcCs�z|��}WnYdS|��dkr(|j}t||�}t||�}|�||�dS|�d�\}}||kr6|}n|}|�d||�dS)z�Adjusts the end point of a text selection

        Arguments:
        - obj: the Accessible object.
        - offset: the new end point - can be to the left or to the right
          depending on the direction of selection
        Nr)r��getNSelections�caretOffsetr�r��addSelection�getSelection�setSelection)r3r�r�r��startOffset�	endOffsetr&r&r'�adjustTextSelectionk
s


zUtilities.adjustTextSelectioncCs�|r|�|�r	dS|��D]}|��tjkr|�d�Sq
|��d}|jrRd|kr5|jjdksRn|j}|��d}|jrRd|krP|jjdkr6nq6z|j|}Wnd}Y||krfd}|S)z!Finds the object before this one.Nrr)	r
r�r�r.�RELATION_FLOWS_FROMr�r{r^r�)r$r3r�r}�prevObjr&r&r'�findPreviousObject�
s$�$&�zUtilities.findPreviousObjectcCs�|r|�|�r	dS|��D]}|��tjkr|�d�Sq
|��d}|jrNd|kr3|jjksNn|j}|��d}|jrNd|krL|jjkr4nq4z|j|}Wnd}Y||krbd}|S)z Finds the object after this one.Nrr)	r
r�r�r.�RELATION_FLOWS_TOr�r{r^r�)r$r3r�r}�nextObjr&r&r'�findNextObject�
s$� "�zUtilities.findNextObjectc
Cs�|�|�\}}}|r|jj�d�r|||fS|�|�r |||fS|�|�}|rD|�|�r=|�|�\}}}|s7n
d||f}|�|�}|s'|�|�}	|	rh|�|	�ra|�|	�\}}}|s[n
d||f}|�|	�}	|	sK|||fS)a�Get all the text applicable text selections for the given object.
        including any previous or next text objects that also have
        selected text and add in their text contents.

        Arguments:
        - obj: the text object to start extracting the selected text from.

        Returns: all the selected text contents plus the start and end
        offsets within the text for the given object.
        �entireDocumentSelected�%s %s)�selectedTextr!r�rxr�rr�r	)
r$r3�textContentsrrr�	selectionr4r�rr&r&r'�allSelectedText�
s0





�


�
zUtilities.allSelectedTextcCs\z|��}WngYSg}z|��}Wnd}Yt|�D]
}|�|�|��q!|S)anGet a list of text selections in the given accessible object,
        equivalent to getNSelections()*texti.getSelection()

        Arguments:
        - obj: An accessible.

        Returns list of start and end offsets for multiple selections, or an
        empty list if nothing is selected or if the accessible does not support
        the text interface.
        r)r�r�r�r�r�)r3r�rp�nSelectionsr�r&r&r'�allTextSelections�
s
zUtilities.allTextSelectionscCs�z|��}Wn'tyd|}t�tj|d�YdSd|}t�tj|d�YdS|�|�}|dkr9dS|�|�}|sPd||f}t�tj|d�dS|�d�}d|||f}t�tj|d�||jkrxd|j|f}t�tj|d�|S)	Nz3INFO: %s does not implement the hypertext interfaceTz3INFO: Exception querying hypertext interface for %sr�z,INFO: No hyperlink object at index %i for %srz/INFO: Hyperlink object at index %i for %s is %szBERROR: The hyperlink start index (%i) should match the offset (%i))	rsr�r	r+r,�getLinkIndexru�	getObjectrv)r$r3r�ryr5r}rorIr&r&r'�getChildAtOffset�
s6



�zUtilities.getChildAtOffsetcCs�d}z|��}Wntyd|}t�tj|d�Y|Swz
|j��|j}Wnd||jf}t�tj|d�Y|Sd||f}t�tj|d�|S)a�Returns the character offset of the embedded object
        character for this object in its parent's accessible text.

        Arguments:
        - obj: an Accessible that should implement the accessible
          hyperlink specialization.

        Returns an integer representing the character offset of the
        embedded object character for this hyperlink in its parent's
        accessible text, or -1 something was amuck.
        r��3INFO: %s does not implement the hyperlink interfaceTz7ERROR: Exception getting startIndex for %s in parent %szINFO: startIndex of %s is %i)rjr�r	r+r,r^r�rv)r$r3r�ror5r&r&r'�characterOffsetInParents$
�

�z!Utilities.characterOffsetInParentcCs:z|��}WnYdSt|���D]}|�|�qdS)zwClears the text selection if the object supports it.

        Arguments:
        - obj: the Accessible object.
        N)r�r�r��removeSelection)r$r3r�r�r&r&r'�clearTextSelection@s�zUtilities.clearTextSelectioncCs4z
|���dd�}WnYdS|ot�d|�S)Nrr�Fz	[^\ufffc])r�r�r\r�r�r&r&r'�containsOnlyEOCsOs
zUtilities.containsOnlyEOCsr�cCs�z	|�|||�}WnYdS|j|vr|Stjtjtjtjtjtjtj	tj
g}t|�}t|�D]&\}}||jkrW|�
|||�}	|�|	�}
|	rS|	��|vrS|
d7}
|
||<q1d�|�S)arExpands the current object replacing EMBEDDED_OBJECT_CHARACTERS
        with their text.

        Arguments
        - obj: the object whose text should be expanded
        - startOffset: the offset of the first character to be included
        - endOffset: the offset of the last character to be included

        Returns the fully expanded text for the object.
        rr8)�	substringr�r.�ROLE_HEADINGr�r�rJrr�r�r�rQ�	enumerater�
expandEOCsr_r�)r$r3rrr��
blockRoles�toBuildr��charrIr�r&r&r'rWs2
�	

�
zUtilities.expandEOCscCsN|�||d�\}}}|�d�dkrdS|�d�dkrdS|�d�dvr%dSdS)	aIdentifies if the current word is flagged as misspelled by the
        application. Different applications and toolkits flag misspelled
        words differently. Thus each script will likely need to implement
        its own version of this method.

        Arguments:
        - obj: An accessible which implements the accessible text interface.
        - offset: Offset in the accessible's text for which to retrieve the
          attributes.

        Returns True if the word is flagged as misspelled.
        T�invalid�spellingz
text-spelling�
misspelled�	underline)�errorr"F)�textAttributesrx)r$r3r��
attributesr4r�r&r&r'�isWordMisspelledszUtilities.isWordMisspelledcCs|���tj�Srr)r*r-r.�STATE_INVALID_ENTRYr�r&r&r'�getError��zUtilities.getErrorcCr�rr&r�r&r&r'�getErrorMessage�r�zUtilities.getErrorMessagecCr�r�r&r�r&r&r'�isErrorMessage�r�zUtilities.isErrorMessagecCs0|�|�}|r|dur|j}|�||d�SdS)Nrr)r�r�r�)r$r3r�r�r&r&r'�getCharacterAtOffset�s
zUtilities.getCharacterAtOffsetcCsVz	|��}|j}WntyYdSd|}t�tj|d�YdS|r)|SdS)z�Get the text interface associated with an object, if it is
        non-empty.

        Arguments:
        - obj: an accessible object
        z.ERROR: Exception getting character count of %sTN)r�r�r�r	r+r,)r$r3r��	charCountr5r&r&r'r��s
��zUtilities.queryNonEmptyTextcCs|jSrr)�any_datarr&r&r'�deletedText�r�zUtilities.deletedTextcCs�|jr|jSz|j��}Wnd|j}t�tj|d�d}Yd}t�tj|d�|tjkrP|�|j�}|rP|�	dd�}|rPd|}t�tj|d�|dSd}t�tj|d�dS)	NrTz"ERROR: Broken text insertion eventrr�z!HACK: Returning last char in '%s'z3FAIL: Unable to correct broken text insertion eventr)
r0rr_r	r+r,r.rr�r�)r$rrcr5r�r�r&r&r'�insertedText�s*

zUtilities.insertedTextc	Cs�d}d}}z|��}Wnd}Yn|��}td|�D]!}|�|�\}}||kr+q|�|||�}|dkr:|d7}||7}q|||gS)z�Get the text selection for the given object.

        Arguments:
        - obj: the text object to extract the selected text from.

        Returns: the selected text contents plus the start and end
        offsets within the text.
        rrr8)r�r�r�r�r)	r$r3r
rr�textObjrr�rr&r&r'r�s 


zUtilities.selectedTextcCsJtj}z
|��j}W||fStyd}Y||fSd}Y||fS)Nrr�)rr�r�r�r�rr&r&r'r��s��zUtilities.getCaretContextcCs|dfSr�r&r�r&r&r'�getFirstCaretPositionr�zUtilities.getFirstCaretPositioncCst�d|d�|�||�dSr�)r�setLocusOfFocus�setCaretOffset)r$r3r�r�r&r&r'�setCaretPosition	szUtilities.setCaretPositioncCs(z|��}WnYdS|�|�dS)z�Set the caret offset on a given accessible. Similar to
        Accessible.setCaretOffset()

        Arguments:
        - obj: Given accessible object.
        - offset: Offset to hich to set the caret.
        N)r�r6)r$r3r��textir&r&r'r6
s
zUtilities.setCaretOffsetcCs&z|��}WnYdS|�||�S)aTReturns the substring of the given object's text specialization.

        Arguments:
        - obj: an accessible supporting the accessible text specialization
        - startOffset: the starting character position
        - endOffset: the ending character position. Note that an end offset
          of -1 means the last character
        r)r�r�)r$r3rrr�r&r&r'rs

zUtilities.substringcCs*|jj��D]\}}||kr|Sq|S)a�Converts the given Atk attribute name into the application's
        equivalent. This is necessary because an application or toolkit
        (e.g. Gecko) might invent entirely new names for the same text
        attributes.

        Arguments:
        - attribName: The name of the text attribute

        Returns the application's equivalent name if found or attribName
        otherwise.
        )r!�attributeNamesDictr�)r$�
attribNamerNr�r&r&r'�getAppNameForAttribute-s

�z Utilities.getAppNameForAttributecCs|jj�||�S)aaConverts the given attribute name into the Atk equivalent. This
        is necessary because an application or toolkit (e.g. Gecko) might
        invent entirely new names for the same attributes.

        Arguments:
        - attribName: The name of the text attribute

        Returns the Atk equivalent name if found or attribName otherwise.
        )r!r9rx)r$r:r&r&r'�getAtkNameForAttribute@sz Utilities.getAtkNameForAttributecCs*z|��}WngYS|dkr|j}d|||f}t�tj|d�t��}g}|}||kr}z|�|�\}	}
}d||	|
|f}t�tj|d�Wnd|}t�tj|d�|YStdd�|	D��}|�t	|
|�||f�t	||d�}||ks0t��}
d	t
|�|
|f}t�tj|d�|S)
z9Returns a list of (start, end, attrsDict) tuples for obj.r�z3INFO: Getting text attributes for %s (chars: %i-%i)Tz"INFO: Attributes at %i: %s (%i-%i)z)ERROR: Exception getting attributes at %icSrerfrhrjr&r&r'rKgrlz;Utilities.getAllTextAttributesForObject.<locals>.<listcomp>rz(INFO: %i attribute ranges found in %.4fs)r�r�r	r+r,r��getAttributeRunrmr�r�rT)r$r3rrr�r5�	startTimerpr��attrListr4r��attrDict�endTimer&r&r'�getAllTextAttributesForObjectMs8�z'Utilities.getAllTextAttributesForObjectc
Cs�i}z|��}Wn
|ddfYS|r#|�|���}|�|d�|dur*|j}|�|�\}}}	|�|�}|�|d�t||�}t|	|d�}	|||	fS)a
Get the text attributes run for a given offset in a given accessible

        Arguments:
        - acc: An accessible.
        - offset: Offset in the accessible's text for which to retrieve the
        attributes.
        - get_defaults: Get the default attributes as well as the unique ones.
        Default is True

        Returns a dictionary of attributes, a start offset where the attributes
        begin, and an end offset. Returns ({}, 0, 0) if the accessible does not
        supprt the text attribute.
        rrN)r��stringToKeysAndDict�getDefaultAttributes�updater�rnr�r�)
r$rUr��get_defaultsrpr��
stringAndDict�
attrStringr4r�r&r&r'r&ps 


zUtilities.textAttributescCs|dkr|dkst|�dkrtjS|�d�s|dkrtjSt�||j�}|dkr5|�d�d�	��	d�}nM|r[|�d	�r[|�d	�d}t
��d
|vrSt�t
|��}n/t�t|��}n'|�d�r{|�|�\}}}tjrst�|||�}nd|||f}nt�||j�}d
||fS)N�weight�boldi�r"zfamily-namercr�"�px�
decimal_point�colorz%i %i %iz%s: %s)ryr�BOLD�endswith�
MISSPELLEDr�getTextAttributeNamer!rir��locale�
localeconv�
pixelCount�float�
rgbFromStringr�
useColorNamesr�	rgbToName)r$rNr��localizedKey�localizedValuer��gr�r&r&r'�localizeTextAttribute�s&
zUtilities.localizeTextAttributecCsvg}|�|||�}|D]-\}}}}	||krq||kr|St||�}t||�}|�|||�}
|�|||
||	g�q|S)zAReturns a list of (start, end, string, language, dialect) tuples.)�'getLanguageAndDialectFromTextAttributesr�r�rr�)r$r3r4r�rp�
allSubstringsrr�language�dialectr�r&r&r'�splitSubstringByLanguage�s
�
z"Utilities.splitSubstringByLanguagec	Cs@|�|||�}|D]\}}}}||kr||kr||fSq	dS)z�Returns a (language, dialect) tuple. If multiple languages apply to
        the substring, language and dialect will be empty strings. Callers must
        do any preprocessing to avoid that condition.)rr)r^)	r$r3r4r�r_rrr`rar&r&r'�!getLanguageAndDialectForSubstring�s�z+Utilities.getLanguageAndDialectForSubstringc
Cs�g}|�|||�}d}}|D]>\}}	}
|
�dd�}d}d|vr(|�dd�\}}|r?||kr?||kr?|dd|	||f|d<n	|�||	||f�||}}q|S)zvReturns a list of (start, end, language, dialect) tuples for obj
        based on what is exposed via text attributes.rr`�-rr�r)rBrxrir�)
r$r3rrrp�attributeSet�lastLanguage�lastDialectr4r�r|r`rar&r&r'r^�sz1Utilities.getLanguageAndDialectFromTextAttributescCsbtjrtjsdSt|j�dks|jtj@rdStj}|�	�}|t
jkr%dS|���
t
j�r/dSdS)z�Given a keyboard event containing an alphanumeric key,
        determine if the script is likely to echo it as a character.
        FrT)rr�r�enableEchoByCharacterrT�event_string�	modifiersr�ORCA_CTRL_MODIFIER_MASKr_r.rr*r-r.)r$rr3rcr&r&r'�willEchoCharacter�s
�
zUtilities.willEchoCharactercCs�ddlm}tj}d}z|�|d�\}}Wnd}Yt|�}	|	tjkrQ|d|jjvrQ|r6|rK||krKt	�
|d�}
t�|
|	�}d||f}|S||7}|S||7}|S)a�Add in the latest line segment, adjusting for repeat characters
        and punctuation.

        Arguments:
        - segment: the segment of repeated characters.
        - line: the current built-up line to characters to speak.
        - respectPunctuation: if False, ignore punctuation level.

        Returns: the current built-up line plus the new segment, after
        adjusting for repeat character counts and punctuation.
        r��punctuation_settingsTrFr)
rrnr�verbalizePunctuationStyle�getPunctuationInforT�repeatCharacterLimitr!�
whitespacer�getCharacterNamer�repeatedCharCount)r$�segment�line�respectPunctuationrn�style�isPunctChar�level�actionr9�
repeatChar�
repeatSegmentr&r&r'�_addRepeatSegment�s,

���zUtilities._addRepeatSegmentcCs:|�|�s|�|�sdSt�d�}|tjtjfvrdSdS)NFroT)rrr�r�r�PUNCTUATION_STYLE_ALL�PUNCTUATION_STYLE_NONE)r$r3rxr&r&r'�shouldVerbalizeAllPunctuation"
s
z'Utilities.shouldVerbalizeAllPunctuationcCs@|}tt�|j|��D]}dt�|�}t�d|||�}q|S)Nz %s z\%s)rXr\�findall�PUNCTUATIONrrsr])r$r�r��symbol�charNamer&r&r'�verbalizeAllPunctuation/
s
z!Utilities.verbalizeAllPunctuationcCsddlm}|t|�}z
|��}|��}Wnd}Yt|�}t|dd�D]a}	|�|	d�}
|
s3q'||
jkr>|krFnn|
j|}n||
j	krQ|krannt|�}|
j|kr`|d8}nq'dt
j}d}
|t|�krs||}
|
|jj
vs�|�|
�s�|d7}||||�<q'd�|�S)a|Adjust line to include the word "link" after any hypertext links.

        Arguments:
        - obj: the accessible object that this line came from.
        - line: the string to adjust for links.
        - startOffset: the caret offset at the start of the line.

        Returns: a new line adjusted to add the speaking of "link" after
        text which is also a link.
        rrmrr�r8r)rrnrTrsrtrQr�rurwrvr�LINKr!rrrpr�)r$r3rvrrnr�	hyperText�nLinks�adjustedLine�nrzr}�
linkString�nextCharr&r&r'�adjustForLinks7
s<
�
�
zUtilities.adjustForLinkscCst�dd|�S)Nz(?<=[a-z])(?=[A-Z])r8)r\r])r�r&r&r'�_processMultiCaseStringl
sz!Utilities._processMultiCaseStringcCs|��s|Sd�t|��S)Nr8)�	isnumericr�rQ)�wordr&r&r'�_convertWordToDigitsp
szUtilities._convertWordToDigitscCs�tjr|�|�}|��rt�|�}tjr#|j�|�}d�	t
|j|��}t|�dkr4t
�|�}||kr4|Stjs9|Sd}|j�|�}d�	t
tj|��}tjrR|�|�}|S)a@Adjust the line to replace words in the pronunciation dictionary,
        with what those words actually sound like.

        Arguments:
        - line: the string to adjust for words in the pronunciation dictionary.

        Returns: a new line adjusted for words found in the pronunciation
        dictionary.
        rr)r�speakMultiCaseStringsAsWordsr�rhr
�adjustForSpeech�speakNumbersAsDigits�WORDS_RErir�rRr�rTrrs�usePronunciationDictionaryr�getPronunciation)r$rv�words�charname�newLiner&r&r'�adjustForPronunciationw
s&



z Utilities.adjustForPronunciationcCs�t|�dkstjdkr
|Sd}|d}}d}tdt|��D]}|||kr-|||7}nd}|�||�}||}||}q|�|||�S)a�Adjust line to include repeat character counts. As some people
        will want this and others might not, there is a setting in
        settings.py that determines whether this functionality is enabled.

        repeatCharacterLimit = <n>

        If <n> is 0, then there would be no repeat characters.
        Otherwise <n> would be the number of same characters (or more)
        in a row that cause the repeat character count output.
        If the value is set to 1, 2 or 3 then it's treated as if it was
        zero. In other words, no repeat character count is given.

        Arguments:
        - line: the string to adjust for repeat character counts.

        Returns: a new line adjusted for repeat character counts (if enabled).
        �rrFrT)rTrrqr�r~)r$rvr�ru�lastChar�
multipleCharsr�r&r&r'�adjustForRepeats�
s
zUtilities.adjustForRepeatscs�tt��j|��}tt��j|��}|D]}�fdd�|D�}tjd�|�}t�|||�}q|D]}�fdd�|D�}tj	d�|�}t�|||�}q1|S)z�Adjusts the string to convert digit-like text, such as subscript
        and superscript numbers, into actual digits.

        Arguments:
        - string: the string to be adjusted

        Returns: a new string which contains actual digits.
        c�g|]
}t�j�|���qSr&)rS�SUPERSCRIPT_DIGITSr}�rHr�rJr&r'rK�
�z-Utilities.adjustForDigits.<locals>.<listcomp>rcr�r&)rS�SUBSCRIPT_DIGITSr}r�rJr&r'rK�
r�)
rXr\r��
SUBSCRIPTS_RE�SUPERSCRIPTS_REr�DIGITS_SUPERSCRIPTr�r]�DIGITS_SUBSCRIPT)r$r��subscripted�
superscripted�number�new�	newStringr&rJr'�adjustForDigits�
s
zUtilities.adjustForDigitscCs�t�d�s
t�d�sdS|�dd�}t�d|�}|r"|d|���}d}dd�t�d	|�D�}d
d�t�d|�D�}t||�}|D]!\}}||f|vrX|dt�	||�7}qB|dt�
||�7}qB|S)
N�onlySpeakDisplayedText�enableSpeechIndentationr� r8z[^ 	]cS�g|]}|���qSr&��span�rH�mr&r&r'rK�
rwz4Utilities.indentationDescription.<locals>.<listcomp>z +cSr�r&r�r�r&r&r'rK�
rwz	+z%s )r�r�r<r\r�r4�finditerrUr�spacesCount�	tabsCount)r$rvr�r��spaces�tabs�spansr4r&r&r'�indentationDescription�
s"
�z Utilities.indentationDescriptioncCs4ddlm}|������}|��\}}}}||fS)z0Gets the absolute position of the mouse pointer.rr)�
gi.repositoryr�Window�
get_screen�get_root_window�get_pointer)r�
rootWindowrCrurCrjr&r&r'�absoluteMouseCoordinates�
sz"Utilities.absoluteMouseCoordinatesr8cCs|s|S|s|S|||S)z�Appends the newText to the given text with the delimiter in between
        and returns the new string.  Edge cases, such as no initial text or
        no newText, are handled gracefully.r&)r��newText�	delimiterr&r&r'r��
s
zUtilities.appendStringcCsT|r|sdS||krdS|j|jko)|j|jko)|j|jko)|j|jko)|j|jkSr�)r�type�detail1�detail2r0)r$�event1�event2r&r&r'�treatAsDuplicateEvent	s
�
�
�
�zUtilities.treatAsDuplicateEventc
CsH|j�d�r�|jr|jsdS|j��}|�tj�sdS|�tj�s#dS|�tj	�r;|j�
�|j��}|�tj�s;dS|��\}}|dkrL|jdkrLdS|dkrW|jdkrWdS|dvra|�
|j�S|��sgdS|j���d	d
�}|�|j�r�|�|j�\}}}||jkr�dS||jkr�|�|�r�|d|�|��}	|	���|���SdS)z�Returns True if event is associated with text being autocompleted
        or autoinserted or autocorrected or autosomethingelsed.

        Arguments:
        - event: the accessible event being examined
        �object:text-changed:insertF�Tab�	T�Return�
)�Up�Down�Page_Up�	Page_Downrr�N)r�rnr0rr*r-r.r.r1r�rBr��lastKeyAndModifiers�isEditableDescendantOfComboBox�lastInputEventWasPrintableKeyr�r�rPrrl�lower)
r$rr4�lastKey�modsr�rr4r��	beginningr&r&r'�isAutoTextEvents>



zUtilities.isAutoTextEventcCs(|dks|dkr
dS||jjvo|dvS)a�Returns True if we are positioned at the end of a sentence.
        This is determined by checking if the current character is a
        white space character and the previous character is one of the
        normal end-of-sentence punctuation characters.

        Arguments:
        - currentChar:  the current character
        - previousChar: the previous character

        Returns True if the given character is a sentence delimiter.
        �
r�Tz!.?:;)r!rr)r$�currentChar�previousCharr&r&r'�isSentenceDelimiterCs

�zUtilities.isSentenceDelimitercCs ||jjvp|dvp||jjkS)z�Returns True if the given character is a word delimiter.

        Arguments:
        - character: the character in question

        Returns True if the given character is a word delimiter.
        z!*+,-./:;<=>?@[\]^_{|})r!rr�NO_BREAK_SPACE_CHARACTER)r$�	characterr&r&r'�isWordDelimiterVs
	�
�zUtilities.isWordDelimitercCsH|durtj}z|���|�}|���|�}WnYdS|�||�S)z9Returns the extents of the intersection of obj1 and obj2.Nr�)r.rBr@rA�intersection)r$r;r<�	coordTyperHrIr&r&r'�intersectingRegioncszUtilities.intersectingRegioncCs�|\}}}}|\}}}	}
t|||d�}t|||	d�}tt|��t|���}
t|||d�}t|||
d�}tt|��t|���}|
rJ|sLdS|
d}|d}|
d|}|d|}||||fS)Nrr�rr�)r�rUrXr�)r$rHrIr�r�r�r�r�r�r�r��xPoints1�xPoints2�
xIntersection�yPoints1�yPoints2�
yIntersectionrurCrDrEr&r&r'r�qszUtilities.intersectioncCs|�||�dkS)Nr�)r�)r$rHrIr&r&r'r��r+zUtilities.containsRegioncCs,tj��}|�|�d}tttjt|���Sr2)r�Keymap�get_default�get_entries_for_keycoderQrR�keyval_namerX)�keycode�keymap�entriesr&r&r'�_allNamesForKeyCode�s
zUtilities._allNamesForKeyCodecCs,ttjtj�s	dStj}|r|j|jfSdSr�)r\r�lastInputEventr�
KeyboardEvent�lastNonModifierKeyEvent�hw_coderj)rr&r&r'�_lastKeyCodeAndModifiers�sz"Utilities._lastKeyCodeAndModifierscCsRttjtj�r!tjr!tj}|jdvr|j}n|j}tjj}||fSd}d}||fS)z�Convenience method which returns a tuple containing the event
        string and modifiers of the last non-modifier key event or ("", 0)
        if there is no such event.)�	BackSpace�Deleterr)	r\rr�rr�r�r�rirj)r�eventStrr�r&r&r'r��s�
�zUtilities.lastKeyAndModifierscCs�z#ddlm}|�|�\}}|�||�}|r"|�d�r |�d�r"|}Wn|�d�r3|t�d�7}|�dd�}|�dd���}Yt	�
|�S)	z3Turns a key sequence into a user-presentable label.rr�+z++r8�<r�>)r�r�accelerator_parse�accelerator_get_labelrPrrsr<r�r
�localizeKeySequence)�sequencerrNr��newSequencer&r&r'�labelFromKeySequence�s"���

zUtilities.labelFromKeySequencecCs�z
|jj|j|WS|j|jjvri|jj|j<Yz|��}Wnty@gd�|jj|j|<|jj|j|YSwz
|�d��d�}Wngd�|jj|j|<|jj|j|YSt|�dkrx|d}|d}|d}n t|�dkr�d}|d}z|d}Wn
d}Ynd}d}d}|�dd	��	�}|�
|�}|�
|�}|�
|�}|j|jjvr�i|jj|j<|||g|jj|j|<|jj|j|S)
a2Gets the mnemonic, accelerator string and possibly shortcut
        for the given object.  These are based upon the first accessible
        action for the object.

        Arguments:
        - obj: the Accessible object

        Returns: list containing strings: [mnemonic, shortcut, accelerator]
        )rrrr�;r�rr�rrgr8)r!r��KEY_BINDING�queryActionr��
getKeyBindingrirTr<r�r)r$r3r{�bindingStrings�mnemonic�fullShortcut�acceleratorr&r&r'�mnemonicShortcutAccelerator�sP��



�z%Utilities.mnemonicShortcutAcceleratorcCs`z&dd�|�d�D�}dd�|D�}dd�|D�}tdd�|D��}W||gSgifYS)a�Converts a string made up of a series of <key>:<value>; pairs
        into a dictionary of keys and values. Text before the colon is the
        key and text afterwards is the value. The final semi-colon, if
        found, is ignored.

        Arguments:
        - string: the string of tokens containing <key>:<value>; pairs.

        Returns a list containing two items:
        A list of the keys in the order they were extracted from the
        string and a dictionary of key/value items.
        cSr�r&�r�)rH�sr&r&r'rKrwz1Utilities.stringToKeysAndDict.<locals>.<listcomp>rcSs"g|]
}t|�d��dkr|�qS)rgr�)rTri�rHrrr&r&r'rKs"cSsg|]}|�d�d���qS)rgr)rir�rr&r&r'rKr�cSsg|]}|�d��qS)rgrhrr&r&r'rKrR)rirm)r�r��keys�
dictionaryr&r&r'rCs�zUtilities.stringToKeysAndDictc	Cs�|�|d�}|�d�}|r|Sz|��}Wn
tyYdSw|j}z|j}WnttfyAd}d|}t�	tj
|d�Ynwz|j}Wnttfy`d}d|}t�	tj
|d�Ynwz|j}	Wnttfy�||d}	d	|}t�	tj
|d�Ynw|	dkr�zt
�td
t
�|	���}
Wn!ty�d|}t�	tj
|d�YdSwt|�dkr�d}
nd
}
d
|
}||S)z�Returns the text to be displayed for the object's current value.

        Arguments:
        - obj: the Accessible object that may or may not have a value.

        Returns a string representing the value.
        F�	valuetextr�z,ERROR: Exception getting maximumValue for %sTz,ERROR: Exception getting minimumValue for %sgY@z0ERROR: Exception getting minimumIncrement for %srz2ERROR: Exception calculating decimal places for %srz%%.%df)rqrxr�r�r�r�r�r�r	r+r,r��minimumIncrement�math�ceilr��log10r:r�)r$r3r|rr�r��maxValuer5�minValue�minIncrement�
decimalPlaces�	formatterr&r&r'�textForValuesX	
�
�
�
��zUtilities.textForValuecCs(zdt|�WSt�tj�YdS)z� Returns a four hex digit representation of the given character
        
        Arguments:
        - The character to return representation
        
        Returns a string representaition of the given character unicode vlue
        z%04xr)�ordr	r��
LEVEL_WARNING)r�r&r&r'�unicodeValueStringRs

zUtilities.unicodeValueStringcCr�rrr&)r$r3r��
layoutModeror&r&r'�getLineContentsAtOffsetbr�z!Utilities.getLineContentsAtOffsetcCr�rrr&)r$r3r�ror&r&r'�getObjectContentsAtOffseter�z#Utilities.getObjectContentsAtOffsetcCs|s|��\}}||dfS�Nr�r��r$r3r��	skipSpacer&r&r'�previousContexth�zUtilities.previousContextcCs|s|��\}}||dfSr(r)r*r&r&r'�nextContextnr-zUtilities.nextContextcCs$d}|�|�}|r|jd}||fS�Nrr)r�r�)r$r�r�r�r&r&r'�lastContextts


zUtilities.lastContextcCspz|��}|j|j}}W||fSty&d|}t�tj|d�YdSd|}t�tj|d�YdS)z5Returns the text range in parent associated with obj.rT�r�r�z0INFO: Exception getting hyperlink indices for %s)rjrvrwr�r	r+r,)r$r3ror4r�r5r&r&r'�getHyperlinkRange|s
�zUtilities.getHyperlinkRangec
shz	���}|j}Wn)ty d�}t�tj|d�gYSd�}t�tj|d�gYSd�|f}t�tj|d�g}t|�D]}|�|�}d||f}t�tj|d�|�|�sf|�	|�qG|ru|sud}t�tj|d���
�}|tjkr�|s�dd�}	|�
�|	�}|tjkr�|r�|d	�
�tjkr�|�|d	�}|s��jr��fd
d�}	|�
�|	�}|S)N�3INFO: %s does not implement the selection interfaceT�4ERROR: Exception querying selection interface for %sz'INFO: %s reports %i selected child(ren)zINFO: Child %i: %sz>INFO: Selected children not retrieved via selection interface.cS�|o	|���tj�Srr)r*r-r.r�rtr&r&r'rv�rwz,Utilities.selectedChildren.<locals>.<lambda>rcs|o|j�jkSrr)r�rtr(r&r'rv�r�)�querySelection�nSelectedChildrenr�r	r+r,r��getSelectedChildr
r�r_r.rr�r�r�r�)
r$r3rr9r5r�rurIrcrZr&r(r'r��sJ



�
�
zUtilities.selectedChildrenc
s�|sdSdd���|�r|Stjtjgtjtjgtjtjgtjtjtjgtj	tj
tjgtjtj
tjgi�|������fdd�}t�
||�S)NcS�|odt�|�vS)Nr��r.r�rtr&r&r'rv�rz1Utilities.getSelectionContainer.<locals>.<lambda>cs�|�o|������vSrr�r_rxrt��isSelectionrc�rolemapr&r'rv�rL)r.r�r�	ROLE_ICONr�rrr�r�r�r�r�r_rz)r$r3�isMatchr&r<r'�getSelectionContainer�s


�	zUtilities.getSelectionContainercs�|r	dt�|�vsdSdt�|�vr|�|�\}}td|�Stjtjgtjtjgi�|�����vr5|j	S��fdd�}t
|�||��S)Nr�rr�cs|������vSrrr;rt�rcr>r&r'rv�rz0Utilities.selectableChildCount.<locals>.<lambda>)r.r��rowAndColumnCountr�rr�r�rr_r�rTr�)r$r3�rows�colsr@r&rBr'�selectableChildCount�s


�zUtilities.selectableChildCountcCs�dt�|�vr|��}|jr|jSz	|��}|j}Wn'ty0d|}t�tj	|d�YdSd|}t�tj	|d�YdSd||f}t�tj	|d�|S)Nr�r3Trr4z%INFO: %s reports %i selected children)
r.r�r��
nSelectedRowsr6r7r�r	r+r,)r$r3r�rr9r5r&r&r'�selectedChildCount�s$
zUtilities.selectedChildCountcCszz	|��}|j}Wn'tyd|}t�tj|d�YdSd|}t�tj|d�YdS|�d�|�|d�fS)Nr3T�NNr4rr)r6r7r�r	r+r,r8)r$r3rr9r5r&r&r'�firstAndLastSelectedChildren�s
z&Utilities.firstAndLastSelectedChildrencCs@dd�}t�||�}||krd||f}t�tj|d�dS|S)NcSr5rr)r*r-r.r�rtr&r&r'rvrwz(Utilities.focusedChild.<locals>.<lambda>z ERROR: focused child of %s is %sT)r.�findDescendantr	r+r,)r$r3�	isFocusedrIr5r&r&r'�focusedChildszUtilities.focusedChildc	Cs�|sdSz|j}Wnd|}t�tj|d�YdSdd�|D�}|D]$}z|��}Wnd|}t�tj|d�Yq%|�tj�rI|Sq%dS)Nr�TcSsg|]}|��tjkr|�qSr&)r_r.rrGr&r&r'rKr�z*Utilities.popupMenuFor.<locals>.<listcomp>�%ERROR: Exception getting state for %s)r�r	r+r,r*r-r.�
STATE_ENABLED)r$r3r�r5�menusr�r4r&r&r'�popupMenuFors(
�zUtilities.popupMenuForcCsX|sdSz
|��}|��}Wnd|}t�tj|d�YdS|tjko+|�tj�S)NF�.ERROR: Exception getting role and state for %sT)	r_r*r	r+r,r.r�r-�STATE_HAS_POPUPrr&r&r'�isButtonWithPopup'szUtilities.isButtonWithPopupcCs\|sdSz|��}Wnd|}t�tj|d�YdS|tjtjfvr'dS|�|�duS�NFr*T)r_r	r+r,r.r�r�rQr�r&r&r'�isMenuButton5szUtilities.isMenuButtoncCs�|ptj}|s	dSz|��}Wnd|}t�tj|d�YdStjtjtj	tj
tjg}||vr4dS|tjtj
fvrF|joE|j��|vSdSrU)rr�r_r	r+r,r.rr�ROLE_CHECK_MENU_ITEM�ROLE_RADIO_MENU_ITEMrr�rr^)r$r3rcr5�	menuRolesr&r&r'�inMenuEs(
�zUtilities.inMenucCs*|ptj}|�|�sdSt�||j�duSr�)rr�rZr.rz�
isContextMenur�r&r&r'�
inContextMenu^s

zUtilities.inContextMenucCstjtjfSrr)r.r�r�rJr&r&r'�_contextMenuParentRoleser�z!Utilities._contextMenuParentRolescCs.|r	|��tjksdS|jo|j��|��vSr�)r_r.rr^r]r�r&r&r'r[hszUtilities.isContextMenucCs"|��tjkr|j|�|�kSdSr�)r_r.rr^r�r�r&r&r'�isTopLevelMenunszUtilities.isTopLevelMenucCs`z
|��}|��}Wnd|}t�tj|d�YdS|tjkr$dS|�tj�o/|�tj	�S)NrRTF)
r_r*r	r+r,r.rr-�STATE_SUPPORTS_AUTOCOMPLETION�STATE_SINGLE_LINErr&r&r'�isSingleLineAutocompleteEntryts

�z'Utilities.isSingleLineAutocompleteEntrycCr�r�r&r�r&r&r'�isEntryCompletionPopupItem�r�z$Utilities.isEntryCompletionPopupItemcsr|sdSz|��}Wnd|}t�tj|d�YdS|tjkr$dS�fdd�|D�}t|�dkr7|dSdS)Nr*TcrEr&)�isEditableTextArearKrJr&r'rK�rLz9Utilities.getEntryForEditableComboBox.<locals>.<listcomp>rr)r_r	r+r,r.r�rT)r$r3rcr5r�r&rJr'�getEntryForEditableComboBox�s
z%Utilities.getEntryForEditableComboBoxcCs|�|�duSrr)rdr�r&r&r'�isEditableComboBox��zUtilities.isEditableComboBoxcCsb|sdSz|��}Wnd|}t�tj|d�YdS|�tj�s%dSdd�}t�||�duS)NFrNTcSrrr)r_r.r�rtr&r&r'rv�rz:Utilities.isEditableDescendantOfComboBox.<locals>.<lambda>)r*r	r+r,r-r.r.rz)r$r3r4r5�
isComboBoxr&r&r'r��sz(Utilities.isEditableDescendantOfComboBoxcCsz|js|�|�S|�|�}|r|�|�S|jj�|�}|p%|jj�|d�}t|�dkr8|djp7|�|d�S|�|�Sr/)r�rrdr!r�r�rTr�)r$r3�entryr�r&r&r'�getComboBoxValue�s



zUtilities.getComboBoxValuecCr�r�r&r�r&r&r'�	isPopOver�r�zUtilities.isPopOvercCsN|�|�sdSz|��}Wnd|}t�tj|d�YdS|�tj�S)NFrNT)rjr*r	r+r,r-r.�STATE_MODALr2r&r&r'�isNonModalPopOver�s
zUtilities.isNonModalPopOvercCr�r�r&r�r&r&r'�isUselessPanel�r�zUtilities.isUselessPanelcCsBt�dtj�}t�|d|�}|�d�\}}}t|�t|�t|�fS)Nz
rgb|[^\w,]rrc)r\�compile�
IGNORECASEr]riry)r$�attributeValue�regexr��red�green�bluer&r&r'rW�szUtilities.rgbFromStringcCr�r�r&r�r&r&r'�isClickableElement�r�zUtilities.isClickableElementcCr�r�r&r�r&r&r'�hasLongDesc�r�zUtilities.hasLongDesccCr�r�r&r�r&r&r'r��r�zUtilities.hasDetailscCr�r�r&r�r&r&r'�	isDetails�r�zUtilities.isDetailscCr�rrr&r�r&r&r'�
detailsFor�r�zUtilities.detailsForcCr�r�r&r�r&r&r'�hasVisibleCaption�r�zUtilities.hasVisibleCaptioncCr�rr&r�r&r&r'�	popupType�r�zUtilities.popupTypecCsh|r	|��tjksdS|�|�}zt|�dd��}W|Sty3d||f}t�tj	|d�YdSw)Nrrz�0z*ERROR: Exception getting value for %s (%s)T)
r_r.rrqryrxr:r	r+r,)r$r3r|r�r5r&r&r'�headingLevel�s
��zUtilities.headingLevelcCsTz|��}Wn
tyYdSwdtjg}t|j�D]}|�|�|vr'dSqdS)NF�toggleT)r
r�r�
ACTION_TOGGLEr��nActions�getName)r$r3r{�toggleActionNamesr�r&r&r'�hasMeaningfulToggleAction�s�
�z#Utilities.hasMeaningfulToggleActioncs@|sdStjtjtjtjg��fdd�}||�r|St�||�S)Ncr�rrr|rtr�r&r'rvr�z1Utilities.containingTableHeader.<locals>.<lambda>)r.r�r�r�r�rz)r$r3�isHeaderr&r�r'�containingTableHeaders�zUtilities.containingTableHeadercCs�|r	|��tjksgSdd�}t�||�}z|��}WngYS|�|�}|�|�|�|�}}|�||�}g}	t	|||�D]
}
|	�
|�|
��qB|	S)NcSr9r�r:rtr&r&r'rvrz0Utilities.columnHeadersForCell.<locals>.<lambda>)r_r.r�rzr�rr�r��getColumnExtentAtr�r�r)r$r3r�r^r�r}r�r��colspan�headers�cr&r&r'�columnHeadersForCell�
zUtilities.columnHeadersForCellcCs�|r	|��tjksgSdd�}t�||�}z|��}WngYS|�|�}|�|�|�|�}}|�||�}g}	t	|||�D]
}
|	�
|�|
��qB|	S)NcSr9r�r:rtr&r&r'rv/rz-Utilities.rowHeadersForCell.<locals>.<lambda>)r_r.r�rzr�rr�r��getRowExtentAtr�r�r)r$r3r�r^r�r}r�r��rowspanr�r�r&r&r'�rowHeadersForCell+r�zUtilities.rowHeadersForCellcC�b|r	|��tjksdSdd�}t�||�}z|��}WnYdS|�|�}|�|�}|�|�S)NcSr9r�r:rtr&r&r'rvDrz/Utilities.columnHeaderForCell.<locals>.<lambda>)r_r.r�rzr�rr�r)r$r3r�r^r�r}�columnIndexr&r&r'�columnHeaderForCell@�


zUtilities.columnHeaderForCellcCr�)NcSr9r�r:rtr&r&r'rvSrz,Utilities.rowHeaderForCell.<locals>.<lambda>)r_r.r�rzr�rr�r)r$r3r�r^r�r}�rowIndexr&r&r'�rowHeaderForCellOr�zUtilities.rowHeaderForCellcCsxtjtjtjtjtjg}|r|��|vsdSdd�}t�||�}z|��}WnYdS|�	|�}|�
|�|�|�fS)Nr1cSr9r�r:rtr&r&r'rvgrz.Utilities.coordinatesForCell.<locals>.<lambda>)r.r�r�r�r�r�r_rzr�rr�r�)r$r3�preferAttributer�r�r^r�r}r&r&r'r�^s �
zUtilities.coordinatesForCellcCs||r	|��tjksdSdd�}t�||�}z|��}WnYdS|�|�}|�|�|�|�}}|�||�|�	||�fS)Nr1cSr9r�r:rtr&r&r'rvurz,Utilities.rowAndColumnSpan.<locals>.<lambda>)
r_r.r�rzr�rr�r�r�r�)r$r3r�r^r�r}r�r�r&r&r'�rowAndColumnSpanqs
zUtilities.rowAndColumnSpancCs&z|��}WnYdS|j|jfS)Nr1)r�r�r)r$r3r�r�r&r&r'rC�s
zUtilities.rowAndColumnCountcCr�r�r&r�r&r&r'�_objectBoundsMightBeBogus�r�z#Utilities._objectBoundsMightBeBoguscCr�r�r&r�r&r&r'�_objectMightBeBogus�r�zUtilities._objectMightBeBogusr�c
Cs�|�|�r|�||||�dkrdS|�|�rdSz|��}WnYdS|dur,tj}|�|||�r5dS||||}}|�|||�rXd|||||f}	t�tj	|	d�dSdS)N�rrrFTz&INFO: %s contains (%i,%i); not (%i,%i))
r��textAtPointr�r@r.rBr-r	r+r,)
r$r3rurCr��marginr�r�r�r5r&r&r'�
containsPoint�s&

zUtilities.containsPointcCs.|sdS|�|�rdStjtjg}|��|vSr�)r�r.rr�r_)r$r3r�r&r&r'r��s
�z Utilities._boundsIncludeChildrencCr�r�r&r�r&r&r'�treatAsEntry�r�zUtilities.treatAsEntrycCs�|r|�|�r	dS|jsdS|��}tjtjg}||vrdS|tjkr/t�|dd��}|duS|tjkr9|j	r9dS|�
�}|�tj�rJ|�tj
�Stjtjg}||vS)NFTcSrrr)r_r.rrtr&r&r'rv�rz,Utilities._treatAsLeafNode.<locals>.<lambda>)rr�r_r.rr�r�rKr+r�r*r-�STATE_EXPANDABLEr�r�r�)r$r3rcr�rhr4r&r&r'�_treatAsLeafNode�s,�
�zUtilities._treatAsLeafNodecCsr|�|�rdSz|��}Wnd|}t�tj|d�YdS|�|||�}d||||f}t�tj|d�|S)Nz(INFO: Exception querying component of %sTz(INFO: %s is descendant of %s at (%i, %i))r3r@r	r+r,�getAccessibleAtPoint)r$r�rurCr�r�r5r�r&r&r'�accessibleAtPoint�s
zUtilities.accessibleAtPointcCsb|sdS|�|�sdS|durtj}|�||||�r'|�|�s$|�|�s&|Sn|�|�s1|�|�r3dSdt�|�vrV|�||||�}|rV||krV|�||||�}|rT|S|Sg}g}|D]>}|�||||�}	|	rl|	S|�||||�suq\|�	|�r�|�
��dd�}
t�
d|
�r�|�|�|���tj�r�|�|�q\t|�dkr�|dSt|�dkr�|dSdS)Nr�rr�u[^\s]r)r�r.rBr�r�r�r�r��descendantAtPointr�r�r�r\r�r�r*r-r1rT)r$r�rurCr�rIr��candidates_showingrZr3r�r&r&r'r��sN
�


�zUtilities.descendantAtPointcCs||fSrrr&)r$r3rurCr�r&r&r'�_adjustPointForObjr�zUtilities._adjustPointForObjcCsR|sdSdt�|�vr
dS|��}|�dd�}ttdd�|�d���}t|�dkS)	NFr�rr�cSs|��Srrrrtr&r&r'rv rVz2Utilities.isMultiParagraphObject.<locals>.<lambda>z

r)r.r�r�r�rQr�rirT)r$r3r�r��chunksr&r&r'�isMultiParagraphObjectsz Utilities.isMultiParagraphObjectcCs�z
|��}|dur|j}WnYdS|�||�\}}}|jj�dd�\}}||kr0|||fS|�||�\}	}
}|jj�d�dkrr|��rK|}|}n|��rS|}|}|�||�}d||�	dd�||f}t
�t
j|d	�|||fS|��r�|}|d
�
�s�|d
��s�|d8}n,|��r�|}||	kr�|
|kr�|kr�nn|
}|�|d|�}
|
�
�s�|
��s�|d}|�||�}d|vr�||	kr�|�d�r�|d7}n	|�d�r�|d8}|�||�}|�||�}d||�	dd�||f}t
�t
j|d	�|||fS)
Nr��penultimateCursorPositionr2�lastTextUnitSpokenr�zEINFO: Adjusted word at offset %i for ongoing word nav is '%s' (%i-%i)r��\nTr�rzAINFO: Adjusted word at offset %i for new word nav is '%s' (%i-%i))r�r��getWordAtOffsetr!r�rx�lastInputEventWasPrevWordNav�lastInputEventWasNextWordNavr�r<r	r+r,�isspacermrnrP)r$r3r�r�r�r4r�r�
prevOffset�prevWord�	prevStart�prevEndr5r�r&r&r'�$getWordAtOffsetAdjustedForNavigation#sd�
�
� 


�
z.Utilities.getWordAtOffsetAdjustedForNavigationcCsnz
|��}|dur|j}WnYdS|�|tj�\}}}d||�dd�||f}t�tj|d�|||fS)Nr�z INFO: Word at %i is '%s' (%i-%i)r�r�T)	r�r��getTextAtOffsetr.�TEXT_BOUNDARY_WORD_STARTr<r	r+r,)r$r3r�r�r�r4r�r5r&r&r'r�os�
zUtilities.getWordAtOffsetc
CsD|�|�}|s	dS|durtj}|durtj}|�||||�\}}|�|||�}d|kr4|jks7dSdS|�||�\}}	}
|sGd|	|
fS|tjkrR|�	�sRdS|�
|	|
|�}|�|||ddf�si|dkridS|�d�rr|dkrw||	|
fS|tj
kr�||	|
fS|�||||tj
�}|ddkr�|d|ddkr�|S||	|
fS)Nr�rrrr�r�)r�r.rB�TEXT_BOUNDARY_LINE_STARTr��getOffsetAtPointr�r�r�r�r�r�rP�TEXT_BOUNDARY_CHARr�)
r$r3rurCr��boundaryr�r�r�r4r�r�r r&r&r'r�|s:
�



 
zUtilities.textAtPointcCsvz	|��}|j}WngYSd||f}t�tj|d�|\}}}}	|�|||d�}
|�|
�\}}td|�}
d|
|f}t�tj|d�z
|
���	t
j�}Wn|
}Yn&|�||||jd�}
|�|
�\}}t|
|�}d|
|f}t�tj|d�|�||||	d�}
|�|
�\}}d|
|f}t�tj|d�|dkr�|}|}t
t||��}|
|vr�|�d|
�|S)	NzINFO: %s has %i rowsTrrzINFO: First cell: %s (row: %i)zINFO: Next cell: %s (row: %i)zINFO: Last cell: %s (row: %i)r�)r�r�r	r+r,r�r�r�r@rAr.rBrErQr��insert)r$r3r�r�r�r5rurCrDrEr�r�r�rvr��	nextIndexrwrDr&r&r'�visibleRows�sB


zUtilities.visibleRowscCs�z|��}WngYSz|��}|�tj�}Wnd|}t�tj|d�gYS|�||�}|s8gS|�	|�\}}||krEgSg}	t
||�D]-}
|�|
�}|rZ|	�|�|D]}z|�
||
�}
WnYq\|
rx|�|
�rx|	�|
�q\qL|	S)Nr�T)r�r@rAr.rBr	r+r,r��_getTableRowRanger�rr�r�r�)r$r3r�r�r�r5rD�
colStartIndex�colEndIndex�cellsr��	colHeaderr�r�r&r&r'r��s@


��zUtilities.getVisibleTableCellscCs�|�|�\}}d|}}|�|�s||fS|�|�}z|��}Wnd|}t�tj|d�||fYS|�tj	�\}	}
}}|�
|	d|
tj	�}
|
rU|�|
�\}}|}|�
|	|d|
tj	�}
|
rn|�|
�\}}|d}||fS)Nrz3ERROR: Exception querying component interface of %sTr)rCr�r�r@r	r+r,rAr.rBr�r�)r$r3�rowCount�columnCountrvrwr^r�r5rurCrDrEr�r�r�r&r&r'r��s*


zUtilities._getTableRowRangecCs�|�|�}z|��}Wnd|}t�tj|d�gYS|�|d�\}}|dkr-gS|r6d|j}}	n|�|�\}}	||	krCgSg}
t||	�D]}|�	||�}z
|�
��tj
�}
WnYqJ|
ri|
�|�qJ|
S)Nr�TFr�r)r�r�r	r+r,r�rr�r�r�r*r-r.r1r�)r$r3�forceFullRowr^r�r5r�r�rvrwr�r�r��showingr&r&r'�getShowingCellsInSameRows4

�z"Utilities.getShowingCellsInSameRowc	Csvz|��}WnYdS|�||�}|s|Sz|��}Wnd|}t�tj|d�YdS|��tj�s9dS|S)Nr)T)	r�r�r*r	r+r,r-r.r1)	r$r3r�r��showingOnlyr�r�r4r5r&r&r'�cellForCoordinates/s zUtilities.cellForCoordinatesc
Cs�z|��}Wnd|}t�tj|d�YdS|tjks dSdd�}t�||�}z|��}WnYdS|�|�}|�	|�|�
|�}}	|d|jkoT|	d|jkS)NrTFcSr9r�r:rtr&r&r'rvPrz&Utilities.isLastCell.<locals>.<lambda>r)
r_r	r+r,r.r�rzr�rr�r�r�r)
r$r3rcr5r�r^r�r}r�r�r&r&r'�
isLastCellEs"

zUtilities.isLastCellcCsfz|��}WnYdSt|j�D]}t|j�D]}|�||�dks+|�||�dkr/dSqqdS)NFrT)r�r�r�rr�r�)r$r3r�r�r�r&r&r'�isNonUniformTable[s��zUtilities.isNonUniformTablecCsjz|��}Wnd|}t�tj|d�YdS|�tj�s%|�tj�r'dSd|}t�tj|d�dS)Nr)TFz'INFO: %s is neither showing nor visible)r*r	r+r,r-r.r1�
STATE_VISIBLEr2r&r&r'�isShowingOrVisibleis
�zUtilities.isShowingOrVisiblecCs�z
|��}|��}Wnd|}t�tj|d�YdS|�tj�r+|�tj�r+dStj	tj
tjtjtj
g}||vrN|�|�rNd|}t�tj|d�dSdS)Nz-ERROR: Exception getting state and role of %sTFz(HACK: Treating %s as showing and visible)r*r_r	r+r,r-r.r1r�rrrWrXrr�)r$r3r4rcr5rYr&r&r'r�ys,
��zUtilities.isShowingAndVisiblecCs.z|j}WdSt�tjd|d�YdS)NzDEAD: %sTF)r�r	r+r,)r$r3r�r&r&r'r�s�zUtilities.isDeadcCs�z|��}|��}|��}Wnt�tjd|d�YdStjtjtj	tj
tjtjtj
tjg}|dkrE||vrEt�tjd|d�dS|�tj�rWt�tjd|d�dS|�tj�rit�tjd|d�dSdS)NzZOMBIE: %s is null or deadTr�zZOMBIE: %s's index is -1zZOMBIE: %s is defunctzZOMBIE: %s is invalidF)r{r*r_r	r+r,r.r�r�r�r�r��	ROLE_PAGEr�r�r-r��
STATE_INVALID)r$r3r}r4rcr&r&r&r'r
�s4�zUtilities.isZombiecs�d�|f}t�tj|d�|r�sdS|��tjtjfvr dS��fdd�}||�r.|}nzt�||�}Wnd|}t�tj|d�d}Yd|�f}t�tj|d�|S)Nz*INFO: Searching for replicant for %s in %sTcs|o
�j|�ddd�S)NT)rFrG)r�rt�r3r$r&r'rv�s�z)Utilities.findReplicant.<locals>.<lambda>z*INFO: Exception from findDescendant for %sz-HACK: Returning %s as replicant for Zombie %s)r	r+r,r_r.r��
ROLE_EMBEDDEDrK)r$r�r3r5�isSame�	replicantr&r�r'�
findReplicant�s$zUtilities.findReplicantcCs<|sdSg}dd�}tt||����}|r|d��S|jS)NcSr�rr�r�r.r�rNr&r&r'rv�r�z3Utilities.getFunctionalChildCount.<locals>.<lambda>r)rQr�r�r�r��r$r3r�rZr�r&r&r'�getFunctionalChildCount�sz!Utilities.getFunctionalChildCountcs^|sdSg}dd�}tt||����}|r&|d��fdd�t����D�}|p.dd�|D�S)NcSr�rrr�rNr&r&r'rv�r�z1Utilities.getFunctionalChildren.<locals>.<lambda>rcrOr&rPrQrNr&r'rK�rRz3Utilities.getFunctionalChildren.<locals>.<listcomp>cSr�r&r&rGr&r&r'rK�r�)rQr�r�r�r�r�r&rNr'�getFunctionalChildren�szUtilities.getFunctionalChildrencCsB|sdSd}dd�}tt||����}|r|d�d�}|p |jS)NcSr�rr)r�r.r�rNr&r&r'rv�r�z/Utilities.getFunctionalParent.<locals>.<lambda>r)rQr�r�r�r^r�r&r&r'�getFunctionalParent�s
zUtilities.getFunctionalParentcsr|sdS|��tjkr%|�d�r%��|�\}}����|��\}}||fS|��tjk}|rP��|�}|r:|d}ndd�}	��t�	||	��}|rN|d}ndS��
|�}
��|
�}|dkri|
|jkri|�
�|fS��|
�}t|�dkr�tj�||�s�tjtjg���fdd�}
tt|
|��}|r�||vs�dS��|�r�tt�j|��}t|�dkr�dS|�|�}t|�}||fS)	Nr1�
readingRowrcSrrr)r_r.rrrtr&r&r'rv
rlz1Utilities.getPositionAndSetSize.<locals>.<lambda>r�cs��|�p
|���vSrr)r
r_rt��layoutRolesr$r&r'rvrlr)r_r.r�rxr�rCr�r�r�rKr�r�r^r{r�rTr7rzrrrQr�rr})r$r3�argsr�r��rowcount�colcountrgr��isMenur^r��siblings�isNotLayoutOnly�position�setSizer&r�r'�getPositionAndSetSize�sD







zUtilities.getPositionAndSetSizecCr�rr&)r$r3�	isBrailler&r&r'�getRoleDescription+r�zUtilities.getRoleDescriptioncCsP|jj�di�}|�t|�d�\}}}d||||f}t�tj|d�|||fS)N�textSelections�rrrz.INFO: Cached selection for %s is '%s' (%i, %i)T)r!r�rxr�r	r+r,)r$r3r�r4r�r�r5r&r&r'�getCachedTextSelection.s

z Utilities.getCachedTextSelectioncs�z|��}Wn(tyd|}t�tj|d�d}Ynd|}t�tj|d�d}Y|jj�d�rL|�|�\}}}|sLd|jjd<i|jjd<|jj�di��t	|��vru��
t	|�����fdd����D�D]}��
|�qmd	\}}	}
|r�z	|�d
�\}}	Wnd|}t�tj|d�d
}}	Y||	kr�|�
||	�}
d||
||	f}t�tj|d�||	|
f�t	|�<�|jjd<dS)
Nz%ERROR: %s doesn't implement AtspiTextTz/ERROR: Exception querying text interface for %sr
Fr�csg|]}��|��kr|�qSr&)rx)rH�k�r�r�r&r'rKMr�z7Utilities.updateCachedTextSelection.<locals>.<listcomp>r�rz-ERROR: Exception getting selected text for %sz+INFO: New selection for %s is '%s' (%i, %i))r�r�r	r+r,r!r�rxrr��poprr�r�)r$r3r�r5r�
selectedStart�selectedEndrur4r�r�r&r�r'�updateCachedTextSelection5sD

z#Utilities.updateCachedTextSelectioncGsPtj}|sdSt��tjdkrd}t�tj|d�dSt��t_|j|�dS)Ng�������?zEINFO: Clipboard contents change notification believed to be duplicateT)	rr�r�r�_last_clipboard_updater	r+r,�onClipboardContentsChanged)r�r%r5r&r&r'r�bs
z$Utilities.onClipboardContentsChangedcCs8|jdurdStj�tj�dd��}|�d|j�|_dS)N�	CLIPBOARDFzowner-change)	r"r�	Clipboardrxr�Atom�intern�connectr��r$�	clipboardr&r&r'�connectToClipboardps

�zUtilities.connectToClipboardcCs4|jdurdStj�tj�dd��}|�|j�dS�Nr�F)r"rr�rxrr�r��
disconnectr�r&r&r'�disconnectFromClipboardxs
z!Utilities.disconnectFromClipboardcCstj�tj�dd��}|��Sr�)rr�rxrr�r��
wait_for_textr�r&r&r'�getClipboardContentsszUtilities.getClipboardContentscCs&tj�tj�dd��}|�|d�dS)Nr�Fr�)rr�rxrr�r��set_text�r$r�r�r&r&r'�setClipboardText�szUtilities.setClipboardTextcCs(tj�tj�dd��}|�|j|�dSr�)rr�rxrr�r��request_text�_appendTextToClipboardCallbackr�r&r&r'�appendTextToClipboard�szUtilities.appendTextToClipboardr�cCs(|�d�}d|||f}|�|d�dS)Nr�z%s%s%sr�)�rstripr�)r$r�r�r��	separatorr&r&r'r�s
z(Utilities._appendTextToClipboardCallbackcCs*ttjtj�s	dStj}|o|�|jj�Sr�)	r\rr�rr�r��isFromApplicationr!r=rr&r&r'�lastInputEventCameFromThisApp�sz'Utilities.lastInputEventCameFromThisAppcCstj}t|tj�sdS|��Sr�)rr�r\rr��isPrintableKeyrr&r&r'r��sz'Utilities.lastInputEventWasPrintableKeycCs|��\}}|tj@Srr�r�r�CTRL_MODIFIER_MASK�r$�	keyStringr�r&r&r'�lastInputEventWasCommand�s
z"Utilities.lastInputEventWasCommandcCs4|��\}}|��r|tj@S|dvr|tj@SdS�N)r�r�F)r�r�r�ALT_MODIFIER_MASKr	r
r&r&r'�lastInputEventWasPageSwitch�s

z%Utilities.lastInputEventWasPageSwitchcCsH|��\}}|dvrdS|tj@s |tj@s |tj@s |tj@r"dSdS)N)�Left�Rightr�r�FT)r�rr	�SHIFT_MODIFIER_MASKr�ORCA_MODIFIER_MASKr
r&r&r'� lastInputEventWasUnmodifiedArrow�s
���z*Utilities.lastInputEventWasUnmodifiedArrowcCs |��p|��p|��p|��Srr)�lastInputEventWasCharNav�lastInputEventWasWordNav�lastInputEventWasLineNav� lastInputEventWasLineBoundaryNavrJr&r&r'�lastInputEventWasCaretNav�s���z#Utilities.lastInputEventWasCaretNavcC�$|��\}}|dvrdS|tj@S�N)rrFrr
r&r&r'r��z"Utilities.lastInputEventWasCharNavcC�"|��\}}|dvrdS|tj@Srrr
r&r&r'r��
z"Utilities.lastInputEventWasWordNavcC�"|��\}}|dksdS|tj@S)NrFrr
r&r&r'r��rz&Utilities.lastInputEventWasPrevWordNavcCr)NrFrr
r&r&r'r��rz&Utilities.lastInputEventWasNextWordNavcC�4|��\}}|dvrdS|�tj�rdS|tj@S)N)r�r�F�r�r�rr�rr	r
r&r&r'r��z"Utilities.lastInputEventWasLineNavcCr�N)�Home�EndFrr
r&r&r'r�rz*Utilities.lastInputEventWasLineBoundaryNavcCr r
r!r
r&r&r'�lastInputEventWasPageNav�r"z"Utilities.lastInputEventWasPageNavcCrr#rr
r&r&r'� lastInputEventWasFileBoundaryNav�rz*Utilities.lastInputEventWasFileBoundaryNavcCs"|��\}}|tj@r|dvSdS)N)r$r%r�r�rrF)r�rrr
r&r&r'�&lastInputEventWasCaretNavWithSelection�s
z0Utilities.lastInputEventWasCaretNavWithSelectioncC�<|��\}}|�|�}d|vrdS|tj@r|tj@SdS�N�zF�r�r�rr	r�r$r�r�r
r&r&r'�lastInputEventWasUndo�

zUtilities.lastInputEventWasUndocCs:|��\}}|�|�}d|vrdS|tj@r|tj@SdSr*r,r-r&r&r'�lastInputEventWasRedos


zUtilities.lastInputEventWasRedocCr))NruFr,r-r&r&r'�lastInputEventWasCutr/zUtilities.lastInputEventWasCutcCr))Nr�Fr,r-r&r&r'�lastInputEventWasCopy%r/zUtilities.lastInputEventWasCopycCr))N�vFr,r-r&r&r'�lastInputEventWasPaste0r/z Utilities.lastInputEventWasPastecCr))Nr�Fr,r-r&r&r'�lastInputEventWasSelectAll;r/z$Utilities.lastInputEventWasSelectAllcCsD|��\}}|dkrdS|��\}}|�|�}d|vrdS|tj@S)Nr�Tr�F)r�r�r�rr	)r$rr�r�r
r&r&r'�lastInputEventWasDeleteFs

z!Utilities.lastInputEventWasDeletecCs>|��\}}|dvrdS|tj@s|tj@s|tj@rdSdS)N)r��ISO_Left_TabFT)r�rr	rrr
r&r&r'�lastInputEventWasTabRs
��zUtilities.lastInputEventWasTabcCsttjtj�Srr)r\rr�r�MouseButtonEventrJr&r&r'�lastInputEventWasMouseButton^rfz&Utilities.lastInputEventWasMouseButtoncC�&tj}t|tj�r|jdko|jSdS�N�1F�rr�r\rr9�button�pressedrr&r&r'�"lastInputEventWasPrimaryMouseClicka�z,Utilities.lastInputEventWasPrimaryMouseClickcCr;�N�2Fr>rr&r&r'�!lastInputEventWasMiddleMouseClickhrBz+Utilities.lastInputEventWasMiddleMouseClickcCr;�N�3Fr>rr&r&r'�$lastInputEventWasSecondaryMouseClickorBz.Utilities.lastInputEventWasSecondaryMouseClickcC�(tj}t|tj�r|jdko|jSdSr<r>rr&r&r'�$lastInputEventWasPrimaryMouseReleasev�z.Utilities.lastInputEventWasPrimaryMouseReleasecCrIrCr>rr&r&r'�#lastInputEventWasMiddleMouseRelease}rKz-Utilities.lastInputEventWasMiddleMouseReleasecCrIrFr>rr&r&r'�&lastInputEventWasSecondaryMouseRelease�rKz0Utilities.lastInputEventWasSecondaryMouseRelease��?c
Cs�tj}|sdSt��}||j|krdS|jj�dd�}|||kr$dSt|tj�r1|�	�s0dSnt|tj
�rJ|�|jj�sJ|�
�\}}|dvrJdSztj��}Wndtj}t�tj|d�YdStjtjtjtjg}	||	vS)NFzlast-table-sort-timer)r��spacer8r*T)rr�r�r!r�rxr\rr9rJr��isHandledBy�leftClickReviewItemr�r�r_r	r+r,r.r�r�r�r�)
r$r�r�now�lastSortTimerr�rcr5r�r&r&r'�lastInputEventWasTableSort�s<�
�z$Utilities.lastInputEventWasTableSortcCs�|�|jtj�r
dSz|j��}|j��}Wnd|j}t�tj|d�YdS|t	j
t	jfvr4dS|t	jkr?|�
t	j�S|t	jkrJ|�
t	j�SdS)NT�-ERROR: Exception getting role and state of %sF)r�rrr�r_r*r	r+r,r.r�rr�r-r�r��r$rrcr4r5r&r&r'�!isPresentableExpandedChangedEvent�s 



z+Utilities.isPresentableExpandedChangedEventcCs@|j�d�s|j�d�sdSz|j��}|j��}Wnd|j}t�tj|d�YdStj	tj
tjtjtj
g}||vrJd}t�tj|d�dS|tjkrg|�tj�sg|�tj�sgd}t�tj|d�dS|�|j�rs|�tj�S|tjkr�|�tj�r�dStj|j|jjfvr�dS|�tj�r�dSd}t�tj|d�dS)	Nzobject:text-changed:zobject:text-attributes-changedFrUTz.INFO: Event is not being presented due to rolez9INFO: Event is not being presented due to role and statesz7INFO: Event is not being presented due to lack of cause)r�rnrr_r*r	r+r,r.r�rr�ROLE_SLIDERr�r�r-r�r�r"rrr�r^r)r$rrcr4r5�ignoreRolesr&r&r'�,isPresentableTextChangedEventForLocusOfFocus�sP
�

�

�
�z6Utilities.isPresentableTextChangedEventForLocusOfFocuscCs<|j�d�sdS|�|j�rdS|��\}}|dkrdSdS)N�object:text-changed:deleteFr�T)r�rnr3rr�)r$rrr�r&r&r'�#isBackSpaceCommandTextDeletionEvent�sz-Utilities.isBackSpaceCommandTextDeletionEventcC�|j�d�sdS|��S�Nr[F)r�rnr6rr&r&r'� isDeleteCommandTextDeletionEvent�z*Utilities.isDeleteCommandTextDeletionEventcCs4|j�d�sdS|��sdS|�|j�\}}}|Sr^)r�rnr.r�r�r$rr4r�r�r&r&r'�isUndoCommandTextDeletionEventsz(Utilities.isUndoCommandTextDeletionEventcCsD|j�d�sdS|��rdS|�|j�\}}}|o!|��|j��kSr^)r�rnr4r�rr�r0rar&r&r'�isSelectedTextDeletionEventsz%Utilities.isSelectedTextDeletionEventcCsF|j�d�sdS|�|j�|�|j�\}}}|o"||jko"||jkS�Nr�F)r�rnr�rr�r0r�rar&r&r'�isSelectedTextInsertionEvents
z&Utilities.isSelectedTextInsertionEventcCs|��sdS|�|�r
dSdSr�)r.rerr&r&r'�isSelectedTextRestoredEvent#s

z%Utilities.isSelectedTextRestoredEventcCr]rd)r�rnrErr&r&r'�%isMiddleMouseButtonTextInsertionEvent,r`z/Utilities.isMiddleMouseButtonTextInsertionEventcCs�|j�d�sdSz|j��}|j��}Wnd|j}t�tj|d�YdS|�t	j
�rF|�t	j�sF|jtj
krFd}t�tj|d�dS|t	jkrPt�d�St|j���dkr^t�d�SdS)	Nr�FrUTzHINFO: Not echoable text insertion event: focusable source is not focused�
enableKeyEchorrh)r�rnrr_r*r	r+r,r-r.r�r�rr�rr�r�rTr0r�rVr&r&r'�isEchoableTextInsertionEvent2s&




z&Utilities.isEchoableTextInsertionEventcCsL|�|�sdSz|��}Wnd|}t�tj|d�YdS|�tj�S)NFr)T)r-r*r	r+r,r-r.r.r2r&r&r'rcLs
zUtilities.isEditableTextAreacCs�|j�d�sdS|��r|��rdS|�|�rdSd|jvr$|��r$dS|�|j�s,dS|��}|s4dS|j	|kr;dSt
t�d|j	��t
t�d|��krNdSd|vr[|j	�
�|vr[dSdS)Nzobject:text-changedF�deleteTz\wr�)r�rnrr.r\r4rcrr�r0r�r\r�r)r$r�contentsr&r&r'�isClipboardTextChangedEventYs(

"z%Utilities.isClipboardTextChangedEventcCsv|ptj}|r|�|�rdS|��}|sdS|�|�\}}}|r&||vr&dS|�|�p,|}|�|�r4dS|o:|j|vSr�)rr�rr�rr�r�)r$r3rkr�r4r�r&r&r'�objectContentsAreInClipboardys

z&Utilities.objectContentsAreInClipboardcCs4d|jjd<d|jjd<d|jjd<d|jjd<dS)NF�undo�redo�paster�last-selection-message)r!r�rJr&r&r'�clearCachedCommandState�sz!Utilities.clearCachedCommandStatecCs�|��r |jj�d�s|j�tj�d|jjd<|�|j�dS|�	�r@|jj�d�s8|j�tj
�d|jjd<|�|j�dSdS)NrnTroF)r.r!r�rx�presentMessager�UNDOr�rr0�REDOrr&r&r'�handleUndoTextEvent�szUtilities.handleUndoTextEventcCsx|��rdS|��r |jj�d�s|j�tj�d|jjd<dS|��r:|jj�d�s8|j�tj	�d|jjd<dSdS)NFrnTro)
r�r.r!r�rxrsrrtr0rurJr&r&r'�handleUndoLocusOfFocusChange�sz&Utilities.handleUndoLocusOfFocusChangecCsH|��rdS|��r"|jj�d�s |j�tjtj�d|jjd<dSdS)NFrpT)	r�r4r!r�rxrsr�CLIPBOARD_PASTED_FULL�CLIPBOARD_PASTED_BRIEFrJr&r&r'�handlePasteLocusOfFocusChange�s�z'Utilities.handlePasteLocusOfFocusChangecCsxtjsd}t�tj|d�dSt��tjj}|dkr)d|}t�tj|d�dS|�|�r:d}t�tj|d�dSdS)Nz.INFO: Not user triggered: No last input event.TFrz5INFO: Not user triggered: Last input event %.2fs ago.zCINFO: Last key was consumed. Probably a bogus event from a key grab)rr�r	r+r,r��isKeyGrabEvent)r$rr5r�r&r&r'�eventIsUserTriggered�s
zUtilities.eventIsUserTriggeredcCs$ttjtj�s	dStj��otjS)zT Returns True if this event appears to be a side-effect of an
        X11 key grab. F)r\rr�rr��
didConsume�
openingDialogrr&r&r'r{�szUtilities.isKeyGrabEventcCs|��rdS|��rdSdSr)rwrzrJr&r&r'�presentFocusChangeReason�s
z"Utilities.presentFocusChangeReasonc	Cst�|�}d|vrdS|��}|�tj�r|�tj�sdS|��}|tjtjfvr+dS|�	�}|j
s4dS|�|�|jkrV|�
d�}||vrGdSd|j}t�tj|d�dSd|vr\dS|��}|j|jkrud|j}t�tj|d�dS|j|jkr�d|j}t�tj|d�dSdS)	Nr�Frz-INFO: All %i children believed to be selectedTr�z)INFO: All %i rows believed to be selectedz,INFO: All %i columns believed to be selected)r.r�r*r-r�r�r_r�rr6r7rHr�r8r	r+r,r�rGr��nSelectedColumnsr)	r$r3r�r4rcrrIr5r�r&r&r'�allItemsSelected�sB

�



zUtilities.allItemsSelectedcCs`|jj�d�}|�|�}|r|rdS||jjd<|��r.|r.|j�tj�t�	d|d�dSdS)Nr�TF)
r!r�rxr�r5rsr�CONTAINER_SELECTED_ALLrr5)r$r3�allAlreadySelected�allCurrentlySelectedr&r&r'�handleContainerSelectionChanges
z(Utilities.handleContainerSelectionChangecCs�z	|��}|j}Wnd|}t�tj|d�YdS|��s"dS|�d�\}}|�||�}|s3dS|r=|�|j	�s=|S|sG|�
|j	�sG|Stt|��}	|sS|	�
�|	D]}
|�||
|�}|re|SqUdS)Nz<ERROR: Exception querying text and getting childCount for %sTr)r�r�r	r+r,r�r�r�rnr�rPrQr�r��_findSelectionBoundaryObject)r$r��	findStartr�r�r5r4r�r��indicesr�r�r&r&r'r�s4
�z&Utilities._findSelectionBoundaryObjectcCs |�|d�}|�|d�}||fSr)r�)r$r�r;r<r&r&r'�_getSelectionAnchorAndFocus@sz%Utilities._getSelectionAnchorAndFocusc
Cs|r|sgSdd�}|j}g}t|��|jj�D]"}|j|}|�|�r%q|�|�|�|�|||��||vr:nq||krA|S||vrT|�|�|�|�|||��z|j|��d}Wn|}Yz|�|�}	Wn
t	ywY|Sw||kr�|	d7}	|d|	�}|S)NcSs|Srrr&rtr&r&r'rvKsz'Utilities._getSubtree.<locals>.<lambda>r)
r�r�r{r^r�r�rPr�r}r:)
r$�startObj�endObjr�r��subtreer�rI�lastObjrwr&r&r'�_getSubtreeGsB


�
�zUtilities._getSubtreecCs"|r	dt�|�vsdS|�|�\}}}|�|�|�|�\}}}|�t|��r)dS|��s:|r:|s:|j�t	j
�dSg}	tt||��}
tt||��}|
�
|�sQdS|
rm|rm|
�|�sm|	�||t	jg�|	�||t	jg�nYt|
�|��}|sxdS|d|dd}
}|
|kr�|	�|
|t	jg�|�|j�r�||
kr�|�||d�}|�|d�n|	�|
|t	jg�|�|j�r�|�||d�}|�|d�|o�t�d�}|��}|	D]:\}}}|�||�}|�|j�}|r�|d8}|j�|||�|r�|s�|jj|dd�|�r|�||�}|�||�q�dS)	Nr�FTrr�rr�)�	interrupt)r.r�r�r��_speakTextSelectionStaterTr(r!�speakMessager�SELECTION_REMOVEDrXr��unionr�r��TEXT_UNSELECTED�
TEXT_SELECTEDrU�symmetric_differencerPr�r�handleTextSelectionChanger�r�r�r��	sayPhrase)r$r3r��oldStart�oldEnd�	oldString�newStart�newEndr��changes�oldChars�newChars�change�changeStart�	changeEndrIr�r4r��messager��
endsWithChildr&r&r'r�os^

��z#Utilities.handleTextSelectionChangecCr�)�!Hacky and to-be-obsoleted method.)r�PARAGRAPH_SELECTED_DOWN�PARAGRAPH_UNSELECTED_DOWN�PARAGRAPH_SELECTED_UP�PARAGRAPH_UNSELECTED_UPrJr&r&r'�_getCtrlShiftSelectionsStrings�s
�z(Utilities._getCtrlShiftSelectionsStringsc	Cs�t�d�rdS|��\}}|tj@}|tj@}|dk}d}|dkr)|r)|r)tj}n�|dkr5|r5|r5tj}n�|dkrG|rG|sG|rCtj	}n�tj
}n|dkrY|rY|sY|rUtj}nqtj}nm|dkrq|rq|rq|�
�}|rl|d}nZ|d}nU|d	kr�|r�|r�|�
�}|r�|d
}nB|d}n=|dkr�|r�|r�|r�tj}n/tj}n+|d
kr�|r�|r�|r�tj}ntj}n|��r�|r�|jj�d�s�d|jjd<tj}ndS|s�dS||jj�d�kr�||jjd<|j�|�dS)r�r�FrNr�r�r�rr�r�r�r$r%r
Trq)r�r�r�rr	rr�LINE_SELECTED_RIGHT�LINE_SELECTED_LEFT�PAGE_SELECTED_DOWN�PAGE_UNSELECTED_DOWN�PAGE_SELECTED_UP�PAGE_UNSELECTED_UPr��DOCUMENT_SELECTED_UP�DOCUMENT_UNSELECTED_UP�DOCUMENT_SELECTED_DOWNr5r!r�rx�DOCUMENT_SELECTED_ALLr�)	r$rr�r��isControlKey�
isShiftKeyrrv�stringsr&r&r'r��s`






z"Utilities._speakTextSelectionState)F)Trr)FF)rrI)Tr�)rr�r�)r8)TT)rT)Nr�F)r�)r�)rN(��__name__�
__module__�__qualname__r.�Registry�
getDesktoprLr�r�r��ZERO_WIDTH_NO_BREAK_SPACEr�r�r\�UNICODE�flagsrnr�r�r�r�r�r�r�r�r	r}rr(r6�staticmethodr@rDr[rdrqrr�r�r�rr�r�r�r�rrr�r�r�rrr	rrrrrrrr r!r"r'r(r)r*r+r,r-r.r/r0r1r2r3r4r5r6r7r8r9r:r;r<r=r>r?r@rArBrCrDrErFrGrHrIrJrKrLrMrNrOrPrQrRrSrTrUrVrWrXrYrZr[r\r]r^r_r`rarbrcrdrerfrgrhrirjrkrlrmrnrorprqrrrsrtrurvrwrxryr{r|r}r~rr�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�rsr�r�r�r�r�r�r�r�r�rrrr
rr)r,r0r1r6r?r�r-rOr�rbr[r{rr r�r�r�r�r�r�r�r!r�r�r�r�r�r�rr�r�r�r�r�rXr�r�r�r�r�r�r�r�r�rprrrr	rrrrrrrr(r*r,r-r.r�r1r2rr�r4r7r6rr;r<rBr&r]rbrcr^rlr~r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrCr!r$r&r'r,r.r0r2r�rArFrHrJrMrQrTrVrZr\r]r[r^rarbrdrer�rirjrlrmrWrurvr�rwrxryrzr|r�r�r�r�r�r�r�r�rCr�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�rrrr�rrrrrrr�r�rrr&r'r(r.r0r1r2r4r5r6r8r:rArErHrJrLrMrTrWrZr\r_rbrcrerfrgrircrlrmrrrvrwrzr|r{rr�r�r�r�r�r�r�r�r&r&r&r'rBs���
#
&E6!
7
 )
&

	
"
r
&
; "66 
V #

?'!#(	
#%$
5&&	,

@7*


/L
',% 	
--




$.


	
 
-"(Fr)$�__doc__�__id__�__version__�__date__�
__copyright__�__license__rV�girSrr.r\r:r�r�rrrrrr	r
rrr
rrrrrrrr�
getManagerr�rr&r&r&r'�<module>sB

Youez - 2016 - github.com/yon3zu
LinuXploit