%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/orca/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/orca/__pycache__/script_utilities.cpython-312.pyc

�

g
f�7���dZdZdZdZdZdZddlZddlZddlZddl	Z	ddl
mZejd	d
�ddl
mZddl
mZdd
l
mZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddl!m"Z"ddl#m$Z$dd l%m&Z&dd!l'm(Z(dd"l)m*Z*dd#l+m,Z,dd$l-m.Z.dd%l/m0Z0Gd&�d'�Z1y)(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)�SequenceMatcher�Atspiz2.0)r)�Gdk��Gtk�)�
colornames)�debug)�
focus_manager)�keynames)�keybindings)�input_event)�mathsymbols)�messages)�
orca_state)�object_properties)�pronunciation_dict)�script_manager)�settings)�settings_manager)�text_attribute_names)�AXComponent)�AXHypertext)�AXObject)�AXSelection)�AXTable)�AXText)�AXUtilities)�AXValuec�t
�eZdZej�ZdZdZgd�Zgd�Ze	jZe	jde�Z
e	jddje��d�e�Ze	jddje��d�e�Ze	jd	e�Zd
ZdZdZd
ZdZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z�d�d�Zd�Z d�Z!�d�d�Z"d�Z#d�Z$d�Z%d�Z&d �Z'�d�d!�Z(�d�d"�Z)d#�Z*d$�Z+d%�Z,d&�Z-d'�Z.d(�Z/d)�Z0d*�Z1d+�Z2d,�Z3d-�Z4d.�Z5d/�Z6d0�Z7d1�Z8d2�Z9d3�Z:d4�Z;d5�Z<d6�Z=d7�Z>d8�Z?d9�Z@d:�ZAd;�ZBd<�ZCd=�ZDd>�ZEd?�ZFd@�ZGdA�ZHdB�ZIdC�ZJdD�ZKdE�ZLdF�ZMdG�ZNdH�ZOdI�ZPdJ�ZQdK�ZRdL�ZSdM�ZTdN�ZUdO�ZVdP�ZWdQ�ZXdR�ZYdS�ZZdT�Z[dU�Z\dV�Z]dW�Z^dX�Z_dY�Z`dZ�Zad[�Zbd\�Zcd]�Zdd^�Zed_�Zfd`�Zgda�Zhdb�Zidc�Zjdd�Zkde�Zldf�Zmdg�Zndh�Zodi�Zpdj�Zqdk�Zrdl�Zs�d�dm�Ztdn�Zudo�Zvdp�Zwdq�Zxdr�Zyds�Zzdt�Z{du�Z|dv�Z}dw�Z~dx�Zdy�Z�dz�Z�d{�Z�d|�Z�d}�Z�d~�Z�d�Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z��d�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z��d�d��Z��d�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z��d�d��Z��d�d��Z��d�d��Z�d��Z�d��Z�d��Z��d�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�e�d���Z�d��Z�d��Z�d��Z�d��Z�d��Z�		�d�d��Z�d��Z�d��Z�d��Z�d��Zǐd�d��Z�d��Z�d„Z�dÄZ�dĄZ�dńZ͐d�dƄZ�e�dDŽ�Z�dȄZ�dɄZ�dʄZ�d˄Z�d̄Z�d̈́Z�d΄Z�dτZ�dЄZؐd�dфZِd�d҄Z�e�dӄ�Zېd�dԄZܐd�dՄZ�dքZ�dׄZ�d؄Z�dلZ�dڄZ�d�dۄZ�d܄Z�d݄Z�dބZ�d߄Z�d�Z�d�Z�d�Z�d�d�Z�d�Z�d�Z�d�Z�d�Z�d�d�Z�d�Z�d�Z�d�Z�d�d�Z�d�Z�d�Z�d�Z�d�Z�d�Z�e�d��Z�e�d��Z�d�Z�d��Z�d��Z�d��Z�e�d����Ze��d�d����Zd���Zd���Zd���Zd���Ze�d����Ze�d����Ze��d���Ze��d���Z	�d��Z
e��d���Ze��d���Z�d��d��Z
�d��d��Z�d��d��Z�d��d��Z�d	��Z�d
��Z�d��Z�d��Z�d
��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��d��Z�d��d��Z�d��Z�d��Z�d��Z �d��Z!�d��Z"�d��Z#�d��Z$�d��Z%�d��Z&�d��Z'�d ��Z(�d!��Z)�d"��Z*�d#��Z+�d$��Z,�d%��Z-�d&��Z.�d'��Z/�d(��Z0�d)��Z1�d*��Z2�d+��Z3�d,��Z4�d-��Z5�d.��Z6�d/��Z7�d0��Z8�d1��Z9�d2��Z:�d��d3��Z;�d��d4��Z<�d5��Z=�d6��Z>�d7��Z?�d��d8��Z@�d9��ZA�d:��ZB�d��d;��ZC�d<��ZD�d=��ZE�d>��ZF�d?��ZG�d@��ZH�d��dA��ZI�dB��ZJ�dC��ZKe��dD���ZL�dE��ZM�dF��ZN�dG��ZO�dH��ZP�dI��ZQ�d��dJ��ZR�dK��ZS�dL��ZT�dM��ZU�dN��ZV�dO��ZW�dP��ZX�dQ��ZY�dR��ZZ�dS��Z[�dT��Z\�dU��Z]�dV��Z^�dW��Z_�dX��Z`�dY��Za�dZ��Zb�d[��Zc�d\��Zd�d]��Ze�d^��Zf�d_��Zg�d`��Zh�da��Zi�db��Zj�dc��Zk�dd��Zl�de��Zm�df��Zn�dg��Zo�dh��Zp�d��di��Zq�dj��Zr�dk��Zs�dl��Zt�dm��Zu�dn��Zv�do��Zw�dp��Zx�dq��Zy�dr��Zz�ds��Z{�dt��Z|�du��Z}�d��dv��Z~�dw��Z�dx��Z��dy��Z��dz��Z��d{��Z��d|��Z��d}��Z��d~��Z��d��Z��d���Z��d��d���Z��d���Z��d���Z��d��d���Z��d��d���Z�y(��	Utilitiesuu)
u⁰�¹�²�³u⁴u⁵u⁶u⁷u⁸u⁹)
u₀u₁u₂u₃u₄u₅u₆u₇u₈u₉z(\W+)�[�z]+z[^\w\s]�displayedDescription�displayedLabel�
displayedText�
keyBinding�nestingLevel�	nodeLevelc�.�||_d|_i|_y)z�Creates an instance of the Utilities class.

        Arguments:
        - script: the script with which this instance is associated.
        N)�_script�_clipboardHandlerId�_selectedMenuBarMenu)�self�scripts  �7/usr/lib/python3/dist-packages/orca/script_utilities.py�__init__zUtilities.__init__ds�����#'�� �$&��!�c�t�tj|�sgStj|�}|�gSd�}t	j
|tjj|�}dt|�d|dg}tjtj|d�|r|Stj|d��\}}|j|�}t|dztj |d���D]�}	tj"||	|�}
t	j$|
tjj&�}|s�K|j)d	�}|j+||�r|j-|
���|j|�|ks��ndt|�d|d
g}tjtj|d�|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
        c�2�tj|�dk\S�Nr)r�get_index_in_parent��xs r4�predz"Utilities.childNodes.<locals>.pred�s���/�/��2�a�7�7r6�SCRIPT UTILITIES:zchild nodes forzvia node-parent-ofTF��prefer_attributer	rzvia node-child-of)r�is_expandedr�	get_tabler�get_relation_targetsr�RelationType�NODE_PARENT_OF�lenr�printTokens�
LEVEL_INFO�get_cell_coordinatesr-�range�
get_row_count�get_cell_at�get_relation�
NODE_CHILD_OF�
get_target�isSameObject�append)
r2�obj�parentr=�nodes�tokens�row�colr-�i�cell�relation�nodeOfs
             r4�
childNodeszUtilities.childNodesus����&�&�s�+��I��"�"�3�'���>��I�
	8��-�-�c�5�3E�3E�3T�3T�VZ�[��%�s�5�z�3D�c�K_�`��
���%�*�*�F�D�9���L��/�/��e�L���S��N�N�3�'�	��s�Q�w�� 5� 5�f�u� U�V�
	�A��&�&�v�q�#�6�D��,�,�T�5�3E�3E�3S�3S�T�H����(�(��+�F�� � ��f�-����T�"�����'�9�4��
	�&�s�5�z�3D�c�K^�_��
���%�*�*�F�D�9��r6c��d|d|g}tjtj|d�|r|sy||k(r|S|g}tj|�}|r)|j|�tj|�}|r�)|j
�|g}tj|�}|r)|j|�tj|�}|r�)|j
�d}tt|�t|��}d}	|	|kr*|j||	||	�r||	}|	dz
}	nn|	|kr�*d|d|d|g}tjtj|d�|S)	z�Finds the common ancestor between Accessible a and Accessible b.

        Arguments:
        - a: Accessible
        - b: Accessible
        z0SCRIPT UTILITIES: Looking for common ancestor of�andTNrr	z$SCRIPT UTILITIES: Common ancestor of�is)
rrGrHr�get_parent_checkedrQ�reverse�minrFrP)
r2�a�brU�aParentsrS�bParents�commonAncestor�	maxSearchrXs
          r4rgzUtilities.commonAncestor�s_��E�a��PQ�R��
���%�*�*�F�D�9��a����6��H��3���,�,�Q�/����O�O�F�#��0�0��8�F��	�����3���,�,�Q�/����O�O�F�#��0�0��8�F��	��������H�
�s�8�}�5�	�
���)�m�� � ��!��h�q�k�:�!)�!����Q�����)�m�9�!�U�A�t�^�\��
���%�*�*�F�D�9��r6c��	|jj|j|S#t$rJ|j|jjvr#i|jj|j<d}YnwxYw|j	|�}|D]#}|j||j
|��}�%||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�	Exception�labelsForObject�appendStringr*)r2rR�labelString�labels�labels     r4r)zUtilities.displayedLabel�s���	��<�<�.�.�t�/C�/C�D�S�I�I���	��#�#�4�<�<�+F�+F�F�DF����+�+�D�,@�,@�A��K�	��
�%�%�c�*���	J�E��!�!�+�t�/A�/A�%�/H�I�
�	J�BM����#�#�D�$8�$8�9�#�>��|�|�*�*�4�+?�+?�@��E�Es�%(�AA;�:A;c��y�NF��r2rRs  r4�preferDescriptionOverNamez#Utilities.preferDescriptionOverName����r6c�(�tj|tjj�}|sgStj|tjj
�}||k(r,d|dg}t
jtj|d�gS|S)z(Return a list of objects describing obj.r>z;'s described-by targets are the same as labelled-by targetsT)	rrCrrD�DESCRIBED_BY�LABELLED_BYrrGrH)r2rR�descriptionsrprUs     r4�descriptionsForObjectzUtilities.descriptionsForObject�s��� �4�4�S�%�:L�:L�:Y�:Y�Z����I��.�.�s�E�4F�4F�4R�4R�S���6�!�)�3�S�U�F����e�.�.���=��I��r6c�b�|j|�}tt|j|��S�N)�detailsForObject�list�mapr*)r2rR�detailss   r4�detailsContentForObjectz!Utilities.detailsContentForObjects*���'�'��,���C��*�*�G�4�5�5r6c�f�tj|tjj�}|sLtj|�r7tj|�r"tj|�D�cgc]}|��}}|s|Sg}|D]$}|j|j|d����&|Scc}w)z4Return a list of objects containing details for obj.c�.�tj|�Sr~)r�is_whitespace_or_emptyr;s r4�<lambda>z,Utilities.detailsForObject.<locals>.<lambda>s��f�&C�&C�A�&F�"F�r6)rrCrrD�DETAILSr�is_toggle_buttonrA�
iter_children�extend�findAllDescendants)r2rR�textOnlyr��child�textObjects�details       r4rzUtilities.detailsForObject	s����/�/��U�5G�5G�5O�5O�P���;�7�7��<��'�'��,�*2�*@�*@��*E�F��u�F�G�F���N����	I�F����t�6�6��F� H�
I�	I�
���Gs�2	B.c��	|jj|j|S#t$rH|j|jjvr#i|jj|j<YnwxYwdj	t|j|j|���}||jj|j|<|jj|j|S)z?Returns the text being displayed for the object describing obj.� )r/rj�DISPLAYED_DESCRIPTIONrl�joinr�r*r|)r2rR�strings   r4r(zUtilities.displayedDescriptions���	M��<�<�.�.�t�/I�/I�J�3�O�O���	M��)�)����1L�1L�L�JL����+�+�D�,F�,F�G��	M�����#�d�0�0�$�2L�2L�S�2Q�R�S��GM����#�#�D�$>�$>�?��D��|�|�*�*�4�+E�+E�F�s�K�Ks�%(�AA9�8A9c�&�	|jj|j|S#t$rd}YnwxYwt	j
|�}t	j|�}|tjjtjjfvr|r|Stj|�}|j|vrd}|s8|tjjtjjfvr|}|s�|tjjtjj fvrN|j#|d��}|s|j#|dd��}dj%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.
        Nr	)�minimumWordsF)�onlyShowingr�r�)r/rj�DISPLAYED_TEXTrlr�get_name�get_roler�Role�PUSH_BUTTON�LABELr�get_all_text�EMBEDDED_OBJECT_CHARACTER�	COMBO_BOX�SPIN_BUTTON�	LIST_ITEM�unrelatedLabelsr�r�r*)r2rRr*�name�rolerps      r4r*zUtilities.displayedText)s���	!��<�<�.�.�t�/B�/B�C�C�H�H���	!� �M�	!��� � ��%��� � ��%���E�J�J�*�*�E�J�J�,<�,<�=�=�$��K��+�+�C�0�
��)�)�]�:� �M���e�j�j�.B�.B�E�J�J�DZ�DZ�-[�![�!�M���%�*�*�*@�*@�%�*�*�BV�BV�)W�!W��)�)�#�A�)�>�F���-�-�c�u�ST�-�U���H�H�S��);�);�V�%D�E�M����d�l�l�&A�&A�A�?A�D�L�L�'�'��(;�(;�<�@M����#�#�D�$7�$7�8��=��|�|�*�*�4�+>�+>�?��D�Ds�%(�6�6Nc���|s|j�\}}tj|tj�}|r|Stj�j�}tj|�r|Sy)zyReturns the document frame which is displaying the content.
        Note that this is intended primarily for web content.N)�getCaretContextr�
find_ancestorr�is_documentr�
getManager�get_locus_of_focus)r2rR�offset�document�focuss     r4�
documentFramezUtilities.documentFrameUsf����.�.�0�K�C���)�)�#�{�/F�/F�G����O��(�(�*�=�=�?���"�"�5�)��L�r6c�z��ddg}|xs"tj�j�}|s)d}tjtj
|d�|S|j
|�}|�+d|g}tjtj
|d�|Stjjtjjg�|j�r)�jtjj�tj |�}|�vr||d<ng|tjj"tjj$fvr||d<�fd�}||�r||d<ntj&||�|d<d|d	|dd
|dg}tjtj
|d�|S)z;Returns the frame and (possibly) the dialog containing obj.Nz>SCRIPT UTILITIES: frameAndDialog() called without valid objectTz5SCRIPT UTILITIES: could not find top-level object forr	rc�2��tj|��vSr~)rr�)r<�dialog_roless �r4�isDialogz*Utilities.frameAndDialog.<locals>.isDialog�s����(�(��+�|�;�;r6r>zis in framez
and dialog)rr�r�r�printMessagerH�topLevelObjectrGrr��DIALOG�FILE_CHOOSER�_treatAlertsAsDialogsrQ�ALERTrr��FRAME�WINDOWr�)	r2rR�results�msg�topLevelrUr�r�r�s	        @r4�frameAndDialogzUtilities.frameAndDialogfs������,���D�]�-�-�/�B�B�D���R�C����u�/�/��d�;��N��&�&�s�+����M�s�S�F����e�.�.���=��N��
�
�)�)�5�:�:�+B�+B�C���%�%�'�����
�
� 0� 0�1�� � ��*���<��!�G�A�J���
�
�(�(�%�*�*�*;�*;�<�<�%���
�
<���}� ���
�%�3�3�C��B���
�%�s�M�7�1�:�|�U\�]^�U_�`��
���%�*�*�F�D�9��r6c�d�|jtj�j�k(ryy�NTF)�sourcerr�r��r2�events  r4� presentEventFromNonShowingObjectz*Utilities.presentEventFromNonShowingObject�s&���<�<�=�3�3�5�H�H�J�J��r6c�,�tj|�Sr~)r�is_focusablerus  r4�grabFocusWhenSettingCaretz#Utilities.grabFocusWhenSettingCaret�s���'�'��,�,r6c��tj|�xr3|j|tj�j��S)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.
        )r�is_combo_boxrPrr�r��r2rRr�s   r4�grabFocusBeforeRoutingz Utilities.grabFocusBeforeRouting�sC���'�'��,�\��%�%�c�=�+C�+C�+E�+X�+X�+Z�[�[�	\r6c��|}|D]r}|�yt|t�s|g}t|dt�rtj|�}ntj
|�}||vrytj|�}�ty)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.
        FrT)�
isinstancer��strr�
get_role_namer�r`)r2rR�	rolesList�currentr��current_roles      r4�hasMatchingHierarchyzUtilities.hasMatchingHierarchy�s��$���	;�D�����d�D�)��v���$�q�'�3�'�'�5�5�g�>��'�0�0��9���4�'���1�1�'�:�G�	;�"r6c���|�"tj�j�}tj|�sytj|tj�duSrs)rr�r�r�is_entryrr��is_tool_barrus  r4�inFindContainerzUtilities.inFindContainer�sM���;��*�*�,�?�?�A�C��#�#�C�(���%�%�c�;�+B�+B�C�4�O�Or6c��y�Nr'rt�r2�roots  r4�getFindResultsCountzUtilities.getFindResultsCount����r6c��yrsrtrus  r4�isAnchorzUtilities.isAnchor�rwr6c��yrsrtrus  r4�isCodezUtilities.isCode�rwr6c��yrsrtrus  r4�isCodeDescendantzUtilities.isCodeDescendant�rwr6c��tj|�sytj|�}|j	d�dk(S)NFzwindow-type�dock�r�is_framer�get_attributes_dict�get�r2rR�attrss   r4�
isDockedFramezUtilities.isDockedFrame�s7���#�#�C�(���,�,�S�1���y�y��'�6�1�1r6c��tj|�sytj|�}|j	d�dk(S)NFz
is-desktop�truer�r�s   r4�	isDesktopzUtilities.isDesktop�s7���#�#�C�(���,�,�S�1���y�y��&�&�0�0r6c��yrsrtrus  r4�isComboBoxWithToggleDescendantz(Utilities.isComboBoxWithToggleDescendant�rwr6c��yrsrtrus  r4�isToggleDescendantOfComboBoxz&Utilities.isToggleDescendantOfComboBox�rwr6c��yrsrtrus  r4�isTypeaheadzUtilities.isTypeahead�rwr6c�B��|�k(rytj|�fd��S)NTc���|xr|�k(Sr~rt)r<�ancestors �r4r�z,Utilities.isOrDescendsFrom.<locals>.<lambda>�s���Q�5H�1��=�r6�rr�)r2rRr�s  `r4�isOrDescendsFromzUtilities.isOrDescendsFrom�s!����(�?���%�%�c�+H�I�Ir6c��y)z�Returns True if the window is a functioning as a dialog.
        This method should be subclassed by application scripts as
        needed.
        Frtrus  r4�isFunctionalDialogzUtilities.isFunctionalDialog�s��r6c��yrsrtrus  r4�	isCommentzUtilities.isCommentrwr6c��yrsrtrus  r4�isContentDeletionzUtilities.isContentDeletion	rwr6c��yrsrtrus  r4�isContentErrorzUtilities.isContentErrorrwr6c��yrsrtrus  r4�isContentInsertionzUtilities.isContentInsertionrwr6c��yrsrtrus  r4�isContentMarkedzUtilities.isContentMarkedrwr6c��yrsrtrus  r4�isContentSuggestionzUtilities.isContentSuggestionrwr6c��yrsrtrus  r4�isInlineSuggestionzUtilities.isInlineSuggestionrwr6c��yrsrtrus  r4�$isFirstItemInInlineContentSuggestionz.Utilities.isFirstItemInInlineContentSuggestionrwr6c��yrsrtrus  r4�#isLastItemInInlineContentSuggestionz-Utilities.isLastItemInInlineContentSuggestionrwr6c��yrsrtrus  r4�isEmptyzUtilities.isEmpty!rwr6c��yrsrtrus  r4�isHiddenzUtilities.isHidden$rwr6c��yrsrtrus  r4�isDPubzUtilities.isDPub'rwr6c��yrsrtrus  r4�isDPubAbstractzUtilities.isDPubAbstract*rwr6c��yrsrtrus  r4�isDPubAcknowledgmentszUtilities.isDPubAcknowledgments-rwr6c��yrsrtrus  r4�isDPubAfterwordzUtilities.isDPubAfterword0rwr6c��yrsrtrus  r4�isDPubAppendixzUtilities.isDPubAppendix3rwr6c��yrsrtrus  r4�isDPubBibliographyzUtilities.isDPubBibliography6rwr6c��yrsrtrus  r4�isDPubBacklinkzUtilities.isDPubBacklink9rwr6c��yrsrtrus  r4�isDPubBibliorefzUtilities.isDPubBiblioref<rwr6c��yrsrtrus  r4�
isDPubChapterzUtilities.isDPubChapter?rwr6c��yrsrtrus  r4�isDPubColophonzUtilities.isDPubColophonBrwr6c��yrsrtrus  r4�isDPubConclusionzUtilities.isDPubConclusionErwr6c��yrsrtrus  r4�isDPubCoverzUtilities.isDPubCoverHrwr6c��yrsrtrus  r4�isDPubCreditzUtilities.isDPubCreditKrwr6c��yrsrtrus  r4�
isDPubCreditszUtilities.isDPubCreditsNrwr6c��yrsrtrus  r4�isDPubDedicationzUtilities.isDPubDedicationQrwr6c��yrsrtrus  r4�
isDPubEndnotezUtilities.isDPubEndnoteTrwr6c��yrsrtrus  r4�isDPubEndnoteszUtilities.isDPubEndnotesWrwr6c��yrsrtrus  r4�isDPubEpigraphzUtilities.isDPubEpigraphZrwr6c��yrsrtrus  r4�isDPubEpiloguezUtilities.isDPubEpilogue]rwr6c��yrsrtrus  r4�isDPubErratazUtilities.isDPubErrata`rwr6c��yrsrtrus  r4�
isDPubExamplezUtilities.isDPubExamplecrwr6c��yrsrtrus  r4�isDPubFootnotezUtilities.isDPubFootnotefrwr6c��yrsrtrus  r4�isDPubForewordzUtilities.isDPubForewordirwr6c��yrsrtrus  r4�isDPubGlossaryzUtilities.isDPubGlossarylrwr6c��yrsrtrus  r4�isDPubGlossrefzUtilities.isDPubGlossreforwr6c��yrsrtrus  r4�isDPubIndexzUtilities.isDPubIndexrrwr6c��yrsrtrus  r4�isDPubIntroductionzUtilities.isDPubIntroductionurwr6c��yrsrtrus  r4�isDPubPagelistzUtilities.isDPubPagelistxrwr6c��yrsrtrus  r4�isDPubPagebreakzUtilities.isDPubPagebreak{rwr6c��yrsrtrus  r4�
isDPubPartzUtilities.isDPubPart~rwr6c��yrsrtrus  r4�
isDPubPrefacezUtilities.isDPubPreface�rwr6c��yrsrtrus  r4�isDPubProloguezUtilities.isDPubPrologue�rwr6c��yrsrtrus  r4�isDPubPullquotezUtilities.isDPubPullquote�rwr6c��yrsrtrus  r4�	isDPubQnazUtilities.isDPubQna�rwr6c��yrsrtrus  r4�isDPubSubtitlezUtilities.isDPubSubtitle�rwr6c��yrsrtrus  r4�	isDPubToczUtilities.isDPubToc�rwr6c��yrsrtrus  r4�isFeedzUtilities.isFeed�rwr6c��yrsrtrus  r4�
isFeedArticlezUtilities.isFeedArticle�rwr6c��yrsrtrus  r4�isFigurezUtilities.isFigure�rwr6c��yrsrtrus  r4�isGridzUtilities.isGrid�rwr6c��yrsrtrus  r4�
isGridCellzUtilities.isGridCell�rwr6c��yrsrtrus  r4�
isLandmarkzUtilities.isLandmark�rwr6c��yrsrtrus  r4�isLandmarkWithoutTypezUtilities.isLandmarkWithoutType�rwr6c��yrsrtrus  r4�isLandmarkBannerzUtilities.isLandmarkBanner�rwr6c��yrsrtrus  r4�isLandmarkComplementaryz!Utilities.isLandmarkComplementary�rwr6c��yrsrtrus  r4�isLandmarkContentInfozUtilities.isLandmarkContentInfo�rwr6c��yrsrtrus  r4�isLandmarkFormzUtilities.isLandmarkForm�rwr6c��yrsrtrus  r4�isLandmarkMainzUtilities.isLandmarkMain�rwr6c��yrsrtrus  r4�isLandmarkNavigationzUtilities.isLandmarkNavigation�rwr6c��yrsrtrus  r4�
isDPubNoterefzUtilities.isDPubNoteref�rwr6c��yrsrtrus  r4�isLandmarkRegionzUtilities.isLandmarkRegion�rwr6c��yrsrtrus  r4�isLandmarkSearchzUtilities.isLandmarkSearch�rwr6c��yrsrtrus  r4�isSVGzUtilities.isSVG�rwr6c��yrsrtrus  r4�speakMathSymbolNameszUtilities.speakMathSymbolNames�rwr6c��yrsrt�r2s r4�isInMathzUtilities.isInMath�rwr6c��yrsrtrus  r4�isMathzUtilities.isMath�rwr6c��yrsrtrus  r4�isMathLayoutOnlyzUtilities.isMathLayoutOnly�rwr6c��yrsrtrus  r4�isMathMultilinezUtilities.isMathMultiline�rwr6c��yrsrtrus  r4�isMathEnclosedzUtilities.isMathEnclosed�rwr6c��yrsrtrus  r4�isMathFencedzUtilities.isMathFenced�rwr6c��yrsrtrus  r4�isMathFractionWithoutBarz"Utilities.isMathFractionWithoutBar�rwr6c��yrsrtrus  r4�
isMathPhantomzUtilities.isMathPhantom�rwr6c��yrsrtrus  r4�isMathMultiScriptzUtilities.isMathMultiScript�rwr6c��yrsrtrus  r4�isMathSubOrSuperScriptz Utilities.isMathSubOrSuperScript�rwr6c��yrsrtrus  r4�isMathUnderOrOverScriptz!Utilities.isMathUnderOrOverScript�rwr6c��yrsrtrus  r4�isMathSquareRootzUtilities.isMathSquareRoot�rwr6c��yrsrtrus  r4�isMathTablezUtilities.isMathTable�rwr6c��yrsrtrus  r4�isMathTableRowzUtilities.isMathTableRow�rwr6c��yrsrtrus  r4�isMathTableCellzUtilities.isMathTableCell�rwr6c��yrsrtrus  r4�isMathTokenzUtilities.isMathToken�rwr6c��yrsrtrus  r4�isMathTopLevelzUtilities.isMathTopLevel�rwr6c��yr~rtrus  r4�getMathDenominatorzUtilities.getMathDenominator����r6c��yr~rtrus  r4�getMathNumeratorzUtilities.getMathNumerator�r�r6c��yr~rtrus  r4�getMathRootBasezUtilities.getMathRootBaser�r6c��yr~rtrus  r4�getMathRootIndexzUtilities.getMathRootIndexr�r6c��yr~rtrus  r4�getMathScriptBasezUtilities.getMathScriptBaser�r6c��yr~rtrus  r4�getMathScriptSubscriptz Utilities.getMathScriptSubscriptr�r6c��yr~rtrus  r4�getMathScriptSuperscriptz"Utilities.getMathScriptSuperscriptr�r6c��yr~rtrus  r4�getMathScriptUnderscriptz"Utilities.getMathScriptUnderscriptr�r6c��yr~rtrus  r4�getMathScriptOverscriptz!Utilities.getMathScriptOverscriptr�r6c��gSr~rtrus  r4�getMathPrescriptszUtilities.getMathPrescripts����	r6c��gSr~rtrus  r4�getMathPostscriptszUtilities.getMathPostscriptsr�r6c��gSr~rtrus  r4�getMathEnclosureszUtilities.getMathEnclosuresr�r6c��dgSr�rtrus  r4�getMathFencedSeparatorsz!Utilities.getMathFencedSeparators s	���t�r6c�
�ddgSr�rtrus  r4�
getMathFenceszUtilities.getMathFences#s���B�x�r6c��yr9rt)r2rR�tests   r4�getMathNestingLevelzUtilities.getMathNestingLevel&s��r6c�
�gd�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�searchrtr�s r4�getLandmarkTypeszUtilities.getLandmarkTypes)s���	r6c�\�tj|�sytj|�duSrs)r�is_progress_barr �get_value_as_percentrus  r4�
isProgressBarzUtilities.isProgressBarFs)���*�*�3�/���+�+�C�0��<�<r6c��|j|j|�tj�j	��Sr~)rPr�rr��get_active_windowrus  r4�topLevelObjectIsActiveWindowz&Utilities.topLevelObjectIsActiveWindowKs9��� � �����$�m�&>�&>�&@�&R�&R�&T�V�	Vr6c��tj�jd�sGtj�jd�s$tj�jd�sy|j|�syt	j
|�rytj�jd�r%t
j|tj�rytj�jd	�}|tjk(ry
|tjk(r|j|�ryy|tjk(r>t
j|�}t!j�j#�}||k(ry
yy)N�speakProgressBarUpdates�brailleProgressBarUpdates�beepProgressBarUpdates)FzUpdates not enabled)FzIs not progress bar)FzHas no size�ignoreStatusBarProgressBars)FzIs status bar descendant�progressBarVerbosity)TzVerbosity is all)TzVerbosity is window)Fz%Top-level object is not active window)TzVerbosity is app)FzApp is not active app)TzNot handled by any other case)rr��
getSettingr�r�has_no_sizerr�r�
is_status_barr�PROGRESS_BAR_ALL�PROGRESS_BAR_WINDOWr��PROGRESS_BAR_APPLICATION�get_applicationr�getActiveScriptApp)r2rR�	verbosity�app�	activeApps     r4�isProgressBarUpdatezUtilities.isProgressBarUpdateOs3���*�*�,�7�7�8Q�R�#�.�.�0�;�;�<W�X�#�.�.�0�;�;�<T�U�/��!�!�#�&�/��"�"�3�'�'��&�&�(�3�3�4Q�R��%�%�c�;�+D�+D�E�8�$�/�/�1�<�<�=S�T�	���1�1�1�+���4�4�4��0�0��5�2�A���9�9�9��*�*�3�/�C�&�1�1�3�F�F�H�I��i��/�1�4r6c�,�tj|�Sr~)r�is_block_quoterus  r4�isBlockquotezUtilities.isBlockquoteqs���)�)�#�.�.r6c�,�tj|�Sr~)r�is_description_listrus  r4�isDescriptionListzUtilities.isDescriptionListt����.�.�s�3�3r6c�,�tj|�Sr~)r�is_description_termrus  r4�isDescriptionListTermzUtilities.isDescriptionListTermwr�r6c�,�tj|�Sr~)r�is_description_valuerus  r4�isDescriptionListDescriptionz&Utilities.isDescriptionListDescriptionzs���/�/��4�4r6c�~�|j|�sgS|j}|j}|j|||�Sr~)r�r�r�)r2rR�_include�_excludes    r4�descriptionListTermszUtilities.descriptionListTerms}s@���%�%�c�*��I��-�-���)�)���&�&�s�H�h�?�?r6c���tj|�tjjtjj
fvrytj|tj�duSrs)	rr�rr��LIST�DESCRIPTION_LISTr�rr�rus  r4�isDocumentListzUtilities.isDocumentList�sM�����S�!�%�*�*�/�/�5�:�:�;V�;V�)W�W���%�%�c�;�+B�+B�C�4�O�Or6c�z�tj|�sytj|tj�duSrs)r�is_panelrr�r�rus  r4�isDocumentPanelzUtilities.isDocumentPanel�s1���#�#�C�(���%�%�c�;�+B�+B�C�4�O�Or6c�,�tj|�Sr~)rr�rus  r4�
isDocumentzUtilities.isDocument�s���&�&�s�+�+r6c�t�|xs"tj�j�}|j|�duSr~)rr�r��getDocumentForObjectrus  r4�inDocumentContentzUtilities.inDocumentContent�s4���D�]�-�-�/�B�B�D���(�(��-�T�9�9r6c�d�|jtj�j��Sr~)�getTopLevelDocumentForObjectrr�r�)r2�windows  r4�activeDocumentzUtilities.activeDocument�s%���0�0��1I�1I�1K�1^�1^�1`�a�ar6c�j�|j|�xr!tj||j�Sr~�rrr�rus  r4�isTopLevelDocumentzUtilities.isTopLevelDocument�s*�����s�#�X�H�,B�,B�3����,X�(X�Xr6c�h�|j|�r|Stj||j�Sr~)rrr�rus  r4rz&Utilities.getTopLevelDocumentForObject�s.���"�"�3�'��J��%�%�c�4�+B�+B�C�Cr6c�n�|sy|j|�r|Stj||j�Sr~r
rus  r4rzUtilities.getDocumentForObject�s0�����?�?�3���J��%�%�c�4�?�?�;�;r6c�~�|sytj|�r|Stj|tj�Srs)r�is_modal_dialogrr�rus  r4�getModalDialogzUtilities.getModalDialog�s4�����&�&�s�+��J��%�%�c�;�+F�+F�G�Gr6c�.�|sy|j|�duSrs)rrus  r4�isModalDialogDescendantz!Utilities.isModalDialogDescendant�s�����"�"�3�'�t�3�3r6c��|Sr~rt)r2�columns  r4�
columnConvertzUtilities.columnConvert�s���
r6c��tj|�sy|j|�}|duxrtj|�Srs)r�is_tabler�is_document_spreadsheet�r2rR�docs   r4�isTextDocumentTablezUtilities.isTextDocumentTable�s@���#�#�C�(���'�'��,���$��O�{�'J�'J�3�'O�#O�Or6c�V�tj|�xr|j|�duSr~)rrrrus  r4�
isGUITablezUtilities.isGUITable�s(���#�#�C�(�S�T�-F�-F�s�-K�t�-S�Sr6c���tj|�rtj|�sy|j	|�}|�ytj
|�ryt
j|�dkDS)NFTi)rrr�supports_tablerrrrKrs   r4�isSpreadSheetTablezUtilities.isSpreadSheetTable�s_���$�$�S�)�h�.E�.E�c�.J���'�'��,���;���.�.�s�3���$�$�S�)�E�1�1r6c�n�tj|�sytj||j�Srs)r�is_table_cell_or_headerrr�rrus  r4�isTextDocumentCellzUtilities.isTextDocumentCell�s,���2�2�3�7���%�%�c�4�+C�+C�D�Dr6c�n�tj|�sytj||j�Srs)rr"rr�rrus  r4�	isGUICellzUtilities.isGUICell�s*���2�2�3�7���%�%�c�4�?�?�;�;r6c�n�tj|�sytj||j�Srs)rr"rr�r rus  r4�isSpreadSheetCellzUtilities.isSpreadSheetCell�s,���2�2�3�7���%�%�c�4�+B�+B�C�Cr6c���tj|�d}|dk(ry|�*|jjj	d�}||k7Stj|�d}||k7S)Nr	���F�
lastColumn�rrIr/�pointOfReferencer�)r2rY�prevCellrr*s     r4�cellColumnChangedzUtilities.cellColumnChanged�sp���-�-�d�3�A�6���R�<�������6�6�:�:�<�H�J���#�#�!�5�5�h�?��B�J���#�#r6c���tj|�d}|dk(ry|�*|jjj	d�}||k7Stj|�d}||k7S)Nrr)F�lastRowr+)r2rYr-rVr0s     r4�cellRowChangedzUtilities.cellRowChanged�sn���*�*�4�0��3���"�9�����l�l�3�3�7�7�	�B�G��g�~���2�2�8�<�Q�?�G��g�~�r6c��|jj�ry|jj�j�ry|j	||�sytj|�}|�y|j|�s#tj�jd�S|j|�r#tj�jd�Stj�jd�S)NF�readFullRowInGUITable�readFullRowInSpreadSheet�readFullRowInDocumentTable)r/�inSayAll�getTableNavigator�'last_input_event_was_navigation_commandr1rrBrrr�r�r )r2rR�prevObj�tables    r4�shouldReadFullRowzUtilities.shouldReadFullRow�s����<�<� � �"���<�<�)�)�+�S�S�U���"�"�3��0���!�!�#�&���=���(�(��/�#�.�.�0�;�;�<S�T�T��"�"�5�)�#�.�.�0�;�;�<V�W�W��*�*�,�7�7�8T�U�Ur6c��yrsrtrus  r4�isSortedzUtilities.isSortedrwr6c��yrsrtrus  r4�isAscendingzUtilities.isAscendingrwr6c��yrsrtrus  r4�isDescendingzUtilities.isDescendingrwr6c�8�|r|j|�sy|j|�rtj}n2|j	|�rtj
}ntj}|r/tj|�rtj|��d|��}|S)Nr'z. )	r=r?r�SORT_ORDER_ASCENDINGrA�SORT_ORDER_DESCENDING�SORT_ORDER_OTHERrr�)r2rR�includeName�results    r4�getSortOrderDescriptionz!Utilities.getSortOrderDescriptions�����
�
�c�*�����C� �&�;�;�F�
�
�
�s�
#�&�<�<�F�&�7�7�F��8�,�,�S�1� �)�)�#�.�/�r�&��:�F��
r6c�Z�tj|�xrtj|�Sr~)r�is_labelr�rus  r4�isFocusableLabelzUtilities.isFocusableLabel(s#���#�#�C�(�J�[�-E�-E�c�-J�Jr6c�\�tj|�xrtj|�Sr~)r�is_listr�rus  r4�isNonFocusableListzUtilities.isNonFocusableList+s&���"�"�3�'�M��0H�0H��0M�,M�Mr6c�z�tj|�sytj|tj�duSrs)r�is_notificationrr�r�rus  r4�isStatusBarNotificationz!Utilities.isStatusBarNotification.s1���*�*�3�/���%�%�c�;�+D�+D�E�T�Q�Qr6c
���tj|�syg}tj|�}|r|j	|�|j|�}|r||vr|j	|�nMdj
t|j|j|dd���}|r||vr|j	|�tj|�}|r||vr|j	|�dj
|�S)Nr'r�Fr	)rrPrr�rQ�
expandEOCsr�r�r*r��get_description)r2rRrUr��textrp�descriptions       r4�getNotificationContentz Utilities.getNotificationContent3s����*�*�3�/����� � ��%����M�M�$�����s�#���D��&��M�M�$���X�X�c�$�"4�"4�d�6J�6J�3�PU�WX�6Y�Z�[�F��&��.��
�
�f�%��.�.�s�3���;�f�4��M�M�+�&��x�x���r6c��|�ytj|�rytj|tj�duS�NFT)r�is_tree_itemrr��is_tree_or_tree_tablerus  r4�isTreeDescendantzUtilities.isTreeDescendantIs:���;���#�#�C�(���%�%�c�;�+L�+L�M�UY�Y�Yr6c��d}tj|�sytj|�}tjtj|��}tj|d�}|j�}tjjtjjtjjtjjg}|tjjk(rtj|�}�n|tjjk(r�tj |�r�|tjj"k(rtj$|�}�n�t'j(|�rd}�n�|tjjk(�rb|j+tj|��}�n<|tjj,k(r|j/|�}�n|tjj0k(rd}�n�|tjj2k(rd}�n�|tjj4k(rd}�n�|tjj6k(r"|j9|j;|��}�ni|tjj<k(rd}�nH|tjj>tjj@fvrd}�n|tjjBtjj"fvrd}�n�||vrd}�n�|tjjk(r|tjjDk(}�n�|tjjDk(rd}�no|tjjFk(rd}�nN|tjjHk(rd}�n-|tjjJtjjLfvrd}�n�|tjjNtjjPtjjRfvrd}�n�|tjjk(r!|tjjBk(rd}�nb|tjjTtjjVfvrd}�n(|jY|�r.t'jZ|�xst'j\|�}n�|tjj^k(rtj|�|vrd}n�|tjj^k(r,tj`|tjb|��rd}nitj |�dk(rtj`||�rd}n8|je|�rd}n$|jg|�s|ji|�sd}|r*d|dg}tkjltjjn|d�|S)z�Returns True if the given object is a container which has
        no presentable information (label, name, displayed text, etc.).FTrr	r>zis deemed to be layout only)8r�is_validr��
get_parent�	get_child�_topLevelRolesrr��MENU�	MENU_ITEMr��	TREE_ITEM�TABLEr�is_layout_table�
TABLE_CELL�get_child_count�
TREE_TABLEr�r�
is_table_cell�isLayoutOnly�SECTIONr��BLOCK_QUOTE�FILLER�SCROLL_PANE�LAYERED_PANEr�r��AUTOCOMPLETE�TEAROFF_MENU_ITEM�	SEPARATOR�LIST_BOXr�r��FORMr��
TOGGLE_BUTTON�TEXT�
PASSWORD_TEXT�ENTRY�REDUNDANT_OBJECT�UNKNOWN�
isTableRowr��
is_selectable�PANEL�has_same_non_empty_namer�rr*r)rrGrH)	r2rR�
layoutOnlyr��
parentRole�
firstChild�
topLevelRoles�ignorePanelParentrUs	         r4rkzUtilities.isLayoutOnlyRsi���
�� � ��%��� � ��%���&�&�x�':�':�3�'?�@�
��'�'��Q�/�
��+�+�-�
�"�Z�Z�_�_�"�Z�Z�1�1�"�Z�Z�1�1�"�Z�Z�1�1�3��
�5�:�:�#�#�#� �0�0��5�J�
�U�Z�Z�*�*�
*�x�/G�/G��/L��U�Z�Z�2�2�2�!)�!2�!2�3�!7�7�
��*�*�:�6�!�
��u�z�z�/�/�/�!�.�.�x�/B�/B�3�/G�H�
�
�U�Z�Z�'�'�
'�!�.�.�s�3�3�J�
�U�Z�Z�+�+�
+��J�
�U�Z�Z�&�&�
&��J�
�U�Z�Z�+�+�
+��J�
�U�Z�Z�,�,�
,�����(;�(;�C�(@�A�J�
�U�Z�Z�,�,�
,��J�
�e�j�j�2�2�E�J�J�4H�4H�I�
I��J�
�e�j�j�)�)�5�:�:�+@�+@�A�
A��J�
�]�
"��J�
�U�Z�Z�_�_�
$�#�u�z�z�';�';�;�J�
�U�Z�Z�)�)�
)��J�
�U�Z�Z�_�_�
$��J�
�U�Z�Z�_�_�
$��J�
�e�j�j�,�,�e�j�j�.F�.F�G�
G��J�
�e�j�j�o�o�u�z�z�'?�'?����AQ�AQ�R�
R��J�
�U�Z�Z�)�)�
)�j�E�J�J�<O�<O�.O��J�
�e�j�j�1�1�5�:�:�3E�3E�F�
F��J�
�_�_�S�
!�)�6�6�s�;�]�{�?X�?X�Y\�?]�^�J�
�U�Z�Z�%�%�
%�(�*;�*;�J�*G�K\�*\��J�
�U�Z�Z�%�%�
%��4�4�S�(�:R�:R�SV�:W�X��J�
�
%�
%�c�
*�a�
/��4�4�S�*�E��J�
�]�]�3�
��J��&�&�s�+�t�/B�/B�3�/G�!�
��)�3�0M�N�F����e�.�.���=��r6c��tj�j�}|r|sytj|�tj|�k(S)z�Returns True if the given object is from the same application that
        currently has keyboard focus.

        Arguments:
        - obj: an Accessible object
        F)rr�r�rr�)rRr�s  r4�
isInActiveAppzUtilities.isInActiveApp�sD���(�(�*�=�=�?������'�'��.�(�2J�2J�3�2O�O�Or6c�,�tj|�S)zReturns True if obj is a link.)r�is_linkrus  r4�isLinkzUtilities.isLink�s���"�"�3�'�'r6c��|j|�sytj|�rytj|�xrtj|�S)z;Returns True if obj is a text entry area that is read only.FT)�
isTextArear�is_read_onlyr��is_editablerus  r4�isReadOnlyTextAreazUtilities.isReadOnlyTextArea�sH�����s�#���#�#�C�(���'�'��,�Q�[�5L�5L�S�5Q�1Q�Qr6c��yrsrtrus  r4�isSwitchzUtilities.isSwitch�rwr6c��|jj}d}|D]}|dk(r�		||}�|}|S#t$rY|SwxYw�Nr))r/r�rl)r2�path�start�rv�ps     r4�getObjectFromPathzUtilities.getObjectFromPath�sd����� � ��
���	�A��B�w��
��a���		��B��	���
���	�
�s�0�	>�>c���tj|�}tj|�}t|�t|�k7ry|r|sy|dd}|dd}|ddk(r|ddk(r
|dd}|dd}|jd�r|jd�ry	|j	d�}|d||d|k(S#t
$r0	|j	d�}n#t
$rt|�}YnwxYwY�CwxYw)NFr	r)r)r�get_pathrF�count�index�
ValueError)r2�obj1�obj2�path1�path2r�s      r4�_hasSamePathzUtilities._hasSamePath�s���!�!�$�'���!�!�$�'���u�:��U��#���%���a�b�	���a�b�	��
��9��?�u�R�y�B���#�2�J�E��#�2�J�E��;�;�r�?�u�{�{�2���	#��K�K��O�E��Q�u�~��q���/�/��
�	#�
#����B�����
#��E�
��
#��	#�s6�B,�,	C%�6C�C%�C�C%�C�C%�$C%c��||k(ry|�|�ytj||�sy|s,tj|�tj|�k7ry|s,tj|�tj|�k7ry|r|j||�ryt
j||�syt
j|�syyr�)	r�have_same_rolerr�rTr�r�objects_have_same_rectr�)r2r�r��comparePaths�ignoreNames�ignoreDescriptionss      r4rPzUtilities.isSameObject�s����4�<���<�4�<���)�)�$��5���x�0�0��6�(�:K�:K�D�:Q�Q��!��'�'��-��1I�1I�$�1O�O���D�-�-�d�D�9���1�1�$��=���&�&�t�,��r6c��|j|�rytj|�xs,tj|�xstj|�S)z{Returns True if obj is a GUI component that is for entering text.

        Arguments:
        - obj: an accessible
        F)r�r�
is_text_input�is_text�is_paragraphrus  r4r�zUtilities.isTextAreasN���;�;�s����(�(��-�-��"�"�3�'�-��'�'��,�	-r6c����fd�}tj�tjj�}tt
||��S)z,Return a list of the labels for this object.c�:���tj��fd��S)Nc���|�k(Sr~rt)r<�accs �r4r�zBUtilities.labelsForObject.<locals>.isNotAncestor.<locals>.<lambda>,s���Q�#�X�r6r�)r�rRs`�r4�
isNotAncestorz0Utilities.labelsForObject.<locals>.isNotAncestor+s����-�-�c�3E�F�F�Fr6)rrCrrDrzr��filter)r2rRr�rGs `  r4rmzUtilities.labelsForObject(s;���	G��.�.�s�E�4F�4F�4R�4R�S���F�=�&�1�2�2r6c�D�����y	�jj�j�S#t$rH�j�jjvr#i�jj�j<YnwxYw��fd�}g}t	j
�|�}|r*|j
|�t	j
||�}|r�*t|�}|�jj�j�<�jj�j�S)zmDetermines the nesting level of this object.

        Arguments:
        -obj: the Accessible object
        rc�����j��r�j|�Stj��r(tjt	j
|��Stj�|�Sr~)r�r�is_list_itemrMrr_r��r<rRr2s ��r4r=z$Utilities.nestingLevel.<locals>.predAs_���� � ��%��(�(��+�+��'�'��,�"�*�*�8�+>�+>�q�+A�B�B��-�-�c�1�5�5r6)r/rj�
NESTING_LEVELrlrr�rQrF)r2rRr=�	ancestorsr�r,s``    r4r,zUtilities.nestingLevel1s����;��	E��<�<�.�.�t�/A�/A�B�3�G�G���	E��!�!����)D�)D�D�BD����+�+�D�,>�,>�?��	E��	6��	��)�)�#�t�4������X�&��-�-�h��=�H���9�~��?K����#�#�D�$6�$6�7��<��|�|�*�*�4�+=�+=�>�s�C�Cs�%-�AA>�=A>c��|j|�sy	|jj|j|S#t$rH|j|jjvr#i|jj|j<YnwxYwg}|}d}|s�tj|tjj�}d}|r|jd�}|j|�r-d|d|g}tjtj|d�d}t|�dkDr,d	|g}tjtj|d�d}n|r|j!|�nd}|s��t|�d
z
|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)FNrr>z#is already in the list of nodes forT�dz/SCRIPT UTILITIES: More than 100 nodes found forr	)r\r/rj�
NODE_LEVELrlrrMrrDrNrOr�rrGrHrFrQ)r2rRrT�node�donerZrUs       r4r-zUtilities.nodeLevelRs����$�$�S�)��	B��<�<�.�.�t���?��D�D���	B����d�l�l�&A�&A�A�?A����+�+�D�O�O�<��	B����������,�,�T�5�3E�3E�3S�3S�T�H��D���*�*�1�-��
�{�{�4� �-�t�5Z�\_�`���!�!�%�"2�"2�F�D�A����5�z�C��K�S�Q���!�!�%�"2�"2�F�D�A�������T�"���)�,=@��J��N����#�#�D�O�O�4�S�9��|�|�*�*�4�?�?�;�C�@�@s�%:�AB�
Bc�6�tj|�ry|j|�rytj|�rtj
|�s�d|dg}t
jtj|d�tj|�rltj|dd�tj|�r@tj
|�r+d|dg}t
jtj|d�yytj|�r+d|d	g}t
jtj|d�ytj|�ry|�ytj||�s,d|d
|g}t
jtj|d�yy)NFr>zis not showing and visibleTz(Suspecting filler might have wrong statezWARNING: Nowzis showing and visiblezSCRIPT UTILITIES: Rect ofz"is unhelpful. Treating as onscreenznot in)r�is_deadrr�
is_showing�
is_visiblerrGrH�	is_filler�clear_cacher�has_no_size_or_invalid_rect�object_is_off_screen�object_intersects_rect)r2rR�boundingboxrUs    r4�
isOnScreenzUtilities.isOnScreen�sU�����C� ���=�=�����&�&�s�+��0F�0F�s�0K�)�3�0L�M�F����e�.�.���=��$�$�S�)��$�$�S�%�1[�\��)�)�#�.�;�3I�3I�#�3N�,�c�3K�L�F��%�%�e�&6�&6���E����2�2�3�7�1�3�8\�]�F����e�.�.���=���+�+�C�0������1�1�#�{�C�)�3��+�F�F����e�.�.���=��r6c�J�tj|�sytj|�r|j	|�}|r|dSytj
|�D]G}tj|dd�tj|�stj|�s�E|cSy)NrF�#Ensuring we have the correct state.)	r�is_menu_barr�supports_selection�selectedChildrenr�r�rA�is_selected)r2�menubar�selected�menus    r4�selectedMenuBarMenuzUtilities.selectedMenuBarMenu�s����&�&�w�/���&�&�w�/��,�,�W�5�H����{�"���*�*�7�3�	�D�� � ��u�.S�T��&�&�t�,��0G�0G��0M���		�r6c���|�ytj|tj�}|�y|jjt
|�����|j|����y�fd�}||�rytj||�duS)NFc���|�k(Sr~rt)r<�selectedMenus �r4�inSelectedMenuz5Utilities.isInOpenMenuBarMenu.<locals>.inSelectedMenu�s�����$�$r6T)rr�rr�r1r��hashr�)r2rRr�r�r�s    @r4�isInOpenMenuBarMenuzUtilities.isInOpenMenuBarMenu�s�����;���(�(��k�.E�.E�F���?���0�0�4�4�T�'�]�C�����3�3�G�<�L����	%��#����%�%�c�>�:�$�F�Fr6c��yrsrtrus  r4�isStaticTextLeafzUtilities.isStaticTextLeaf�rwr6c��yrsrtrus  r4�isListItemMarkerzUtilities.isListItemMarker�rwr6c��|j|�ryttjdt	j
|���S)NFz\w+)r��bool�rer�rr�rus  r4�hasPresentableTextzUtilities.hasPresentableText�s4��� � ��%���B�I�I�f�f�&9�&9�#�&>�?�@�@r6c	�B���j||�sgStj|�tjj
k(rgSt
j|�st
j|�r|gSt
j|�r'�j|��jt|�<t
jtj|��r�j|�s|gSt
j|�r�tj |�s�tj"|dd�tj |�}d|d|�d�g}t%j&t$j(|d�|s)d|g}t%j&t$j(|d�|�t+j,|�}tj.|�r*tj0|�r�j3|�}|r|Sg}tj4|�xstj6|�}|r<t
j8|�st
j:|�r|j=|�n"�j?|�r|j=|��fd�}tj@||�D]#}	|jC�jE|	|���%t
j|�rd�jt|�<|r|St
jF|�r|stIjJ|�rgStjjLtjjNtjjPtjjRtjjTtjjVtjjXtjjZtjj\g	}
tj|�|
vr|sgS|gS)NTzRoot is empty filler.r>znow reports z	 childrenz"WARNING: unexpectedly empty fillerc�4��|duxr�j|�Sr~)r��r<r2s �r4r=z*Utilities.getOnScreenObjects.<locals>.preds ����D�=�A��)>�)>�q�)A�%A�Ar6)/r�rr�rr��INVALIDr�	is_buttonr�r�r�r1r�r_r�r�rhr�rrGrHr�get_rectrr��getVisibleTableCellsr�rT�is_page_tab�is_imagerQr�r�r��getOnScreenObjectsrJrr��CANVASrn�IMAGE�LINKrtr~rlro�VIEWPORT)r2r��extentsr�rU�visibleCells�objects�
hasNameOrDescr=r��
containerss`          r4r�zUtilities.getOnScreenObjects�s"������t�W�-��I����T�"�e�j�j�&8�&8�8��I�� � ��&�+�*B�*B�4�*H��6�M��"�"�4�(�48�4L�4L�T�4R�D�%�%�d�4�j�1��"�"�8�#6�#6�t�#<�=��+�+�D�1��6�M�� � ��&�x�/G�/G��/M�� � ��t�-D�E��,�,�T�2�E�)�4�<��w�i�1P�Q�F����e�.�.���=��>��E���!�!�%�"2�"2�F�D�A��?�!�*�*�4�0�G��"�"�4�(�X�-H�-H��-N��4�4�T�:�L��#�#��� �)�)�$�/�Q�8�3K�3K�D�3Q�
��k�5�5�d�;�{�?S�?S�TX�?Y��N�N�4� �
�
$�
$�T�
*��N�N�4� �	B��+�+�D�$�7�	D�E��N�N�4�2�2�5�'�B�C�	D��"�"�4�(�48�D�%�%�d�4�j�1���N�����%�m��@]�@]�^b�@c��I��j�j�'�'��j�j�'�'��j�j�&�&��j�j�o�o��j�j�)�)��j�j�&�&��j�j�(�(��j�j�,�,��j�j�)�)�+�
����T�"�j�0���I��v�
r6c��tj|�}|sytj|��ytj|�rytj
|�rytjtj|��sytj|tj
�D�cgc]}|��}}t|�|k(ryycc}w)z9Determines if obj is a table row -- real or functionally.FT)	rrhr_r�is_table_rowr"rr�rF)rR�
childCountr<�cellss    r4r|zUtilities.isTableRow s����-�-�c�2�
������s�#�+���#�#�C�(���.�.�s�3���#�#�H�$7�$7��$<�=��$�2�2�3��8[�8[�\�]�q��]��]��u�:��#����	^s�*	Cc���tj|�r|Sd�}tj||�}|�:|jj
j
tj|��s|}|S)Nc�Z�tj|�xstj|�Sr~)rr"r�r;s r4r=z*Utilities.realActiveAncestor.<locals>.pred>s$���6�6�q�9�X�[�=U�=U�VW�=X�Xr6)r�
is_focusedrr�r/�	utilitiesrkr_)r2rRr=r�s    r4�realActiveAncestorzUtilities.realActiveAncestor:sb���!�!�#�&��J�	Y��)�)�#�t�4�����<�<�)�)�6�6�x�7J�7J�8�7T�U��C��
r6c����tj|�rytj|�s|Stj|�r|S�fd�}tj
||�}|�|S|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.
        Nc�r��|xr3�j|�xr�j|�j�Sr~)r�r*�stripr�s �r4r=z,Utilities.realActiveDescendant.<locals>.pred[s5����W�T�2�2�1�5�5�W�$�:L�:L�Q�:O�:U�:U�:W�Wr6)rr�rrjr��find_descendant)r2rRr=r�s`   r4�realActiveDescendantzUtilities.realActiveDescendantHsf������C� ���(�(��-��J����S�!��J�	X��(�(��d�3�����L��
r6c�T�|�ytj|tj�duSrs)rr�rr�rus  r4�isStatusBarDescendantzUtilities.isStatusBarDescendantds(���;���%�%�c�;�+D�+D�E�T�Q�Qr6c��tj|�sgStj�}|jjjd�}|s@d�}t
t||j|���}||jjd<tj�}d||z
d��}tjtj|d�|S)N�statusBarItemsc�.�tj|�Sr~)rr�r;s r4�includez)Utilities.statusBarItems.<locals>.includers��&�4�4�Q�7�7�7r6z1SCRIPT UTILITIES: Time getting status bar items: z.4fT)rr��timer/r,r�r�r�r�rr�rH)r2rRr��itemsr�endr�s       r4rzUtilities.statusBarItemsjs����(�(��-��I��	�	������-�-�1�1�2B�C���
8�����)@�)@��)E�F�G�E�>C�D�L�L�)�)�*:�;��i�i�k��A�#��+�c�AR�S��
���5�+�+�S�$�7��r6c��yr~rtr�s  r4�infoBarzUtilities.infoBar~r�r6c�D�tjjtjjtjjtjj
g}|j
�r)|jtjj�|Sr~)	rr�r�r�r�r�r�rQr�)r2�roless  r4razUtilities._topLevelRoles�sf�����"�"����(�(����!�!����"�"�$���%�%�'��L�L����)�)�*��r6c���tj�j�}|sy||j|�k(}d|d|g}t	j
tj|d�|S)NFr>zis top-level object:T)rr�r�r�rrGrH)r2r�r�rUs    r4�_locusOfFocusIsTopLevelObjectz'Utilities._locusOfFocusIsTopLevelObject�s`���(�(�*�=�=�?����
�d�)�)�%�0�
0��%�u�.D�b�I��
���%�*�*�F�D�9��	r6c���tj��}|�yttj|��D]�}tj||�}tj
|�fd���/d|d�g}t
jtj|d�|cSd|d�g}t
jtj|d���y)z�Searches each frame/window/dialog of an application to find the one
        which contains child. This is extremely non-performant and should only
        be used to work around broken accessibility trees where topLevelObject
        fails.Nc���|�k(Sr~rt)r<r�s �r4r�z5Utilities._findWindowWithDescendant.<locals>.<lambda>�s���!�u�*�r6r>�containsTzdoes not contain)	rr�rJrhr`r�rrGrH)r2r�r�rXrrUs `    r4�_findWindowWithDescendantz#Utilities._findWindowWithDescendant�s�����&�&�u�-���;���x�/�/��4�5�	>�A��'�'��Q�/�F��'�'��0D�E�Q�-�v�z�5�I���!�!�%�"2�"2�F�D�A��
�)�6�3E�u�M�F����e�.�.���=�	>�r6c���tj|�|j�vxrCtjtj|��tj
jk(Sr~)rr�rar_rr��APPLICATIONrus  r4�_isTopLevelObjectzUtilities._isTopLevelObject�sR��� � ��%��)<�)<�)>�>�V��!�!�(�"5�"5�c�":�;�u�z�z�?U�?U�U�	Vr6c�<�|j|�r|}n tj||j�}d|d|g}tjtj
|d�|�:|r8d}tjtj
|d�|j|�}|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
        r>zis top-level object for:TzISCRIPT UTILITIES: Attempting to find top-level object via fallback search)rrr�rrGrHr�r)r2rR�useFallbackSearchr�rUr�s      r4r�zUtilities.topLevelObject�s����!�!�#�&��B��'�'��T�-C�-C�D�B�%�r�+E�s�K��
���%�*�*�F�D�9�
�:�+�]�C����u�/�/��d�;��/�/��4�B��	r6c�b�|xs"tj�j�}|j|�}|syt	j
|dd�t
j|�rt
j|�ry|j|tj�j��syy)NFr�T)rr�r�r�rr�r�	is_active�
is_defunctrPr�)r2rRr�s   r4� topLevelObjectIsActiveAndCurrentz*Utilities.topLevelObjectIsActiveAndCurrent�s����D�]�-�-�/�B�B�D���&�&�s�+�������X�u�.S�T��$�$�X�.�+�2H�2H��2R��� � ��=�+C�+C�+E�+W�+W�+Y�Z��r6c��||k(rytt|�t|��}|dg|zzd|}|dg|zzd|}ttt|�t|���D]}||||kry||||kDs�yy)zpCompares the two paths and returns -1, 0, or 1 to indicate if path1
        is before, the same, or after path2.rr)Nr	)�maxrFrJrb)r�r��sizer<s    r4�pathComparisonzUtilities.pathComparison�s���
�E�>���3�u�:�s�5�z�*���"����$�e�t�,���"����$�e�t�,���s�3�u�:�s�5�z�2�3�	�A��Q�x�%��(�"���Q�x�%��(�"��		�r6c�0�tj|||�Sr~)r�find_all_descendants)r2r��	includeIf�	excludeIfs    r4r�zUtilities.findAllDescendants�s���,�,�T�9�i�H�Hr6c	�����|jjr'|jjj|�rgStjj
tjjg�tjjtjjtjjtjjtjjtjjtjjtjjtjjg	���fd�}��fd�}|j!|||�}t#j$|�}g}|D]�}	t#j$|	�xs|j'|	�}
|
r-|
|t#j$t#j(|	��fvr�Zt+|
j-��|kr�w|j/|
�dk\r��|j1|	���t3j4|�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.
        c���|rtj|��vsytj|�ry�rtj|�syyrY)rr��
get_relationsrr�)r<�
labelRolesr�s ��r4r�z+Utilities.unrelatedLabels.<locals>._includesB����(�+�+�A�.�*�<���%�%�a�(���;�#9�#9�!�#<��r6c�j��|rtj|��vry�rtj|�syyr�)rr�rr�)r<r��	skipRoless ��r4r�z+Utilities.unrelatedLabels.<locals>._excludes1�����)�)�!�,�	�9���;�#9�#9�!�#<��r6r)r/�
spellcheck�
isCheckWindowrr�r��STATICr�rtrb�MENU_BARro�
SPLIT_PANEre�TREErir�rr�r*r_rF�split�findrQr�sort_objects_by_position)
r2r�r�r�r�r�rp�rootName�labels_filteredrqr�r(r*s
  `        @@r4r�zUtilities.unrelatedLabels�s�����<�<�"�"�t�|�|�'>�'>�'L�'L�T�'R��I��j�j�&�&��
�
�(9�(9�:�
��Z�Z�)�)��Z�Z�(�(��Z�Z�_�_��Z�Z�(�(��Z�Z�+�+��Z�Z�*�*��Z�Z�%�%��Z�Z�_�_��Z�Z�*�*�,�	�	�	��(�(��x��B���$�$�T�*�����	*�E��$�$�U�+�H�t�/A�/A�%�/H�D����8�+<�+<�X�=P�=P�QV�=W�+X� Y�Y���4�:�:�<� �<�/���}�}�T�"�a�'���"�"�5�)�	*��3�3�O�D�Dr6c��y)NTrtr�s r4r�zUtilities._treatAlertsAsDialogs(r�r6c�F��	�tjjg�	�j�r)�	j	tjj
��	�fd�}t
jt
j|�|�D�cgc]}|��}}|jt
j�j|�|�D�cgc]}|��c}�d�}d�}tt|t|���}tt||��}t|�Scc}wcc}w)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.
        c�X��tj|��vxs�j|�Sr~)rr�r�)r<r
r2s ��r4r�z8Utilities.unfocusedAlertAndDialogCount.<locals>.isDialog;s)����$�$�Q�'�5�0�N�D�4K�4K�A�4N�Nr6c��tj|�xrCtj|�xr,tj|�xstj
|�Sr~)rr�r�rr�rhr;s r4�
isPresentablez=Utilities.unfocusedAlertAndDialogCount.<locals>.isPresentableAsM���)�)�!�,�J��1G�1G��1J�J��&�&�q�)�H�X�-E�-E�a�-H�
Jr6c�J�tj�j|�Sr~)rr��can_be_active_windowr;s r4�cannotBeActiveWindowzDUtilities.unfocusedAlertAndDialogCount.<locals>.cannotBeActiveWindowEs��$�/�/�1�F�F�q�I�I�Ir6)rr�r�r�rQr�rr�r�r�r�r�r��setrF)
r2rRr�r<�dialogsr:r=�presentable�	unfocusedr
s
`        @r4�unfocusedAlertAndDialogCountz&Utilities.unfocusedAlertAndDialogCount+s�������"�"�#���%�%�'��L�L����)�)�*�	O�'�4�4�X�5M�5M�c�5R�T\�]�^��1�^��^����8�#9�#9�$�:M�:M�c�:R�T\�#]�^�a��^�_�	J�	J��6�-��W��>�?���� 4�k�B�C�	��9�~���_��^s�	D�	Dc���tj|�sytj|tjj
�}|r|j
d�Stj|�S)z!Finds the object before this one.Nr)rr^rMrrD�
FLOWS_FROMrO�get_previous_object�r2rRrZs   r4�findPreviousObjectzUtilities.findPreviousObjectRsX��� � ��%���(�(��e�.@�.@�.K�.K�L����&�&�q�)�)��+�+�C�0�0r6c���tj|�sytj|tjj
�}|r|j
d�Stj|�S)z Finds the object after this one.Nr)rr^rMrrD�FLOWS_TOrO�get_next_objectrFs   r4�findNextObjectzUtilities.findNextObject^sX��� � ��%���(�(��e�.@�.@�.I�.I�J����&�&�q�)�)��'�'��,�,r6c���tj|�\}}}|r*|jjj	d�r|||fS|j|�r|||fS|j
|�}|r6tj|�d}|sn|�d|��}|j
|�}|r�6|j|�}|r6tj|�d}|sn|�d|��}|j|�}|r�6|||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.
        �entireDocumentSelectedrr�)r�get_selected_textr/r,r�r'rGrK)r2rR�textContents�startOffset�	endOffsetr9�	selection�nextObjs        r4�allSelectedTextzUtilities.allSelectedTextjs��06�/G�/G��/L�,��k�9��D�L�L�9�9�=�=�>V�W���i�7�7��!�!�#�&���i�7�7��)�)�#�.����0�0��9�!�<�I���'�[��,��8�L��-�-�g�6�G���%�%�c�*����0�0��9�!�<�I���*�^�1�Y�K�8�L��)�)�'�2�G���[�)�3�3r6c��	|j|||�}|j|vr|Stjj
tjjtjjtjjtjjtjjtjjtjjg}t|�}t|�D]b\}}||jk(s�tj |||z�}	|j#|	�}
|	rt%j&|	�|vr|
dz
}
|
||<�ddj)|�S#t$rYywxYw)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.
        r'r�)�	substringrlr�rr��HEADINGr�r��	PARAGRAPHrlrerg�	TABLE_ROWr��	enumerater�get_child_at_offsetrSrr�r�)r2rRrPrQr��
blockRoles�toBuildrX�charr�rGs           r4rSzUtilities.expandEOCs�s<��	��^�^�C��i�@�F��)�)��7��M��j�j�(�(��j�j�o�o��j�j�*�*��j�j�*�*��j�j�(�(��j�j�&�&��j�j�+�+��j�j�*�*�,�
��v�,�� ��)�	$�G�A�t��t�5�5�5�#�7�7��Q��_�M������/���X�.�.�u�5��C��c�M�F�#���
�
	$��w�w�w����1�	��	�s�E;�;	F�Fc�,�tj|�Sr~)r�is_invalid_entryrus  r4�getErrorzUtilities.getError�����+�+�C�0�0r6c��yr�rtrus  r4�getErrorMessagezUtilities.getErrorMessage�r�r6c��yrsrtrus  r4�isErrorMessagezUtilities.isErrorMessage�rwr6c��|jSr~)�any_datar�s  r4�deletedTextzUtilities.deletedText�s���~�~�r6c��|jr|jSd}tjtj|d�t	j
|j�rPtj|j�}|r/d|dg}tjtj|d�|dSd}tjtj|d�y)Nz-SCRIPT UTILITIES: Broken text insertion eventTzHACK: Returning last char in '�'r)z3FAIL: Unable to correct broken text insertion eventr')
rhrr�rHr�is_password_textr�rr�rG)r2r�r�r�rUs     r4�insertedTextzUtilities.insertedText�s����>�>��>�>�!�=��
���5�+�+�S�$�7��'�'����5��(�(����6�F��:�F�C�H���!�!�%�"2�"2�F�D�A��b�z�!�C��
���5�+�+�S�$�7�r6c�x�tj�j�}tj|�}||fSr~)rr�r�r�get_caret_offsetr�s   r4r�zUtilities.getCaretContext�s3���&�&�(�;�;�=���(�(��-���F�{�r6c�
�|dfSr9rtrus  r4�getFirstCaretPositionzUtilities.getFirstCaretPosition�s
���A�v�
r6c�r�tj�jd|d�|j||�yrs)rr��set_locus_of_focus�setCaretOffset)r2rRr�r�s    r4�setCaretPositionzUtilities.setCaretPosition�s-��� � �"�5�5�d�C��G����C��(r6c�0�tj||�yr~)r�set_caret_offsetr�s   r4rtzUtilities.setCaretOffset�s������V�,r6c�0�tj|||�Sr~)r�
get_substring)r2rRrPrQs    r4rVzUtilities.substring�s���#�#�C��i�@�@r6c�p�|jjj�D]\}}||k(s�|cS|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)r2�
attribName�key�values    r4�getAppNameForAttributez Utilities.getAppNameForAttribute�s?���,�,�9�9�?�?�A�	�J�C���
�"��
�	��r6c�N�|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.
        )r/r{r�)r2r|s  r4�getAtkNameForAttributez Utilities.getAtkNameForAttribute�s!���|�|�.�.�2�2�:�z�J�Jr6c�.�tj||�Sr~)r�get_text_attributes_at_offset)r2r�r��get_defaultss    r4�textAttributeszUtilities.textAttributess���3�3�C��@�@r6c�D�|dk(r#|dk(st|�dkDrtjS|jd�s|dk(rtjStj||j�}|dk(r2|jd�dj�jd�}n�|r||jd	�rk|jd	�d}tj�d
|vrtjt|��}n�tjt|��}nw|jd�rF|j|�\}}}tj rt#j$|||�}n)d|||fz}n tj||j�}|�d
|��S)N�weight�boldi��spellingzfamily-name�,r�"�px�
decimal_point�colorz%i %i %iz: )�intr�BOLD�endswith�
MISSPELLEDr�getTextAttributeNamer/r1r��locale�
localeconv�
pixelCount�float�
rgbFromStringr�
useColorNamesr
�	rgbToName)r2r}r~�localizedKey�localizedValue�r�grds        r4�localizeTextAttributezUtilities.localizeTextAttributes^���(�?����3�u�:��3C��=�=� ��<�<�
�#�u�
�':��&�&�&�+�@�@��d�l�l�S���-��"�[�[��-�a�0�6�6�8�>�>�s�C�N�
�u�~�~�d�+��K�K��%�a�(�E�� � �"�?�3�u�<�!)�!4�!4�U�5�\�!B��!)�!4�!4�S��Z�!@��
�\�\�'�
"��(�(��/�G�A�q�!��%�%�!+�!5�!5�a��A�!>��!+�q�!�Q�i�!7��1�F�F�u�d�l�l�[�N���r�.�!1�2�2r6c���g}|j|||�}|D]V\}}}}	||k\r�||kr|St||�}t||�}|j|||�}
|j	|||
||	g��X|S)zAReturns a list of (start, end, string, language, dialect) tuples.)�'getLanguageAndDialectFromTextAttributesrrbrVrQ)r2rRr�r	r��
allSubstringsrPrQ�language�dialectr�s           r4�splitSubstringByLanguagez"Utilities.splitSubstringByLanguage,s������D�D�S�%�QT�U�
�9F�	K�5�K��H�g��	�!���k�!���	��e�[�1�K��C��+�I��^�^�C��i�@�F��I�I�{�I�v�x��I�J�	K��	r6c�d�|j|||�}|D]\}}}}||ks�||k\s�||fcSy)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.)r'r')r�)	r2rRr�r	r�rPrQr�r�s	         r4�!getLanguageAndDialectForSubstringz+Utilities.getLanguageAndDialectForSubstring=sP��
�D�D�S�%�QT�U�
�9F�	)�5�K��H�g��e�#�	�S�(8���(�(�	)�r6c��g}tj|||�}dx}}|D]h\}}	}
|
jdd�}d}d|vr|jdd�\}}|r||k(r||k(r|dd|	||f|d<n|j	||	||f�||}}�j|S)zvReturns a list of (start, end, language, dialect) tuples for obj
        based on what is exposed via text attributes.r'r��-r	r)r)r�get_all_text_attributesr�r1rQ)
r2rRrPrQr��attributeSet�lastLanguage�lastDialectr�r	r�r�r�s
             r4r�z1Utilities.getLanguageAndDialectFromTextAttributesIs������5�5�c�;�	�R��%'�'��{�#/�		:��U�C���y�y��R�0�H��G��h��$,�N�N�3��$:�!��'��l�h�.�;�'�3I��B����C��7�:��2���	�	�5�#�x��9�:�(0�'�+�L�		:��	r6c�2�tj�j�}|rtjsyt|j�dk7s|jtjzrytj|�rytj|�ryy)z�Given a keyboard event containing an alphanumeric key,
        determine if the script is likely to echo it as a character.
        Fr	T)
rr�r�r�enableEchoByCharacterrF�event_string�	modifiersr�ORCA_CTRL_MODIFIER_MASKrrlr�)r2r�r�s   r4�willEchoCharacterzUtilities.willEchoCharacter]sv��
�(�(�*�=�=�?���H�:�:���u�!�!�"�a�'��o�o�� C� C�C���'�'��.���"�"�5�)��r6c��|j�r||zSt|�}|tjk\r@|d|jj
vr%|d}t
j||�}|�d|�d�}|S||z
}|S)auAdd 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.

        Returns: the current built-up line plus the new segment, after
        adjusting for repeat character counts and punctuation.
        rr�)�isalnumrFr�repeatCharacterLimitr/�
whitespacer�repeatedCharCount)r2�segment�liner��
repeatChar�
repeatSegments      r4�_addRepeatSegmentzUtilities._addRepeatSegmentxs����?�?���'�>�!��G����H�1�1�1�g�a�j����H_�H_�6_� ���J�$�6�6�z�5�I�M��V�1�]�O�1�-�D���
�G�O�D��r6c���|j|�s|j|�sytj�j	d�}|t
jt
jfvryy)NF�verbalizePunctuationStyleT)r�r�rr�r�r�PUNCTUATION_STYLE_ALL�PUNCTUATION_STYLE_NONE)r2rR�styles   r4�shouldVerbalizeAllPunctuationz'Utilities.shouldVerbalizeAllPunctuation�sY�����C� �D�$9�$9�#�$>��
!�+�+�-�8�8�9T�U���X�3�3�X�5T�5T�U�U��r6c��|}ttj|j|��D]"}d|�d�}tjd|z||�}�$|S)Nr�z\%s)r>r��findall�PUNCTUATION�sub)r2r�rG�symbol�charNames     r4�verbalizeAllPunctuationz!Utilities.verbalizeAllPunctuation�sV�����"�*�*�T�%5�%5�v�>�?�	?�F��6�(�!�}�H��V�V�F�V�O�X�v�>�F�	?��
r6c��|t|�z}tj|||�}|D�cgc]}tj|���}}t	|D�cgc]}||z
��	c}d��}t|�}	|D]@}
dtj��}|
t|	�kr|	|
j�r|dz
}||	|
|
�Bdj|	�Scc}wcc}w)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.
        T)rar�r')
rFr�get_all_links_in_range�get_link_end_offset�sortedr�rr�r�r�)r2rRr�rPrQ�links�link�offsetsr�rU�or�s            r4�adjustForLinkszUtilities.adjustForLinks�s��� �#�d�)�+�	��2�2�3��Y�O��EJ�K�T�;�2�2�4�8�K��K��W�E�6�&�;�.�E�t�T���d����	!�A������(�F��3�v�;��6�!�9�#4�#4�#6��#�
�� �F�1�Q�K�		!��w�w�v����L��Es�C�Cc�0�tjdd|�S)Nz(?<=[a-z])(?=[A-Z])r�)r�r�)r�s r4�_processMultiCaseStringz!Utilities._processMultiCaseString�s���v�v�,�c�6�:�:r6c�Z�|j�s|Sdjt|��S)Nr�)�	isnumericr�r�)�words r4�_convertWordToDigitszUtilities._convertWordToDigits�s$���~�~���K��x�x��T�
�#�#r6c��|jdd�}tjr|j|�}|j	�rtj|�}tjr@|jj|�}djt|j|��}|j|�}t|�dk(rF|jj!�s,|j#�rtj$|�}||k7r|Stj&s|Sd}|jj|�}djtt(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�r'r	)�replacer�speakMultiCaseStringsAsWordsr�r�r�adjustForSpeech�speakNumbersAsDigits�WORDS_REr1r�r�r��adjustForDigitsrFr/r6r��getCharacterName�usePronunciationDictionaryr�getPronunciation)r2r��words�charname�newLines     r4�adjustForPronunciationz Utilities.adjustForPronunciation�s1���|�|�H�c�*���0�0��/�/��5�D��$�$�&��.�.�t�4�D��(�(��M�M�'�'��-�E��7�7�3�t�8�8�%�@�A�D��#�#�D�)���t�9��>�$�,�,�"7�"7�"9�d�m�m�o�"�3�3�D�9�H��4�����2�2��K����
�
�#�#�D�)���'�'�#�0�A�A�5�I�J���0�0��2�2�7�;�G��r6c��t|�dkstjdkr|Sd}|dx}}tdt|��D]/}|||k(r	|||z
}n|j	||�}||}||}�1|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).
        �r'rr	)rFrr�rJr�)r2r�r�r��lastCharrXs      r4�adjustForRepeatszUtilities.adjustForRepeats�s���&
��I��M�x�<�<�q�@��K���!�!�W�$��(��q�#�d�)�$�	�A��A�w�(�"��4��7�"���0�0��'�B���q�'���A�w�H�	��%�%�g�w�7�7r6c	��ttj|j|��}ttj|j|��}|D]l}|D�cgc]&}t|jj|����(}}tjdj|�z}tj|||�}�n|D]l}|D�cgc]&}t|jj|����(}}tjdj|�z}tj|||�}�n|Scc}wcc}w)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.
        r')r>r�r��
SUBSCRIPTS_RE�SUPERSCRIPTS_REr��SUPERSCRIPT_DIGITSr�r�DIGITS_SUPERSCRIPTr�r��SUBSCRIPT_DIGITS�DIGITS_SUBSCRIPT)r2r��subscripted�
superscripted�number�d�new�	newStrings        r4r�zUtilities.adjustForDigits	s���"�*�*�T�%7�%7��@�A���B�J�J�t�';�';�V�D�E�
�#�	7�F�BH�I�Q�3�t�.�.�4�4�Q�7�8�I�C�I� �3�3�b�g�g�c�l�B�I��V�V�F�I�v�6�F�	7�
"�	7�F�@F�G�1�3�t�,�,�2�2�1�5�6�G�C�G� �1�1�B�G�G�C�L�@�I��V�V�F�I�v�6�F�	7�
�
��J��
Hs�+D7�
+D<c��tj�jd�s#tj�jd�sy|jdd�}t	j
d|�}|r|d|j
�}d}t	jd|�D�cgc]}|j���}}t	jd|�D�cgc]}|j���}}t||z�}|D]H\}}||f|vr|tj||z
��d�z
}�+|tj||z
��d�z
}�J|Scc}wcc}w)	N�onlySpeakDisplayedText�enableSpeechIndentationr'r�r�z[^ 	]z +z	+)
rr�r�r�r�r�r��finditer�spanr�r�spacesCount�	tabsCount)	r2r�r	rG�m�spaces�tabs�spansr�s	         r4�indentationDescriptionz Utilities.indentationDescription5	s7���&�&�(�3�3�4L�M�"�-�-�/�:�:�;T�U���|�|�H�c�*���i�i��$�'���������%�D���$&�K�K��d�$;�<�q�!�&�&�(�<��<�"$�+�+�e�T�":�;�Q�����;��;��v��}�%��!�	@�L�U�C��s�|�v�%��X�1�1�#��+�>�?�q�A�A���X�/�/��e��<�=�Q�?�?��		@��
��=��;s�E�Ec��ddlm}|j�j�j	�}|j�\}}}}||fS)z0Gets the absolute position of the mouse pointer.rr)�
gi.repositoryr�Window�
get_screen�get_root_window�get_pointer)r�
rootWindowrr<�yr�s      r4�absoluteMouseCoordinatesz"Utilities.absoluteMouseCoordinatesK	sF��	&��S�Z�Z�\�,�,�.�>�>�@�
�",�"8�"8�":����1�i��!�t�r6c�"�|s|S|s|S||z|zS)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.rt)rU�newText�	delimiters   r4rnzUtilities.appendStringU	s$����K���N��i��'�)�)r6c�"�|r|sy||k(ry|j|jk(xrj|j|jk(xrO|j|jk(xr4|j|jk(xr|j|jk(Srs)r��type�detail1�detail2rh)r2�event1�event2s   r4�treatAsDuplicateEventzUtilities.treatAsDuplicateEventb	s����6���V����}�}��
�
�-�3����v�{�{�*�3����&�.�.�0�3����&�.�.�0�3����6�?�?�2�		3r6c�$�|jjd��r�|jr|jsyt	j
|j�syt	j|j�syt	j|j�rAtj|jdd�t	j|j�sy|j�\}}|dk(r|jdk7ry|dk(r|jdk7ry|d	vr|j|j�S|j�sytj|j�}|j!|j�r�tj"|j�\}}}||jk(ry||jk(rR|j!|�rA|d
|j%|�}|j'�j!|j'��Sy)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:insertFr��Tab�	T�Return�
)�Up�Down�Page_Up�	Page_DownN)r�
startswithrhr�rr�r�r�rr�r��lastKeyAndModifiers�isEditableDescendantOfComboBox�lastInputEventWasPrintableKeyrr�r�rNr2�lower)	r2r��lastKey�modsr�rRr�r	�	beginnings	         r4�isAutoTextEventzUtilities.isAutoTextEventp	s����:�:� � �!=�>��>�>������*�*�5�<�<�8���)�)�%�,�,�7���'�'����5��$�$�U�\�\�5�:_�`�"�-�-�e�l�l�;� � �4�4�6�M�G�T��%��E�N�N�d�$:���(�"�u�~�~��'=���@�@��:�:�5�<�<�H�H��5�5�7���(�(����6�F����u�~�~�.�(.�(@�(@����(N�%�	�5�#�����.���U�^�^�+����	�0J� &�'>����I�(>� ?�I�$�?�?�,�5�5�g�m�m�o�F�F�r6c�T�|dk(s|dk(ry||jjvxr|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.
        �
rTz!.?:;)r/r�)r2�currentChar�previousChars   r4�isSentenceDelimiterzUtilities.isSentenceDelimiter�	s:���$��+��"5���d�l�l�5�5�5�+��7�*�	+r6c�t�||jjvxs|dvxs||jjk(S)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/r��NO_BREAK_SPACE_CHARACTER)r2�	characters  r4�isWordDelimiterzUtilities.isWordDelimiter�	sC���D�L�L�3�3�3�E��8�8�E��t�|�|�D�D�D�	Er6c��tjj�}|j|�d}t	ttjt|���Sr�)r�Keymap�get_default�get_entries_for_keycoder�r��keyval_namer>)�keycode�keymap�entriess   r4�_allNamesForKeyCodezUtilities._allNamesForKeyCode�	sC�����'�'�)���0�0��9�"�=���C�����W��6�7�7r6c��ttjtj�sytj
}|r|j|jfSy)N)rr)r�r�lastInputEventr�
KeyboardEvent�lastNonModifierKeyEvent�hw_coder�)r�s r4�_lastKeyCodeAndModifiersz"Utilities._lastKeyCodeAndModifiers�	s?���*�3�3�[�5N�5N�O���2�2����=�=�%�/�/�1�1�r6c�,�ttjtj�retj
rUtj
}|jdvr
|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�Deleter'r)	r�rr?rr@rAr9r�r�)r��eventStrr)s   r4r$zUtilities.lastKeyAndModifiers�	s����j�/�/��1J�1J�K��1�1��6�6�E�� � �$;�;� �,�,�� �-�-���,�,�6�6�D�
�$����H��D��$��r6c�X�	ddlm}|j|�\}}|j||�}|r$|j	d�r|j	d�r|}tj|�S#t
$r5|j
dd�}|j
dd�j�}Y�RwxYw)	z3Turns a key sequence into a user-presentable label.rr�+z++�<r'�>r�)
rr�accelerator_parse�accelerator_get_labelr�rlr�r�r
�localizeKeySequence)�sequencerr}r)�newSequences     r4�labelFromKeySequencezUtilities.labelFromKeySequence�	s���		:�)�-��-�-�h�7�I�C��3�#�3�3�C��>�K���(�(��-��1E�1E�d�1K�&��
�+�+�H�5�5��	�	:��'�'��R�0�H��'�'��S�1�7�7�9�H�	:�s�AA+�+;B)�(B)c�V�	|jj|j|S#t$rH|j|jjvr#i|jj|j<YnwxYwt	j
|d�}|sNgd�|jj|j|<|jj|j|S|j
d�}t|�dk(r|d}|d}|d}n3t|�dkDrd}|d}	|d}n#t$rd}Yn
wxYwd}d}d}|jdd	�j�}|j|�}|j|�}|j|�}|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]
        r)r'r'r'�;�r	�r'�:r�)r/rj�KEY_BINDINGrlr�get_action_key_bindingr1rFr�r�rQ)r2rR�
keybinding�bindingStrings�mnemonic�fullShortcut�accelerators       r4�mnemonicShortcutAcceleratorz%Utilities.mnemonicShortcutAccelerator�	s��	C��<�<�.�.�t�/?�/?�@��E�E���	C����t�|�|�'B�'B�B�@B����+�+�D�,<�,<�=��	C���4�4�S�!�<�
��AM�D�L�L�'�'��(8�(8�9�#�>��<�<�.�.�t�/?�/?�@��E�E�$�)�)�#�.���~��!�#�+�A�.�H�+�A�.�L�+�A�.�K�
��
 �1�
$��H�+�A�.�L�
!�,�Q�/����
!� ��
!�� �H��L��K�#�+�+�C��5�;�;�=���0�0��>���,�,�X�6���/�/��<�����4�<�<�#>�#>�>�<>�D�L�L�'�'��(8�(8�9��|�[�1�	
���#�#�D�$4�$4�5�c�:��|�|�*�*�4�+;�+;�<�S�A�As"�%(�AA9�8A9�'D-�-D;�:D;c��	|jd�D�cgc]}|j���}}|D�cgc]"}t|jd��dk(s�!|��$}}|D�cgc]$}|jd�dj���&}}t|D�cgc]}|jd���c}�}||gScc}wcc}wcc}wcc}w#t$rgifcYSwxYw)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.
        rSrVrUr)r1r�rF�dictrl)r��sr�item�keys�
dictionarys      r4�stringToKeysAndDictzUtilities.stringToKeysAndDict+
s���	�(.���S�(9�:�1�Q�W�W�Y�:�E�:�&+�I�d�s�4�:�:�c�?�/C�q�/H�T�I�E�I�;@�A�4�D�J�J�s�O�A�&�,�,�.�A�D�A��5�A�4�t�z�z�#��A�B�J��j�!�!��;��I��A��A���	��r�6�M�	�sJ�C
�B6�C
�"B;�B;�C
�)C�C
�C�+C
�6C
�

C�Cc��	t|�d�S#t$r&tjtj�YywxYw)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
        �04xr')�ordrlr�printException�
LEVEL_WARNING)r3s r4�unicodeValueStringzUtilities.unicodeValueStringD
s<��	��)�n�S�)�*���	�� � ��!4�!4�5��	�s��,>�>c��gSr~rt)r2rRr��
layoutMode�useCaches     r4�getLineContentsAtOffsetz!Utilities.getLineContentsAtOffsetT
r�r6c��gSr~rt)r2rRr�rns    r4�getObjectContentsAtOffsetz#Utilities.getObjectContentsAtOffsetW
r�r6c�:�|s|j�\}}||dz
fS�Nr	�r��r2rRr��	skipSpaces    r4�previousContextzUtilities.previousContextZ
�%����.�.�0�K�C���F�Q�J��r6c�:�|s|j�\}}||dzfSrsrtrus    r4�nextContextzUtilities.nextContext`
rxr6c�N�tdtj|�dz
�}||fS�Nrr	)rr�get_character_count)r2r�r�s   r4�lastContextzUtilities.lastContextf
s(���Q��2�2�4�8�1�<�=���V�|�r6c�\��tj|�}|r|Sd}tjtj|d�tj|�}|tjjk(r"|s |j|tj�}|tjjk(ry|rwtj|d�tjjk(rD|j|d�}tj|��|s�r�fd�}|j||�}|S)NzJSCRIPT UTILITIES: Selected children not retrieved via selection interface.Trc�4��tj|��k(Sr~)rr�)r<r�s �r4r=z(Utilities.selectedChildren.<locals>.pred{
s���#�,�,�Q�/�4�7�7r6)r�get_selected_childrenrr�rHrr�rr�rbr�rr�r�r�r�)r2rR�childrenr�r�r=r�s      @r4r�zUtilities.selectedChildrenj
s�����4�4�S�9����O�Z��
���5�+�+�S�$�7�� � ��%���5�:�:�?�?�"�8��.�.�s�K�4K�4K�L�H��5�:�:�'�'�'��H�-�-�h�q�k�:�e�j�j�o�o�M��,�,�X�a�[�9�H��$�$�S�)�D���8� �2�2�3��=���r6c��yrsrtrus  r4�speakSelectedCellRangez Utilities.speakSelectedCellRange�
rwr6c
����|sy|j|�rytj|�r|Stjj
tjjgtjjtjjgtjjtjjgtjjtjjtjjgtjjtjjtjjgtjjtjjtjjgi}|j!tj"|����fd�}tj$||�S)Nc�b���rtj|��vrytj|�Srs)rr�r�)r<�
matchingRoless �r4�isMatchz0Utilities.getSelectionContainer.<locals>.isMatch�
s,�����!2�!2�1�!5�]�!J���.�.�q�1�1r6)r�rr�rr�r�rp�ICONr�rtrdr0rirgrerYr�r�r�)r2rR�rolemapr�r�s    @r4�getSelectionContainerzUtilities.getSelectionContainer�
s1������?�?�3����&�&�s�+��J�
�J�J����
�
� 7� 7�8��J�J�O�O�e�j�j�5�5�6��J�J� � �5�:�:�#6�#6�"7��J�J� � �5�:�:�?�?�E�J�J�4I�4I�"J��J�J�!�!�E�J�J�$4�$4�e�j�j�6K�6K�#L��J�J� � �5�:�:�#3�#3�U�Z�Z�5J�5J�"K�

�� ���H�$5�$5�c�$:�;�
�	2�
�%�%�c�7�3�3r6c����tj|�sytj|�r!tj|�}td|�Stjjtjjgtjjtjjgi�tj|����vrtj|�S��fd�}t|j||��S)Nrc�P��tj|��j��vSr~)rr�r�)r<r�r�s ��r4r�z/Utilities.selectableChildCount.<locals>.isMatch�
s"����$�$�Q�'�7�;�;�t�+<�<�<r6)rr�rrrKrrr�rtr�r0rdr�rhrFr�)r2rR�rowsr�r�r�s    @@r4�selectableChildCountzUtilities.selectableChildCount�
s�����*�*�3�/���"�"�3�'��(�(��-�D��q�$�<��
�J�J���%�*�*�"6�"6�!7��J�J�O�O�e�j�j�2�2�3�
��
� � ��%���w���+�+�C�0�0�	=��4�*�*�3��8�9�9r6c��tj|�rtj|�St	j
|�Sr~)rrr�get_selected_row_countr�get_selected_child_countrus  r4�selectedChildCountzUtilities.selectedChildCount�
s2���"�"�3�'��1�1�#�6�6��3�3�C�8�8r6c��|�ytj|tj�D�cgc]}|��}}|D]}tj|�s�|cSycc}wr~)rr�r�is_menu�
is_enabled)r2rRr��menusr�s     r4�popupMenuForzUtilities.popupMenuFor�
s]���;��$,�$:�$:�3��@S�@S�$T�U�5��U��U��	�D��%�%�d�+���	���Vs�	Ac�Z�tj|�xrtj|�Sr~)rr��	has_popuprus  r4�isButtonWithPopupzUtilities.isButtonWithPopup�
s#���$�$�S�)�H�k�.C�.C�C�.H�Hr6c���tj�j�}||k(rytj|�sytj|�}|sy|tj|�k(Srs)rr�r�rr�rr�)r2rRr�r�s    r4�isPopupMenuForCurrentItemz#Utilities.isPopupMenuForCurrentItem�
s`���(�(�*�=�=�?���%�<���"�"�3�'��� � ��%�����x�(�(��/�/�/r6c�T�tj|�xr|j|�Sr~)rr�r�rus  r4�isMenuWithNoSelectedChildz#Utilities.isMenuWithNoSelectedChild�
s&���"�"�3�'�L��0G�0G��0L�,L�Lr6c�V�tj|�xr|j|�duSr~)rr�r�rus  r4�isMenuButtonzUtilities.isMenuButton�
s(���$�$�S�)�P�d�.?�.?��.D�D�.P�Pr6c�L�|xs"tj�j�}|�ytj|�stj
|�rytj|�stj|�r&tj|tj
�duSyrY)
rr�r�r�is_menu_item_of_any_kindr�r��is_separatorrr�rus  r4�inMenuzUtilities.inMenu�
s����D�]�-�-�/�B�B�D���;���/�/��4��8K�8K�C�8P������$��(@�(@��(E��)�)�#�{�/B�/B�C�4�O�O�r6c��|xs"tj�j�}|j|�syt	j
||j�duSrs)rr�r�r�rr��
isContextMenurus  r4�
inContextMenuzUtilities.inContextMenu�
sK���D�]�-�-�/�B�B�D���{�{�3����%�%�c�4�+=�+=�>�d�J�Jr6c�j�tjjtjjfSr~)rr�r�r�r�s r4�_contextMenuParentRolesz!Utilities._contextMenuParentRoles�
s!���z�z������!2�!2�2�2r6c��tj|�sytjtj|��|j�vSrs)rr�rr�r_r�rus  r4r�zUtilities.isContextMenu�
s=���"�"�3�'��� � ��!4�!4�S�!9�:�d�>Z�>Z�>\�\�\r6c�|�tj|�sytj|�|j	|�k(Srs)rr�rr_r�rus  r4�isTopLevelMenuzUtilities.isTopLevelMenu�
s4���"�"�3�'���"�"�3�'�4�+>�+>�s�+C�C�Cr6c��tj|�sytj|�sytj|�Srs)rr��supports_autocompletion�is_single_linerus  r4�isSingleLineAutocompleteEntryz'Utilities.isSingleLineAutocompleteEntry�
s5���#�#�C�(���2�2�3�7���)�)�#�.�.r6c��yrsrtrus  r4�isEntryCompletionPopupItemz$Utilities.isEntryCompletionPopupItemrwr6c��tj|�sytj||j�D�cgc]}|��}}t|�dk(r|dSycc}w)Nr	r)rr�rr��isEditableTextArearF)r2rRr<r�s    r4�getEntryForEditableComboBoxz%Utilities.getEntryForEditableComboBox	sX���'�'��,��'�5�5�c�4�;R�;R�S�T�!�A�T��T��x�=�A���A�;����	Us�	Ac�(�|j|�duSr~)r�rus  r4�isEditableComboBoxzUtilities.isEditableComboBoxs���/�/��4�D�@�@r6c�z�tj|�sytj|tj�duSrs)rr�rr�r�rus  r4r%z(Utilities.isEditableDescendantOfComboBoxs1���&�&�s�+���%�%�c�;�+C�+C�D�D�P�Pr6c���tj|�s|j|�S|j|�}|r|j|�S|jj
j
|�}|xs9|jj
j
tj|d��}t|�dk(r%|djxs|j|d�S|j|�Sr|)
rrhr*r�r/r�r�r`rFr�)r2rR�entryr�s    r4�getComboBoxValuezUtilities.getComboBoxValues����'�'��,��%�%�c�*�*��0�0��5����%�%�e�,�,��<�<�)�)�:�:�3�?���b�t�|�|�5�5�F�F�x�GY�GY�Z]�_`�Ga�b���x�=�A���A�;�#�#�F�t�'9�'9�(�1�+�'F�F��!�!�#�&�&r6c��yrsrtrus  r4�	isPopOverzUtilities.isPopOver+rwr6c�R�|j|�sytj|�Srs)r�r�is_modalrus  r4�isNonModalPopOverzUtilities.isNonModalPopOver.s%���~�~�c�"���'�'��,�,�,r6c��yrsrtrus  r4�isUselessPanelzUtilities.isUselessPanel3rwr6c���tjdtj�}tj|d|�}|j	d�\}}}t|�t|�t|�fS)Nz
rgb|[^\w,]r'r�)r��compile�
IGNORECASEr�r1r�)r2�attributeValue�regexr��red�green�blues       r4r�zUtilities.rgbFromString6sV���
�
�=�"�-�-�8������r�>�2��!�<�<��,���U�D��3�x��U��S��Y�.�.r6c��yrsrtrus  r4�isClickableElementzUtilities.isClickableElement=rwr6c��yrsrtrus  r4�hasLongDesczUtilities.hasLongDesc@rwr6c��yrsrtrus  r4�
hasDetailszUtilities.hasDetailsCrwr6c��yrsrtrus  r4�	isDetailszUtilities.isDetailsFrwr6c��gSr~rtrus  r4�
detailsForzUtilities.detailsForIr�r6c��yrsrtrus  r4�hasVisibleCaptionzUtilities.hasVisibleCaptionLrwr6c��yr�rtrus  r4�	popupTypezUtilities.popupTypeOr�r6c�8�tj|�sytj|�}tj||�}	t|j
dd��}|S#t$r/d|d|dg}tjtj|d�YywxYw)Nr�level�0z-SCRIPT UTILITIES: Exception getting value for�(�)T)r�
is_headingr�rr�r�r�r�rrGrH)r2rR�	use_cacher�r~rUs      r4�headingLevelzUtilities.headingLevelRs����%�%�c�*��#�/�/��4�4�	��,�,�S�)�<��	���	�	�'�3�/�0�E�����	�E�s�C�QV�X[�\�F����e�.�.���=��	�s�A!�!5B�Bc�z�tj|d�xs$tj|tj�S)N�toggle)r�
has_actionr�
ACTION_TOGGLErus  r4�hasMeaningfulToggleActionz#Utilities.hasMeaningfulToggleActionbs5���"�"�3��1�I��"�"�3�(9�(G�(G�H�	Ir6c�x�tj|�r|Stj|tj�Sr~)r�is_table_headerrr�rus  r4�containingTableHeaderzUtilities.containingTableHeaderfs.���&�&�s�+��J��%�%�c�;�+F�+F�G�Gr6c�,�tj|�Sr~�r�is_indeterminaterus  r4�setSizeUnknownzUtilities.setSizeUnknownlrbr6c�,�tj|�Sr~r�rus  r4�rowOrColumnCountUnknownz!Utilities.rowOrColumnCountUnknownorbr6c��|�ytj|�rytj|�xstj|�Srs)rr�rr�r�rus  r4�_boundsIncludeChildrenz Utilities._boundsIncludeChildrenrs?���;���"�"�3�'���'�'��,�L��0G�0G��0L�M�Mr6c��yrsrtrus  r4�treatAsEntryzUtilities.treatAsEntry{rwr6c��|�tj|�rytj|�sytj|�stj
|�rytj|�r&tj|tj�duStj|�rtj|�rytj|�rtj|�Stj|�ryyrY)rr�rhr�is_autocompleter�r�r�r�r�r��
is_expandablerAr�rus  r4�_treatAsLeafNodezUtilities._treatAsLeafNode~s����;�(�*�*�3�/���'�'��,���&�&�s�+�{�/G�/G��/L���#�#�C�(��+�+�C��1E�1E�F�$�N�N����s�#��(9�(9�#�(>���$�$�S�)�"�.�.�s�3�3�3�� � ��%��r6c���|sytj|�sytj|�}t	td�|j
d���}t|�dkDS)NFc�"�|j�Sr~)r�r;s r4r�z2Utilities.isMultiParagraphObject.<locals>.<lambda>�s��q�w�w�y�r6z

r	)r�
supports_textrr�r�r�r1rF)r2rRr��chunkss    r4�isMultiParagraphObjectz Utilities.isMultiParagraphObject�sR�����%�%�c�*���$�$�S�)���f�0�&�,�,�v�2F�G�H���6�{�Q��r6c	���tj||�\}}}|jjj	dd�\}}||k7r|||fStj||�\}}	}
|jjj	d�dk(r�|j�r|}|}n|j
�r|}|}tj|||�}|jdd�}d|�d|�d	|�d
|�d�	}tjtj|d�|||fS|j�r.|}|d
j�s|d
j�sl|dz}nf|j
�rV|}||k7r|	|cxkr|
krnn|	}tj||dz
|�}
|
j�s|
j�s|dz
}tj|||�}d|vr2||k(r-|jd�r|dz
}n|jd�r|dz}tj|||�}|jdd�}d|�d|�d	|�d
|�d�	}tjtj|d�|||fS)N�penultimateCursorPositionr��lastTextUnitSpokenr�rz\nz*SCRIPT UTILITIES: Adjusted word at offset z for ongoing word nav is '�' (r�r�Tr)r	z for new word nav is ')r�get_word_at_offsetr/r,r��lastInputEventWasPrevWordNav�lastInputEventWasNextWordNavryr�rr�rH�isspacer�r#r�)r2rRr�r�r�r	r9�
prevOffset�prevWord�	prevStart�prevEnd�debugStringr�r�s              r4�$getWordAtOffsetAdjustedForNavigationz.Utilities.getWordAtOffsetAdjustedForNavigation�s���!�4�4�S�&�A���e�S�"�l�l�;�;�?�?�'��5�����c�>����#�#�(.�'@�'@��*�'U�$��)�W��<�<�(�(�,�,�-A�B�f�L��0�0�2��� ���2�2�4�"�����'�'��U�C�8�D��,�,�t�U�3�K�<�V�H�E��=��E�7�!�C�5��3�
�
���u�/�/��d�;����#�#��,�,�.��E�
��H�$�$�&�$�r�(�*:�*:�*<��q���
�
.�
.�
0��C��x��I��$A�'�$A�!��
�+�+�C��!��V�D�H��$�$�&�(�*:�*:�*<���
���#�#�C���4���4�<�D�H�,����t�$���
�����t�$��q����#�#�C���4���l�l�4��/��8���A��}�C��w�a��u�A�
/�	�	���5�+�+�S�$�7��U�C��r6c�
�|dtjjfvrtj|||�\}}}n�|tjj
k(rtj|||�\}}}ns|tjjk(rtj|||�\}}}n:|tjjk(rtj|||�\}}}ny|sd||fS|tjjk(r|j�sytj|||�}tj�}	||	_||	_dx|	_|	_t%j&||	�s|dk7ry|j)d�r|dk(r|||fS|tjjk(r|||fS|j+|||tjj�}
|
ddk(r|
d|
dz
dk(r|
S|||fS)N)r'rrr'rrrUr	)r�TextBoundaryType�
LINE_STARTr�get_line_at_point�SENTENCE_START�get_sentence_at_point�
WORD_START�get_word_at_point�CHAR�get_character_at_pointr��get_range_rect�Rectr<r
�width�heightr�get_rect_intersectionr��textAtPoint)r2rRr<r
�boundaryr�r�r	r��rectr^s           r4rzUtilities.textAtPoint�s�����e�4�4�?�?�@�@�!'�!9�!9�#�q�!�!D��F�E�3�
��/�/�>�>�
>�!'�!=�!=�c�1�a�!H��F�E�3�
��/�/�:�:�
:�!'�!9�!9�#�q�!�!D��F�E�3�
��/�/�4�4�
4�!'�!>�!>�s�A�q�!I��F�E�3����u�c�>�!��u�-�-�8�8�8�������'�'��U�C�8���z�z�|��������#$�$��
�T�[��0�0��$�?�F�d�N�����t�$��$���5�#�%�%��u�-�-�2�2�2��5�#�%�%�����Q��5�+A�+A�+F�+F�G����7�d�?�t�A�w��a��0�A�5��K��u�c�!�!r6c�H�tj|�}d|d|�d�g}tjtj|d�tj||j|jdz�}tj|d��d}td|�}d	|d
|��g}tjtj|d�tj|�}tj||j|j|jzdz�}|tj|d��dft||�}	d|d
|�d�g}tjtj|d�tj||j|j|jzdz
�}tj|d��d}d
|d
|�d�g}tjtj|d�|dk(r|}|}
tt|	|
��}||vr|jd|�|S)NzSCRIPT UTILITIES: zhas z rowsTr	Fr?rzSCRIPT UTILITIES: First cell:z(row: zSCRIPT UTILITIES: Next cell:r�zSCRIPT UTILITIES: Last cell:r))rrKrrGrHr�get_descendant_at_pointr<r
rIrr�rr�rJ�insert)r2rR�
table_rect�nRowsrUrYrV�
startIndex�	cell_rect�	nextIndex�endIndexr�s            r4�visibleRowszUtilities.visibleRowss����%�%�c�*��&��t�E�7�%�-@�A��
���%�*�*�F�D�9��2�2�3�
���j�l�l�UV�FV�W���*�*�4�%�H��K����C�[�
�1�4�6�#���H��
���%�*�*�F�D�9� �(�(��.�	��2�2�����z�|�|�i�.>�.>�>��B�D���W�
)�
)�$��
G��
J�J��
�C�(�	�0�$�&���Q��H��
���%�*�*�F�D�9��2�2�����z�|�|�j�.?�.?�?�!�C�E���*�*�4�%�H��K��0�$�&���Q��H��
���%�*�*�F�D�9��"�9��C����E�)�X�.�/���T�!��K�K��:�&��r6c���tj|�sgS|j|tj|��}|sgS|j|�\}}||k(rgSg}t
||�D]�}g}|D]�}tj|||�}	|	��|s?tj|	�}|r(|j|d�r|j|d�|j|	�s�p|j|	�����|Sr9)rrr&rr��_getTableRowRangerJrrL�get_column_headersr�rQ)
r2rRr��
colStartIndex�colEndIndexr�rW�headersrVrYs
          r4r�zUtilities.getVisibleTableCells9s����&�&�s�+��I�����[�%9�%9�#�%>�?����I�%)�%;�%;�C�%@�"�
�{��K�'��I������4�	'�C��G��
'���*�*�3��S�9���<���&�8�8��>�G��4�?�?�7�1�:�#>����W�Q�Z�0��?�?�4�(��L�L��&�
'�	'�$�r6c��tj|�}|�ytj|d�}d|}}|j|�s||fSt	j
|�}t	j||jdz|j�}|rtj|d��d}|}t	j||j|jzdz
|j�}|rtj|d��d}|dz}||fS)N�r)r)Frr	r?)rrB�get_column_countr'rr�rr<r
rIr)	r2rRr:�columnCountr"r%rrYrs	         r4r(zUtilities._getTableRowRangeZs����!�!�#�&���=���.�.�u�e�<�� �+�H�
��%�%�c�*��x�'�'��#�#�E�*���2�2�5�$�&�&�1�*�d�f�f�M����1�1�$��O�PQ�R�F��J��2�2�5�$�&�&�4�:�:�:M�PQ�:Q�SW�SY�SY�Z����1�1�$��O�PQ�R�F���z�H��8�#�#r6c�~�tj|d��d}|dk(rgStj|�}|rdtj|�}}n|j	|�\}}||k(rgSg}t||�D]@}tj|||�}	tj|	�s�0|j|	��B|S)NFr?rr))
rrIrBr/r(rJrLrr�rQ)
r2rR�forceFullRowrVr:r"r%r�rXrYs
          r4�getShowingCellsInSameRowz"Utilities.getShowingCellsInSameRowqs����*�*�3��G��J���"�9��I��!�!�#�&���#$�g�&>�&>�u�&E��J�#'�#9�#9�#�#>� �J����!��I����z�8�,�	#�A��&�&�u�c�1�5�D��%�%�d�+����T�"�	#�
�r6c�d���d�d|g}tjtj|d�|r�sytj|�stj
|�ry��fd�}||�r|}nt
j||�}d|d�g}tjtj|d�|S)Nz-SCRIPT UTILITIES: Searching for replicant for�inTc�.���j|�dd��S)NT)r�r�)rPr�s ��r4�isSamez'Utilities.findReplicant.<locals>.isSame�s����$�$�Q��$�D�$�Q�Qr6zHACK: Returningzas replicant for invalid object)rrGrHrr�is_embeddedrr�)r2r�rRrUr7�	replicants` `   r4�
findReplicantzUtilities.findReplicant�s����A�3��d�S��
���%�*�*�F�D�9��������%��)@�)@��)F��	R��$�<��I� �0�0��v�>�I�#�Y�0Q�SV�W��
���%�*�*�F�D�9��r6c��tj|tjj�}|r|j�Stj|�Sr~)rrMrrDrE�
get_n_targetsrhrFs   r4�getFunctionalChildCountz!Utilities.getFunctionalChildCount�sC���(�(��e�.@�.@�.O�.O�P����)�)�+�+��'�'��,�,r6c�\�tj|tjj�}|r|S|j|�r|j
|�S|j|�r |j|j|��Stj|�D�cgc]}|��c}Scc}wr~)rrCrrDrEr�r�r��
valuesForTerm�termForValuer�)r2rR�siblingrGr<s     r4�getFunctionalChildrenzUtilities.getFunctionalChildren�s����.�.�s�E�4F�4F�4U�4U�V����M��%�%�g�.��,�,�S�1�1��,�,�W�5��%�%�d�&7�&7��&@�A�A�#�1�1�#�6�7�a��7�7��7s�	B)c��tj|tjj�}|r|jd�Stj|�Sr9)rrMrrDrNrOr_rFs   r4�getFunctionalParentzUtilities.getFunctionalParent�sE���(�(��e�.@�.@�.N�.N�O����&�&�q�)�)��"�"�3�'�'r6c�8�
�|�ytj|�rU|jd�rDtj|�d}tj
tj|��}||fStj|�rJ|j|�}|r|d}n1d�}|jtj||��}|r|d}ny|j|�}|j|�}|dkDr/|tj|�k(rtj|�|fS|j||�}	t!|	�dkrrtj"|tj�sNt$j&j(t$j&j*g�
�
fd�}
t-t/|
|	��}	|	r||	vsy|j1|�r.t-t/|j0|	��}	t!|	�dk(ry|	j3|�}t!|	�}||fS)Nr.�
readingRowrc�Z�tj|�xstj|�Sr~)rr��is_list_boxr;s r4�isMenuz/Utilities.getPositionAndSetSize.<locals>.isMenu�s#��&�.�.�q�1�O�[�5L�5L�Q�5O�Or6r�c�`��tj|�xrtj|��vSr~)rr^r�)r<�layoutRoless �r4�isNotLayoutOnlyz8Utilities.getPositionAndSetSize.<locals>.isNotLayoutOnly�s)����(�(��+�W��0A�0A�!�0D�K�0W�Wr6r	)rrjr�rrIrKrBr�r�rr�rDr=r_r:rBrFr�rr�rsrrr�r�rKr�)r2rR�argsrV�rowcountr�rIrSr��siblingsrL�position�setSizerKs             @r4�getPositionAndSetSizezUtilities.getPositionAndSetSize�s�����;���$�$�S�)�d�h�h�|�.D��.�.�s�3�A�6�C��,�,�W�->�->�s�-C�D�H���=� ��#�#�C�(��,�,�S�1�H���q�k��P� �0�0��1I�1I�#�v�1V�W���"�1�+�C�!��)�)�#�.���1�1�&�9�
�����(�*=�*=�c�*B� B��/�/��4�j�@�@��-�-�f�c�:���x�=�3��x�'=�'=�c�;�C[�C[�'\� �:�:�/�/����1M�1M�N�K�
X��F�?�H�=�>�H��S�H�_��� � ��%��F�4�#8�#8�(�C�D�H��8�}��!���>�>�#�&���h�-���� � r6c��|j|�sy|r:|j|�s)tj|�}|r|j|�s�)|Sr~)r�r�r�get_previous_siblingrus  r4r@zUtilities.termForValue�sL���0�0��5���$�4�4�S�9��/�/��4�C��$�4�4�S�9��
r6c���|j|�sgSg}tj|�}|rK|j|�r:|j	|�tj|�}|r|j|�r�:|Sr~)r�r�get_next_siblingr�rQ)r2rR�valuess   r4r?zUtilities.valuesForTerm�so���)�)�#�.��I����'�'��,���d�7�7��<��M�M�#���+�+�C�0�C��d�7�7��<��
r6c�6�t|j|��Sr~)rFr?rus  r4�getValueCountForTermzUtilities.getValueCountForTerm�s���4�%�%�c�*�+�+r6c��yr�rt)r2rR�	isBrailles   r4�getRoleDescriptionzUtilities.getRoleDescription�r�r6c	��|jjjdi�}|jt|�d�\}}}d|d|�d|�d|�d�g}t	j
tj|d�|||fS)	N�textSelections)rrr'z&SCRIPT UTILITIES: Cached selection for�is 'r�, r�T)r/r,r�r�rrGrH)r2rRr^r�r	r�rUs       r4�getCachedTextSelectionz Utilities.getCachedTextSelection�s������6�6�:�:�;K�R�P��+�/�/��S�	�:�F���s�F�:�C�4��x�s�SX�RY�Y[�\_�[`�`a�Ab�c��
���%�*�*�F�D�9��c�6�!�!r6c	��|jjjd�rH|j|�d}|s2d|jjd<i|jjd<|jjjdi�}t	|�|vrc|jt	|��}|j
�D�cgc]}|j|�|k(s�|��c}D]}|j|��tj|�\}}}	d|d|�d|�d|	�d	�g}
tjtj|
d
�||	|f|t	|�<||jjd<ycc}w)NrMrFr^z#SCRIPT UTILITIES: New selection forr_rr`r�T)r/r,r�rTr��poprcrrNrrGrH)r2rR�selectedTextr^r~�kr<r�r�r	rUs           r4�updateCachedTextSelectionz#Utilities.updateCachedTextSelection
sg���<�<�(�(�,�,�-E�F��/�/��4�Q�7�L��JO����-�-�.F�G�BD����-�-�.>�?����6�6�:�:�;K�R�P����9��&�"�&�&�t�C�y�1�E�!/�!4�!4�!6�Y�A�.�:L�:L�Q�:O�SX�:X�a�Y�
&���"�"�1�%�
&�$�5�5�c�:����s�7���V�H�C�PU�w�VX�Y\�X]�]^�>_�`��
���%�*�*�F�D�9�$)�3��$6��t�C�y�!�:H����%�%�&6�7��Zs�
E<�'E<c�F�tj�j�}|�ytj�tj
z
dkr(d}t
jtj|d�ytj�t_|j|�y)Ng�������?zDSCRIPT UTILITIES: Clipboard contents change believed to be duplicateT)
rr��getActiveScriptrr"�_last_clipboard_updaterr�rH�onClipboardContentsChanged)rMr3r�s   r4rjz$Utilities.onClipboardContentsChanged
sx���*�*�,�<�<�>���>���9�9�;��9�9�9�D�@�X�C����u�/�/��d�;��+/�9�9�;�	�(�)��)�)�4�0r6c���|j�ytjjtj
j
dd��}|jd|j�|_y)N�	CLIPBOARDFzowner-change)	r0r�	Clipboardr�r�Atom�intern�connectrj�r2�	clipboards  r4�connectToClipboardzUtilities.connectToClipboard(
sR���#�#�/���M�M�%�%�c�h�h�o�o�k�5�&I�J�	�#,�#4�#4��D�;�;�$=�� r6c���|j�ytjjtj
j
dd��}|j|j�y�NrlF)r0rrmr�rrnro�
disconnectrqs  r4�disconnectFromClipboardz!Utilities.disconnectFromClipboard0
sH���#�#�+���M�M�%�%�c�h�h�o�o�k�5�&I�J�	����T�5�5�6r6c��tjjtjjdd��}|j
�Sru)rrmr�rrnro�
wait_for_textrqs  r4�getClipboardContentszUtilities.getClipboardContents7
s4���M�M�%�%�c�h�h�o�o�k�5�&I�J�	��&�&�(�(r6c��tjjtjjdd��}|j
|d�y)NrlFr))rrmr�rrnro�set_text�r2rUrrs   r4�setClipboardTextzUtilities.setClipboardText;
s5���M�M�%�%�c�h�h�o�o�k�5�&I�J�	����4��$r6c��tjjtjjdd��}|j
|j|�yru)rrmr�rrnro�request_text�_appendTextToClipboardCallbackr}s   r4�appendTextToClipboardzUtilities.appendTextToClipboard?
s;���M�M�%�%�c�h�h�o�o�k�5�&I�J�	����t�B�B�D�Ir6c�Z�|jd�}|�|�|��}|j|d�y)Nrr))�rstripr|)r2rrrUr�	separators     r4r�z(Utilities._appendTextToClipboardCallbackC
s2���{�{�4� ����	�{�7�)�,�����4��$r6c���ttjtj�sytj
}|xr%|j
|jj�Srs)	r�rr?rr@rA�isFromApplicationr/r�r�s  r4�lastInputEventCameFromThisAppz'Utilities.lastInputEventCameFromThisAppH
sF���*�3�3�[�5N�5N�O���2�2���B��0�0����1A�1A�B�Br6c�x�tj}t|tj�sy|j�Srs)rr?r�rr@�isPrintableKeyr�s  r4r&z'Utilities.lastInputEventWasPrintableKeyO
s/���)�)���%��!:�!:�;���#�#�%�%r6c�N�|j�\}}|tjzSr~�r$r�CTRL_MODIFIER_MASK�r2�	keyStringr)s   r4�lastInputEventWasCommandz"Utilities.lastInputEventWasCommandV
s%���2�2�4��	�4��k�4�4�4�4r6c��|j�\}}|j�r|tjzS|dvr|tjzSy�N)r!r"F)r$r�r�ALT_MODIFIER_MASKr�r�s   r4�lastInputEventWasPageSwitchz%Utilities.lastInputEventWasPageSwitchZ
sN���2�2�4��	�4���� ��+�7�7�7�7��0�0��+�8�8�8�8�r6c���|j�\}}|dvry|tjzs9|tjzs&|tjzs|tj
zryy)N)�Left�Rightrr FT)r$rr��SHIFT_MODIFIER_MASKr��ORCA_MODIFIER_MASKr�s   r4� lastInputEventWasUnmodifiedArrowz*Utilities.lastInputEventWasUnmodifiedArrowd
s^���2�2�4��	�4��;�;���+�0�0�0��[�4�4�4��[�2�2�2��[�3�3�3��r6c��|j�xs4|j�xs"|j�xs|j�Sr~)�lastInputEventWasCharNav�lastInputEventWasWordNav�lastInputEventWasLineNav� lastInputEventWasLineBoundaryNavr�s r4�lastInputEventWasCaretNavz#Utilities.lastInputEventWasCaretNavq
sH���,�,�.�7��,�,�.�7��,�,�.�7��4�4�6�	7r6c��|j�\}}|dvry|tjzs|tjzryy)N�r�r�FT)r$rr�r�r�s   r4r�z"Utilities.lastInputEventWasCharNavw
sB���2�2�4��	�4��-�-���+�0�0�0��[�2�2�2��r6c�X�|j�\}}|dvry|tjzS)Nr�Fr�r�s   r4r�z"Utilities.lastInputEventWasWordNav�
s1���2�2�4��	�4��-�-���k�4�4�4�4r6c�Z�|j�\}}|dk(sy|tjzS)Nr�Fr�r�s   r4rz&Utilities.lastInputEventWasPrevWordNav�
s0���2�2�4��	�4��F�"���k�4�4�4�4r6c�Z�|j�\}}|dk(sy|tjzS)Nr�Fr�r�s   r4rz&Utilities.lastInputEventWasNextWordNav�
s0���2�2�4��	�4��G�#���k�4�4�4�4r6c��|j�\}}|dvry|jtj�j	��ry|t
jzS)N)rr F�r$r%rr�r�rr�r�s   r4r�z"Utilities.lastInputEventWasLineNav�
sV���2�2�4��	�4��N�*���.�.�}�/G�/G�/I�/\�/\�/^�_���;�9�9�9�:�:r6c�Z�|j�\}}|dvry|tjzS�N)�Home�EndFr�r�s   r4r�z*Utilities.lastInputEventWasLineBoundaryNav�
s3���2�2�4��	�4��O�+���;�9�9�9�:�:r6c��|j�\}}|dvry|jtj�j	��ry|t
jzSr�r�r�s   r4�lastInputEventWasPageNavz"Utilities.lastInputEventWasPageNav�
sW���2�2�4��	�4��4�4���.�.�}�/G�/G�/I�/\�/\�/^�_���;�9�9�9�:�:r6c�X�|j�\}}|dvry|tjzSr�r�r�s   r4� lastInputEventWasFileBoundaryNavz*Utilities.lastInputEventWasFileBoundaryNav�
s0���2�2�4��	�4��O�+���k�4�4�4�4r6c�X�|j�\}}|tjzr|dvSy)N)r�r�rr r�r�F)r$rr�r�s   r4�&lastInputEventWasCaretNavWithSelectionz0Utilities.lastInputEventWasCaretNavWithSelection�
s1���2�2�4��	�4��+�1�1�1�� N�N�N�r6c��|j�\}}|j|�}d|vry|tjzr|tjzSy�N�zF�rCr=rr�r��r2r:r)r
s    r4�lastInputEventWasUndozUtilities.lastInputEventWasUndo�
�T���5�5�7�
����+�+�G�4���h����+�0�0�0��{�>�>�>�?�?�r6c��|j�\}}|j|�}d|vry|tjzr|tjzSyr�r�r�s    r4�lastInputEventWasRedozUtilities.lastInputEventWasRedo�
sQ���5�5�7�
����+�+�G�4���h����+�0�0�0��+�9�9�9�9�r6c��|j�\}}|j|�}d|vry|tjzr|tjzSy)Nr<Fr�r�s    r4�lastInputEventWasCutzUtilities.lastInputEventWasCut�
r�r6c��|j�\}}|j|�}d|vry|tjzr|tjzSy)N�cFr�r�s    r4�lastInputEventWasCopyzUtilities.lastInputEventWasCopy�
r�r6c��|j�\}}|j|�}d|vry|tjzr|tjzSy)N�vFr�r�s    r4�lastInputEventWasPastez Utilities.lastInputEventWasPaste�
r�r6c��|j�\}}|j|�}d|vry|tjzr|tjzSy)NrcFr�r�s    r4�lastInputEventWasSelectAllz$Utilities.lastInputEventWasSelectAll�
r�r6c��|j�\}}|dvry|j�\}}|j|�}d|vry|tjzS)N)rF�	KP_DeleteTr�F)r$rCr=rr�)r2r�r)r:r
s     r4�lastInputEventWasDeletez!Utilities.lastInputEventWasDeletes^���2�2�4��	�4��/�/���5�5�7�
����+�+�G�4���h����k�4�4�4�4r6c��|j�\}}|dvry|tjzs&|tjzs|tjzryy)N)r�ISO_Left_TabFT)r$rr�r�r�r�s   r4�lastInputEventWasTabzUtilities.lastInputEventWasTabsP���2�2�4��	�4��3�3���+�0�0�0��[�2�2�2��[�3�3�3��r6c�R�ttjtj�Sr~)r�rr?r�MouseButtonEventr�s r4�lastInputEventWasMouseButtonz&Utilities.lastInputEventWasMouseButtons���*�3�3�[�5Q�5Q�R�Rr6c��tj}t|tj�r|j
dk(xr|jSy�N�1F�rr?r�rr��button�pressedr�s  r4�"lastInputEventWasPrimaryMouseClickz,Utilities.lastInputEventWasPrimaryMouseClick�8���)�)���e�[�9�9�:��<�<�3�&�8�5�=�=�8�r6c��tj}t|tj�r|j
dk(xr|jSy�N�2Fr�r�s  r4�!lastInputEventWasMiddleMouseClickz+Utilities.lastInputEventWasMiddleMouseClick$r�r6c��tj}t|tj�r|j
dk(xr|jSy�N�3Fr�r�s  r4�$lastInputEventWasSecondaryMouseClickz.Utilities.lastInputEventWasSecondaryMouseClick+r�r6c��tj}t|tj�r|j
dk(xr
|jSyr�r�r�s  r4�$lastInputEventWasPrimaryMouseReleasez.Utilities.lastInputEventWasPrimaryMouseRelease2�;���)�)���e�[�9�9�:��<�<�3�&�<�u�}�}�+<�<�r6c��tj}t|tj�r|j
dk(xr
|jSyr�r�r�s  r4�#lastInputEventWasMiddleMouseReleasez-Utilities.lastInputEventWasMiddleMouseRelease9r�r6c��tj}t|tj�r|j
dk(xr
|jSyr�r�r�s  r4�&lastInputEventWasSecondaryMouseReleasez0Utilities.lastInputEventWasSecondaryMouseRelease@r�r6c�B�tj}|sytj�}||jz
|kDry|jjjdd�}||z
|kryt
|tj�r|j�sXyt
|tj�r=|j|jj�s|j�\}}|dvrytjt!j"�j%��S)NFzlast-table-sort-timeg)r�spacer�)rr?rr/r,r�r�rr�r�r@�isHandledBy�leftClickReviewItemr$rr�rr�r�)r2�deltar��now�lastSortTimer�r)s       r4�lastInputEventWasTableSortz$Utilities.lastInputEventWasTableSortGs����)�)�����i�i�k�������e�#���|�|�4�4�8�8�9O�QT�U������%���e�[�9�9�:��<�<�>��
��{�8�8�
9��$�$�T�\�\�%E�%E�F�"&�":�":�"<��	�4��$<�<� ��*�*�=�+C�+C�+E�+X�+X�+Z�[�[r6c��|j|jtj�j	��rytj|j�stj|j�rytj|j�stj|j�rtj|j�Syr�)rPr�rr�r�rr�rHr�r�r�r�s  r4�!isPresentableExpandedChangedEventz+Utilities.isPresentableExpandedChangedEvent_s������U�\�\�=�+C�+C�+E�+X�+X�+Z�[���#�#�E�L�L�1�[�5L�5L�U�\�\�5Z���#�#�E�L�L�1�[�5J�5J�5�<�<�5X��)�)�%�,�,�7�7�r6c�l�|jjd�s|jjd�sytj|j�s]tj
|j�s>tj|j�stj|j�r(d}tjtj|d�ytj|j�r_|j|j�rytj|j�rytj�j!�rgytj"|j�rGtj$|j�s(d}tjtj|d�ytj�j'�|jt)j*|j�fvryd}tjtj|d�y)Nzobject:text-changed:zobject:text-attributes-changedFz:SCRIPT UTILITIES: Event is not being presented due to roleTzESCRIPT UTILITIES: Event is not being presented due to role and stateszCSCRIPT UTILITIES: Event is not being presented due to lack of cause)rr#r�is_menu_relatedr��	is_slider�is_spin_buttonrJrr�rHr�r�rlrr��
focus_is_deadrjr�r�rr_�r2r�r�s   r4�,isPresentableTextChangedEventForLocusOfFocusz6Utilities.isPresentableTextChangedEventForLocusOfFocusks����z�z�$�$�%;�<��:�:�(�(�)I�J���&�&�u�|�|�4��#�#�E�L�L�1��(�(����6��"�"�5�<�<�0�N�C����u�/�/��d�;���!�!�%�,�,�/�������-���+�+�E�L�L�9���'�'�)�7�7�9��
�
&�
&�u�|�|�
4�[�=T�=T�UZ�Ua�Ua�=b�Y�C����u�/�/��d�;���#�#�%�8�8�:�
�\�\�8�.�.�u�|�|�<�=�>��S��
���5�+�+�S�$�7�r6c��|jjd�sy|j|j�ry|j	�\}}|dk(ryy)N�object:text-changed:deleteFrET)rr#rr�r$)r2r�r�r)s    r4�#isBackSpaceCommandTextDeletionEventz-Utilities.isBackSpaceCommandTextDeletionEvent�sK���z�z�$�$�%A�B���=�=����&���2�2�4��	�4���#��r6c��|jjd�sy|jjd�ry|j�S)Nr�F�system)rr#r�r�r�s  r4� isDeleteCommandTextDeletionEventz*Utilities.isDeleteCommandTextDeletionEvent�s<���z�z�$�$�%A�B���:�:���x�(���+�+�-�-r6c��|jjd�sy|j�sy|j|j�\}}}|S�Nr�F)rr#r�rar��r2r�r�r	r�s     r4�isUndoCommandTextDeletionEventz(Utilities.isUndoCommandTextDeletionEvent�sJ���z�z�$�$�%A�B���)�)�+��!�8�8����F���s�F��z�r6c��|jjd�sy|j�ry|j|j�\}}}|xr+|j�|jj�k(Sr�)rr#r�rar�r�rhr�s     r4�isSelectedTextDeletionEventz%Utilities.isSelectedTextDeletionEvent�se���z�z�$�$�%A�B���&�&�(��!�8�8����F���s�F��B�&�,�,�.�E�N�N�,@�,@�,B�B�Br6c��|jjd�sy|j|j�|j	|j�\}}}|xr ||j
k(xr||jk(S�NrF)rr#rfr�rarhrr�s     r4�isSelectedTextInsertionEventz&Utilities.isSelectedTextInsertionEvent�sg���z�z�$�$�%A�B���&�&�u�|�|�4�!�8�8����F���s�F��M�&�E�N�N�2�M�u��
�
�7M�Mr6c�J�|j�sy|j|�ryyrY)r�rr�s  r4�isSelectedTextRestoredEventz%Utilities.isSelectedTextRestoredEvent�s%���)�)�+���,�,�U�3��r6c�Z�|jjd�sy|j�Sr)rr#r�r�s  r4�%isMiddleMouseButtonTextInsertionEventz/Utilities.isMiddleMouseButtonTextInsertionEvent�s'���z�z�$�$�%A�B���5�5�7�7r6c�|�|jjd�sytj|j�rvtj
|j�sW|jt
j�j�k7r(d}tjtj|d�ytj|j�r#tj�jd�St|j j#��dk(r#tj�jd�Sy)NrFzTSCRIPT UTILITIES: Not echoable text insertion event: focusable source is not focusedT�
enableKeyEchor	r�)rr#rr�r�r�rr�r�rr�rHrlrr�rFrhr�r�s   r4�isEchoableTextInsertionEventz&Utilities.isEchoableTextInsertionEvent�s����z�z�$�$�%A�B���#�#�E�L�L�1��)�)�%�,�,�7��|�|�}�7�7�9�L�L�N�N�3�C����u�/�/��d�;���'�'����5�#�.�.�0�;�;�O�L�L��u�~�~�#�#�%�&�!�+�#�.�.�0�;�;�<S�T�T�r6c�P�|j|�sytj|�Srs)r�rr�rus  r4r�zUtilities.isEditableTextArea�s"�����s�#���&�&�s�+�+r6c�4�|jjd�sy|j�r|j�ry|j	|�ryd|jvr|j�ry|j
|j�sy|j�}|sy|j|k(ryttjd|j��ttjd|��k7ryd|vr|jj�|vryy)Nzobject:text-changedF�deleteTz\wr)rr#r�r�r�r�r�r�rzrhr�r�r�r�)r2r��contentss   r4�isClipboardTextChangedEventz%Utilities.isClipboardTextChangedEvent�s����z�z�$�$�%:�;���,�,�.�$�2L�2L�2N���3�3�E�:���u�z�z�!�d�&A�&A�&C���&�&�u�|�|�4���,�,�.�����>�>�X�%����	�	�%����0�1�T�"�)�)�E�8�:T�5U�U��
�8����� 5� 5� 7�8� C��r6c�p�|xs"tj�j�}|rtj|�ry|j�}|syt
j|�\}}}|r||vry|j|�xs|}tj|�ry|xrtj|�|vSrY)
rr�r�rr�rzrrNrr�)r2rRrr�r�r	s      r4�objectContentsAreInClipboardz&Utilities.objectContentsAreInClipboards����D�]�-�-�/�B�B�D���h�&�&�s�+���,�,�.����#�5�5�c�:����s��f��(���'�'��,�3������C� ���9�x�(�(��-��9�9r6c���d|jjd<d|jjd<d|jjd<d|jjd<y)NF�undo�redo�paster'�last-selection-message)r/r,r�s r4�clearCachedCommandStatez!Utilities.clearCachedCommandStatesS��05����%�%�f�-�05����%�%�f�-�16����%�%�g�.�BD����%�%�&>�?r6c�P�|j�r�|jjjd�sB|jj	t
j�d|jjd<|j|j�y|j�r�|jjjd�sB|jj	t
j�d|jjd<|j|j�yy)NrTrF)r�r/r,r��presentMessager�UNDOrfr�r��REDOr�s  r4�handleUndoTextEventzUtilities.handleUndoTextEvents����%�%�'��<�<�0�0�4�4�V�<����+�+�H�M�M�:�8<����-�-�f�5��*�*�5�<�<�8���%�%�'��<�<�0�0�4�4�V�<����+�+�H�M�M�:�8<����-�-�f�5��*�*�5�<�<�8��r6c��|j�ry|j�rh|jjj	d�sB|jjtj�d|jjd<y|j�rh|jjj	d�sB|jjtj�d|jjd<yy)NFrTr)
rr�r/r,r�rrrr�rr�s r4�handleUndoLocusOfFocusChangez&Utilities.handleUndoLocusOfFocusChange0s����-�-�/���%�%�'��<�<�0�0�4�4�V�<����+�+�H�M�M�:�8<����-�-�f�5���%�%�'��<�<�0�0�4�4�V�<����+�+�H�M�M�:�8<����-�-�f�5��r6c�4�|j�ry|j�rw|jjj	d�sQ|jjtjtj�d|jjd<yy)NFrT)	rr�r/r,r�rr�CLIPBOARD_PASTED_FULL�CLIPBOARD_PASTED_BRIEFr�s r4�handlePasteLocusOfFocusChangez'Utilities.handlePasteLocusOfFocusChangeBss���-�-�/���&�&�(��<�<�0�0�4�4�W�=����+�+��2�2�H�4S�4S�U�9=����-�-�g�6��r6c��yrsrtr�s  r4�eventIsCanvasNoisezUtilities.eventIsCanvasNoiseOrwr6c��yrsrtr�s  r4�eventIsSpinnerNoisezUtilities.eventIsSpinnerNoiseRrwr6c�6�tjs(d}tjtj|d�ytj
�tjj
z
}|dkDr-d|d�d�}tjtj|d�yy)Nz:SCRIPT UTILITIES: Not user triggered: No last input event.TFr	z7SCRIPT UTILITIES: Not user triggered: Last input event z.2fzs ago.)rr?rr�rHr)r2r�r�r�s    r4�eventIsUserTriggeredzUtilities.eventIsUserTriggeredUs~���(�(�N�C����u�/�/��d�;���	�	��j�7�7�<�<�<���1�9�K�E�RU�;�V\�]�C����u�/�/��d�;��r6c�H�|j�ry|j�ryyr�)rr#r�s r4�presentFocusChangeReasonz"Utilities.presentFocusChangeReasoncs#���,�,�.���-�-�/��r6c��tj|�sytj|�rtj|�sytj
|�stj|�rytj|�}|tj|�k(r[tj|d�}tj|�|k7ryd|�d�}tjtj|d�ytj |�S)NFrzSCRIPT UTILITIES: All z! children believed to be selectedT)rr�rr�rAr�r�rhrr��get_selected_childr_rr�rHr�all_cells_are_selected)r2rRr�r�r�s     r4�allItemsSelectedzUtilities.allItemsSelectedjs����*�*�3�/���$�$�S�)�+�2I�2I�#�2N���#�#�C�(�K�,?�,?��,D���-�-�c�2�
���=�=�c�B�B� �2�2�3��:�E��"�"�5�)�S�0��*�:�,�6W�X�C����u�/�/��d�;���-�-�c�2�2r6c�n�|jjjd�}|j|�}|r|ry||jjd<|j	�rQ|rO|jjtj�tj�jd|d�yy)Nr/TF)r/r,r�r/r�rr�CONTAINER_SELECTED_ALLrr�rs)r2rR�allAlreadySelected�allCurrentlySelecteds    r4�handleContainerSelectionChangez(Utilities.handleContainerSelectionChange�s���!�\�\�:�:�>�>�?Q�R��#�4�4�S�9���"6��<P����%�%�&8�9��*�*�,�1E��L�L�'�'��(G�(G�H��$�$�&�9�9�$��U�K��r6c�>�tj|�sy|j|�\}}}|j|�|j|�\}}}|j	t|��ry|j
�s.|r,|s*|jjtj�yg}	tt||��}
tt||��}|
j|�sy|
rY|rW|
j|�sF|	j||tj g�|	j||tj"g��nt%|
j'|��}|sy|d|ddz}}
|
|krn|	j|
|tj"g�|j)|j*�r�||
k(r�t-j.||dz
�}|j1|d�nh|	j|
|tj g�|j)|j*�r+t-j.||dz
�}|j1|d�|xr$t3j4�j7d�}|	D]�\}}}t9j:|||�}|j)|j*�}|r|dz}|jj=|||�|r|s|jj|d��|s��t-j.||�}|j1||���y)NFTrr)r	r�)�	interrupt)rr�rarf�_speakTextSelectionStaterFr�r/�speakMessager�SELECTION_REMOVEDr>rJ�union�intersectionrQ�TEXT_UNSELECTED�
TEXT_SELECTEDr��symmetric_differencer�r�rr[�handleTextSelectionChangerr�r�rry�	sayPhrase)r2rRr8�oldStart�oldEnd�	oldString�newStart�newEndr��changes�oldChars�newChars�change�changeStart�	changeEndr�r�r	�messager��
endsWithChilds                     r4r?z#Utilities.handleTextSelectionChange�s���
�%�%�c�*��&*�&A�&A�#�&F�#��&�)��&�&�s�+�&*�&A�&A�#�&F�#��&�)��(�(��Y��8���:�:�<��S\��L�L�%�%�h�&@�&@�A�����u�X�v�.�/���u�X�v�.�/���~�~�h�'�����)>�)>�x�)H��N�N�H�f�h�.F�.F�G�H��N�N�H�f�h�.D�.D�E�F��H�9�9�(�C�D�F���%+�A�Y��r�
�Q���K��(�"�����Y��8N�8N�O�P��%�%�d�&D�&D�E�&�T_�J_�(�;�;�C��!��L�E��2�2�5�%�@�����Y��8P�8P�Q�R��%�%�d�&D�&D�E�(�;�;�C��!��L�E��2�2�5�%�@�#�W�$�/�/�1�<�<�=U�V�V�	�#*�	D��E�3���)�)�#�u�c�:�F�"�O�O�D�,J�,J�K�M���q����L�L�"�"�3��s�3��M����)�)�'�U�)�C��#�7�7��S�A���.�.�u�l�C�	D�r6c�~�tjtjtjtjgS)�!Hacky and to-be-obsoleted method.)r�PARAGRAPH_SELECTED_DOWN�PARAGRAPH_UNSELECTED_DOWN�PARAGRAPH_SELECTED_UP�PARAGRAPH_UNSELECTED_UPr�s r4�_getCtrlShiftSelectionsStringsz(Utilities._getCtrlShiftSelectionsStrings�s0���0�0��2�2��.�.��0�0�2�	2r6c���tj�jd�ry|j�\}}|tj
z}|tjz}|dkD}d}|dk(r|r|rtj}�n�|dk(r|r|rtj}�nh|dk(r*|r(|s&|rtj}�nKtj}�n9|dk(r*|r(|s&|rtj}�ntj}�n
|dk(r"|r |r|j�}|r|d}n�|d}n�|d	k(r"|r |r|j�}|r|d
}n�|d}n�|dk(r(|r&|r$|rtj}n�tj }n�|d
k(r(|r&|r$|rtj"}nstj}nb|j%�rR|rP|j&j(j+d�s*d|j&j(d<tj,}ny|sy||j&j(j+d�k7r4||j&j(d<|j&j/|�y)rOr�FrNr"r!r r	rrUrTr�r�rMTr)rr�r�r$rr�r�r�LINE_SELECTED_RIGHT�LINE_SELECTED_LEFT�PAGE_SELECTED_DOWN�PAGE_UNSELECTED_DOWN�PAGE_SELECTED_UP�PAGE_UNSELECTED_UPrT�DOCUMENT_SELECTED_UP�DOCUMENT_UNSELECTED_UP�DOCUMENT_SELECTED_DOWNr�r/r,r��DOCUMENT_SELECTED_ALLr8)	r2�nSelectionsrGr)�isControlKey�
isShiftKeyrdr��stringss	         r4r7z"Utilities._speakTextSelectionState�s���&�&�(�3�3�4L�M���1�1�3���$��k�<�<�<���K�;�;�;�
�"�Q�������#����/�/�D��)�#����.�.�D��+�%�:�l���2�2���4�4���)�#��L���0�0���2�2���&� �j�\��9�9�;�G���q�z���q�z���$��J�<��9�9�;�G���q�z���q�z���&� �j�\���4�4���6�6���%��Z�L���6�6���4�4��
�
,�
,�
.�<��<�<�0�0�4�4�5M�N�JN����-�-�.F�G��5�5������4�<�<�0�0�4�4�5M�N�N�FJ�D�L�L�)�)�*B�C��L�L�%�%�d�+�r6c����d}|�+|dz
}tjtj|d�y|�6|jj	d�r|j
j
|�Stj��rUtj��r@tj��r+|dz
}tjtj|d�ytj��sUtj��stj��r+|dz
}tjtj|d�ytj���rAtj ��r+|dz
}tjtj|d�yy�fd	�}�fd
�}tj"�t$j&j(|�r+|dz
}tjtj|d�ytj"�t$j&j(|�r+|dz
}tjtj|d�yy)
Nz<SCRIPT UTILITIES: Not interrupting for locusOfFocus change: z
event is NoneTFz object:active-descendant-changedzsuspected editable cellzsuspected menuitem state changez:old locusOfFocus is ancestor with name of new locusOfFocusc���|�k(Sr~rt)�target�oldLocusOfFocuss �r4�isOldz=Utilities.shouldInterruptForLocusOfFocusChange.<locals>.isOld;�����_�,�,r6c���|�k(Sr~rt)rf�newLocusOfFocuss �r4�isNewz=Utilities.shouldInterruptForLocusOfFocusChange.<locals>.isNew>rir6z*new locusOfFocus controls old locusOfFocusz*old locusOfFocus controls new locusOfFocus)rr�rHrr#r/�#stopSpeechOnActiveDescendantChangedrrjr�r�r��is_check_menu_item�is_radio_menu_itemr�is_ancestorr�rCrrD�CONTROLLER_FOR)r2rgrkr�r�rhrls ``    r4�$shouldInterruptForLocusOfFocusChangez.Utilities.shouldInterruptForLocusOfFocusChanges����L���=��?�"�C����u�/�/��d�;�������!6�!6�7Y�!Z��<�<�C�C�E�J�J��$�$�_�5�+�:M�:M�o�:^��&�&��7��,�,�C����u�/�/��d�;���*�*�?�;��.�.��?��1�1�/�B��4�4�C����u�/�/��d�;�������A�� � ��1��S�S���"�"�5�#3�#3�S�$�?���	-�	-��(�(��).�);�);�)J�)J�E�S��?�?�C����u�/�/��d�;���(�(��).�);�);�)J�)J�E�S��?�?�C����u�/�/��d�;��r6c	��|r|syttd|j�|j��j�d�}d|�d|�d|�d|�d�	}t	j
tj|d�||k\S)	NFrUz&SCRIPT UTILITIES: Similarity between 'z', 'z': z
 (threshold: r�T)�roundrr'�ratiorr�rH)r2�str1�str2�	threshold�
similarityr�s      r4�stringsAreRedundantzUtilities.stringsAreRedundantMs�������?�4�����t�z�z�|�L�R�R�T�VW�X�
�4�T�F�$�t�f�C�
�|�T�$�+�Q�
(�	�	���5�+�+�S�$�7��Y�&�&r6)Tr~)F)FFT)NN)TrT)rr)rs)r�)TT)rT)Nr)F)r)g�?(��__name__�
__module__�__qualname__rrir��ZERO_WIDTH_NO_BREAK_SPACEr�r�r��UNICODE�flagsr�r�r�r�r�r�r�rkr�rWr�r�r5r\rgr)rvr|r�rr(r*r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrr
rrrrrrrrrrr r"r$r&r(r*r,r.r0r2r4r6r8r:r<r>r@rBrDrFrHrJrLrNrPrRrTrVrXrZr\r^r`rbrdrfrhrjrlrnrprrrtrvrxrzr|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�rrrrrrrrrrrr r#r%r'r.r1r;r=r?rArHrKrNrQrWr\rk�staticmethodr�r�r�r�r�r�rPr�rmr,r-r�r�r�r�r�r�r�r|r�rrrrrarrrr�rr r�r�r�rBrGrKrTrSrardrfrirmr�rqrurtrVrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrnrr+r0r4r=rCr$rQr^rerkrorqrwrzr~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
rr&r�r(r3r:r=rBrDrRr@r?rYr\rarfrjrsrwrzr~r�r�r�r&r�r�r�r�r�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�rrrrrr�rrrrrr#r%r'r)r+r/r4r?rTr7rrrzrtr6r4r"r"HsM	��&�T�Y�Y�[�� (�� (��	;��	;��
�J�J�E��r�z�z�(�E�*�H� �b�j�j�1�R�W�W�-?�%@�$A��!D�e�L�O��B�J�J��2�7�7�+;�#<�"=�R�@�%�H�M��"�*�*�Z��/�K�3��&�O�$�N��K�"�M��J�	'�"3�j+�ZF�6�� 6��&L�*E�X�"&�P�-�
\�$�LP�����2�1����J����������������������������������������������������������������������������������������������������:=�
V� 5�D/�4�4�5�@�P�
P�
,�:�b�Y�D�<�H�4��P�T�
2�E�
<�
D�

$�	�V�,���� K�N�R�
 �,Z�R�h�P��P�(�
	R��
� 0�DHM�(,��>-� 3�D�B,A�\$�L�$G�.��A�
D�L����2��8R��(����,V��.
�����&I�;E�z��N
1�
-�$4�L& �P1�����$�
�
)�-�A��&K�A�3�8�"
��(�6�2���2�;��;��$��$�,�\"8�H�2�,�����
*��
*�3�(�T+�&E��8��8�
����� �� �&�6��6� 9B�v�"��"�0�
��
�������0�4�6:�,9�
	�I�0�M�Q��K�3�]�D�
/���A�Q�
'��-�
�/��������� I�H�1�1�N���0	�I �V&"�P#�J�B$�.�*�*-�8�(�/!�b�
�,��"�I�,�1��1�=�7�)�%�J�%�
C�&�5���7�	�5�5�5�;�;�;�5��	�	�	�	�	�	�
5�
�S�������\�0
��B�.��C�N��8��(,�
�@:�&E��"�$�����3�0�D�L2�>�@.�`
'r6r")2�__doc__�__id__�__version__�__date__�
__copyright__�__license__�gir�r�r�difflibr�require_versionrrrrr'r
rrr
rrrrrrrrrrr�ax_componentr�ax_hypertextr�	ax_objectr�ax_selectionr�ax_tabler�ax_textr�ax_utilitiesr�ax_valuer r"rtr6r4�<module>r�s���(C�

������5�
���	�
�	��#�����7�E�"�������������� ����"�%�%��%���%��O@'�O@'r6

Zerion Mini Shell 1.0