Mini Shell

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

3

�p5[�z�@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 ej!�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.ZLGPL�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�eZdZejjd�ZdZddddddd	d
ddg
Zd
dddddddddg
Z	e
jZe
j
de�Ze
j
ddje�e�Ze
j
ddje	�e�ZdZdZdZdZdZdd �Zd!d"�Zed#d$��Zd%d&�Zd'd(�Zed)d*��Zd+d,�Zd-d.�Zd/d0�Z d1d2�Z!d3d4�Z"d5d6�Z#�d�d8d9�Z$d:d;�Z%ed<d=��Z&d>d?�Z'd@dA�Z(dBdC�Z)dDdE�Z*�d�dFdG�Z+dHdI�Z,dJdK�Z-dLdM�Z.dNdO�Z/dPdQ�Z0dRdS�Z1dTdU�Z2dVdW�Z3dXdY�Z4dZd[�Z5d\d]�Z6d^d_�Z7d`da�Z8dbdc�Z9ddde�Z:dfdg�Z;dhdi�Z<djdk�Z=dldm�Z>dndo�Z?dpdq�Z@drds�ZAdtdu�ZBdvdw�ZCdxdy�ZDdzd{�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��Z`d�d��Zad�d��Zb�d�d�d��Zcd�d��Zdd�d��Zed�d��Zfd�d��Zgd�d��Zhd�dÄZid�dńZjd�dDŽ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�Zd�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�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�e�d(�d)��Z��d*�d+�Z��d,�d-�Z��d.�d/�Z��d0�d1�Z��d��d3�d4�Z��d5�d6�Z�e�d7�d8��Z��d9�d:�Z�e�d;�d<��Z�e�d=�d>��Z��d?�d@�Z��dA�dB�Z��d��dC�dD�Z��dE�dF�Z��dG�dH�Z��d��dI�dJ�Z�e�dK�dL��Z��dM�dN�Z��dO�dP�Z��dQ�dR�Z��dS�dT�Z��dU�dV�Z��dW�dX�Z��dY�dZ�Z��d��d[�d\�Z�e�d��d]�d^��Z�e�d��d_�d`��Z�e�da�db��Z�e�dc�dd��Z��de�df�Z��dg�dh�Z��d��dj�dk�Z��dl�dm�Z��dn�do�Z��dp�dq�Z�e�dr�ds��Z��dt�du�Z��dv�dw�Zdx�dy�Z�e�dz�d{��ZĐd|�d}�Z�e�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ؐd��d��Zِd��d��Zڐd��d��d��Zېd��d��Z�e�d��d���Z�e�d��d���Zސd��d��Zߐd��d��Z�d��d��Z�d��d��Z�e�d��d���Z�e�d��d��d���Z�d��d��Z�d��d��Z�ddÄZ�d��dĐdńZ�dƐdDŽ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�d֐dׄZ�e�dؐdل�Z�d��dڐdۄZ�d��dܐd݄Z�dÐdސd߄Z��dŐd�d�Z��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���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�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/�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(e�dG�dH���Z)�dI�dJ��Z*�dK�dL��Z+�dM�dN��Z,�dO�dP��Z-�dQ�dR��Z.�dS�dT��Z/�dU�dV��Z0�dW�dX��Z1�dY�dZ��Z2�d[�d\��Z3�d]�d^��Z4�d_�d`��Z5�da�db��Z6�dc�dd��Z7�de�df��Z8�dg�dh��Z9�di�dj��Z:�dk�dl��Z;�dm�dn��Z<�do�dp��Z=�dq�dr��Z>�ds�dt��Z?�du�dv��Z@�dw�dx��ZA�dy�dz��ZB�d{�d|��ZC�d}�d~��ZD�d�d���ZE�dʐd��d���ZF�d��d���ZG�d��d���ZH�d��d���ZI�d��d���ZJ�d��d���ZK�d��d���ZL�d��d���ZM�d��d���ZN�d��d���ZO�d��d���ZP�d��d���ZQ�dːd��d���ZR�d��d���ZS�d��d���ZT�d��d���ZU�d��d���ZV�d��d���ZW�d��d���ZX�d��d���ZY�d��d���ZZd7S(��	Utilitiesruu⁰�¹�²�³u⁴u⁵u⁶u⁷u⁸u⁹u₀u₁u₂u₃u₄u₅u₆u₇u₈u₉z(\W+)z[%s]+��displayedLabel�
displayedTextZ
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"�&/usr/lib/python3.6/script_utilities.py�__init__[szUtilities.__init__c
Cs\y|j�}Wn"d|}tjtj|d�dS|jtj�s@dS|jtj�rPdS|jtj�S)Nz$ERROR: Exception getting state of %sTF)	�getStater�println�
LEVEL_INFO�contains�pyatspi�STATE_ACTIVEZSTATE_ICONIFIED�
STATE_SHOWING)r �obj�state�msgr"r"r#�"_isActiveAndShowingAndNotIconifiedlsz,Utilities._isActiveAndShowingAndNotIconifiedc	Cs:|sdS|j�}ytjd|�}Wn
dS|jdd�S)Nrzcat /proc/%s/cmdline�� )Zget_process_id�
subprocessZ	getoutput�replace)�app�pidZcmdliner"r"r#�_getAppCommandLine|szUtilities._getAppCommandLinecCs�|sdSy|j�}Wnd}YnXd|||j|�f}tjtj|d�|j�|j|�sxd|}tjtj|d�dSd|}tjtj|d�dS)NFzINFO: Looking at %s from %s %sTz3INFO: %s is not active and showing, or is iconifiedzINFO: %s can be active window)�getApplicationr6rr&r'�
clearCacher/)r �windowr4r.r"r"r#�canBeActiveWindow�s 

zUtilities.canBeActiveWindowcsg}|p�j�}xN|D]F}y|j�fdd�|D��Wqd|}tjtj|d�YqXqW|s�dttt|��}tjtj|d�dSt|�dkr�d|d	}tjtj|d�|d	St	|t
j�j�d
�}dttt|��}tjtj|d�d|d	}tjtj|d�|d	S)
z:Tries to locate the active window; may or may not succeed.csg|]}�j|�r|�qSr")r:)�.0�child)r r"r#�
<listcomp>�sz*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�extendrr&r'�list�map�str�len�sorted�	functools�
cmp_to_key�sizeComparison)r ZappsZ
candidatesr4r.r")r r#�activeWindow�s,
zUtilities.activeWindowc	Cs�|sdSt|gj�s|g}t|gj�s,|g}d}|j}xP|r�||jkr�y|j�}WnPYnX||krr|}Pq8||kr~Pq8|j}q8W|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)r,Z
ancestorRoles�	stopRoles�ancestor�roler"r"r#�ancestorWithRole�s(
zUtilities.ancestorWithRolec	CsJytdd�|j�D��}Wni}YnX|jd�}|rBt|�S|j�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.
        cSsg|]}|jdd��qS)�:r)�split)r;�attrr"r"r#r=�sz'Utilities.cellIndex.<locals>.<listcomp>ztable-cell-index)�dict�
getAttributes�get�int�getIndexInParent)r r,�attrs�indexr"r"r#�	cellIndex�s	

zUtilities.cellIndexcCspy|jj�}Wn
gS|j�jtj�s.gSg}|j�}y^xX|D]P}|j�tjkrBx8t	|j
��D](}|j|�}|rb|j�dkrb|j
|�qbW|SqBWWnYnX|j|�}|j|�}	|j|�}
|j|�}d}x�t	|	d|j�D]�}
|j|
|
�}|�s�q�|j�}x\|D]T}|j�tjk�r
|jd�}|j||��rB|j
|�n|j|�}||k�rZd}P�q
W|r�Pq�W|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
        rFrT���)rL�
queryTabler%r(r)�STATE_EXPANDED�getRelationSet�getRelationType�RELATION_NODE_PARENT_OF�range�getNTargets�	getTargetrY�appendr\�
getRowAtIndex�getColumnAtIndexr�nRows�getAccessibleAt�RELATION_NODE_CHILD_OF�isSameObject)r r,�table�nodes�	relations�relation�target�noder[�row�colr�done�i�cellZnodeOfZcurrentLevelr"r"r#�
childNodes�sT











zUtilities.childNodesc
CsVd||f}tjtj|d�|o"|s(dS||kr4|S|g}y6|j}x"|rd|j|krd|j|�|j}qDW|j�Wntjtj�YnX|g}y6|j}x"|r�|j|kr�|j|�|j}q�W|j�Wntjtj�YnXd}tt	|�t	|��}d}	x8|	|k�r2|j
||	||	��r.||	}|	d7}	q�Pq�Wd|||f}tjtj|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)rr&r'rLrf�reverse�printExceptionZLEVEL_FINEST�minrDrl)
r �a�br.ZaParentsrLZbParents�commonAncestorZ	maxSearchrvr"r"r#r~CsF




zUtilities.commonAncestorcCs�tjtjtjg}|j�jtj�s,|j�|kr0dSd}xnt|j	ddd�D]X}||j�tj
kr|||j�jtj�r|||}n||j�|kr�|j||�}|rHPqHW|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])
r)�	ROLE_TREE�ROLE_TREE_TABLE�
ROLE_TABLEr%r(�STATE_MANAGES_DESCENDANTSrMrc�
childCount�ROLE_PUSH_BUTTONZSTATE_IS_DEFAULT�
defaultButton)r r,�	skipRolesr�rvr"r"r#r�ys 

zUtilities.defaultButtoncCs�y|jj|j|S|j|jjkr6i|jj|j<d}YnX|j|�}x|D]}|j||j|��}qPW||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 r,ZlabelString�labels�labelr"r"r#r�s


zUtilities.displayedLabelcCs^y|jj|j|Sd}YnXy|j�}|j}Wn,d|}tjtj|d�d}d}YnX|tj	krv|rv|Sy|j
�}|jd|j�}WnYnX|j
|kr�d}|s�y
|j}Wnttfk
r�YnX|o�|tj	tjgk�r|j|�}|�s
|j|dd�}djt|j|��}|j|jjk�r: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 %sTrrF)�onlyShowingr1)rr��DISPLAYED_TEXTrM�namerr&r'r)r��	queryText�getText�characterCount�EMBEDDED_OBJECT_CHARACTER�LookupError�RuntimeError�ROLE_LIST_ITEM�unrelatedLabels�joinrBr)r r,rrPr�r.�textr�r"r"r#r�sF






zUtilities.displayedTextNcCsj|s|j�\}}tjtjtjtjtjtjg}tjtj	g}|j
|||�}|rftjrftjj
�|krftj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_PANErQr�locusOfFocusrM)r r,�offsetZdocRolesrN�documentr"r"r#�
documentFrame�szUtilities.documentFramecCsdS)z5Returns the URI of the document frame that is active.Nr")r r"r"r#�documentFrameURIszUtilities.documentFrameURIc
CsR|sdS|j�jtj�r|Sx0|D](}ytj|�}|r:|SWq"Yq"Xq"WdS)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)�rootr<�	candidater"r"r#r�s


zUtilities.focusedObjectcCs^ddg}|j}xJ|rX|j|krX|j�tjkr4||d<|j�tjtjgkrP||d<|j}qW|S)z;Returns the frame and (possibly) the dialog containing obj.Nrr)rLrMr)r��ROLE_DIALOGZROLE_FILE_CHOOSER)r r,�resultsrLr"r"r#�frameAndDialog(s


zUtilities.frameAndDialogcCsdS)NFr")r �eventr"r"r#� presentEventFromNonShowingObject8sz*Utilities.presentEventFromNonShowingObjectcCs*|r&|j�tjkr&|j|tj�r&dSdS)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)rMr)�ROLE_COMBO_BOXrlrr�)r r,r�r"r"r#�grabFocusBeforeRouting;sz Utilities.grabFocusBeforeRoutingc
Cs~|}xt|D]l}|dkrdSt|t�s*|g}y$t|dt�rD|j�}n|j�}Wnd}YnX||krldS|j|�}q
WdS)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)rJrArCZgetRoleNamerM�validParent)r r,Z	rolesListZcurrentrPZcurrent_roler"r"r#�hasMatchingHierarchyMs 



zUtilities.hasMatchingHierarchyc	CsL|s
tj}y|j�}Wn
dS|tjkr0dSdd�}tj||�}|dk	S)zyReturns True if the given object is in the Find toolbar.

        Arguments:
        - obj: an accessible object
        FcSs|o|j�tjkS)N)rMr)Z
ROLE_TOOL_BAR)�xr"r"r#�<lambda>�sz)Utilities.inFindToolbar.<locals>.<lambda>N)rr�rMr)�
ROLE_ENTRY�findAncestor)r r,rPZ	isToolbarZtoolbarr"r"r#�
inFindToolbarvs
zUtilities.inFindToolbarcCsdS)NFr")r r,r"r"r#�isAnchor�szUtilities.isAnchorcCsdS)NFr")r r,r"r"r#�isComboBoxWithToggleDescendant�sz(Utilities.isComboBoxWithToggleDescendantcCsdS)NFr")r r,r"r"r#�isToggleDescendantOfComboBox�sz&Utilities.isToggleDescendantOfComboBoxcCsdS)NFr")r r,r"r"r#�isTypeahead�szUtilities.isTypeaheadcCsdS)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"r#�isFunctionalDialog�szUtilities.isFunctionalDialogcCsdS)NFr")r r,r"r"r#�isEmpty�szUtilities.isEmptycCsdS)NFr")r r,r"r"r#�isHidden�szUtilities.isHiddencCsdS)NFr")r r,r"r"r#�isDPub�szUtilities.isDPubcCsdS)NFr")r r,r"r"r#�isDPubAbstract�szUtilities.isDPubAbstractcCsdS)NFr")r r,r"r"r#�isDPubAcknowledgments�szUtilities.isDPubAcknowledgmentscCsdS)NFr")r r,r"r"r#�isDPubAfterword�szUtilities.isDPubAfterwordcCsdS)NFr")r r,r"r"r#�isDPubAppendix�szUtilities.isDPubAppendixcCsdS)NFr")r r,r"r"r#�isDPubBibliography�szUtilities.isDPubBibliographycCsdS)NFr")r r,r"r"r#�isDPubBacklink�szUtilities.isDPubBacklinkcCsdS)NFr")r r,r"r"r#�isDPubBiblioref�szUtilities.isDPubBibliorefcCsdS)NFr")r r,r"r"r#�
isDPubChapter�szUtilities.isDPubChaptercCsdS)NFr")r r,r"r"r#�isDPubColophon�szUtilities.isDPubColophoncCsdS)NFr")r r,r"r"r#�isDPubConclusion�szUtilities.isDPubConclusioncCsdS)NFr")r r,r"r"r#�isDPubCover�szUtilities.isDPubCovercCsdS)NFr")r r,r"r"r#�isDPubCredit�szUtilities.isDPubCreditcCsdS)NFr")r r,r"r"r#�
isDPubCredits�szUtilities.isDPubCreditscCsdS)NFr")r r,r"r"r#�isDPubDedication�szUtilities.isDPubDedicationcCsdS)NFr")r r,r"r"r#�
isDPubEndnote�szUtilities.isDPubEndnotecCsdS)NFr")r r,r"r"r#�isDPubEndnotes�szUtilities.isDPubEndnotescCsdS)NFr")r r,r"r"r#�isDPubEpigraph�szUtilities.isDPubEpigraphcCsdS)NFr")r r,r"r"r#�isDPubEpilogue�szUtilities.isDPubEpiloguecCsdS)NFr")r r,r"r"r#�isDPubErrata�szUtilities.isDPubErratacCsdS)NFr")r r,r"r"r#�
isDPubExample�szUtilities.isDPubExamplecCsdS)NFr")r r,r"r"r#�isDPubFootnote�szUtilities.isDPubFootnotecCsdS)NFr")r r,r"r"r#�isDPubForeword�szUtilities.isDPubForewordcCsdS)NFr")r r,r"r"r#�isDPubGlossary�szUtilities.isDPubGlossarycCsdS)NFr")r r,r"r"r#�isDPubGlossref�szUtilities.isDPubGlossrefcCsdS)NFr")r r,r"r"r#�isDPubIndex�szUtilities.isDPubIndexcCsdS)NFr")r r,r"r"r#�isDPubIntroduction�szUtilities.isDPubIntroductioncCsdS)NFr")r r,r"r"r#�isDPubPagelist�szUtilities.isDPubPagelistcCsdS)NFr")r r,r"r"r#�isDPubPagebreak�szUtilities.isDPubPagebreakcCsdS)NFr")r r,r"r"r#�
isDPubPart�szUtilities.isDPubPartcCsdS)NFr")r r,r"r"r#�
isDPubPrefaceszUtilities.isDPubPrefacecCsdS)NFr")r r,r"r"r#�isDPubPrologueszUtilities.isDPubProloguecCsdS)NFr")r r,r"r"r#�isDPubPullquoteszUtilities.isDPubPullquotecCsdS)NFr")r r,r"r"r#�	isDPubQna
szUtilities.isDPubQnacCsdS)NFr")r r,r"r"r#�isDPubSubtitle
szUtilities.isDPubSubtitlecCsdS)NFr")r r,r"r"r#�	isDPubTocszUtilities.isDPubToccCsdS)NFr")r r,r"r"r#�isFeedszUtilities.isFeedcCsdS)NFr")r r,r"r"r#�isFigureszUtilities.isFigurecCsdS)NFr")r r,r"r"r#�
isLandmarkszUtilities.isLandmarkcCsdS)NFr")r r,r"r"r#�isLandmarkBannerszUtilities.isLandmarkBannercCsdS)NFr")r r,r"r"r#�isLandmarkComplementarysz!Utilities.isLandmarkComplementarycCsdS)NFr")r r,r"r"r#�isLandmarkContentInfo"szUtilities.isLandmarkContentInfocCsdS)NFr")r r,r"r"r#�isLandmarkForm%szUtilities.isLandmarkFormcCsdS)NFr")r r,r"r"r#�isLandmarkMain(szUtilities.isLandmarkMaincCsdS)NFr")r r,r"r"r#�isLandmarkNavigation+szUtilities.isLandmarkNavigationcCsdS)NFr")r r,r"r"r#�
isDPubNoteref.szUtilities.isDPubNoterefcCsdS)NFr")r r,r"r"r#�isLandmarkRegion1szUtilities.isLandmarkRegioncCsdS)NFr")r r,r"r"r#�isLandmarkSearch4szUtilities.isLandmarkSearchcCsdS)NFr")r r,r"r"r#�speakMathSymbolNames7szUtilities.speakMathSymbolNamescCsdS)NFr")r r"r"r#�isInMath:szUtilities.isInMathcCsdS)NFr")r r,r"r"r#�isMath=szUtilities.isMathcCsdS)NFr")r r,r"r"r#�isMathLayoutOnly@szUtilities.isMathLayoutOnlycCsdS)NFr")r r,r"r"r#�isMathMultilineCszUtilities.isMathMultilinecCsdS)NFr")r r,r"r"r#�isMathEnclosedFszUtilities.isMathEnclosedcCsdS)NFr")r r,r"r"r#�isMathFencedIszUtilities.isMathFencedcCsdS)NFr")r r,r"r"r#�isMathFractionWithoutBarLsz"Utilities.isMathFractionWithoutBarcCsdS)NFr")r r,r"r"r#�
isMathPhantomOszUtilities.isMathPhantomcCsdS)NFr")r r,r"r"r#�isMathMultiScriptRszUtilities.isMathMultiScriptcCsdS)NFr")r r,r"r"r#�isMathSubOrSuperScriptUsz Utilities.isMathSubOrSuperScriptcCsdS)NFr")r r,r"r"r#�isMathUnderOrOverScriptXsz!Utilities.isMathUnderOrOverScriptcCsdS)NFr")r r,r"r"r#�isMathSquareRoot[szUtilities.isMathSquareRootcCsdS)NFr")r r,r"r"r#�isMathTable^szUtilities.isMathTablecCsdS)NFr")r r,r"r"r#�isMathTableRowaszUtilities.isMathTableRowcCsdS)NFr")r r,r"r"r#�isMathTableCelldszUtilities.isMathTableCellcCsdS)NFr")r r,r"r"r#�isMathTokengszUtilities.isMathTokencCsdS)NFr")r r,r"r"r#�isMathTopLeveljszUtilities.isMathTopLevelcCsdS)Nr")r r,r"r"r#�getMathDenominatormszUtilities.getMathDenominatorcCsdS)Nr")r r,r"r"r#�getMathNumeratorpszUtilities.getMathNumeratorcCsdS)Nr")r r,r"r"r#�getMathRootBasesszUtilities.getMathRootBasecCsdS)Nr")r r,r"r"r#�getMathRootIndexvszUtilities.getMathRootIndexcCsdS)Nr")r r,r"r"r#�getMathScriptBaseyszUtilities.getMathScriptBasecCsdS)Nr")r r,r"r"r#�getMathScriptSubscript|sz Utilities.getMathScriptSubscriptcCsdS)Nr")r r,r"r"r#�getMathScriptSuperscriptsz"Utilities.getMathScriptSuperscriptcCsdS)Nr")r r,r"r"r#�getMathScriptUnderscript�sz"Utilities.getMathScriptUnderscriptcCsdS)Nr")r r,r"r"r#�getMathScriptOverscript�sz!Utilities.getMathScriptOverscriptcCsgS)Nr")r r,r"r"r#�getMathPrescripts�szUtilities.getMathPrescriptscCsgS)Nr")r r,r"r"r#�getMathPostscripts�szUtilities.getMathPostscriptscCsgS)Nr")r r,r"r"r#�getMathEnclosures�szUtilities.getMathEnclosurescCsdgS)Nrr")r r,r"r"r#�getMathFencedSeparators�sz!Utilities.getMathFencedSeparatorscCsddgS)Nrr")r r,r"r"r#�
getMathFences�szUtilities.getMathFencescCsdS)Nrr")r r,Ztestr"r"r#�getMathNestingLevel�szUtilities.getMathNestingLevelcCs:ddddddddd	d
ddd
ddddddddddddddgS)NZbannerZ
complementaryZcontentinfozdoc-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-tocZform�mainZ
navigationZregion�searchr")r r"r"r#�getLandmarkTypes�s6zUtilities.getLandmarkTypescCs�|o|j�tjksdSy|j�}WnLtk
rNd|}tjtj|d�dSd|}tjtj|d�dSy,|j|j	kr�d|}tjtj|d�dSWn"d|}tjtj|d�dSdS)NFz&ERROR: %s doesn't implement AtspiValueTz%ERROR: Exception getting value for %szINFO: %s is busy indicatorz+INFO: %s is either busy indicator or broken)
rMr)ZROLE_PROGRESS_BAR�
queryValue�NotImplementedErrorrr&r'�maximumValue�minimumValue)r r,�valuer.r"r"r#�
isProgressBar�s,zUtilities.isProgressBarcCs�tjd�r(tjd�r(tjd�r(dS|j|�s6dS|j|�rDdStjd�rfd	d
�}tj||�rfdStjd�}|tjkr~dS|tjkr�|j	|�}|t
jkr�dSdd|t
jffS|tjk�r�|r�|j
}n|j�}|t
jjk�r�dSdd|t
jjffSdS)NZspeakProgressBarUpdatesZbrailleProgressBarUpdatesZbeepProgressBarUpdatesF�Updates not enabled�Is not progress bar�Has no sizeZignoreStatusBarProgressBarscSs|o|j�tjkS)N)rMr)�ROLE_STATUS_BAR)r�r"r"r#r��sz/Utilities.isProgressBarUpdate.<locals>.<lambda>�Is status bar descendantZprogressBarVerbosityT�Verbosity is all�Verbosity is windowzWindow %s is not %s�Verbosity is appzApp %s is not %s�Not handled by any other case)Fr)Fr)Fr)Fr)Tr )Tr!)Tr")Tr#)�_settingsManager�
getSettingr�	hasNoSizer)r�rZPROGRESS_BAR_ALLZPROGRESS_BAR_WINDOW�topLevelObjectrrIZPROGRESS_BAR_APPLICATIONZhost_applicationr7�activeScriptr4)r r,r��isStatusBar�	verbosity�topLevelr4r"r"r#�isProgressBarUpdate�s8







zUtilities.isProgressBarUpdatecCs�y"|j�}|j|j|j}}}WnLtk
rNd|}tjtj|d�dSd|}tjtj|d�dS||ko�|knr�d|ko�dknr�t|�SdSt|||d�S)Nz&ERROR: %s doesn't implement AtspiValueTz%ERROR: Exception getting value for %sr�d)	rr�currentValuerrrr&r'rX)r r,rZminval�valZmaxvalr.r"r"r#�getValueAsPercent�s zUtilities.getValueAsPercentcCs|o|j�tjkS)N)rMr)ZROLE_BLOCK_QUOTE)r r,r"r"r#�isBlockquoteszUtilities.isBlockquotec	CsR|o|j�tjksdSytj||j�}Wn d|}tjtj|�dS|dk	S)NFz'ERROR: Exception finding ancestor of %s)rMr)�	ROLE_LISTr��
isDocumentrr&r')r r,r�r.r"r"r#�isDocumentListszUtilities.isDocumentListc	CsR|o|j�tjksdSytj||j�}Wn d|}tjtj|�dS|dk	S)NFz'ERROR: Exception finding ancestor of %s)rMr)�
ROLE_PANELr�r3rr&r')r r,r�r.r"r"r#�isDocumentPanelszUtilities.isDocumentPanelcCs,tjtjtjtjtjtjg}|o*|j�|kS)N)r)r�r�r�r�r�r�rM)r r,Z
documentRolesr"r"r#r3)szUtilities.isDocumentcCs|ptj}|j|�dk	S)N)rr��getContainingDocument)r r,r"r"r#�inDocumentContent2s
zUtilities.inDocumentContentc
Cs^|sdSytj||j�}Wn"d|}tjtj|d�dSd||f}tjtj|d�|S)Nz'ERROR: Exception finding ancestor of %sTz"INFO: Document containing %s is %s)r)r�r3rr&r')r r,�docr.r"r"r#r76szUtilities.getContainingDocumentc
sd|sdStjtjg��fdd�}||�r,|Sytj||�}Wn"d|}tjtj|d�dS|S)Ncs|o|j��kS)N)rM)r�)�
tableRolesr"r#r�Jsz$Utilities.getTable.<locals>.<lambda>z'ERROR: Exception finding ancestor of %sT)r)r�r�r�rr&r')r r,�isTablermr.r")r:r#�getTableEszUtilities.getTablecCs6|o|j�tjksdS|j|�}|s(dS|j�tjkS)NF)rMr)r�r7r�)r r,r9r"r"r#�isTextDocumentTableWs
zUtilities.isTextDocumentTablecCs$|o|j�tjksdS|j|�dkS)NF)rMr)r�r7)r r,r"r"r#�
isGUITableaszUtilities.isGUITablecCs�|sdSy|j�}Wn"d|}tjtj|d�dS|tjksFdS|j|�}|sXdS|j�tjkrjdSy|j�}WnNt	k
r�d|}tjtj|d�Yn.d|}tjtj|d�YnX|j
dkSdS)NFz#ERROR: Exception getting role of %sTz2ERROR: Table %s does not implement table interfacez/ERROR: Exception querying table interface of %si)rMrr&r'r)r�r7r�r^rri)r r,rPr.r9rmr"r"r#�isSpreadSheetTablegs2


zUtilities.isSpreadSheetTablec
Csb|sdSy|j�}Wn"d|}tjtj|d�dStjtjtjg}||krTdStj||j	�S)NFz#ERROR: Exception getting role of %sT)
rMrr&r'r)�ROLE_TABLE_CELL�ROLE_COLUMN_HEADER�ROLE_ROW_HEADERr�r=)r r,rPr.�	cellRolesr"r"r#�isTextDocumentCell�szUtilities.isTextDocumentCellc
Csb|sdSy|j�}Wn"d|}tjtj|d�dStjtjtjg}||krTdStj||j	�S)NFz#ERROR: Exception getting role of %sT)
rMrr&r'r)r@rArBr�r?)r r,rPr.rCr"r"r#�isSpreadSheetCell�szUtilities.isSpreadSheetCellcCs0|j|�\}}|dkrdS|jjjd�}||kS)NrF�
lastColumnr])�coordinatesForCellr�pointOfReferencerW)r rwrs�columnrFr"r"r#�cellColumnChanged�s
zUtilities.cellColumnChangedcCs0|j|�\}}|dkrdS|jjjd�}||kS)NrF�lastRowr])rGrrHrW)r rwrsrIrKr"r"r#�cellRowChanged�s
zUtilities.cellRowChangedcCsR|jj�rdS|j|�}|s dS|j|�s4tjd�S|j|�rHtjd�Stjd�S)NFZreadFullRowInGUITableZreadFullRowInSpreadSheetZreadFullRowInDocumentTable)rZinSayAllr<r7r$r%r?)r r,rmr"r"r#�shouldReadFullRow�s





zUtilities.shouldReadFullRowc
Csjy|j�}|j�}Wn
dS|tjkr.dS|jtj�r>dS|jtj�rfd|}tjtj	|d�dSdS)NFTz-INFO: %s is focused but lacks state focusable)
rMr%r)�
ROLE_LABELr(�STATE_FOCUSABLEr�rr&r')r r,rPr-r.r"r"r#�isFocusableLabel�s
zUtilities.isFocusableLabelc
Csjy|j�}|j�}Wn
dS|tjkr.dS|jtj�r>dS|jtj�rfd|}tjtj	|d�dSdS)NFz-INFO: %s is focused but lacks state focusableT)
rMr%r)r2r(rOr�rr&r')r r,rPr-r.r"r"r#�isNonFocusableList�s
zUtilities.isNonFocusableListcCs2|o|j�tjksdSdd�}tj||�r.dSdS)NFcSs|o|j�tjkS)N)rMr)r)r�r"r"r#r��sz3Utilities.isStatusBarNotification.<locals>.<lambda>T)rMr)ZROLE_NOTIFICATIONr�)r r,r)r"r"r#�isStatusBarNotification�sz!Utilities.isStatusBarNotificationcCs6|sdS|j�tjkrdSdd�}tj||�r2dSdS)NFTcSs|o|j�tjtjgkS)N)rMr)rr�)r�r"r"r#r�sz,Utilities.isTreeDescendant.<locals>.<lambda>)rMr)�ROLE_TREE_ITEMr�)r r,ZisTreer"r"r#�isTreeDescendantszUtilities.isTreeDescendantc#Cs
d}|j|�s|j|�rdSytdd�|j�D��}Wni}YnXy|j�}Wnd}YnXy|jj�}Wnd}YnXy|d}Wnd}YnX|j�}tjtj	tj
tjg}|tjko�|j
d�dk�r�y|j�}	WnXtk
�rd	|}
tjtj|
d�d}Ynxd
|}
tjtj|
d�d}YnRX|	j�oL|	j�sd|j�jtj�}n,|j�pt|j|��s�|	jd��p�|	jd�}�nT|tjk�r�|j�r�|tjk�r�d}n.|j�tjk�r�d}n|tjk�r�|j|j�}�n�|tj k�r|j!|�}�n�|tj"k�rd}�n�|tj#k�r0d}�n�|tj$k�rDd}�n�|tj%tj&gk�r^d}�n�|tj'tjgk�rxd}�np||k�r�d}�n^|tjk�r�|tj(k}�nD|tj(k�r�d}�n0|tj)k�r�d}�n|tj*k�r�d}�n|tj+tj,gk�r�d}n�|tj-tj.tj/gk�rd}n�|tj
k�r2|tj'k�r2d}n�|j0|��rd|j�}|jtj1��p^|jtj2�}n�|tj3k�r�|j�r�|�r�|j�|k�r�d}nV|jdk�r�|j�r�|j|jk�r�d}n.|j4|��r�d}n|j5|��p�|j|��s�d}|�rd|}
tjtj|
d�|S)
z�Returns True if the given object is a container which has
        no presentable information (label, name, displayed text, etc.).FTcSsg|]}|jdd��qS)rRr)rS)r;rTr"r"r#r=sz*Utilities.isLayoutOnly.<locals>.<listcomp>Nrzlayout-guess�truez2ERROR: Table %s does not implement table interfacez/ERROR: Exception querying table interface of %srz$INFO: %s is deemed to be layout only)6�isDead�isZombierUrVrMrL�_topLevelRolesr)�	ROLE_MENU�ROLE_MENU_ITEMr�rSr�rWr^rrr&r'ri�nColumnsr%r(r�r�r�getColumnHeader�getRowHeaderr@r�r��isLayoutOnlyZROLE_SECTIONr1�ROLE_FILLERr�ZROLE_AUTOCOMPLETE�ROLE_TEAROFF_MENU_ITEM�ROLE_SEPARATOR�
ROLE_LIST_BOXr�r2Z	ROLE_FORMr��ROLE_TOGGLE_BUTTON�	ROLE_TEXT�ROLE_PASSWORD_TEXTr��
isTableRowrOZSTATE_SELECTABLEr5r�r)r r,Z
layoutOnlyrZrPZ
parentRoleZ
firstChild�
topLevelRolesZignorePanelParentrmr.r-r"r"r#r^s�





"zUtilities.isLayoutOnlycCs$|stjrdStjj�|j�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�r7)r,r"r"r#�
isInActiveAppxs	zUtilities.isInActiveAppcCsP|sdSy|j�}Wn0ttfk
rDd|}tjtj|d�dSX|tjkS)zReturns True if obj is a link.Fz$ERROR: Exception getting role for %sT)rMr�r�rr&r'r)Z	ROLE_LINK)r r,rPr.r"r"r#�isLink�szUtilities.isLinkcCs4|j|�sdS|j�}|jtj�o.|jtj�}|S)z;Returns True if obj is a text entry area that is read only.F)�
isTextArear%r(r)rO�STATE_EDITABLE)r r,r-ZreadOnlyr"r"r#�isReadOnlyTextArea�s
zUtilities.isReadOnlyTextAreacCsdS)NFr")r r,r"r"r#�isSwitch�szUtilities.isSwitchcCs�tjj|�}tjj|�}t|�t|�kr,dS|dd�}|dd�}|jd�r\|jd�r\dSy|jd�}Wn@tk
r�y|jd�}Wntk
r�t|�}YnXYnX|d|�|d|�kS)NFrrr]r]r]r])r)�utilsZgetPathrD�countr[�
ValueError)r �obj1�obj2�path1�path2r[r"r"r#�_hasSamePath�s zUtilities._hasSamePathFc	Cs�||krdS|s|rdSy�|j�|j�kr2dS|j|jkrH|rHdS|r\|j||�r\dS|j�jtj�}|j�jtj�}||kr�dS|jdkr�|jdkr�|j	dkr�|j
dkr�dSWnYnXdS)NTFr)rMr�ru�queryComponent�
getExtentsr)�DESKTOP_COORDSr��y�width�height)r rqrr�comparePaths�ignoreNames�extents1�extents2r"r"r#rl�s*
zUtilities.isSameObjectcCs*|j|�rdS|o(|j�tjtjtjfkS)z{Returns True if obj is a GUI component that is for entering text.

        Arguments:
        - obj: an accessible
        F)rirMr)rdr�ZROLE_PARAGRAPH)r r,r"r"r#rj�s

zUtilities.isTextAreacCsdd�tjD�S)znRetrieves the list of currently running apps for the desktop
        as a list of Accessible objects.
        cSsg|]}|dk	r|�qS)Nr")r;r�r"r"r#r=�sz/Utilities.knownApplications.<locals>.<listcomp>)r�_desktopr"r"r"r#r?�szUtilities.knownApplicationsc	Cs�g}y|j�}Wn0ttfk
r@d|}tjtj|d�|SXg}xX|D]P}|j�tjkrLx<t	d|j
��D]*}|j|�}||krn|j|�|j|�qnWqLW|S)z�Return a list of the objects that are labelling this object.

        Argument:
        - obj: the object in question

        Returns a list of the objects that are labelling this object.
        z+ERROR: Exception getting relationset for %sTr)
r`r�r�rr&r'rar)ZRELATION_LABELLED_BYrcrdrerf)	r r,r�ror.Z
allTargetsrprvrqr"r"r#r��s 
	

zUtilities.labelsForObjectc
CsTd}y|j�}WnY�n2X|jd�}|o4t|��rP|jd�}t|�dkr�xP|D]H}|jd�dkrT|dj�s~|dd
�}|dj�s�|dd�}|}PqTW|jd�d}|s�|S|ddkr�|dd�}|jd�d}nr|jd��s�|}n`|jd�d}|jd��r|jd�d}|jd	�d}|jd
�d}|jd�d}|jd�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]r]���r]r]r]r]r]r�)�queryHyperlink�getURIrDrS�find�isalnumro�
startswith)r,�basename�	hyperlink�uriZ
expression�itemr"r"r#�linkBasenamesB


zUtilities.linkBasenamecCs�|sdSy|j�Wntk
r(dSXy|j�}Wntk
rJdSXx6t|j��D]&}|j|�}||jkrZ||jkrZ|SqZWdS)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
        rr]r]r]r])r�r�queryHypertextrc�	getNLinks�getLink�
startIndex�endIndex)r,ZcharacterIndexZ	hypertextrv�linkr"r"r#�	linkIndexYs 


zUtilities.linkIndexc	s�|sdSy�jj�j|S�j�jjkr>i�jj�j<YnX�j|�r\�fdd�}n,|j�tjkrtdd�}n|j���fdd�}g}tj||�}x|r�|j|�tj||�}q�Wt	|�}|�jj�j|<�jj�j|S)zmDetermines the nesting level of this object.

        Arguments:
        -obj: the Accessible object
        rcs
�j|�S)N)r1)r�)r r"r#r��sz(Utilities.nestingLevel.<locals>.<lambda>cSs|o|jo|jj�tjkS)N)rLrMr)r2)r�r"r"r#r��scs|o|j��kS)N)rM)r�)rPr"r#r��s)
rr��
NESTING_LEVELr1rMr)r�r�rfrD)r r,�predZ	ancestorsrOrr")rPr r#rzs*


zUtilities.nestingLevelcCsf|j|�sd
Sy|jj|j|S|j|jjkrDi|jj|j<YnXg}|}d}x�|�s8y|j�}Wn0ttfk
r�d|}tjtj	|d�dSXd}x&|D]}|j
�tjkr�|j
d�}Pq�W|j|��r�d||f}tjtj	|d�d}t|�dk�r d	|}tjtj	|d�d}qX|�r2|j|�qXd}qXWt|�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
        rFz+ERROR: Exception getting relationset for %sTNrz0ERROR: %s is already in the list of nodes for %sr-z&INFO: More than 100 nodes found for %sr]r])rTrr��
NODE_LEVELr`r�r�rr&r'rar)rkrerorDrf)r r,rnrrruror.rpr"r"r#r�sH	


zUtilities.nodeLevelc
Cs\|j|�rdS|j|�rdS|j|�sBd|}tjtj|d�dSy|j�jtj	�}Wn"d|}tjtj|d�dS|j
dkr�|jdkr�d|}tjtj|d�dS|jp�|j
�s
|js�d|}tjtj|d�dS|j�tjk�rd|}tjtj|d�dSdS|dk�s$|j|j��r(dS|j||��sXd	|||f}tjtj|d�dSdS)
NFz#INFO: %s is not showing and visibleTz'ERROR: Exception getting extents for %srz!INFO: %s has negative coordinatesz$INFO: %s has no size and no childrenzINFO: %s has no sizezINFO: %s %s not in %s)rVr��isShowingAndVisiblerr&r'rvrwr)rxr�ryrzr{r�rMrY�_boundsIncludeChildrenrL�containsRegion)r r,�boundingboxr.Zboxr"r"r#�
isOnScreen�sF


zUtilities.isOnScreencCs�y|j�}Wn"d|}tjtj|d�dS|tjkr>dSdtj|�krf|j|�}|rb|dSdSxd|D]\}y|j�|j	�}Wn&d|}tjtj|d�wlYnX|j
tj�s�|j
tj�rl|SqlWdS)Nz#ERROR: Exception getting role of %sT�	Selectionrz$ERROR: Exception getting state of %s)
rMrr&r'r)�
ROLE_MENU_BAR�listInterfaces�selectedChildrenr8r%r(r_�STATE_SELECTED)r �menubarrPr.�selected�menur-r"r"r#�selectedMenuBarMenus2


zUtilities.selectedMenuBarMenucsz|sdSdd�}tj||�}|dkr(dS|jjt|����dkrJ|j|���sRdS�fdd�}||�rjdStj||�dk	S)NFcSs|o|j�tjkS)N)rMr)r�)r�r"r"r#r�$sz/Utilities.isInOpenMenuBarMenu.<locals>.<lambda>cs|�kS)Nr")r�)�selectedMenur"r#r�0sT)r)r�rrW�hashr�)r r,Z	isMenuBarr�ZinSelectedMenur")r�r#�isInOpenMenuBarMenu s
zUtilities.isInOpenMenuBarMenucCs�|j||�sgSy|j�}Wn"d|}tjtj|d�gS|tjkrNgS|tjkr^|gS|tjkr||j	|�|j
t|�<|jr�|jj�tjkr�|j
|�r�|gS|dkr�y|j�}|jtj�}Wn(d|}tjtj|d�d}YnXtj|�}d|k�r d|k�r |j|�}|�r |Stjtjg}g}	|tjk�rD|j�s^||k�rhdtj|�k�rh|	j|�x |D]}
|	j|j|
|���qnW|tjk�r�d|j
t|�<|	�r�|	Stjtjtjtjtjg}||k�r�gS|gS)	Nz#ERROR: Exception getting role of %sTz&ERROR: Exception getting extents of %sr�Tabler�ZText)rrrr)r�rMrr&r'r)ZROLE_INVALIDr�r�r�rr�rLr�rvrwrxr��getVisibleTableCellsrZROLE_UNKNOWN�
ROLE_PAGE_TABr�rfr@�getOnScreenObjectsr_rbr5r�Z
ROLE_VIEWPORT)r r��extentsrPr.�	componentZ
interfacesZvisibleCellsZnonTextZobjectsr<Z
containersr"r"r#r�6sb








zUtilities.getOnScreenObjectscCs�y|o|jo|jsdSWn"d|}tjtj|d�dS|j�}|tjkrRdS|tjkr`dS|jj�tj	kstdSdd�}t
t|dd�|D���}t|�|jkr�dSdS)z9Determines if obj is a table row -- real or functionally.Fz5ERROR: Exception getting parent and childCount for %sTcSs|o|j�tjtjtjgkS)N)rMr)r@rBrA)r�r"r"r#r��sz&Utilities.isTableRow.<locals>.<lambda>cSsg|]}|�qSr"r")r;r�r"r"r#r=�sz(Utilities.isTableRow.<locals>.<listcomp>)
rLr�rr&r'rMr)�ROLE_TABLE_ROWr@r�rA�filterrD)r,r.rPZisCellZcellChildrenr"r"r#rfvs&

zUtilities.isTableRowcsZ|j�jtj�r|Stjtjtjtjg�tj|�fdd��}|rV|j	j
j|j�rV|}|S)Ncs|o|j��kS)N)rM)r�)�rolesr"r#r��sz.Utilities.realActiveAncestor.<locals>.<lambda>)
r%r(r)r�r@rArBr�r�rZ	utilitiesr^rL)r r,rOr")r�r#�realActiveAncestor�szUtilities.realActiveAncestorcsJ�j|�rdS|j�tjkr |S�fdd�|D�}t|�dkrF|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|]}�j|�j�r|�qSr")r�strip)r;r�)r r"r#r=�sz2Utilities.realActiveDescendant.<locals>.<listcomp>rr)rVrMr)r@rD)r r,Z
hasContentr")r r#�realActiveDescendant�s

zUtilities.realActiveDescendantcCs�tjtjtjg}|j�jtj�s,|j�|kr0dSd}xZt|j	ddd�D]D}||j�tj
krh||}n||j�|kr�|j||�}|rHPqHW|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)rr�r�r%r(r�rMrcr�r�	statusBar)r r,r�r�rvr"r"r#r��s

zUtilities.statusBarcCsdS)Nr")r r�r"r"r#�infoBar�szUtilities.infoBarcCstjtjtjtjgS)N)r)�
ROLE_ALERTr�r��ROLE_WINDOW)r r"r"r#rX�szUtilities._topLevelRolesc
Csltjs
dSytjj�}Wn$dtj}tjtj|d�dS||j�k}dtj|f}tjtj|d�|S)NFz$ERROR: Exception getting role for %sTz INFO: %s is top-level object: %s)rr�rMrr&r'rX)r rPr.�rvr"r"r#�_locusOfFocusIsTopLevelObject�s
z'Utilities._locusOfFocusIsTopLevelObjectcCsH|sdS|j�}x2|rB|jrB|j�|krB|jj�tjkrB|j}qW|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)rXrLrMr)�ROLE_APPLICATION)r r,ZstopAtRolesr"r"r#r'�s
zUtilities.topLevelObjectc
Cs�|ptj}|j|�}|sdS|j�y|j�}Wn"d|}tjtj|d�dS|jt	j
�sn|jt	j�rrdS|j|tj
�s�dSdS)NFz-ERROR: Exception getting state of topLevel %sT)rr�r'r8r%rr&r'r(r)r*�
STATE_DEFUNCTrlrI)r r,r+r-r.r"r"r#� topLevelObjectIsActiveAndCurrents"

z*Utilities.topLevelObjectIsActiveAndCurrentc	Cs`y$|j�jtj�}|j�jtj�}Wn
dS|j|jd}|j|jd}t||�|kS)z1Determines if obj1 and obj2 are on the same line.Fr�)rvrwr)rxryr{�abs)rqrr�deltaZbbox1Zbbox2Zcenter1Zcenter2r"r"r#�
onSameLine szUtilities.onSameLinecCs|||krdSxFttt|�t|���D],}||||kr<dS||||kr$dSq$W|r\dSt|�t|�}tt|d�d�S)zpCompares the two paths and returns -1, 0, or 1 to indicate if path1
        is before, the same, or after path2.rrr]r])rcr{rD�max)rsrtZtreatDescendantAsSamer�r�r"r"r#�pathComparison/szUtilities.pathComparisoncCs�y"|j�jtj�}|j|j}}Wnd\}}YnXy"|j�jtj�}|j|j}}Wnd\}}YnX||||S)Nr)rr)rr)rvrwr)rxrzr{)rqrr�bbox�width1�height1�width2�height2r"r"r#rHCszUtilities.sizeComparisoncCs�y"|j�jtj�}|j|j}}Wnd\}}YnXy"|j�jtj�}|j|j}}Wnd\}}YnX||p~||}|r�|j|jkr�|j�|j�}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.rr)rr)rrr])
rvrwr)rxr�ryrLrYr�r{)rqrrr��x1�y1�x2�y2r�r"r"r#�spatialComparisonSs 

zUtilities.spatialComparisonc
CsN|sdSy|j�jtj�}Wn"d|}tjtj|d�dS|joJ|jS)NFz'ERROR: Exception getting extents for %sT)	rvrwr)rxrr&r'rzr{)r r,r�r.r"r"r#r&sszUtilities.hasNoSizecsPtjtjtjg��fdd�}tj||�}|rLd||f}tjtj|d�dSdS)NcsF|sdS|j��krdSdtj|�kr0|jdkSdtj|�krBdSdS)NFTr��2ZDocument)rMr)r�r�)r�)r�r"r#�isMatch�s
z7Utilities._hasNonDescendableDescendant.<locals>.isMatchzINFO: %s has descendant %sTF)r)ZROLE_PAGE_TAB_LISTZROLE_SPLIT_PANEr��findDescendantrr&r')r r�r��matchr.r")r�r#�_hasNonDescendableDescendant�s
z&Utilities._hasNonDescendableDescendantTcCs�|j|�rgS|jjr(|jjj|�r(gSdd�}ytj||�}Wn
gSy$dd�|D�}|rndd�|D�}Wn
gSi}x2|D]*}|jr�|j|j|jjgkr�q�|||j<q�Wt|j	��}t
|tj|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.
        cSs|o|j�tjkS)N)rMr)rN)r�r"r"r#r��sz+Utilities.unrelatedLabels.<locals>.<lambda>cSsg|]}|j�s|�qSr")r`)r;r�r"r"r#r=�sz-Utilities.unrelatedLabels.<locals>.<listcomp>cSs g|]}|j�jtj�r|�qSr")r%r(r)r+)r;r�r"r"r#r=�s)r>)r�rZ
spellcheckZ
isCheckWindowr)�findAllDescendantsr�rLrA�valuesrErFrGr�)r r�r�ZhasRoleZ	allLabelsr��dr�r"r"r#r��s,

zUtilities.unrelatedLabelscCs�d}|j�}|j|�}|r~|j�tjkr~|j�tjkr~|j|�r~x:|D]2}|j�tjksr|j�tjksr|j|�rH|d7}qHW|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.
        rr)r7r'rMr)r�r�r�)r r,ZalertAndDialogCountr4r9r<r"r"r#�unfocusedAlertAndDialogCount�s


z&Utilities.unfocusedAlertAndDialogCountc	Csy|j�jd�SdSdS)zjReturn the URI for a given link object.

        Arguments:
        - obj: the Accessible object.
        rN)r�r�)r r,r"r"r#r��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)rL)r r,r"r"r#r��szUtilities.validParentc
Cszy|j�}Wn
dS|j�sH|j}t||�}t||�}|j||�n.|jd�\}}||krd|}n|}|jd||�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�ZaddSelection�getSelectionZsetSelection)r,r�r�r��startOffset�	endOffsetr"r"r#�adjustTextSelection�s


zUtilities.adjustTextSelectionc	Cs�|sdSx(|j�D]}|j�tjkr|jd�SqW|j�d}|jrxd|ko^|jjdknrx|j}|j�d}y|j|}Wnd}YnX||kr�d}|S)z!Finds the object before this one.Nrr)r`rar)ZRELATION_FLOWS_FROMrerYrLr�)r r,rpr[�prevObjr"r"r#�findPreviousObject	s (
zUtilities.findPreviousObjectc	Cs�|sdSx(|j�D]}|j�tjkr|jd�SqW|j�d}|jrtd|koZ|jjknrt|j}|j�d}y|j|}Wnd}YnX||kr�d}|S)z Finds the object after this one.Nrr)r`rar)ZRELATION_FLOWS_TOrerYrLr�)r r,rpr[�nextObjr"r"r#�findNextObject1	s $
zUtilities.findNextObjectc
Cs�|j|�\}}}|r,|jjjd�r,|||fS|j|�r@|||fS|j|�}x>|r�|j|�r||j|�\}}}|spPd||f}|j|�}qLW|j|�}	x>|	r�|j|	�r�|j|	�\}}}|s�Pd||f}|j|	�}	q�W|||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.
        �entireDocumentSelectedz%s %s)�selectedTextrrHrWrEr��queryNonEmptyTextr�)
r r,�textContentsr�r�r��	selection�start�endr�r"r"r#�allSelectedTextJ	s,






zUtilities.allSelectedTextcCs`y|j�}Wn
gSg}y|j�}Wnd}YnXx t|�D]}|j|j|��qDW|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�rcrfr�)r,r�r��nSelectionsrvr"r"r#�allTextSelectionsq	s

zUtilities.allTextSelectionscCs�d}y|j�}Wn,tk
r<d|}tjtj|d�Yn^Xy|jj�|j}Wn*d||jf}tjtj|d�YnXd||f}tjtj|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.
        rz3INFO: %s does not implement the hyperlink interfaceTz7ERROR: Exception getting startIndex for %s in parent %szINFO: startIndex of %s is %ir])r�rrr&r'rLr�r�)r r,r�r�r.r"r"r#�characterOffsetInParent�	s


z!Utilities.characterOffsetInParentc	Cs<y|j�}Wn
dSxt|j��D]}|jd�q&WdS)zwClears the text selection if the object supports it.

        Arguments:
        - obj: the Accessible object.
        Nr)r�rcr�ZremoveSelection)r,r�rvr"r"r#�clearTextSelection�	szUtilities.clearTextSelectionrc
Cs�y|j|||�}Wn
dS|j|kr�d}x$|D]}|j|�|krFP|d7}q2Wt|�}|j|j�}xBt|�D]6}	|j|j�}
||	|}|j|�}|s�d}|||
<qpWdj|�}|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.
        rrr)	�	substringr�r�rArorcr[�
expandEOCsr�)r r,r�r��stringZchildOffsetr<ZtoBuildrorvr[Z	childTextr"r"r#r��	s*



zUtilities.expandEOCscCsN|j||d�\}}}|jd�dkr&dS|jd�dkr8dS|jd�dkrJdSdS)	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.
        TZinvalid�spellingz
text-spellingZ
misspelledZ	underline�errorF)�textAttributesrW)r r,r��
attributesr�r�r"r"r#�isWordMisspelled�	szUtilities.isWordMisspelledcCs|j�jtj�S)N)r%r(r)ZSTATE_INVALID_ENTRY)r r,r"r"r#�getError
szUtilities.getErrorcCsdS)Nrr")r r,r"r"r#�getErrorMessage
szUtilities.getErrorMessagecCsdS)NFr")r r,r"r"r#�isErrorMessage
szUtilities.isErrorMessagecCs0|j|�}|r,|dkr|j}|j||d�SdS)Nrr)r�r�r�)r r,r�r�r"r"r#�getCharacterAtOffset
s
zUtilities.getCharacterAtOffsetc	Cs(y|j�}WnYnX|jr$|SdS)z�Get the text interface associated with an object, if it is
        non-empty.

        Arguments:
        - obj: an accessible object
        N)r�r�)r r,r�r"r"r#r�
szUtilities.queryNonEmptyTextcCs|jS)N)�any_data)r r�r"r"r#�deletedText&
szUtilities.deletedTextc
Cs�|jr|jSy|jj�}Wn*d|j}tjtj|d�d}YnXd}tjtj|d�|tjkr�|j|j�}|r�|j	dd	�}|r�d|}tjtj|d�|d
Sd}tjtj|d�dS)Nz#ERROR: Exception getting role of %sTz"ERROR: Broken text insertion eventrrz!HACK: Returning last char in '%s'z3FAIL: Unable to correct broken text insertion eventrr]r])
r��sourcerMrr&r'r)rer�r�)r r�rPr.r�r�r"r"r#�insertedText)
s*


zUtilities.insertedTextc	Cs�d}d}}y|j�}Wnd}Yn
X|j�}xPtd|�D]B}|j|�\}}||krZq>|j|||�}|dkrx|d7}||7}q>W|||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.
        rrr1)r�r�rcr�r�)	r r,r�r�r�ZtextObjr�rvr�r"r"r#r�D
s 

zUtilities.selectedTextcCsDtj}y|j�j}Wn&tk
r,d}Ynd}YnX||fS)Nrrr])rr�r�r�r)r r,r�r"r"r#r�b
s
zUtilities.getCaretContextcCs|dfS)Nrr")r r,r"r"r#�getFirstCaretPositionm
szUtilities.getFirstCaretPositioncCstjd|d�|j||�dS)NF)r
ZsetLocusOfFocus�setCaretOffset)r r,r�r�r"r"r#�setCaretPositionp
szUtilities.setCaretPositionc	Cs&y|j�}Wn
dS|j|�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�r)r r,r�Ztextir"r"r#rt
s
zUtilities.setCaretOffsetc	Cs$y|j�}Wn
dS|j||�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 r,r�r�r�r"r"r#r��
s

zUtilities.substringcCs*x$|jjj�D]\}}||kr|SqW|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�attributeNamesDict�items)r �
attribNamer>rr"r"r#�getAppNameForAttribute�
s
z Utilities.getAppNameForAttributecCs|jjj||�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.
        )rrrW)r rr"r"r#�getAtkNameForAttribute�
sz Utilities.getAtkNameForAttributec

Cs�i}y|j�}Wn|ddfS|rB|j|j��}|j|d�|dkrP|j}|j|�\}}}	|j|�}|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��stringToKeysAndDictZgetDefaultAttributes�updater�rVr{r�)
r Zaccr�Zget_defaultsr�r�Z
stringAndDictZ
attrStringr�r�r"r"r#r��
s 


zUtilities.textAttributescCs|dkr"|dkst|�dkr"tjS|jd�s4|dkr:tjStj||j�}|dkrj|jd�dj	�j	d�}n�|r�|jd	�r�|jd	�d}t
j�d
|kr�tjt
|��}ntjt|��}nN|jd�r�|j|�\}}}tjr�tj|||�}nd|||f}ntj||j�}d
||fS)NZweightZboldi�r�zfamily-namer�r�"ZpxZ
decimal_pointZcolorz%i %i %iz%s: %s)rXrZBOLD�endswithZ
MISSPELLEDrZgetTextAttributeNamerrSr��locale�
localeconvZ
pixelCount�float�
rgbFromStringrZ
useColorNamesrZ	rgbToName)r r>rZlocalizedKeyZlocalizedValue�r�gr}r"r"r#�localizeTextAttribute�
s&
zUtilities.localizeTextAttributecCsftjstjrdSt|j�dks.|jtj@r2dStj}|j	�}|t
jkrNdS|j�j
t
j�rbdSdS)z�Given a keyboard event containing an alphanumeric key,
        determine if the script is likely to echo it as a character.
        FrT)rr�r�enableEchoByCharacterrD�event_string�	modifiersr	ZORCA_CTRL_MODIFIER_MASKrMr)rer%r(rk)r r�r,rPr"r"r#�willEchoCharacter�
s
zUtilities.willEchoCharacterc
	Cs�ddlm}ddlm}tj}d}y|j|d�\}}	Wnd}YnXt|�}
|
tjkr�|d|jj	kr�|s~|r�||kr�|j
|d�}tj||
�}d||f}q�||7}n||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_settings)rTrFz%s %s)
rrrrZverbalizePunctuationStyle�getPunctuationInforD�repeatCharacterLimitr�
whitespace�getCharacterNamerZrepeatedCharCount)
r �segment�lineZrespectPunctuationrrZstyleZisPunctChar�level�actionroZ
repeatCharZ
repeatSegmentr"r"r#�_addRepeatSegments&



zUtilities._addRepeatSegmentcCs(ddlm}|t|�}y|j�}|j�}Wnd}YnXt|�}x�t|dd�D]�}	|j|	d�}
|
slqT||
jko�|knr�|
j|}n8||
j	ko�|knrTt|�}|
j|kr�|d8}nqTdt
j}d}
|t|�kr�||}
|
|jj
k�p|j|
��s|d7}||||�<qTWdj|�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.
        r)rrr1rr])rrrDr�r�rArcr�r�r�rZLINKrrrr�)r r,rr�rr�Z	hyperTextZnLinksZadjustedLine�nr�r[Z
linkStringZnextCharr"r"r#�adjustForLinks6s8



zUtilities.adjustForLinkscCstjdd|�S)Nz(?<=[a-z])(?=[A-Z])r1)�re�sub)r�r"r"r#�_processMultiCaseStringksz!Utilities._processMultiCaseStringcCs|j�s|Sdjt|��S)Nr1)�	isnumericr�rA)Zwordr"r"r#�_convertWordToDigitsoszUtilities._convertWordToDigitscCs�tjr|j|�}|j�r"tj|�}tjrF|jj|�}dj	t
|j|��}tjsP|Sd}|jj|�}dj	t
t
j|��}tjr�|j|�}|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.
        r)rZspeakMultiCaseStringsAsWordsr&r�rZadjustForSpeechZspeakNumbersAsDigits�WORDS_RErSr�rBr(ZusePronunciationDictionaryrZgetPronunciation)r rZwords�newLiner"r"r#�adjustForPronunciationvs


z Utilities.adjustForPronunciationcCs�t|�dkstjdkr|Sd}|d}}d}xPtdt|��D]>}|||kr\|||7}nd}|j||�}||}||}q>W|j|||�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)rDrrrcr!)r rr*rZlastCharZ
multipleCharsrvr"r"r#�adjustForRepeats�szUtilities.adjustForRepeatscs�ttj�j|��}ttj�j|��}x<|D]4}�fdd�|D�}tjdj|�}tj|||�}q*Wx<|D]4}�fdd�|D�}tj	dj|�}tj|||�}qhW|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.
        csg|]}t�jj|���qSr")rC�SUPERSCRIPT_DIGITSr[)r;r�)r r"r#r=�sz-Utilities.adjustForDigits.<locals>.<listcomp>rcsg|]}t�jj|���qSr")rC�SUBSCRIPT_DIGITSr[)r;r�)r r"r#r=�s)
�setr$�findall�
SUBSCRIPTS_RE�SUPERSCRIPTS_RErZDIGITS_SUPERSCRIPTr�r%ZDIGITS_SUBSCRIPT)r r�ZsubscriptedZ
superscriptedZnumber�new�	newStringr")r r#�adjustForDigits�s


zUtilities.adjustForDigitscCs�tjd�stjd�rdS|jdd�}tjd|�}|rF|d|j��}d}dd�tjd	|�D�}d
d�tjd|�D�}t||�}xJ|D]B\}}||f|kr�|dtj	||�7}q�|dtj
||�7}q�W|S)
N�onlySpeakDisplayedTextZenableSpeechIndentationr� r1z[^ 	]cSsg|]}|j��qSr")�span)r;�mr"r"r#r=�sz4Utilities.indentationDescription.<locals>.<listcomp>z +cSsg|]}|j��qSr")r9)r;r:r"r"r#r=�sz	+z%s )r$r%r3r$rr��finditerrErZspacesCountZ	tabsCount)r rr��resultZspacesZtabsZspansr�r"r"r#�indentationDescription�s 
z Utilities.indentationDescriptioncCs4ddlm}|j�j�j�}|j�\}}}}||fS)z0Gets the absolute position of the mouse pointer.r)r)�
gi.repositoryrZWindowZ
get_screenZget_root_windowZget_pointer)rZ
rootWindowr9r�ryrr"r"r#�absoluteMouseCoordinates�sz"Utilities.absoluteMouseCoordinatesr1cCs|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��newTextZ	delimiterr"r"r#r��s
zUtilities.appendStringcCs�|jjd�r�|js|jr dS|jj�}|jtj�s:dS|jtj�sJdS|jtj	�rz|jj
�|jj�}|jtj�szdS|j�\}}|dkr�|jdkr�dS|dkr�|jdkr�dS|dkr�|j
|j�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
        zobject:text-changed:insertFZTab�	T�Return�
�Up�Down�Page_Up�	Page_Down)rDrErFrG)�typer�r�r�r%r(r)rkr+rOr8r��lastKeyAndModifiers�isEditableDescendantOfComboBox)r r�r-ZlastKey�modsr"r"r#�isAutoTextEvents*


zUtilities.isAutoTextEventcCs(|dks|dkrdS||jjko&|dkS)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.
        �
rCTz!.?:;)rr)r ZcurrentCharZpreviousCharr"r"r#�isSentenceDelimiter$s
zUtilities.isSentenceDelimitercCs ||jjkp|dkp||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!*+,-./:;<=>?@[\]^_{|})rrZNO_BREAK_SPACE_CHARACTER)r �	characterr"r"r#�isWordDelimiter7s	zUtilities.isWordDelimiterc
CsF|dkrtj}y |j�j|�}|j�j|�}Wn
dS|j||�S)z9Returns the extents of the intersection of obj1 and obj2.Nr)rrrr)r)rxrvrw�intersection)r rqrr�	coordTyper~rr"r"r#�intersectingRegionDszUtilities.intersectingRegioncCs�|\}}}}|\}}}	}
t|||d�}t|||	d�}tt|�jt|���}
t|||d�}t|||
d�}tt|�jt|���}|
o�|s�dS|
d}|d}|
d|}|d|}||||fS)Nrr)rrrrr]r])rcrEr0rQ)r r~rr�r�r�r�r�r�r�r�ZxPoints1ZxPoints2Z
xIntersectionZyPoints1ZyPoints2Z
yIntersectionr�ryrzr{r"r"r#rQRszUtilities.intersectioncCs|j||�dkS)Nr)rrrr)rQ)r r~rr"r"r#r�hszUtilities.containsRegioncCs,tjj�}|j|�d}tttjt|���S)Nrr])rZKeymapZget_defaultZget_entries_for_keycoderArB�keyval_namer0)�keycodeZkeymapZentriesr"r"r#�_allNamesForKeyCodeks
zUtilities._allNamesForKeyCodecCs,ttjtj�sdStj}|r(|j|jfSdS)Nr)rr)rr)rJr�lastInputEventr
�
KeyboardEvent�lastNonModifierKeyEventZhw_coder)r�r"r"r#�_lastKeyCodeAndModifiersqsz"Utilities._lastKeyCodeAndModifierscCsLttjtj�r<tjr<tj}|jdkr,|j}n|j}tjj}nd}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[r\)	rJrrWr
rXrYrTrr)r��eventStrrKr"r"r#rI|s

zUtilities.lastKeyAndModifiersc	Cs�yHddlm}|j|�\}}|j||�}|rF|jd�sB|jd�rF|}Wn@|jd�rh|tjd�7}|jdd�}|jdd�j�}YnXt	j
|�S)	z3Turns a key sequence into a user-presentable label.r)r�+z++r1�<r�>)r>rZaccelerator_parseZaccelerator_get_labelrrrr3r�rZlocalizeKeySequence)Zsequencerr>rKZnewSequencer"r"r#�labelFromKeySequence�s
zUtilities.labelFromKeySequencecCs�y|jj|j|S|j|jjkr6i|jj|j<YnXy|j�}Wn:tk
r�dddg|jj|j|<|jj|j|SXy|jd�jd�}Wn0dddg|jj|j|<|jj|j|St|�dkr�|d}|d}|d}nFt|�dk�r*d}|d}y|d}Wnd}YnXnd}d}d}|jdd�j	�}|j
|�}|j
|�}|j
|�}|j|jjk�r�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]
        rr�;�rr�rRr1)rr��KEY_BINDING�queryActionrZ
getKeyBindingrSrDr3r�ra)r r,r ZbindingStringsZmnemonicZfullShortcutZacceleratorr"r"r#�mnemonicShortcutAccelerator�sJ	



z%Utilities.mnemonicShortcutAcceleratorc	Cs^yFdd�|jd�D�}dd�|D�}dd�|D�}tdd�|D��}WngifS||gS)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.
        cSsg|]}|j��qSr")r�)r;�sr"r"r#r=�sz1Utilities.stringToKeysAndDict.<locals>.<listcomp>rbcSs"g|]}t|jd��dkr|�qS)rRr�)rDrS)r;r�r"r"r#r=�scSsg|]}|jd�dj��qS)rRr)rSr�)r;r�r"r"r#r=�scSsg|]}|jd��qS)rR)rS)r;r�r"r"r#r=�s)rSrU)r�r�keysZ
dictionaryr"r"r#r	�szUtilities.stringToKeysAndDictc1Cs�y|j�}Wn
dSx"|D]}|jd�r|dd�SqWy|j�}Wntk
r\dSX|j}y
|j}Wn4ttfk
r�d}d|}tj	tj
|d�YnXy
|j}Wn4ttfk
r�d}d|}tj	tj
|d�YnXy
|j}	Wn>ttfk
�r,||d	}	d
|}tj	tj
|d�YnX|	dk�r�yt
jtdt
j|	���}
Wn.tk
�r�d|}tj	tj
|d�dSXnt|�d
k�r�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.
        rZ	valuetext�
Ngz,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)rVr�rrr.rr�r�rr&r'rZminimumIncrement�mathZceilr�Zlog10rpr�)r r,r�Z	attributerr.ZmaxValuer.ZminValueZminIncrementZ
decimalPlacesZ	formatterr"r"r#�textForValue�sT





zUtilities.textForValuec	Cs(ydt|�Stjtj�dSdS)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%04xrN)�ordrrzZ
LEVEL_WARNING)rOr"r"r#�unicodeValueString9
s

zUtilities.unicodeValueStringcCsgS)Nr")r r,r�Z
layoutMode�useCacher"r"r#�getLineContentsAtOffsetI
sz!Utilities.getLineContentsAtOffsetcCsgS)Nr")r r,r�rnr"r"r#�getObjectContentsAtOffsetL
sz#Utilities.getObjectContentsAtOffsetcCs|s|j�\}}||dfS)Nr)r�)r r,r��	skipSpacer"r"r#�previousContextO
szUtilities.previousContextcCs|s|j�\}}||dfS)Nr)r�)r r,r�rqr"r"r#�nextContextU
szUtilities.nextContextcCs$d}|j|�}|r|jd}||fS)Nrr)r�r�)r r�r�r�r"r"r#�lastContext[
s


zUtilities.lastContextcCs.y|j�}Wntk
r dSX|j|jfS)zSReturns the start and end indices associated with the embedded
        object, obj.r)rr)r�rr�r�)r,r�r"r"r#�getHyperlinkRangec
s
zUtilities.getHyperlinkRangec
s�y�j�}|j}WnLtk
r>d�}tjtj|d�gSd�}tjtj|d�gSd�|f}tjtj|d�g}x.t|�D]"}|j|�}|j|�s�|j	|�q�W�j
�}|tjko�|�rdd�}	ytj
�|	�}Wn$d�}tjtj|d�YnX|tjk�r�|�r�|dj
�tjk�r�|j|d�}|�r��j�r��fd	d�}	ytj
�|	�}Wn$d�}tjtj|d�YnX|S)
Nz3INFO: %s does not implement the selection interfaceTz4ERROR: Exception querying selection interface for %sz%INFO: %s reports %i selected childrencSs|o|j�jtj�S)N)r%r(r)r�)r�r"r"r#r��
sz,Utilities.selectedChildren.<locals>.<lambda>z1ERROR: Exception calling findAllDescendants on %srcs|o|j�jkS)N)r�)r�)r,r"r#r��
s)�querySelection�nSelectedChildrenrrr&r'rcZgetSelectedChildrWrfrMr)rYr�r�r�r�)
r r,r�ror.�childrenr�r<rPr�r")r,r#r�o
sJ


zUtilities.selectedChildrencCs�y|j�}|j}WnLtk
r>d|}tjtj|d�dSd|}tjtj|d�dSd||f}tjtj|d�|S)Nz3INFO: %s does not implement the selection interfaceTrz4ERROR: Exception querying selection interface for %sz%INFO: %s reports %i selected children)rvrwrrr&r')r r,r�ror.r"r"r#�selectedChildCount�
s
zUtilities.selectedChildCountcCs@dd�}tj||�}||kr<d||f}tjtj|d�dS|S)NcSs|o|j�jtj�S)N)r%r(r)r�)r�r"r"r#r��
sz(Utilities.focusedChild.<locals>.<lambda>z ERROR: focused child of %s is %sT)r)r�rr&r')r r,Z	isFocusedr<r.r"r"r#�focusedChild�
szUtilities.focusedChildcCst|r|jrdSdd�|D�}xP|D]H}y|j�}Wn&d|}tjtj|d�w$YnX|jtj�r$|Sq$WdS)NcSsg|]}|j�tjkr|�qSr")rMr)rY)r;r<r"r"r#r=�
sz*Utilities.popupMenuFor.<locals>.<listcomp>z%ERROR: Exception getting state for %sT)r�r%rr&r'r(r)Z
STATE_ENABLED)r r,Zmenusr�r-r.r"r"r#�popupMenuFor�
s
zUtilities.popupMenuForc
CsZ|sdSy|j�}Wn"d|}tjtj|d�dS|tjtjgkrLdS|j|�dk	S)NFz$ERROR: Exception getting role for %sT)rMrr&r'r)r�rcr{)r r,rPr.r"r"r#�isMenuButton�
szUtilities.isMenuButtoncCsdS)NFr")r r,r"r"r#�isEntryCompletionPopupItem�
sz$Utilities.isEntryCompletionPopupItemc
sp|sdSy|j�}Wn"d|}tjtj|d�dS|tjkrFdS�fdd�|D�}t|�dkrl|dSdS)Nz$ERROR: Exception getting role for %sTcsg|]}�j|�r|�qSr")�isEditableTextArea)r;r�)r r"r#r=�
sz9Utilities.getEntryForEditableComboBox.<locals>.<listcomp>rr)rMrr&r'r)r�rD)r r,rPr.rxr")r r#�getEntryForEditableComboBox�
s
z%Utilities.getEntryForEditableComboBoxcCs|j|�dk	S)N)r)r r,r"r"r#�isEditableComboBox�
szUtilities.isEditableComboBoxc
Cs`|sdSy|j�}Wn"d|}tjtj|d�dS|jtj�sHdSdd�}tj||�dk	S)NFz%ERROR: Exception getting state for %sTcSs|o|j�tjkS)N)rMr)r�)r�r"r"r#r��
sz:Utilities.isEditableDescendantOfComboBox.<locals>.<lambda>)r%rr&r'r(r)rkr�)r r,r-r.�
isComboBoxr"r"r#rJ�
sz(Utilities.isEditableDescendantOfComboBoxcCsdS)NFr")r r,r"r"r#�	isPopOverszUtilities.isPopOverc
CsL|j|�sdSy|j�}Wn"d|}tjtj|d�dS|jtj�S)NFz%ERROR: Exception getting state for %sT)r�r%rr&r'r(r)ZSTATE_MODAL)r r,r-r.r"r"r#�isNonModalPopOvers
zUtilities.isNonModalPopOvercCsdS)NFr")r r,r"r"r#�isUselessPanelszUtilities.isUselessPanelcCsBtjdtj�}tj|d|�}|jd�\}}}t|�t|�t|�fS)Nz
rgb|[^\w,]rr�)r$�compile�
IGNORECASEr%rSrX)r ZattributeValueZregexr�ZredZgreenZbluer"r"r#rszUtilities.rgbFromStringcCsdS)NFr")r r,r"r"r#�isClickableElementszUtilities.isClickableElementcCsdS)NFr")r r,r"r"r#�hasLongDescszUtilities.hasLongDesccCs�|o|j�tjksdSytdd�|j�D��}Wn"d|}tjtj|d�dSyt|j	dd��}Wn0t
k
r�d||f}tjtj|d�dSX|S)	NrcSsg|]}|jdd��qS)rRr)rS)r;rTr"r"r#r='sz*Utilities.headingLevel.<locals>.<listcomp>z*ERROR: Exception getting attributes for %sTr�0z*ERROR: Exception getting value for %s (%s))rMr)ZROLE_HEADINGrUrVrr&r'rXrWrp)r r,rZr.rr"r"r#�headingLevel"szUtilities.headingLevelcCsVy|j�}Wntk
r dSXdtjg}x$t|j�D]}|j|�|kr8dSq8WdS)NFZtoggleT)rerrZ
ACTION_TOGGLErcZnActionsZgetName)r r,r ZtoggleActionNamesrvr"r"r#�hasMeaningfulToggleAction6s
z#Utilities.hasMeaningfulToggleActionc
Cs�|o|j�tjksgSdd�}tj||�}y|j�}Wn
gS|j|�}|j|�|j|�}}|j||�}g}	x&t	|||�D]}
|	j
|j|
��q�W|	S)NcSs|odtj|�kS)Nr�)r)r�)r�r"r"r#r�Gsz0Utilities.columnHeadersForCell.<locals>.<lambda>)rMr)r@r�r^r\rgrh�getColumnExtentAtrcrfr\)r r,r;rLrmr[rsrtZcolspan�headers�cr"r"r#�columnHeadersForCellCs
zUtilities.columnHeadersForCellc
Cs�|o|j�tjksgSdd�}tj||�}y|j�}Wn
gS|j|�}|j|�|j|�}}|j||�}g}	x&t	|||�D]}
|	j
|j|
��q�W|	S)NcSs|odtj|�kS)Nr�)r)r�)r�r"r"r#r�\sz-Utilities.rowHeadersForCell.<locals>.<lambda>)rMr)r@r�r^r\rgrh�getRowExtentAtrcrfr])r r,r;rLrmr[rsrtZrowspanr�rr"r"r#�rowHeadersForCellXs
zUtilities.rowHeadersForCellc	Cs`|o|j�tjksdSdd�}tj||�}y|j�}Wn
dS|j|�}|j|�}|j|�S)NcSs|odtj|�kS)Nr�)r)r�)r�r"r"r#r�qsz/Utilities.columnHeaderForCell.<locals>.<lambda>)rMr)r@r�r^r\rhr\)r r,r;rLrmr[ZcolumnIndexr"r"r#�columnHeaderForCellms

zUtilities.columnHeaderForCellc	Cs`|o|j�tjksdSdd�}tj||�}y|j�}Wn
dS|j|�}|j|�}|j|�S)NcSs|odtj|�kS)Nr�)r)r�)r�r"r"r#r��sz,Utilities.rowHeaderForCell.<locals>.<lambda>)rMr)r@r�r^r\rgr])r r,r;rLrmr[ZrowIndexr"r"r#�rowHeaderForCell|s

zUtilities.rowHeaderForCellc	Csntjtjtjg}|o|j�|ks$dSdd�}tj||�}y|j�}Wn
d	S|j|�}|j|�|j	|�fS)
NrcSs|odtj|�kS)Nr�)r)r�)r�r"r"r#r��sz.Utilities.coordinatesForCell.<locals>.<lambda>r]r])r]r]r]r])r]r])
r)r@rArBrMr�r^r\rgrh)r r,r�r;rLrmr[r"r"r#rG�s
zUtilities.coordinatesForCellc
Csz|o|j�tjksdSdd�}tj||�}y|j�}Wn
d	S|j|�}|j|�|j|�}}|j||�|j	||�fS)
NrcSs|odtj|�kS)Nr�)r)r�)r�r"r"r#r��sz,Utilities.rowAndColumnSpan.<locals>.<lambda>r]r])r]r]r]r])r]r])
rMr)r@r�r^r\rgrhr�r�)r r,r;rLrmr[rsrtr"r"r#�rowAndColumnSpan�s
zUtilities.rowAndColumnSpanc	Cs$y|j�}Wn
dS|j|jfS)Nrr]r])r]r])r^rir[)r r,rmr"r"r#�rowAndColumnCount�s
zUtilities.rowAndColumnCountr�c
Csty|j�}Wn
dS|j|||�r*dS||||}}|j|||�rpd|||||f}	tjtj|	d�dSdS)NFTz&INFO: %s contains (%i,%i); not (%i,%i))rvr(rr&r')
r r,r�ryrRZmarginr�r�r�r.r"r"r#�
containsPoint�szUtilities.containsPointcCs |sdStjtjg}|j�|kS)NF)r)rYr�rM)r r,r�r"r"r#r��s
z Utilities._boundsIncludeChildrencCsj|s|j|�rdS|jsdS|j�}|tjkr4dS|j�}|jtj�rV|jtj�Stj	tj
g}||kS)NFT)rVr�rMr)r�r%r(ZSTATE_EXPANDABLEr_r�r�)r r,rPr-r�r"r"r#�_treatAsLeafNode�s
zUtilities._treatAsLeafNodec
CsD|sdS|dkrtj}|j||||�rB|j|�s<|j|�rZ|Sn|j|�sV|j|�rZdSdtj|�k�ry|j�}Wn(d|}tjtj	|d�d}YnxX|j
|||�}d||||f}tjtj	|d�|o�||k�r|j||||�}d||||f}tjtj	|d�|�r|Sx(|D] }|j||||�}	|	�r|	S�qWdS)Nr�z)ERROR: Exception querying component of %sTzINFO: %s is at (%s, %s) in %s)r)rxr�r�r�r�rvrr&r'�getAccessibleAtPoint�descendantAtPoint)
r r�r�ryrRr�r.r<rwr,r"r"r#r��s<


zUtilities.descendantAtPointcCs||fS)Nr")r r,r�ryrRr"r"r#�_adjustPointForObjszUtilities._adjustPointForObjcCs�|j|�}|sdS|dkr tj}|dkr.tj}|j||||�\}}|j|||�}d|kod|jknsndS|j||�\}}	}
|s�d|	|
fS|tjkr�|j	�r�dS|j
|	|
|�}|j|||ddf�s�dS||	|
fS)Nrrr)rrr)rrr)rrr)rrr)r�r)rxZTEXT_BOUNDARY_LINE_STARTr�ZgetOffsetAtPointr�ZgetTextAtOffsetZTEXT_BOUNDARY_WORD_STARTr�ZgetRangeExtentsr�)r r,r�ryrR�boundaryr�r�r�r�r�r�r"r"r#�textAtPoints(

zUtilities.textAtPointcCsxy|j�}|j}Wn
gSd||f}tjtj|d�|\}}}}	|j|||d�}
|j|
�\}}td|�}
d|
|f}tjtj|d�y|
j�j	t
j�}Wn|
}YnNX|j||||jd�}
|j|
�\}}t|
|�}d|
|f}tjtj|d�|j||||	d�}
|j|
�\}}d|
|f}tjtj|d�|dk�rL|}|}t
t||��}|
|k�rt|jd|
�|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^rirr&r'r�rGr�rvrwr)rxr{rArc�insert)r r,r�rmrir.r�ryrzr{rwrsrtr�r�Z	nextIndexr��rowsr"r"r#�visibleRows(sB





zUtilities.visibleRowscCs�y|j�}Wn
gSy|j�}|jtj�}Wn"d|}tjtj|d�gS|j||�}|shgS|j	|�\}}||kr�gSg}	xpt
||�D]b}
|j|
�}|r�|	j|�xD|D]<}y|j
||
�}
Wnw�YnX|
r�|j|
�r�|	j|
�q�Wq�W|	S)Nz&ERROR: Exception getting extents of %sT)r^rvrwr)rxrr&r'r��_getTableRowRangercr\rfrjr�)r r,rmr�r�r.r�Z
colStartIndexZcolEndIndex�cellsrtZ	colHeaderrsrwr"r"r#r�Ts<


zUtilities.getVisibleTableCellsc
Cs�|j|�\}}d|}}|j|�s*||fS|j|�}y|j�}Wn&d|}tjtj|d�||fS|jtj	�\}	}
}}|j
|	d|
tj	�}
|
r�|j|
�\}}|}|j
|	|d|
tj	�}
|
r�|j|
�\}}|d}||fS)Nrz3ERROR: Exception querying component interface of %sTr)r�rEr<rvrr&r'rwr)rxr�rG)r r,ZrowCountZcolumnCountr�r�rLr�r.r�ryrzr{rwrsrIr"r"r#r�ys*


zUtilities._getTableRowRangec
Cs�|j|�}y|j�}Wn"d|}tjtj|d�gS|j|�\}}|dkrTgS|j|�\}}||krngSg}	xPt||�D]B}
|j||
�}y|j	�j
tj�}Wnw~YnX|r~|	j
|�q~W|	S)Nz/ERROR: Exception querying table interface of %sTrr])r<r^rr&r'rGr�rcrjr%r(r)r+rf)
r r,rLrmr.rsrIr�r�r�rvrwZshowingr"r"r#�getShowingCellsInSameRow�s.
z"Utilities.getShowingCellsInSameRowc	Csry|j�}Wn
dS|j||�}|s,|Sy|j�}Wn"d|}tjtj|d�dS|�jtj�sndS|S)Nz$ERROR: Exception getting state of %sT)	r^rjr%rr&r'r(r)r+)	r r,rsrIZshowingOnlyrmrwr-r.r"r"r#�cellForCoordinates�s zUtilities.cellForCoordinatesc
Cs�y|j�}Wn"d|}tjtj|d�dS|tjks>dSdd�}tj||�}y|j�}Wn
dS|j|�}|j	|�|j
|�}}	|d|jko�|	d|jkS)Nz#ERROR: Exception getting role of %sTFcSs|odtj|�kS)Nr�)r)r�)r�r"r"r#r��sz&Utilities.isLastCell.<locals>.<lambda>r)
rMrr&r'r)r@r�r^r\rgrhrir[)
r r,rPr.r;rLrmr[rsrtr"r"r#�
isLastCell�s"

zUtilities.isLastCellcCshy|j�}Wn
dSxJt|j�D]<}x6t|j�D](}|j||�dksX|j||�dkr4dSq4Wq$WdS)NFrT)r^rcrir[r�r�)r r,rmrr�r"r"r#�isNonUniformTable�szUtilities.isNonUniformTablec
Cshy|j�}Wn"d|}tjtj|d�dS|jtj�sH|jtj�rLdSd|}tjtj|d�dS)Nz$ERROR: Exception getting state of %sTFz'INFO: %s is neither showing nor visible)r%rr&r'r(r)r+�
STATE_VISIBLE)r r,r-r.r"r"r#�isShowingOrVisible�szUtilities.isShowingOrVisiblecCs�y|j�}|j�}Wn"d|}tjtj|d�dS|jtj�rT|jtj�rTdStj	tj
tjtjtj
g}||kr�|j|�r�d|}tjtj|d�dSdS)Nz-ERROR: Exception getting state and role of %sTFz(HACK: Treating %s as showing and visible)r%rMrr&r'r(r)r+r�rYrZZROLE_CHECK_MENU_ITEMZROLE_RADIO_MENU_ITEMrar�)r r,r-rPr.Z	menuRolesr"r"r#r��s(zUtilities.isShowingAndVisiblec
Cs.y
|j}Wntjtjd|d�dSdS)NzDEAD: %sTF)r�rr&r')r r,r�r"r"r#rVs
zUtilities.isDeadc
Cs�y|j�}|j�}|j�}Wntjtjd|d�dStjtjtj	tj
tjtjtj
g}|dkr�||kr�tjtjd|d�dS|jtj�r�tjtjd|d�dS|jtj�r�tjtjd|d�dSdS)	NzZOMBIE: %s is null or deadTrzZOMBIE: %s's index is -1zZOMBIE: %s is defunctzZOMBIE: %s is invalidFr])rYr%rMrr&r'r)r�r�r�rNZ	ROLE_PAGEr�r�r(r�Z
STATE_INVALID)r r,r[r-rPrgr"r"r#rW"s0zUtilities.isZombiec
s�|o�sdS|j�tjtjgkr$dS��fdd�}||�r@|}n:ytj||�}Wn(d|}tjtj|d�d}YnXd|�f}tjtj|d�|S)Ncs|o�j|�ddd�S)NT)r|r})rl)r�)r,r r"r#r�Hsz)Utilities.findReplicant.<locals>.<lambda>z*INFO: Exception from findDescendant for %sTz-HACK: Returning %s as replicant for Zombie %s)rMr)r�Z
ROLE_EMBEDDEDr�rr&r')r r�r,ZisSameZ	replicantr.r")r,r r#�
findReplicant>s 
zUtilities.findReplicantcCs<|sdSg}dd�}tt||j���}|r6|dj�S|jS)NcSs|j�tjkS)N)rar)rb)rr"r"r#r�]sz3Utilities.getFunctionalChildCount.<locals>.<lambda>r)rAr�r`rdr�)r r,r<r�ror"r"r#�getFunctionalChildCountXsz!Utilities.getFunctionalChildCountcs^|sdSg}dd�}tt||j���}|rL|d��fdd�t�j��D�}|p\dd�|D�S)NcSs|j�tjkS)N)rar)rb)rr"r"r#r�isz1Utilities.getFunctionalChildren.<locals>.<lambda>rcsg|]}�j|��qSr")re)r;rv)rr"r#r=msz3Utilities.getFunctionalChildren.<locals>.<listcomp>cSsg|]}|�qSr"r")r;r<r"r"r#r=os)rAr�r`rcrd)r r,r<r�ror")rr#�getFunctionalChildrendszUtilities.getFunctionalChildrencCsB|sdSd}dd�}tt||j���}|r8|djd�}|p@|jS)NcSs|j�tjkS)N)rar)rk)rr"r"r#r�vsz/Utilities.getFunctionalParent.<locals>.<lambda>r)rAr�r`rerL)r r,r<r�ror"r"r#�getFunctionalParentqszUtilities.getFunctionalParentc
s|sdS|j�tjk}|r0�j|�}|r0|d}�j|�}�j|�}|dkrb||jkrb|j�|fS�j|�}t	|�dkr�tj
j||�r�tjtj
g���fdd�}tt||��}|o�||ks�dS�j|��r�tt�j|��}t	|�dk�r�dS|j|�}t	|�}	||	fS)Nrrr-cs�j|�p|j��kS)N)rWrM)r�)�layoutRolesr r"r#r��sz1Utilities.getPositionAndSetSize.<locals>.<lambda>r]r])r]r]r]r])r]r]r]r])r]r])rMr)r�r�r�r�rLrYr�rDrnr�rar`rAr�rPr[)
r r,r�r�rLr�ZsiblingsZisNotLayoutOnlyZpositionZsetSizer")r�r r#�getPositionAndSetSize}s2




zUtilities.getPositionAndSetSizecCsP|jjjdi�}|jt|�d�\}}}d||||f}tjtj|d�|||fS)N�textSelectionsrrz.INFO: Cached selection for %s is '%s' (%i, %i)T)rrr)rrHrWr�rr&r')r r,r�r�r�r�r.r"r"r#�getCachedTextSelection�s
z Utilities.getCachedTextSelectioncs�y|j�}WnVtk
r<d|}tjtj|d�d}Yn(d|}tjtj|d�d}YnX|jjjd�r�|j|�\}}}|s�d|jjd<i|jjd<|jjjdi��t	|��kr�j
t	|���x*��fdd��j�D�D]}�j
|�q�Wd\}}	}
|�r�y|jd	�\}}	Wn,d|}tjtj|d�d	}}	YnX||	k�r�|j
||	�}
x(|
j|j��r�|	d8}	|
dd�}
�q\Wd
||
||	f}tjtj|d�||	|
f�t	|�<�|jjd<dS)Nz%ERROR: %s doesn't implement AtspiTextTz/ERROR: Exception querying text interface for %sr�Fr�csg|]}�j|��kr|�qSr")rW)r;�k)r�rr"r#r=�sz7Utilities.updateCachedTextSelection.<locals>.<listcomp>rrz-ERROR: Exception getting selected text for %srz+INFO: New selection for %s is '%s' (%i, %i))rrrr])r�rrr&r'rrHrWr�r��poprhr�r�rr�)r r,r�r.r�Z
selectedStartZselectedEndr�r�r�r�r")r�rr#�updateCachedTextSelection�sJ


z#Utilities.updateCachedTextSelectioncGstj}|sdS|j|�dS)N)rr(�onClipboardContentsChanged)�argsr!r"r"r#r��sz$Utilities.onClipboardContentsChangedcCs8|jdk	rdStjjtjjdd��}|jd|j�|_dS)N�	CLIPBOARDFzowner-change)	rr�	ClipboardrWr�Atom�internZconnectr�)r �	clipboardr"r"r#�connectToClipboard�s

zUtilities.connectToClipboardcCs4|jdkrdStjjtjjdd��}|j|j�dS)Nr�F)rrr�rWrr�r�Z
disconnect)r r�r"r"r#�disconnectFromClipboard�s
z!Utilities.disconnectFromClipboardcCstjjtjjdd��}|j�S)Nr�F)rr�rWrr�r�Z
wait_for_text)r r�r"r"r#�getClipboardContents�szUtilities.getClipboardContentscCs&tjjtjjdd��}|j|d�dS)Nr�Frr])rr�rWrr�r��set_text)r r�r�r"r"r#�setClipboardText�szUtilities.setClipboardTextcCs(tjjtjjdd��}|j|j|�dS)Nr�F)rr�rWrr�r�Zrequest_text�_appendTextToClipboardCallback)r r�r�r"r"r#�appendTextToClipboard�szUtilities.appendTextToClipboardcCs&|jd�}d||f}|j|d�dS)NrCz%s
%srr])�rstripr�)r r�r�r@r"r"r#r��s
z(Utilities._appendTextToClipboardCallbackcCstj}t|tj�sdS|j�S)NF)rrWrJr
rXZisPrintableKey)r r�r"r"r#�lastInputEventWasPrintableKey�sz'Utilities.lastInputEventWasPrintableKeycCs|j�\}}|tj@S)N)rIr	�CTRL_MODIFIER_MASK)r �	keyStringrKr"r"r#�lastInputEventWasCommandsz"Utilities.lastInputEventWasCommandcCs$|j�\}}|dkrdS|tj@S)N�Left�RightF)r�r�)rIr	r�)r r�rKr"r"r#�lastInputEventWasCharNavsz"Utilities.lastInputEventWasCharNavcCs"|j�\}}|dkrdS|tj@S)Nr�r�F)r�r�)rIr	r�)r r�rKr"r"r#�lastInputEventWasWordNavsz"Utilities.lastInputEventWasWordNavcCs4|j�\}}|dkrdS|jtj�r(dS|tj@S)NrDrEF)rDrE)rIrJrr�r	r�)r r�rKr"r"r#�lastInputEventWasLineNavsz"Utilities.lastInputEventWasLineNavcCs$|j�\}}|dkrdS|tj@S)N�Home�EndF)r�r�)rIr	r�)r r�rKr"r"r#� lastInputEventWasLineBoundaryNavsz*Utilities.lastInputEventWasLineBoundaryNavcCs4|j�\}}|dkrdS|jtj�r(dS|tj@S)NrFrGF)rFrG)rIrJrr�r	r�)r r�rKr"r"r#�lastInputEventWasPageNav&sz"Utilities.lastInputEventWasPageNavcCs"|j�\}}|dkrdS|tj@S)Nr�r�F)r�r�)rIr	r�)r r�rKr"r"r#� lastInputEventWasFileBoundaryNav0sz*Utilities.lastInputEventWasFileBoundaryNavcCs"|j�\}}|tj@r|dkSdS)	Nr�r�rDrEr�r�F)r�r�rDrEr�r�)rIr	�SHIFT_MODIFIER_MASK)r r�rKr"r"r#�&lastInputEventWasCaretNavWithSelection7s
z0Utilities.lastInputEventWasCaretNavWithSelectioncCs<|j�\}}|j|�}d|kr"dS|tj@r8|tj@SdS)N�zF)rZrVr	r�r�)r rUrKrr"r"r#�lastInputEventWasUndo>s

zUtilities.lastInputEventWasUndocCs:|j�\}}|j|�}d|kr"dS|tj@r6|tj@SdS)Nr�F)rZrVr	r�r�)r rUrKrr"r"r#�lastInputEventWasRedoIs


zUtilities.lastInputEventWasRedocCs<|j�\}}|j|�}d|kr"dS|tj@r8|tj@SdS)Nr�F)rZrVr	r�r�)r rUrKrr"r"r#�lastInputEventWasCutTs

zUtilities.lastInputEventWasCutcCs<|j�\}}|j|�}d|kr"dS|tj@r8|tj@SdS)Nr�F)rZrVr	r�r�)r rUrKrr"r"r#�lastInputEventWasCopy_s

zUtilities.lastInputEventWasCopycCs<|j�\}}|j|�}d|kr"dS|tj@r8|tj@SdS)N�vF)rZrVr	r�r�)r rUrKrr"r"r#�lastInputEventWasPastejs

z Utilities.lastInputEventWasPastecCs<|j�\}}|j|�}d|kr"dS|tj@r8|tj@SdS)Nr|F)rZrVr	r�r�)r rUrKrr"r"r#�lastInputEventWasSelectAllus

z$Utilities.lastInputEventWasSelectAllcCsD|j�\}}|dkrdS|j�\}}|j|�}d|kr:dS|tj@S)Nr\Tr�F)rIrZrVr	r�)r r�rKrUrr"r"r#�lastInputEventWasDelete�s
z!Utilities.lastInputEventWasDeletecCs&tj}t|tj�r"|jdko |jSdS)N�1F)rrWrJr
�MouseButtonEvent�button�pressed)r r�r"r"r#�"lastInputEventWasPrimaryMouseClick�sz,Utilities.lastInputEventWasPrimaryMouseClickcCs&tj}t|tj�r"|jdko |jSdS)N�2F)rrWrJr
r�r�r�)r r�r"r"r#�!lastInputEventWasMiddleMouseClick�sz+Utilities.lastInputEventWasMiddleMouseClickcCs&tj}t|tj�r"|jdko |jSdS)N�3F)rrWrJr
r�r�r�)r r�r"r"r#�$lastInputEventWasSecondaryMouseClick�sz.Utilities.lastInputEventWasSecondaryMouseClickcCs(tj}t|tj�r$|jdko"|jSdS)Nr�F)rrWrJr
r�r�r�)r r�r"r"r#�$lastInputEventWasPrimaryMouseRelease�sz.Utilities.lastInputEventWasPrimaryMouseReleasecCs(tj}t|tj�r$|jdko"|jSdS)Nr�F)rrWrJr
r�r�r�)r r�r"r"r#�#lastInputEventWasMiddleMouseRelease�sz-Utilities.lastInputEventWasMiddleMouseReleasecCs(tj}t|tj�r$|jdko"|jSdS)Nr�F)rrWrJr
r�r�r�)r r�r"r"r#�&lastInputEventWasSecondaryMouseRelease�sz0Utilities.lastInputEventWasSecondaryMouseRelease��?c

Cs�tj}|sdStj�}||j|kr(dS|jjjdd�}|||krHdSt|tj�rb|j	�s�dSn2t|tj
�r�|j|jj�s�|j
�\}}|d	kr�dSytjj�}Wn$dtj}tjtj|d�dStjtjtjtjg}	||	kS)
NFzlast-table-sort-timegrB�spacer1z$ERROR: Exception getting role for %sT)rBr�r1)rrW�timerrHrWrJr
r�r�rXZisHandledByZleftClickReviewItemrIr�rMrr&r'r)rArBZROLE_TABLE_COLUMN_HEADERZROLE_TABLE_ROW_HEADER)
r r�r�ZnowZlastSortTimer�rKrPr.r�r"r"r#�lastInputEventWasTableSort�s8
z$Utilities.lastInputEventWasTableSortcCsN|jjd�r |jjd�r dSy|jj�}|jj�}Wn$d|j}tjtj|d�dStj	tj
tjtjtj
g}||kr�d}tjtj|d�dS|tjkr�|jtj�r�|jtj�r�d}tjtj|d�dS|j|j�r�|jtj�S|tjk�r
|jtj��r
dStj|j|jjgk�r$dS|jtj��r6dSd}tjtj|d�dS)	Nzobject:text-changed:zobject:text-attributes-changedFz-ERROR: Exception getting role and state of %sTz.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)rHr�r�rMr%rr&r'r)rNrYrZZROLE_SLIDERZROLE_SPIN_BUTTONr@r(r�r�r�rerr�rLrV)r r�rPr-r.ZignoreRolesr"r"r#�,isPresentableTextChangedEventForLocusOfFocus�sH


z6Utilities.isPresentableTextChangedEventForLocusOfFocuscCs,|jjd�sdS|j�\}}|dkr(dSdS)Nzobject:text-changed:deleteFr[T)rHr�rI)r r�r�rKr"r"r#�#isBackSpaceCommandTextDeletionEventsz-Utilities.isBackSpaceCommandTextDeletionEventcCs|jjd�sdS|j�S)Nzobject:text-changed:deleteF)rHr�r�)r r�r"r"r#� isDeleteCommandTextDeletionEventsz*Utilities.isDeleteCommandTextDeletionEventcCs4|jjd�sdS|j�sdS|j|j�\}}}|S)Nzobject:text-changed:deleteF)rHr�r�r�r�)r r�r�r�r�r"r"r#�isUndoCommandTextDeletionEventsz(Utilities.isUndoCommandTextDeletionEventcCsD|jjd�sdS|j�rdS|j|j�\}}}|oB|j�|jj�kS)Nzobject:text-changed:deleteF)rHr�r�r�r�r�r�)r r�r�r�r�r"r"r#�isSelectedTextDeletionEvent"sz%Utilities.isSelectedTextDeletionEventcCsF|jjd�sdS|j|j�|j|j�\}}}|oD||jkoD||jkS)Nzobject:text-changed:insertF)rHr�r�r�r�r�Zdetail1)r r�r�r�r�r"r"r#�isSelectedTextInsertionEvent,s
z&Utilities.isSelectedTextInsertionEventcCs|j�sdS|j|�rdSdS)NFT)r�r�)r r�r"r"r#�isSelectedTextRestoredEvent4s

z%Utilities.isSelectedTextRestoredEventcCs|jjd�sdS|j�S)Nzobject:text-changed:insertF)rHr�r�)r r�r"r"r#�%isMiddleMouseButtonTextInsertionEvent=sz/Utilities.isMiddleMouseButtonTextInsertionEventc
Csx|jjd�sdSy|jj�}Wn$d|j}tjtj|d�dS|tjkrXt	j
d�St|jj
��dkrtt	j
d�SdS)Nzobject:text-changed:insertFz#ERROR: Exception getting role of %sTZ
enableKeyEchorr)rHr�r�rMrr&r'r)rer$r%rDr�r�)r r�rPr.r"r"r#�isEchoableTextInsertionEventCs



z&Utilities.isEchoableTextInsertionEventc
CsJ|j|�sdSy|j�}Wn"d|}tjtj|d�dS|jtj�S)NFz$ERROR: Exception getting state of %sT)rjr%rr&r'r(r)rk)r r,r-r.r"r"r#r~Vs
zUtilities.isEditableTextAreacCs�|jjd�sdS|j�s"|j�r&dS|j|�r4dSd|jkrJ|j�rJdS|j|j�sZdS|j�}|sjdS|j	|krxdSt
tjd|j	��t
tjd|��kr�dSd|kr�|j	j
�|kr�dSdS)Nzobject:text-changedF�deleteTz\wrC)rHr�r�r�r�r�r~r�r�r��boolr$rr�)r r��contentsr"r"r#�isClipboardTextChangedEventcs(

"z%Utilities.isClipboardTextChangedEventcCsx|ptj}|s|j|�rdS|j�}|s.dS|j|�\}}}|rN||krNdS|j|�pZ|}|j|�rjdS|ov|j|kS)NFT)rr�rVr�r�r�r�)r r,r�r�r�r�r"r"r#�objectContentsAreInClipboard�s

z&Utilities.objectContentsAreInClipboardcCs4d|jjd<d|jjd<d|jjd<d|jjd<dS)NF�undo�redo�pasterzlast-selection-message)rrH)r r"r"r#�clearCachedCommandState�sz!Utilities.clearCachedCommandStatecCs�|j�r@|jjjd�s0|jjtj�d|jjd<|j|j�dS|j	�r�|jjjd�sp|jjtj
�d|jjd<|j|j�dSdS)Nr�Tr�F)r�rrHrW�presentMessager�UNDOr�r�r��REDO)r r�r"r"r#�handleUndoTextEvent�szUtilities.handleUndoTextEventcCsx|j�rdS|j�r@|jjjd�s<|jjtj�d|jjd<dS|j�rt|jjjd�sp|jjtj	�d|jjd<dSdS)NFr�Tr�)
r�r�rrHrWr�rr�r�r�)r r"r"r#�handleUndoLocusOfFocusChange�sz&Utilities.handleUndoLocusOfFocusChangecCsH|j�rdS|j�rD|jjjd�s@|jjtjtj�d|jjd<dSdS)NFr�T)	r�r�rrHrWr�rZCLIPBOARD_PASTED_FULLZCLIPBOARD_PASTED_BRIEF)r r"r"r#�handlePasteLocusOfFocusChange�sz'Utilities.handlePasteLocusOfFocusChangecCs|j�rdS|j�rdSdS)NTF)rr)r r"r"r#�presentFocusChangeReason�s
z"Utilities.presentFocusChangeReasoncCsf|j|�\}}}|j|�|j|�\}}}|jjjd�t|�krDdS|jt|��rVdSg}tt	||��}	tt	||��}
|	j
|
�s�dS|	r�|
r�|	j|
�r�|j||t
jg�|j||t
jg�n\t|	j|
��}|s�dS|d|dd}}
|	|
k�r|j||
t
jg�n|j||
t
jg�tjd�}x:|D]2\}}}|jj|||�|�r,|jj|dd��q,WdS)	NZlastAutoCompleteFTrrr7)Z	interruptr])r�r�rrHrWr��_speakTextSelectionStaterDr0rc�unionrQrfrZTEXT_UNSELECTEDZ
TEXT_SELECTEDrE�symmetric_differencer$r%Z	sayPhrase�speakMessage)r r,ZoldStartZoldEndZ	oldStringZnewStartZnewEndr5ZchangesZoldCharsZnewCharsZchangeZchangeStartZ	changeEndrr�r��messager"r"r#�handleTextSelectionChange�s8


z#Utilities.handleTextSelectionChangecCstjtjtjtjgS)z!Hacky and to-be-obsoleted method.)rZPARAGRAPH_SELECTED_DOWNZPARAGRAPH_UNSELECTED_DOWNZPARAGRAPH_SELECTED_UPZPARAGRAPH_UNSELECTED_UP)r r"r"r#�_getCtrlShiftSelectionsStringssz(Utilities._getCtrlShiftSelectionsStringsc	Cs�tjd�rdS|j�\}}|tj@}|tj@}|dk}d}|dkrT|rT|rTtj}�n\|dkrn|rn|rntj}�nB|dkr�|r�|r�|r�tj	}ntj
}�n|dkr�|r�|r�|r�tj}ntj}n�|dkr�|r�|r�|j
�}|r�|d}n|d}n�|d	ko�|o�|�r |j
�}|�r|d
}n|d}n�|dk�rL|�rL|�rL|�rDtj}ntj}nd|d
k�rx|�rx|�rx|�rptj}ntj}n8|j��r�|�r�|jjjd��s�d|jjd<tj}ndS|�s�dS||jjjd�k�r�||jjd<|jj|�dS)z!Hacky and to-be-obsoleted method.r7FrNrGrFrErrDr�rcr�r�r�Tzlast-selection-message)r$r%rIr	r�r�rZLINE_SELECTED_RIGHTZLINE_SELECTED_LEFTZPAGE_SELECTED_DOWNZPAGE_UNSELECTED_DOWNZPAGE_SELECTED_UPZPAGE_UNSELECTED_UPr
ZDOCUMENT_SELECTED_UPZDOCUMENT_UNSELECTED_UPZDOCUMENT_SELECTED_DOWNr�rrHrWZDOCUMENT_SELECTED_ALLr)	r r�r]rKZisControlKeyZ
isShiftKeyr�rZstringsr"r"r#rs`









z"Utilities._speakTextSelectionState)N)N)N)N)N)FF)N)N)N)r)F)Tr])rr])N)N)NF)T)r1)N)TT)rTr])Nr]Fr])Nr]F)r�)N)NN)F)r�)N([�__name__�
__module__�__qualname__r)ZRegistryZ
getDesktopr�r�r.r/r$�UNICODE�flagsr�r)r�r3r2r�r�rdr�r�r$r/�staticmethodr6r:rIrQr\rxr~r�rrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrrrrrr	r
rrr
rrrrrrr,r0r1r4r6r3r8r7r<r=r>r?rDrErJrLrMrPrQrRrTr^rhrirlrmrurlrjr?r�r�r�rrr�r�r�r�rfr�r�r�r�rXr�r'r�r�r�rHr�r&r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�r�rrrr�rrr�rrr!r#r&r(r+r-r6r=r?r�rLrNrPrSrQr�rVrZrIrarfr	rkrmrorprrrsrtrur�ryrzr{r|r}rr�rJr�r�r�rr�r�r�r�r�r�r�r�rGr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rVrWr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r~r�r�r�rrrrr	r
rr"r"r"r#rBs�

#'E6!9!)&

	
"

j&&<!"6. @  
)'#*	
%%5!&
!
@=,


	',%	
 0

$.


	
 
-r)$�__doc__Z__id__�__version__Z__date__Z
__copyright__Z__license__rFZgir
rjr)r$r2r�r>rrrrrrrr	r
rrr
rrrrrrZ
getManagerr$rr"r"r"r#�<module>s@