
    g
f7                       d Z dZdZdZdZdZddlZddlZddlZddl	Z	ddl
mZ  ej                  d	d
       ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm Z  ddl!m"Z" ddl#m$Z$ dd l%m&Z& dd!l'm(Z( dd"l)m*Z* dd#l+m,Z, dd$l-m.Z. dd%l/m0Z0  G d& d'      Z1y)(zCommonly-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Atspiz2.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   e Zd Z ej                         ZdZdZg dZg dZe	j                  Z e	j                  de      Z e	j                  ddj                  e       de      Z e	j                  ddj                  e       de      Z e	j                  d	e      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ddZd Z d Z!ddZ"d Z#d Z$d Z%d Z&d  Z'dd!Z(dd"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ddmZtdn Zudo Zvdp Zwdq Zxdr Zyds Zzdt Z{du Z|dv Z}dw Z~dx Zdy Zdz Zd{ Zd| Zd} Zd~ Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd ZddZd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd ZddZddZd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd ZddZddZddZd Zd Zd ZddZd Zd Zd Zd Zd Zd Zed        Zd Zd Zd Zd Zd Z	 	 ddZd Zd Zd Zd ZǐddZd Zd ZdÄ ZdĄ Zdń Z͐ddƄZedǄ        ZdȄ ZdɄ Zdʄ Zd˄ Zd̄ Zd̈́ Zd΄ Zdτ ZdЄ ZؐddфZِdd҄Zedӄ        ZېddԄZܐddՄZdք Zdׄ Zd؄ Zdل Zdڄ ZddۄZd܄ Zd݄ Zdބ Zd߄ Zd Zd Zd ZddZd Zd Zd Zd ZddZd Zd Zd ZddZd Zd Zd Zd Zd Zed        Zed        Zd Zd Zd Zd Zed        Z edd       Zd Zd Zd Zd Zed        Zed        Zed         Zed        Z	d Z
ed        Ze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Zy(  	Utilitiesu   ￼u   ﻿)
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)zCreates 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__zUtilities.__init__d   s     #' $&!    c                 t   t        j                  |      sg S t        j                  |      }|g S d }t	        j
                  |t        j                  j                  |      }dt        |      d|dg}t        j                  t        j                  |d       |r|S t        j                  |d      \  }}| j                  |      }t        |dz   t        j                   |d            D ]  }	t        j"                  ||	|      }
t	        j$                  |
t        j                  j&                        }|sK|j)                  d	      }| j+                  ||      r|j-                  |
       | j                  |      |k  s n dt        |      d|d
g}t        j                  t        j                  |d       |S )zGets 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    t        j                  |       dk\  S Nr   )r   get_index_in_parentxs    r4   predz"Utilities.childNodes.<locals>.pred   s    //2a77r6   SCRIPT UTILITIES:zchild nodes forzvia node-parent-ofTFprefer_attributer	   r   zvia 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   
childNodeszUtilities.childNodesu   s    &&s+I""3'>I
	8 --c53E3E3T3TVZ[%s5z3DcK_`%**FD9L //eLSNN3'	sQw 5 5fu UV 
	A&&vq#6D,,T53E3E3S3STH((+F  f-T"'94
	 &s5z3DcK^_%**FD9r6   c                    d|d|g}t        j                  t         j                  |d       |r|sy||k(  r|S |g}t        j                  |      }|r)|j                  |       t        j                  |      }|r)|j                          |g}t        j                  |      }|r)|j                  |       t        j                  |      }|r)|j                          d}t        t        |      t        |            }d}	|	|k  r*| j                  ||	   ||	         r||	   }|	dz  }	nn|	|k  r*d|d|d|g}t        j                  t         j                  |d       |S )	zFinds the common ancestor between Accessible a and Accessible b.

        Arguments:
        - a: Accessible
        - b: Accessible
        z0SCRIPT UTILITIES: Looking for common ancestor ofandTNr   r	   z$SCRIPT UTILITIES: Common ancestor ofis)
r   rG   rH   r   get_parent_checkedrQ   reverseminrF   rP   )
r2   abrU   aParentsrS   bParentscommonAncestor	maxSearchrX   s
             r4   rg   zUtilities.commonAncestor   s_    EaPQR%**FD9a6H3,,Q/OOF#008F  	3,,Q/OOF#008F  	Hs8}5	)m  !hqk:!)!Q )m 9!UAt^\%**FD9r6   c                    	 | j                   j                  | j                     |   S # t        $ rJ | j                  | j                   j                  vr#i | j                   j                  | j                  <   d}Y nw xY w| j	                  |      }|D ]#  }| j                  || j                  |            }% || j                   j                  | j                     |<   | j                   j                  | j                     |   S )aX  If 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*   )r2   rR   labelStringlabelslabels        r4   r)   zUtilities.displayedLabel   s    	<<..t/C/CDSII 	##4<<+F+FFDF++D,@,@AK	
 %%c* 	JE!!+t/A/A%/HI 	J BM##D$8$89#>||**4+?+?@EEs   %( AA;:A;c                      yNF r2   rR   s     r4   preferDescriptionOverNamez#Utilities.preferDescriptionOverName       r6   c                 (   t        j                  |t        j                  j                        }|sg S t        j                  |t        j                  j
                        }||k(  r,d|dg}t        j                  t        j                  |d       g S |S )z(Return a list of objects describing obj.r>   z;'s described-by targets are the same as labelled-by targetsT)	r   rC   r   rD   DESCRIBED_BYLABELLED_BYr   rG   rH   )r2   rR   descriptionsrp   rU   s        r4   descriptionsForObjectzUtilities.descriptionsForObject   s      44S%:L:L:Y:YZI..sE4F4F4R4RS6!)3SUFe..=Ir6   c                 b    | j                  |      }t        t        | j                  |            S N)detailsForObjectlistmapr*   )r2   rR   detailss      r4   detailsContentForObjectz!Utilities.detailsContentForObject  s*    '',C**G455r6   c                 f   t        j                  |t        j                  j                        }|sLt        j                  |      r7t        j                  |      r"t        j                  |      D cg c]  }| }}|s|S g }|D ]$  }|j                  | j                  |d              & |S c c}w )z4Return a list of objects containing details for obj.c                 .    t        j                  |        S r~   )r   is_whitespace_or_emptyr;   s    r4   <lambda>z,Utilities.detailsForObject.<locals>.<lambda>  s    f&C&CA&F"F r6   )r   rC   r   rD   DETAILSr   is_toggle_buttonrA   iter_childrenextendfindAllDescendants)r2   rR   textOnlyr   childtextObjectsdetails          r4   r   zUtilities.detailsForObject	  s     //U5G5G5O5OP;77<'',*2*@*@*EFuFGFN 	IFt66F H I	I
  Gs   2	B.c                    	 | j                   j                  | j                     |   S # t        $ rH | j                  | j                   j                  vr#i | j                   j                  | j                  <   Y nw xY wdj	                  t        | j                  | j                  |                  }|| j                   j                  | j                     |<   | j                   j                  | j                     |   S )z?Returns the text being displayed for the object describing obj. )r/   rj   DISPLAYED_DESCRIPTIONrl   joinr   r*   r|   )r2   rR   strings      r4   r(   zUtilities.displayedDescription  s    	M<<..t/I/IJ3OO 	M))1L1LLJL++D,F,FG	M #d00$2L2LS2QRSGM##D$>$>?D||**4+E+EFsKKs   %( AA98A9c                 &   	 | j                   j                  | j                     |   S # t        $ r d}Y nw xY wt	        j
                  |      }t	        j                  |      }|t        j                  j                  t        j                  j                  fv r|r|S t        j                  |      }| j                  |v rd}|s8|t        j                  j                  t        j                  j                  fvr|}|s|t        j                  j                  t        j                  j                   fv rN| j#                  |d      }|s| j#                  |dd      }dj%                  t'        | j(                  |            }| j                  | j                   j                  vr#i | j                   j                  | j                  <   || j                   j                  | j                     |<   | j                   j                  | j                     |   S )zReturns 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_TEXTrl   r   get_nameget_roler   RolePUSH_BUTTONLABELr   get_all_textEMBEDDED_OBJECT_CHARACTER	COMBO_BOXSPIN_BUTTON	LIST_ITEMunrelatedLabelsr   r   r*   )r2   rR   r*   namerolerp   s         r4   r*   zUtilities.displayedText)  s   	!<<..t/B/BCCHH 	! M	!   %  %EJJ**EJJ,<,<==$K++C0))]: Mejj.B.BEJJDZDZ-[![ !M%***@*@%**BVBV)W!W))#A)>F--cuST-UHHS););V%DEMdll&A&AA?ADLL''(;(;<@M##D$7$78=||**4+>+>?DDs   %( 66Nc                     |s| j                         \  }}t        j                  |t        j                        }|r|S t        j                         j                         }t        j                  |      r|S y)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)r2   rR   offsetdocumentfocuss        r4   documentFramezUtilities.documentFrameU  sf     ..0KC))#{/F/FGO((*==?""5)Lr6   c                 z   ddg}|xs" t        j                         j                         }|s)d}t        j                  t        j
                  |d       |S | j                  |      }|+d|g}t        j                  t        j
                  |d       |S t        j                  j                  t        j                  j                  g| j                         r)j                  t        j                  j                         t        j                   |      }|v r||d<   ng|t        j                  j"                  t        j                  j$                  fv r||d<   fd} ||      r||d<   nt        j&                  ||      |d<   d|d	|d   d
|d   g}t        j                  t        j
                  |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	   r   c                 2    t        j                  |       v S r~   )r   r   )r<   dialog_roless    r4   isDialogz*Utilities.frameAndDialog.<locals>.isDialog  s    ((+|;;r6   r>   zis in framez
and dialog)r   r   r   r   printMessagerH   topLevelObjectrG   r   r   DIALOGFILE_CHOOSER_treatAlertsAsDialogsrQ   ALERTr   r   FRAMEWINDOWr   )	r2   rR   resultsmsgtopLevelrU   r   r   r   s	           @r4   frameAndDialogzUtilities.frameAndDialogf  s    ,D]--/BBDRCu//d;N&&s+MsSFe..=N

))5::+B+BC%%'

 0 01  *<!GAJ

((%***;*;<<%
< } 
%33CB
%sM71:|U\]^U_`%**FD9r6   c                 d    |j                   t        j                         j                         k(  ryyNTF)sourcer   r   r   r2   events     r4    presentEventFromNonShowingObjectz*Utilities.presentEventFromNonShowingObject  s&    <<=335HHJJr6   c                 ,    t        j                  |      S r~   )r   is_focusableru   s     r4   grabFocusWhenSettingCaretz#Utilities.grabFocusWhenSettingCaret  s    '',,r6   c                     t        j                  |      xr3 | j                  |t        j                         j                                S )ay  Whether 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_boxrP   r   r   r   r2   rR   r   s      r4   grabFocusBeforeRoutingz Utilities.grabFocusBeforeRouting  sC     '', \%%c=+C+C+E+X+X+Z[[	\r6   c                     |}|D ]r  }| yt        |t              s|g}t        |d   t              rt        j                  |      }nt        j
                  |      }||vr yt        j                  |      }t y)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.
        Fr   T)
isinstancer   strr   get_role_namer   r`   )r2   rR   	rolesListcurrentr   current_roles         r4   hasMatchingHierarchyzUtilities.hasMatchingHierarchy  s    $  	;DdD)v$q'3''55g>'0094'11':G	;" r6   c                     |"t        j                         j                         }t        j                  |      syt        j                  |t        j                        d uS rs   )r   r   r   r   is_entryr   r   is_tool_barru   s     r4   inFindContainerzUtilities.inFindContainer  sM    ;**,??AC##C(%%c;+B+BC4OOr6   c                      yNr'   rt   r2   roots     r4   getFindResultsCountzUtilities.getFindResultsCount      r6   c                      yrs   rt   ru   s     r4   isAnchorzUtilities.isAnchor  rw   r6   c                      yrs   rt   ru   s     r4   isCodezUtilities.isCode  rw   r6   c                      yrs   rt   ru   s     r4   isCodeDescendantzUtilities.isCodeDescendant  rw   r6   c                     t        j                  |      syt        j                  |      }|j	                  d      dk(  S )NFzwindow-typedockr   is_framer   get_attributes_dictgetr2   rR   attrss      r4   isDockedFramezUtilities.isDockedFrame  s7    ##C(,,S1yy'611r6   c                     t        j                  |      syt        j                  |      }|j	                  d      dk(  S )NFz
is-desktoptruer   r   s      r4   	isDesktopzUtilities.isDesktop  s7    ##C(,,S1yy&&00r6   c                      yrs   rt   ru   s     r4   isComboBoxWithToggleDescendantz(Utilities.isComboBoxWithToggleDescendant  rw   r6   c                      yrs   rt   ru   s     r4   isToggleDescendantOfComboBoxz&Utilities.isToggleDescendantOfComboBox  rw   r6   c                      yrs   rt   ru   s     r4   isTypeaheadzUtilities.isTypeahead  rw   r6   c                 B    |k(  ryt        j                  |fd      S )NTc                     | xr | k(  S r~   rt   )r<   ancestors    r4   r   z,Utilities.isOrDescendsFrom.<locals>.<lambda>  s    Q5H1= r6   r   r   )r2   rR   r   s     `r4   isOrDescendsFromzUtilities.isOrDescendsFrom  s!    (?%%c+HIIr6   c                      y)zReturns True if the window is a functioning as a dialog.
        This method should be subclassed by application scripts as
        needed.
        Frt   ru   s     r4   isFunctionalDialogzUtilities.isFunctionalDialog  s     r6   c                      yrs   rt   ru   s     r4   	isCommentzUtilities.isComment  rw   r6   c                      yrs   rt   ru   s     r4   isContentDeletionzUtilities.isContentDeletion	  rw   r6   c                      yrs   rt   ru   s     r4   isContentErrorzUtilities.isContentError  rw   r6   c                      yrs   rt   ru   s     r4   isContentInsertionzUtilities.isContentInsertion  rw   r6   c                      yrs   rt   ru   s     r4   isContentMarkedzUtilities.isContentMarked  rw   r6   c                      yrs   rt   ru   s     r4   isContentSuggestionzUtilities.isContentSuggestion  rw   r6   c                      yrs   rt   ru   s     r4   isInlineSuggestionzUtilities.isInlineSuggestion  rw   r6   c                      yrs   rt   ru   s     r4   $isFirstItemInInlineContentSuggestionz.Utilities.isFirstItemInInlineContentSuggestion  rw   r6   c                      yrs   rt   ru   s     r4   #isLastItemInInlineContentSuggestionz-Utilities.isLastItemInInlineContentSuggestion  rw   r6   c                      yrs   rt   ru   s     r4   isEmptyzUtilities.isEmpty!  rw   r6   c                      yrs   rt   ru   s     r4   isHiddenzUtilities.isHidden$  rw   r6   c                      yrs   rt   ru   s     r4   isDPubzUtilities.isDPub'  rw   r6   c                      yrs   rt   ru   s     r4   isDPubAbstractzUtilities.isDPubAbstract*  rw   r6   c                      yrs   rt   ru   s     r4   isDPubAcknowledgmentszUtilities.isDPubAcknowledgments-  rw   r6   c                      yrs   rt   ru   s     r4   isDPubAfterwordzUtilities.isDPubAfterword0  rw   r6   c                      yrs   rt   ru   s     r4   isDPubAppendixzUtilities.isDPubAppendix3  rw   r6   c                      yrs   rt   ru   s     r4   isDPubBibliographyzUtilities.isDPubBibliography6  rw   r6   c                      yrs   rt   ru   s     r4   isDPubBacklinkzUtilities.isDPubBacklink9  rw   r6   c                      yrs   rt   ru   s     r4   isDPubBibliorefzUtilities.isDPubBiblioref<  rw   r6   c                      yrs   rt   ru   s     r4   isDPubChapterzUtilities.isDPubChapter?  rw   r6   c                      yrs   rt   ru   s     r4   isDPubColophonzUtilities.isDPubColophonB  rw   r6   c                      yrs   rt   ru   s     r4   isDPubConclusionzUtilities.isDPubConclusionE  rw   r6   c                      yrs   rt   ru   s     r4   isDPubCoverzUtilities.isDPubCoverH  rw   r6   c                      yrs   rt   ru   s     r4   isDPubCreditzUtilities.isDPubCreditK  rw   r6   c                      yrs   rt   ru   s     r4   isDPubCreditszUtilities.isDPubCreditsN  rw   r6   c                      yrs   rt   ru   s     r4   isDPubDedicationzUtilities.isDPubDedicationQ  rw   r6   c                      yrs   rt   ru   s     r4   isDPubEndnotezUtilities.isDPubEndnoteT  rw   r6   c                      yrs   rt   ru   s     r4   isDPubEndnoteszUtilities.isDPubEndnotesW  rw   r6   c                      yrs   rt   ru   s     r4   isDPubEpigraphzUtilities.isDPubEpigraphZ  rw   r6   c                      yrs   rt   ru   s     r4   isDPubEpiloguezUtilities.isDPubEpilogue]  rw   r6   c                      yrs   rt   ru   s     r4   isDPubErratazUtilities.isDPubErrata`  rw   r6   c                      yrs   rt   ru   s     r4   isDPubExamplezUtilities.isDPubExamplec  rw   r6   c                      yrs   rt   ru   s     r4   isDPubFootnotezUtilities.isDPubFootnotef  rw   r6   c                      yrs   rt   ru   s     r4   isDPubForewordzUtilities.isDPubForewordi  rw   r6   c                      yrs   rt   ru   s     r4   isDPubGlossaryzUtilities.isDPubGlossaryl  rw   r6   c                      yrs   rt   ru   s     r4   isDPubGlossrefzUtilities.isDPubGlossrefo  rw   r6   c                      yrs   rt   ru   s     r4   isDPubIndexzUtilities.isDPubIndexr  rw   r6   c                      yrs   rt   ru   s     r4   isDPubIntroductionzUtilities.isDPubIntroductionu  rw   r6   c                      yrs   rt   ru   s     r4   isDPubPagelistzUtilities.isDPubPagelistx  rw   r6   c                      yrs   rt   ru   s     r4   isDPubPagebreakzUtilities.isDPubPagebreak{  rw   r6   c                      yrs   rt   ru   s     r4   
isDPubPartzUtilities.isDPubPart~  rw   r6   c                      yrs   rt   ru   s     r4   isDPubPrefacezUtilities.isDPubPreface  rw   r6   c                      yrs   rt   ru   s     r4   isDPubProloguezUtilities.isDPubPrologue  rw   r6   c                      yrs   rt   ru   s     r4   isDPubPullquotezUtilities.isDPubPullquote  rw   r6   c                      yrs   rt   ru   s     r4   	isDPubQnazUtilities.isDPubQna  rw   r6   c                      yrs   rt   ru   s     r4   isDPubSubtitlezUtilities.isDPubSubtitle  rw   r6   c                      yrs   rt   ru   s     r4   	isDPubToczUtilities.isDPubToc  rw   r6   c                      yrs   rt   ru   s     r4   isFeedzUtilities.isFeed  rw   r6   c                      yrs   rt   ru   s     r4   isFeedArticlezUtilities.isFeedArticle  rw   r6   c                      yrs   rt   ru   s     r4   isFigurezUtilities.isFigure  rw   r6   c                      yrs   rt   ru   s     r4   isGridzUtilities.isGrid  rw   r6   c                      yrs   rt   ru   s     r4   
isGridCellzUtilities.isGridCell  rw   r6   c                      yrs   rt   ru   s     r4   
isLandmarkzUtilities.isLandmark  rw   r6   c                      yrs   rt   ru   s     r4   isLandmarkWithoutTypezUtilities.isLandmarkWithoutType  rw   r6   c                      yrs   rt   ru   s     r4   isLandmarkBannerzUtilities.isLandmarkBanner  rw   r6   c                      yrs   rt   ru   s     r4   isLandmarkComplementaryz!Utilities.isLandmarkComplementary  rw   r6   c                      yrs   rt   ru   s     r4   isLandmarkContentInfozUtilities.isLandmarkContentInfo  rw   r6   c                      yrs   rt   ru   s     r4   isLandmarkFormzUtilities.isLandmarkForm  rw   r6   c                      yrs   rt   ru   s     r4   isLandmarkMainzUtilities.isLandmarkMain  rw   r6   c                      yrs   rt   ru   s     r4   isLandmarkNavigationzUtilities.isLandmarkNavigation  rw   r6   c                      yrs   rt   ru   s     r4   isDPubNoterefzUtilities.isDPubNoteref  rw   r6   c                      yrs   rt   ru   s     r4   isLandmarkRegionzUtilities.isLandmarkRegion  rw   r6   c                      yrs   rt   ru   s     r4   isLandmarkSearchzUtilities.isLandmarkSearch  rw   r6   c                      yrs   rt   ru   s     r4   isSVGzUtilities.isSVG  rw   r6   c                      yrs   rt   ru   s     r4   speakMathSymbolNameszUtilities.speakMathSymbolNames  rw   r6   c                      yrs   rt   r2   s    r4   isInMathzUtilities.isInMath  rw   r6   c                      yrs   rt   ru   s     r4   isMathzUtilities.isMath  rw   r6   c                      yrs   rt   ru   s     r4   isMathLayoutOnlyzUtilities.isMathLayoutOnly  rw   r6   c                      yrs   rt   ru   s     r4   isMathMultilinezUtilities.isMathMultiline  rw   r6   c                      yrs   rt   ru   s     r4   isMathEnclosedzUtilities.isMathEnclosed  rw   r6   c                      yrs   rt   ru   s     r4   isMathFencedzUtilities.isMathFenced  rw   r6   c                      yrs   rt   ru   s     r4   isMathFractionWithoutBarz"Utilities.isMathFractionWithoutBar  rw   r6   c                      yrs   rt   ru   s     r4   isMathPhantomzUtilities.isMathPhantom  rw   r6   c                      yrs   rt   ru   s     r4   isMathMultiScriptzUtilities.isMathMultiScript  rw   r6   c                      yrs   rt   ru   s     r4   isMathSubOrSuperScriptz Utilities.isMathSubOrSuperScript  rw   r6   c                      yrs   rt   ru   s     r4   isMathUnderOrOverScriptz!Utilities.isMathUnderOrOverScript  rw   r6   c                      yrs   rt   ru   s     r4   isMathSquareRootzUtilities.isMathSquareRoot  rw   r6   c                      yrs   rt   ru   s     r4   isMathTablezUtilities.isMathTable  rw   r6   c                      yrs   rt   ru   s     r4   isMathTableRowzUtilities.isMathTableRow  rw   r6   c                      yrs   rt   ru   s     r4   isMathTableCellzUtilities.isMathTableCell  rw   r6   c                      yrs   rt   ru   s     r4   isMathTokenzUtilities.isMathToken  rw   r6   c                      yrs   rt   ru   s     r4   isMathTopLevelzUtilities.isMathTopLevel  rw   r6   c                      y r~   rt   ru   s     r4   getMathDenominatorzUtilities.getMathDenominator      r6   c                      y r~   rt   ru   s     r4   getMathNumeratorzUtilities.getMathNumerator  r  r6   c                      y r~   rt   ru   s     r4   getMathRootBasezUtilities.getMathRootBase  r  r6   c                      y r~   rt   ru   s     r4   getMathRootIndexzUtilities.getMathRootIndex  r  r6   c                      y r~   rt   ru   s     r4   getMathScriptBasezUtilities.getMathScriptBase  r  r6   c                      y r~   rt   ru   s     r4   getMathScriptSubscriptz Utilities.getMathScriptSubscript  r  r6   c                      y r~   rt   ru   s     r4   getMathScriptSuperscriptz"Utilities.getMathScriptSuperscript  r  r6   c                      y r~   rt   ru   s     r4   getMathScriptUnderscriptz"Utilities.getMathScriptUnderscript  r  r6   c                      y r~   rt   ru   s     r4   getMathScriptOverscriptz!Utilities.getMathScriptOverscript  r  r6   c                     g S r~   rt   ru   s     r4   getMathPrescriptszUtilities.getMathPrescripts      	r6   c                     g S r~   rt   ru   s     r4   getMathPostscriptszUtilities.getMathPostscripts  r  r6   c                     g S r~   rt   ru   s     r4   getMathEnclosureszUtilities.getMathEnclosures  r  r6   c                     dgS r   rt   ru   s     r4   getMathFencedSeparatorsz!Utilities.getMathFencedSeparators   s	    tr6   c                 
    ddgS r   rt   ru   s     r4   getMathFenceszUtilities.getMathFences#  s    Bxr6   c                      yr9   rt   )r2   rR   tests      r4   getMathNestingLevelzUtilities.getMathNestingLevel&  s    r6   c                 
    g dS )N)bannercomplementarycontentinfozdoc-acknowledgmentszdoc-afterwordzdoc-appendixzdoc-bibliographyzdoc-chapterzdoc-conclusionzdoc-creditszdoc-endnoteszdoc-epiloguez
doc-erratazdoc-forewordzdoc-glossaryz	doc-indexzdoc-introductionzdoc-pagelistzdoc-partzdoc-prefacezdoc-prologuezdoc-tocformmain
navigationregionsearchrt   r  s    r4   getLandmarkTypeszUtilities.getLandmarkTypes)  s     	r6   c                 \    t        j                  |      syt        j                  |      d uS rs   )r   is_progress_barr    get_value_as_percentru   s     r4   isProgressBarzUtilities.isProgressBarF  s)    **3/++C0<<r6   c                     | j                  | j                  |      t        j                         j	                               S r~   )rP   r   r   r   get_active_windowru   s     r4   topLevelObjectIsActiveWindowz&Utilities.topLevelObjectIsActiveWindowK  s9      $m&>&>&@&R&R&TV 	Vr6   c                    t        j                         j                  d      sGt        j                         j                  d      s$t        j                         j                  d      sy| j                  |      syt	        j
                  |      ryt        j                         j                  d      r%t        j                  |t        j                        ryt        j                         j                  d	      }|t        j                  k(  ry
|t        j                  k(  r| j                  |      ryy|t        j                  k(  r>t        j                  |      }t!        j                         j#                         }||k(  ryyy)NspeakProgressBarUpdatesbrailleProgressBarUpdatesbeepProgressBarUpdates)FzUpdates not enabled)FzIs not progress bar)FzHas no sizeignoreStatusBarProgressBars)FzIs status bar descendantprogressBarVerbosity)TzVerbosity is all)TzVerbosity is window)Fz%Top-level object is not active window)TzVerbosity is app)FzApp is not active app)TzNot handled by any other case)r   r   
getSettingr  r   has_no_sizer   r   r   is_status_barr   PROGRESS_BAR_ALLPROGRESS_BAR_WINDOWr  PROGRESS_BAR_APPLICATIONget_applicationr   getActiveScriptApp)r2   rR   	verbosityapp	activeApps        r4   isProgressBarUpdatezUtilities.isProgressBarUpdateO  s3   **,778QR#..0;;<WX#..0;;<TU/!!#&/""3''&&(334Q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HIi/14r6   c                 ,    t        j                  |      S r~   )r   is_block_quoteru   s     r4   isBlockquotezUtilities.isBlockquoteq  s    ))#..r6   c                 ,    t        j                  |      S r~   )r   is_description_listru   s     r4   isDescriptionListzUtilities.isDescriptionListt      ..s33r6   c                 ,    t        j                  |      S r~   )r   is_description_termru   s     r4   isDescriptionListTermzUtilities.isDescriptionListTermw  r  r6   c                 ,    t        j                  |      S r~   )r   is_description_valueru   s     r4   isDescriptionListDescriptionz&Utilities.isDescriptionListDescriptionz  s    //44r6   c                 ~    | j                  |      sg S | j                  }| j                   }| j                  |||      S r~   )r  r  r   )r2   rR   _include_excludes       r4   descriptionListTermszUtilities.descriptionListTerms}  s@    %%c*I--))&&sHh??r6   c                     t        j                  |      t        j                  j                  t        j                  j
                  fvryt        j                  |t        j                        d uS rs   )	r   r   r   r   LISTDESCRIPTION_LISTr   r   r   ru   s     r4   isDocumentListzUtilities.isDocumentList  sM    S!%**//5::;V;V)WW%%c;+B+BC4OOr6   c                 z    t        j                  |      syt        j                  |t         j                        d uS rs   )r   is_panelr   r   r   ru   s     r4   isDocumentPanelzUtilities.isDocumentPanel  s1    ##C(%%c;+B+BC4OOr6   c                 ,    t        j                  |      S r~   )r   r   ru   s     r4   
isDocumentzUtilities.isDocument  s    &&s++r6   c                 t    |xs" t        j                         j                         }| j                  |      d uS r~   )r   r   r   getDocumentForObjectru   s     r4   inDocumentContentzUtilities.inDocumentContent  s4    D]--/BBD((-T99r6   c                 d    | j                  t        j                         j                               S r~   )getTopLevelDocumentForObjectr   r   r   )r2   windows     r4   activeDocumentzUtilities.activeDocument  s%    001I1I1K1^1^1`aar6   c                 j    | j                  |      xr! t        j                  || j                          S r~   r  r   r   ru   s     r4   isTopLevelDocumentzUtilities.isTopLevelDocument  s*    s#XH,B,B3,X(XXr6   c                 h    | j                  |      r|S t        j                  || j                         S r~   )r  r   r   ru   s     r4   r  z&Utilities.getTopLevelDocumentForObject  s.    ""3'J%%c4+B+BCCr6   c                 n    |sy | j                  |      r|S t        j                  || j                         S r~   r
  ru   s     r4   r  zUtilities.getDocumentForObject  s0    ??3J%%c4??;;r6   c                 ~    |syt        j                  |      r|S t        j                  |t         j                        S rs   )r   is_modal_dialogr   r   ru   s     r4   getModalDialogzUtilities.getModalDialog  s4    &&s+J%%c;+F+FGGr6   c                 .    |sy| j                  |      d uS rs   )r  ru   s     r4   isModalDialogDescendantz!Utilities.isModalDialogDescendant  s    ""3't33r6   c                     |S r~   rt   )r2   columns     r4   columnConvertzUtilities.columnConvert  s    r6   c                     t        j                  |      sy| j                  |      }|d uxr t        j                  |       S rs   )r   is_tabler  is_document_spreadsheetr2   rR   docs      r4   isTextDocumentTablezUtilities.isTextDocumentTable  s@    ##C('',$O{'J'J3'O#OOr6   c                 V    t        j                  |      xr | j                  |      d u S r~   )r   r  r  ru   s     r4   
isGUITablezUtilities.isGUITable  s(    ##C(ST-F-Fs-Kt-SSr6   c                     t        j                  |      rt        j                  |      sy| j	                  |      }|yt        j
                  |      ryt        j                  |      dkD  S )NFTi   )r   r  r   supports_tabler  r  r   rK   r  s      r4   isSpreadSheetTablezUtilities.isSpreadSheetTable  s_    $$S)h.E.Ec.J'',;..s3$$S)E11r6   c                 n    t        j                  |      syt        j                  || j                        S rs   )r   is_table_cell_or_headerr   r   r  ru   s     r4   isTextDocumentCellzUtilities.isTextDocumentCell  s,    2237%%c4+C+CDDr6   c                 n    t        j                  |      syt        j                  || j                        S rs   )r   r"  r   r   r  ru   s     r4   	isGUICellzUtilities.isGUICell  s*    2237%%c4??;;r6   c                 n    t        j                  |      syt        j                  || j                        S rs   )r   r"  r   r   r   ru   s     r4   isSpreadSheetCellzUtilities.isSpreadSheetCell  s,    2237%%c4+B+BCCr6   c                     t        j                  |      d   }|dk(  ry|*| j                  j                  j	                  d      }||k7  S t        j                  |      d   }||k7  S )Nr	   F
lastColumnr   rI   r/   pointOfReferencer   )r2   rY   prevCellr  r*  s        r4   cellColumnChangedzUtilities.cellColumnChanged  sp    --d3A6R<66::<HJ ## !55h?BJ##r6   c                     t        j                  |      d   }|dk(  ry|*| j                  j                  j	                  d      }||k7  S t        j                  |      d   }||k7  S )Nr   r)  FlastRowr+  )r2   rY   r-  rV   r0  s        r4   cellRowChangedzUtilities.cellRowChanged  sn    **403"9ll3377	BG g~ 228<Q?Gg~r6   c                    | j                   j                         ry| j                   j                         j                         ry| j	                  ||      syt        j                  |      }|y| j                  |      s#t        j                         j                  d      S | j                  |      r#t        j                         j                  d      S t        j                         j                  d      S )NFreadFullRowInGUITablereadFullRowInSpreadSheetreadFullRowInDocumentTable)r/   inSayAllgetTableNavigator'last_input_event_was_navigation_commandr1  r   rB   r  r   r   r  r   )r2   rR   prevObjtables       r4   shouldReadFullRowzUtilities.shouldReadFullRow  s    <<  "<<))+SSU""30!!#&=((/#..0;;<STT""5)#..0;;<VWW**,778TUUr6   c                      yrs   rt   ru   s     r4   isSortedzUtilities.isSorted  rw   r6   c                      yrs   rt   ru   s     r4   isAscendingzUtilities.isAscending  rw   r6   c                      yrs   rt   ru   s     r4   isDescendingzUtilities.isDescending  rw   r6   c                 8   |r| j                  |      sy| j                  |      rt        j                  }n2| j	                  |      rt        j
                  }nt        j                  }|r/t        j                  |      rt        j                  |       d| }|S )Nr'   z. )	r=  r?  r   SORT_ORDER_ASCENDINGrA  SORT_ORDER_DESCENDINGSORT_ORDER_OTHERr   r   )r2   rR   includeNameresults       r4   getSortOrderDescriptionz!Utilities.getSortOrderDescription  s    c*C &;;Fs#&<<F&77F8,,S1 ))#./r&:Fr6   c                 Z    t        j                  |      xr t        j                  |      S r~   )r   is_labelr   ru   s     r4   isFocusableLabelzUtilities.isFocusableLabel(  s#    ##C(J[-E-Ec-JJr6   c                 \    t        j                  |      xr t        j                  |       S r~   )r   is_listr   ru   s     r4   isNonFocusableListzUtilities.isNonFocusableList+  s&    ""3'M0H0H0M,MMr6   c                 z    t        j                  |      syt        j                  |t         j                        d uS rs   )r   is_notificationr   r   r  ru   s     r4   isStatusBarNotificationz!Utilities.isStatusBarNotification.  s1    **3/%%c;+D+DETQQr6   c           
         t        j                  |      syg }t        j                  |      }|r|j	                  |       | j                  |      }|r||vr|j	                  |       nMdj                  t        | j                  | j                  |dd                  }|r||vr|j	                  |       t        j                  |      }|r||vr|j	                  |       dj                  |      S )Nr'   r   Fr	   )r   rP  r   r   rQ   
expandEOCsr   r   r*   r   get_description)r2   rR   rU   r   textrp   descriptions          r4   getNotificationContentz Utilities.getNotificationContent3  s    **3/  %MM$s#D&MM$XXc$"4"4d6J6J3PUWX6YZ[F&.f%..s3;f4MM+&xxr6   c                     |yt        j                  |      ryt        j                  |t         j                        d uS NFT)r   is_tree_itemr   r   is_tree_or_tree_tableru   s     r4   isTreeDescendantzUtilities.isTreeDescendantI  s:    ;##C(%%c;+L+LMUYYYr6   c                    d}t        j                  |      syt        j                  |      }t        j                  t        j                  |            }t        j                  |d      }| j                         }t        j                  j                  t        j                  j                  t        j                  j                  t        j                  j                  g}|t        j                  j                  k(  rt        j                  |      }n |t        j                  j                  k(  rt        j                   |      r|t        j                  j"                  k(  rt        j$                  |       }nt'        j(                  |      rd}n|t        j                  j                  k(  rb| j+                  t        j                  |            }n<|t        j                  j,                  k(  r| j/                  |       }n|t        j                  j0                  k(  rd}n|t        j                  j2                  k(  rd}n|t        j                  j4                  k(  rd}n|t        j                  j6                  k(  r"| j9                  | j;                  |            }ni|t        j                  j<                  k(  rd}nH|t        j                  j>                  t        j                  j@                  fv rd}n|t        j                  jB                  t        j                  j"                  fv rd}n||v rd}n|t        j                  j                  k(  r|t        j                  jD                  k(  }n|t        j                  jD                  k(  rd}no|t        j                  jF                  k(  rd}nN|t        j                  jH                  k(  rd}n-|t        j                  jJ                  t        j                  jL                  fv rd}n|t        j                  jN                  t        j                  jP                  t        j                  jR                  fv rd}n|t        j                  j                  k(  r!|t        j                  jB                  k(  rd}nb|t        j                  jT                  t        j                  jV                  fv rd}n(| jY                  |      r.t'        jZ                  |      xs t'        j\                  |       }n|t        j                  j^                  k(  rt        j                  |      |v rd}n|t        j                  j^                  k(  r,t        j`                  |t        jb                  |            rd}nit        j                   |      dk(  rt        j`                  ||      rd}n8| je                  |      rd}n$| jg                  |      s| ji                  |      sd}|r*d|dg}tk        jl                  tj        jn                  |d       |S )zReturns True if the given object is a container which has
        no presentable information (label, name, displayed text, etc.).FTr   r	   r>   zis deemed to be layout only)8r   is_validr   
get_parent	get_child_topLevelRolesr   r   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  r  r*   r)   r   rG   rH   )	r2   rR   
layoutOnlyr   
parentRole
firstChildtopLevelRolesignorePanelParentrU   s	            r4   rk  zUtilities.isLayoutOnlyR  si    
  %  %&&x':':3'?@
''Q/
++-"ZZ__"ZZ11"ZZ11"ZZ113
 5::### 005JUZZ***x/G/G/LUZZ222!)!2!23!77
**:6!
uzz///!..x/B/B3/GH
UZZ'''!..s33JUZZ+++JUZZ&&&JUZZ+++JUZZ,,,(;(;C(@AJUZZ,,,Jejj22EJJ4H4HIIJejj))5::+@+@AAJ]"JUZZ__$#uzz';';;JUZZ)))JUZZ__$JUZZ__$Jejj,,ejj.F.FGGJejjoouzz'?'?AQAQRRJUZZ)))jEJJ<O<O.OJejj115::3E3EFFJ__S!)66s;]{?X?XY\?]^JUZZ%%%(*;*;J*GK\*\JUZZ%%%44S(:R:RSV:WXJ%%c*a/44S*EJ]]3J&&s+t/B/B3/G!
)30MNFe..=r6   c                     t        j                         j                         }| r|syt        j                  |      t        j                  |       k(  S )zReturns True if the given object is from the same application that
        currently has keyboard focus.

        Arguments:
        - obj: an Accessible object
        F)r   r   r   r   r  )rR   r   s     r4   isInActiveAppzUtilities.isInActiveApp  sD     ((*==?''.(2J2J32OOOr6   c                 ,    t        j                  |      S )zReturns True if obj is a link.)r   is_linkru   s     r4   isLinkzUtilities.isLink  s     ""3''r6   c                     | j                  |      syt        j                  |      ryt        j                  |      xr t        j                  |       S )z;Returns True if obj is a text entry area that is read only.FT)
isTextArear   is_read_onlyr   is_editableru   s     r4   isReadOnlyTextAreazUtilities.isReadOnlyTextArea  sH     s###C('',Q[5L5LS5Q1QQr6   c                      yrs   rt   ru   s     r4   isSwitchzUtilities.isSwitch  rw   r6   c                     | j                   j                  }d }|D ]  }|dk(  r		 ||   } |}|S # t        $ r Y  |S w xY wNr)  )r/   r  rl   )r2   pathstartrvps        r4   getObjectFromPathzUtilities.getObjectFromPath  sd       	ABwa		 B	   	s   0	>>c                    t        j                  |      }t        j                  |      }t        |      t        |      k7  ry|r|sy|dd  }|dd  }|d   dk(  r|d   dk(  r
|d d }|d d }|j                  d      r|j                  d      ry	 |j	                  d      }|d| |d| k(  S # t
        $ r0 	 |j	                  d      }n# t
        $ r t        |      }Y nw xY wY Cw xY w)NFr	   r)  r   )r   get_pathrF   countindex
ValueError)r2   obj1obj2path1path2r  s         r4   _hasSamePathzUtilities._hasSamePath  s   !!$'!!$'u:U#% ab	ab	
 9?uRyB#2JE#2JE ;;r?u{{2	#KKOE Qu~q//  	##B #E
#	#s6   B, ,	C%6CC%CC%CC%$C%c                    ||k(  ry||yt        j                  ||      sy|s,t        j                  |      t        j                  |      k7  ry|s,t        j                  |      t        j                  |      k7  ry|r| j                  ||      ryt        j                  ||      syt        j                  |      syyr   )	r   have_same_roler   r   rT  r  r   objects_have_same_rectr  )r2   r  r  comparePathsignoreNamesignoreDescriptionss         r4   rP   zUtilities.isSameObject  s    4<<4<))$5x006(:K:KD:QQ!''-1I1I$1OOD--dD9 11$=&&t,r6   c                     | j                  |      ryt        j                  |      xs, t        j                  |      xs t        j                  |      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_paragraphru   s     r4   r  zUtilities.isTextArea  sN     ;;s ((- -""3'-'',	-r6   c                     fd}t        j                  t        j                  j                        }t        t        ||            S )z,Return a list of the labels for this object.c                 :     t        j                   fd       S )Nc                     | k(  S r~   rt   )r<   accs    r4   r   zBUtilities.labelsForObject.<locals>.isNotAncestor.<locals>.<lambda>,  s    Q#X r6   r   )r  rR   s   `r4   isNotAncestorz0Utilities.labelsForObject.<locals>.isNotAncestor+  s    --c3EFFFr6   )r   rC   r   rD   rz   r   filter)r2   rR   r  rG  s    `  r4   rm   zUtilities.labelsForObject(  s;    	G ..sE4F4F4R4RSF=&122r6   c                 D    y	  j                   j                   j                        S # t        $ rH  j                   j                   j                  vr#i  j                   j                   j                  <   Y nw xY w fd}g }t	        j
                  |      }|r*|j                  |       t	        j
                  ||      }|r*t        |      }| j                   j                   j                     <    j                   j                   j                        S )zmDetermines the nesting level of this object.

        Arguments:
        -obj: the Accessible object
        r   c                     j                        rj                  |       S t        j                        r(t        j                  t	        j
                  |             S t        j                  |       S r~   )r  r   is_list_itemrM  r   r_  r  r<   rR   r2   s    r4   r=   z$Utilities.nestingLevel.<locals>.predA  s_      %((++'',"**8+>+>q+ABB--c155r6   )r/   rj   NESTING_LEVELrl   r   r   rQ   rF   )r2   rR   r=   	ancestorsr   r,   s   ``    r4   r,   zUtilities.nestingLevel1  s    ;	E<<..t/A/AB3GG 	E!!)D)DDBD++D,>,>?	E	6 	))#t4X&--h=H  9~?K##D$6$67<||**4+=+=>sCCs   %- AA>=A>c                    | j                  |      sy	 | j                  j                  | j                     |   S # t        $ rH | j                  | j                  j                  vr#i | j                  j                  | j                  <   Y nw xY wg }|}d}|st        j                  |t        j                  j                        }d}|r|j                  d      }|j                  |      r-d|d|g}t        j                  t        j                  |d       d}t        |      dkD  r,d	|g}t        j                  t        j                  |d       d}n|r|j!                  |       nd}|st        |      d
z
  | j                  j                  | j                     |<   | j                  j                  | j                     |   S )zDetermines 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)  FNr   r>   z#is already in the list of nodes forTd   z/SCRIPT UTILITIES: More than 100 nodes found forr	   )r\  r/   rj   
NODE_LEVELrl   r   rM   r   rD   rN   rO   r  r   rG   rH   rF   rQ   )r2   rR   rT   nodedonerZ   rU   s          r4   r-   zUtilities.nodeLevelR  s    $$S)	B<<..t?DD 	Bdll&A&AA?A++DOO<	B ,,T53E3E3S3STHD**1-
 {{4 -t5Z\_`!!%"2"2FDA5zCKSQ!!%"2"2FDAT") , =@JN##DOO4S9||**4??;C@@s   %: AB
Bc                 6   t        j                  |      ry| j                  |      ryt        j                  |      rt        j
                  |      sd|dg}t        j                  t        j                  |d       t        j                  |      rlt        j                  |dd       t        j                  |      r@t        j
                  |      r+d|dg}t        j                  t        j                  |d       yyt        j                  |      r+d|d	g}t        j                  t        j                  |d       yt        j                  |      ry|yt        j                  ||      s,d|d
|g}t        j                  t        j                  |d       yy)NFr>   zis not showing and visibleTz(Suspecting filler might have wrong statezWARNING: Nowzis showing and visiblezSCRIPT UTILITIES: Rect ofz"is unhelpful. Treating as onscreenznot in)r   is_deadr  r   
is_showing
is_visibler   rG   rH   	is_fillerclear_cacher   has_no_size_or_invalid_rectobject_is_off_screenobject_intersects_rect)r2   rR   boundingboxrU   s       r4   
isOnScreenzUtilities.isOnScreen  sU   C ==&&s+0F0Fs0K)30LMFe..=$$S)$$S%1[\))#.;3I3I#3N,c3KLF%%e&6&6E2237138\]Fe..=++C011#{C)3+FFe..=r6   c                 J   t        j                  |      sy t        j                  |      r| j	                  |      }|r|d   S y t        j
                  |      D ]G  }t        j                  |dd       t        j                  |      st        j                  |      sE|c S  y )Nr   F#Ensuring we have the correct state.)	r   is_menu_barr   supports_selectionselectedChildrenr   r  rA   is_selected)r2   menubarselectedmenus       r4   selectedMenuBarMenuzUtilities.selectedMenuBarMenu  s    &&w/&&w/,,W5H{"**73 	D  u.ST&&t,0G0G0M		 r6   c                    |yt        j                  |t        j                        }|y| j                  j                  t        |            | j                  |      yfd} ||      ryt        j                  ||      d uS )NFc                     | k(  S r~   rt   )r<   selectedMenus    r4   inSelectedMenuz5Utilities.isInOpenMenuBarMenu.<locals>.inSelectedMenu  s    $$r6   T)r   r   r   r  r1   r   hashr  )r2   rR   r  r  r  s       @r4   isInOpenMenuBarMenuzUtilities.isInOpenMenuBarMenu  s    ;((k.E.EF?0044T']C33G<L	% #%%c>:$FFr6   c                      yrs   rt   ru   s     r4   isStaticTextLeafzUtilities.isStaticTextLeaf  rw   r6   c                      yrs   rt   ru   s     r4   isListItemMarkerzUtilities.isListItemMarker  rw   r6   c                     | j                  |      ryt        t        j                  dt	        j
                  |                  S )NFz\w+)r  boolrer  r   r   ru   s     r4   hasPresentableTextzUtilities.hasPresentableText  s4      %BIIff&9&9#&>?@@r6   c           	      B     j                  ||      sg S t        j                  |      t        j                  j
                  k(  rg S t        j                  |      st        j                  |      r|gS t        j                  |      r' j                  |       j                  t        |      <   t        j                  t        j                  |            r j                  |      s|gS t        j                  |      rt        j                   |      st        j"                  |dd       t        j                   |      }d|d| dg}t%        j&                  t$        j(                  |d       |s)d|g}t%        j&                  t$        j(                  |d       |t+        j,                  |      }t        j.                  |      r*t        j0                  |      r j3                  |      }|r|S g }t        j4                  |      xs t        j6                  |      }|r<t        j8                  |      st        j:                  |      r|j=                  |       n" j?                  |      r|j=                  |        fd}t        j@                  ||      D ]#  }	|jC                   jE                  |	|             % t        j                  |      rd  j                  t        |      <   |r|S t        jF                  |      r|stI        jJ                  |      rg S t        j                  jL                  t        j                  jN                  t        j                  jP                  t        j                  jR                  t        j                  jT                  t        j                  jV                  t        j                  jX                  t        j                  jZ                  t        j                  j\                  g	}
t        j                  |      |
v r|sg S |gS )NTzRoot is empty filler.r>   znow reports z	 childrenz"WARNING: unexpectedly empty fillerc                 4    | d uxr j                  |        S r~   )r  r<   r2   s    r4   r=   z*Utilities.getOnScreenObjects.<locals>.pred  s     D=A)>)>q)A%AAr6   )/r  r   r   r   r   INVALIDr   	is_buttonr   r  r  r1   r  r_  r  r  rh  r  r   rG   rH   r   get_rectr  r  getVisibleTableCellsr   rT  is_page_tabis_imagerQ   r  r   r   getOnScreenObjectsrJ  r   r   CANVASrn  IMAGELINKrt  r~  rl  ro  VIEWPORT)r2   r   extentsr  rU   visibleCellsobjectshasNameOrDescr=   r   
containerss   `          r4   r  zUtilities.getOnScreenObjects  s"   tW-IT"ejj&8&88I  &+*B*B4*H6M""4(484L4LT4RD%%d4j1""8#6#6t#<=++D16M  &x/G/G/M  t-DE,,T2E)4<wi1PQFe..=>E!!%"2"2FDA?!**40G""4(X-H-H-N44T:L## ))$/Q83K3KD3Qk55d;{?S?STX?YNN4 $$T*NN4 	B ++D$7 	DENN4225'BC	D ""4(48D%%d4j1N%m@]@]^b@cIjj''jj''jj&&jjoojj))jj&&jj((jj,,jj))+
 T"j0Ivr6   c                    t        j                  |       }|syt        j                  |       yt        j                  |       ryt        j
                  |       ryt        j                  t        j                  |             syt        j                  | t        j
                        D cg c]  }| }}t        |      |k(  ryyc c}w )z9Determines if obj is a table row -- real or functionally.FT)	r   rh  r_  r   is_table_rowr"  r  r   rF   )rR   
childCountr<   cellss       r4   r|  zUtilities.isTableRow   s     --c2
s#+##C(..s3##H$7$7$<=$2238[8[\]q]]u:#	 ^s   *	Cc                     t        j                  |      r|S d }t        j                  ||      }|:| j                  j
                  j                  t        j                  |            s|}|S )Nc                 Z    t        j                  |       xs t        j                  |       S r~   )r   r"  r  r;   s    r4   r=   z*Utilities.realActiveAncestor.<locals>.pred>  s$    66q9X[=U=UVW=XXr6   )r   
is_focusedr   r   r/   	utilitiesrk  r_  )r2   rR   r=   r   s       r4   realActiveAncestorzUtilities.realActiveAncestor:  sb    !!#&J	Y ))#t4<<))66x7J7J87TUC
r6   c                      t        j                  |      ryt        j                  |      s|S t        j                  |      r|S  fd}t        j
                  ||      }||S |S )a2  Given 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    | xr3 j                  |        xr j                  |       j                         S r~   )r  r*   stripr  s    r4   r=   z,Utilities.realActiveDescendant.<locals>.pred[  s5    WT22155W$:L:LQ:O:U:U:WWr6   )r   r  r   rj  r   find_descendant)r2   rR   r=   r   s   `   r4   realActiveDescendantzUtilities.realActiveDescendantH  sf     C ((-JS!J	X ((d3L
r6   c                 T    |yt        j                  |t        j                        d uS rs   )r   r   r   r  ru   s     r4   isStatusBarDescendantzUtilities.isStatusBarDescendantd  s(    ;%%c;+D+DETQQr6   c                    t        j                  |      sg S t        j                         }| j                  j                  j                  d      }|s@d }t        t        || j                  |                  }|| j                  j                  d<   t        j                         }d||z
  d}t        j                  t        j                  |d       |S )NstatusBarItemsc                 .    t        j                  |        S r~   )r   r  r;   s    r4   includez)Utilities.statusBarItems.<locals>.includer  s    &44Q777r6   z1SCRIPT UTILITIES: Time getting status bar items: z.4fT)r   r  timer/   r,  r   r   r  r  r   r   rH   )r2   rR   r  itemsr  endr   s          r4   r  zUtilities.statusBarItemsj  s    ((-I		--112BC8 )@)@)EFGE>CDLL))*:;iikA#+cARS5++S$7r6   c                      y r~   rt   r   s     r4   infoBarzUtilities.infoBar~  r  r6   c                 D   t         j                  j                  t         j                  j                  t         j                  j                  t         j                  j
                  g}| j                         r)|j                  t         j                  j                         |S r~   )	r   r   r   r   r   r   r   rQ   r   )r2   roless     r4   ra  zUtilities._topLevelRoles  sf    ""((!!""$ %%'LL))*r6   c                     t        j                         j                         }|sy|| j                  |      k(  }d|d|g}t	        j
                  t        j                  |d       |S )NFr>   zis top-level object:T)r   r   r   r   r   rG   rH   )r2   r   r  rU   s       r4   _locusOfFocusIsTopLevelObjectz'Utilities._locusOfFocusIsTopLevelObject  s`    ((*==?d))%00%u.DbI%**FD9	r6   c                    t        j                        }|yt        t        j                  |            D ]  }t        j                  ||      }t        j
                  |fd      /d|dg}t        j                  t        j                  |d       |c S d|dg}t        j                  t        j                  |d        y)zSearches 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(  S r~   rt   )r<   r   s    r4   r   z5Utilities._findWindowWithDescendant.<locals>.<lambda>  s    !u* r6   r>   containsTzdoes not contain)	r   r  rJ   rh  r`  r  r   rG   rH   )r2   r   r  rX   r  rU   s    `    r4   _findWindowWithDescendantz#Utilities._findWindowWithDescendant  s     &&u-;x//45 	>A''Q/F''0DEQ-vz5I!!%"2"2FDA)63EuMFe..=	> r6   c                     t        j                  |      | j                         v xrC t        j                  t        j                  |            t        j
                  j                  k(  S r~   )r   r   ra  r_  r   r   APPLICATIONru   s     r4   _isTopLevelObjectzUtilities._isTopLevelObject  sR      %)<)<)>> V!!("5"5c":;uzz?U?UU	Vr6   c                 <   | j                  |      r|}n t        j                  || j                         }d|d|g}t        j                  t        j
                  |d       |:|r8d}t        j                  t        j
                  |d       | j                  |      }|S )zReturns 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>   zis top-level object for:TzISCRIPT UTILITIES: Attempting to find top-level object via fallback search)r  r   r   r   rG   rH   r   r  )r2   rR   useFallbackSearchr  rU   r   s         r4   r   zUtilities.topLevelObject  s     !!#&B''T-C-CDB%r+EsK%**FD9:+]Cu//d;//4B	r6   c                 b   |xs" t        j                         j                         }| j                  |      }|syt	        j
                  |dd       t        j                  |      rt        j                  |      ry| j                  |t        j                         j                               syy)NFr  T)r   r   r   r   r   r  r   	is_active
is_defunctrP   r  )r2   rR   r   s      r4    topLevelObjectIsActiveAndCurrentz*Utilities.topLevelObjectIsActiveAndCurrent  s    D]--/BBD&&s+Xu.ST$$X.+2H2H2R  =+C+C+E+W+W+YZr6   c                    | |k(  ryt        t        |       t        |            }| dg|z  z   d| } |dg|z  z   d| }t        t        t        |       t        |                  D ]  }| |   ||   k  r y| |   ||   kD  s y y)zpCompares the two paths and returns -1, 0, or 1 to indicate if path1
        is before, the same, or after path2.r   r)  Nr	   )maxrF   rJ   rb   )r  r  sizer<   s       r4   pathComparisonzUtilities.pathComparison  s    
 E>3u:s5z*"$et,"$et,s3u:s5z23 	AQx%("Qx%("		 r6   c                 0    t        j                  |||      S r~   )r   find_all_descendants)r2   r   	includeIf	excludeIfs       r4   r   zUtilities.findAllDescendants  s    ,,T9iHHr6   c           	         | j                   j                  r'| j                   j                  j                  |      rg S t        j                  j
                  t        j                  j                  gt        j                  j                  t        j                  j                  t        j                  j                  t        j                  j                  t        j                  j                  t        j                  j                  t        j                  j                  t        j                  j                  t        j                  j                  g	fd}fd}| j!                  |||      }t#        j$                  |      }g }|D ]  }	t#        j$                  |	      xs | j'                  |	      }
|
r-|
|t#        j$                  t#        j(                  |	            fv rZt+        |
j-                               |k  rw|j/                  |
      dk\  r|j1                  |	        t3        j4                  |      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                     | rt        j                  |       v syt        j                  |       ryrt        j                  |       syyrY  )r   r   get_relationsr   r  )r<   
labelRolesr   s    r4   r  z+Utilities.unrelatedLabels.<locals>._include  sB    (++A.*<%%a(;#9#9!#<r6   c                 j    | rt        j                  |       v ryrt        j                  |       syyr   )r   r   r   r  )r<   r   	skipRoless    r4   r  z+Utilities.unrelatedLabels.<locals>._exclude  s1    ))!,	9;#9#9!#<r6   r   )r/   
spellcheckisCheckWindowr   r   r   STATICr   rt  rb  MENU_BARro  
SPLIT_PANEre  TREEri  r   r   r   r*   r_  rF   splitfindrQ   r   sort_objects_by_position)r2   r   r   r   r  r  rp   rootNamelabels_filteredrq   r   r(  r*  s     `        @@r4   r   zUtilities.unrelatedLabels  s    <<""t||'>'>'L'LT'RIjj&&

(9(9:
ZZ))ZZ((ZZ__ZZ((ZZ++ZZ**ZZ%%ZZ__ZZ**,			 ((xB$$T*  	*E$$U+Ht/A/A%/HD8+<+<X=P=PQV=W+X YY4::< </}}T"a'""5)	* 33ODDr6   c                      y)NTrt   r  s    r4   r   zUtilities._treatAlertsAsDialogs(  r  r6   c                 F   	 t         j                  j                  g	 j                         r)	j	                  t         j                  j
                         	 fd}t        j                  t        j                  |      |      D cg c]  }| }}|j                  t        j                   j                  |      |      D cg c]  }| c}       d }d }t        t        |t        |                  }t        t        ||            }t        |      S c c}w c c}w )ac  If 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    t        j                  |       v xs j                  |       S r~   )r   r   r   )r<   r  r2   s    r4   r   z8Utilities.unfocusedAlertAndDialogCount.<locals>.isDialog;  s)    $$Q'50ND4K4KA4NNr6   c                     t        j                  |       xrC t        j                  |       xr, t        j                  |       xs t        j
                  |       S r~   )r   r  r  r   r   rh  r;   s    r4   isPresentablez=Utilities.unfocusedAlertAndDialogCount.<locals>.isPresentableA  sM    ))!, J1G1G1J J&&q)HX-E-Ea-HJr6   c                 J    t        j                         j                  |        S r~   )r   r   can_be_active_windowr;   s    r4   cannotBeActiveWindowzDUtilities.unfocusedAlertAndDialogCount.<locals>.cannotBeActiveWindowE  s    $//1FFqIIIr6   )r   r   r   r   rQ   r   r   r   r  r   r   r   r  setrF   )
r2   rR   r   r<   dialogsr:  r=  presentable	unfocusedr  s
   `        @r4   unfocusedAlertAndDialogCountz&Utilities.unfocusedAlertAndDialogCount+  s     ""#%%'LL))*	O '44X5M5Mc5RT\]^1^^8#9#9$:M:Mc:RT\#]^a^_	J	J 6-W>? 4kBC	9~ _^s   	D	Dc                     t        j                  |      syt        j                  |t        j                  j
                        }|r|j                  d      S t        j                  |      S )z!Finds the object before this one.Nr   )r   r^  rM   r   rD   
FLOWS_FROMrO   get_previous_objectr2   rR   rZ   s      r4   findPreviousObjectzUtilities.findPreviousObjectR  sX       %((e.@.@.K.KL&&q))++C00r6   c                     t        j                  |      syt        j                  |t        j                  j
                        }|r|j                  d      S t        j                  |      S )z Finds the object after this one.Nr   )r   r^  rM   r   rD   FLOWS_TOrO   get_next_objectrF  s      r4   findNextObjectzUtilities.findNextObject^  sX       %((e.@.@.I.IJ&&q))'',,r6   c                    t        j                  |      \  }}}|r*| j                  j                  j	                  d      r|||fS | j                  |      r|||fS | j                  |      }|r6t        j                  |      d   }|sn| d| }| j                  |      }|r6| j                  |      }|r6t        j                  |      d   }|sn| d| }| j                  |      }|r6|||fS )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.
        entireDocumentSelectedr   r   )r   get_selected_textr/   r,  r   r'  rG  rK  )r2   rR   textContentsstartOffset	endOffsetr9  	selectionnextObjs           r4   allSelectedTextzUtilities.allSelectedTextj  s    06/G/G/L,k9DLL99==>VWi77!!#&i77))#.009!<I'[,8L--g6G  %%c*009!<I*^1YK8L))'2G  [)33r6   c                    	 | j                  |||      }| j                  |vr|S t        j                  j
                  t        j                  j                  t        j                  j                  t        j                  j                  t        j                  j                  t        j                  j                  t        j                  j                  t        j                  j                  g}t        |      }t        |      D ]b  \  }}|| j                  k(  st        j                   |||z         }	| j#                  |	      }
|	rt%        j&                  |	      |v r|
dz  }
|
||<   d dj)                  |      S # t        $ r Y yw xY w)ar  Expands 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   )	substringrl   r   r   r   HEADINGr  r   	PARAGRAPHrl  re  rg  	TABLE_ROWr   	enumerater   get_child_at_offsetrS  r   r   r   )r2   rR   rP  rQ  r   
blockRolestoBuildrX   charr   rG  s              r4   rS  zUtilities.expandEOCs  s<   	^^Ci@F ))7Mjj((jjoojj**jj**jj((jj&&jj++jj**,
 v, ) 	$GAtt555#77Q_M/X..u5CcMF#
	$ www1  		s   E; ;	FFc                 ,    t        j                  |      S r~   )r   is_invalid_entryru   s     r4   getErrorzUtilities.getError      ++C00r6   c                      yr   rt   ru   s     r4   getErrorMessagezUtilities.getErrorMessage  r   r6   c                      yrs   rt   ru   s     r4   isErrorMessagezUtilities.isErrorMessage  rw   r6   c                     |j                   S r~   )any_datar   s     r4   deletedTextzUtilities.deletedText  s    ~~r6   c                    |j                   r|j                   S d}t        j                  t        j                  |d       t	        j
                  |j                        rPt        j                  |j                        }|r/d|dg}t        j                  t        j                  |d       |d   S d}t        j                  t        j                  |d       y)Nz-SCRIPT UTILITIES: Broken text insertion eventTzHACK: Returning last char in ''r)  z3FAIL: Unable to correct broken text insertion eventr'   )
rh  r   r   rH   r   is_password_textr   r   r   rG   )r2   r   r   r   rU   s        r4   insertedTextzUtilities.insertedText  s    >>>>!=5++S$7''5((6F:FCH!!%"2"2FDAbz!C5++S$7r6   c                 x    t        j                         j                         }t        j                  |      }||fS r~   )r   r   r   r   get_caret_offsetr   s      r4   r   zUtilities.getCaretContext  s3    &&(;;=((-F{r6   c                 
    |dfS r9   rt   ru   s     r4   getFirstCaretPositionzUtilities.getFirstCaretPosition  s     Avr6   c                 r    t        j                         j                  d |d       | j                  ||       y rs   )r   r   set_locus_of_focussetCaretOffset)r2   rR   r   r   s       r4   setCaretPositionzUtilities.setCaretPosition  s-      "55dCGC(r6   c                 0    t        j                  ||       y r~   )r   set_caret_offsetr   s      r4   rt  zUtilities.setCaretOffset  s    V,r6   c                 0    t        j                  |||      S r~   )r   get_substring)r2   rR   rP  rQ  s       r4   rV  zUtilities.substring  s    ##Ci@@r6   c                 p    | j                   j                  j                         D ]  \  }}||k(  s|c S  |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 	JC
"
	 r6   c                 N    | j                   j                  j                  ||      S )aa  Converts 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   )r2   r|  s     r4   getAtkNameForAttributez Utilities.getAtkNameForAttribute  s!     ||..22:zJJr6   c                 .    t        j                  ||      S r~   )r   get_text_attributes_at_offset)r2   r  r   get_defaultss       r4   textAttributeszUtilities.textAttributes  s    33C@@r6   c                 D   |dk(  r#|dk(  st        |      dkD  rt        j                  S |j                  d      s|dk(  rt        j                  S t        j                  || j                        }|dk(  r2|j                  d      d   j                         j                  d      }n|r||j                  d	      rk|j                  d	      d   }t        j                         d
   |v rt        j                  t        |            }nt        j                  t        |            }nw|j                  d      rF| j                  |      \  }}}t        j                   rt#        j$                  |||      }n)d|||fz  }n t        j                  || j                        }| d| S )Nweightboldi  spellingzfamily-name,r   "pxdecimal_pointcolorz%i %i %iz: )intr   BOLDendswith
MISSPELLEDr   getTextAttributeNamer/   r1  r  locale
localeconv
pixelCountfloatrgbFromStringr   useColorNamesr
   	rgbToName)r2   r}  r~  localizedKeylocalizedValuergrd   s           r4   localizeTextAttributezUtilities.localizeTextAttribute  s^   (?3u:3C== <<
#u
':&&&+@@dllS-"[[-a0668>>sCNu~~d+KK%a(E  "?3u<!)!4!4U5\!B!)!4!4SZ!@\\'"((/GAq!%%!+!5!5aA!>!+q!Qi!71FFudll[Nr.!122r6   c                     g }| j                  |||      }|D ]V  \  }}}}	||k\  r||k  r |S t        ||      }t        ||      }| j                  |||      }
|j	                  |||
||	g       X |S )zAReturns a list of (start, end, string, language, dialect) tuples.)'getLanguageAndDialectFromTextAttributesr  rb   rV  rQ   )r2   rR   r  r	  r  allSubstringsrP  rQ  languagedialectr   s              r4   splitSubstringByLanguagez"Utilities.splitSubstringByLanguage,  s     DDS%QTU9F 	K5KHg	!k! 	 e[1KC+I^^Ci@FII{IvxIJ	K 	r6   c                 d    | j                  |||      }|D ]  \  }}}}||k  s||k\  s||fc S  y)zReturns 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  )	r2   rR   r  r	  r  rP  rQ  r  r  s	            r4   !getLanguageAndDialectForSubstringz+Utilities.getLanguageAndDialectForSubstring=  sP    
 DDS%QTU9F 	)5KHge#	S(8((	) r6   c                    g }t        j                  |||      }dx}}|D ]h  \  }}	}
|
j                  dd      }d}d|v r|j                  dd      \  }}|r||k(  r||k(  r|d   d   |	||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   r1  rQ   )r2   rR   rP  rQ  r  attributeSetlastLanguagelastDialectr  r	  r   r  r  s                r4   r  z1Utilities.getLanguageAndDialectFromTextAttributesI  s     55c;	R%''{#/ 		:UCyyR0HGh$,NN3$:!'lh.;'3IBC7:2		5#x9:(0'+L		: 	r6   c                 2   t        j                         j                         }|rt        j                  syt        |j                        dk7  s|j                  t        j                  z  ryt        j                  |      ryt        j                  |      ryy)zGiven 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_MASKr   rl  r  )r2   r   r   s      r4   willEchoCharacterzUtilities.willEchoCharacter]  sv    
 ((*==?H::u!!"a'oo C CC''.""5)r6   c                     |j                         r||z   S t        |      }|t        j                  k\  r@|d   | j                  j
                  vr%|d   }t        j                  ||      }| d| d}|S ||z  }|S )au  Add in the latest line segment, adjusting for repeat characters
        and punctuation.

        Arguments:
        - segment: the segment of repeated characters.
        - line: the current built-up line to characters to speak.

        Returns: the current built-up line plus the new segment, after
        adjusting for repeat character counts and punctuation.
        r   r   )isalnumrF   r   repeatCharacterLimitr/   
whitespacer   repeatedCharCount)r2   segmentliner  
repeatCharrepeatSegments         r4   _addRepeatSegmentzUtilities._addRepeatSegmentx  s     ??'>!GH111gajH_H_6_ J$66z5IMV1]O1-D  GODr6   c                     | j                  |      s| j                  |      syt        j                         j	                  d      }|t
        j                  t
        j                  fv ryy)NFverbalizePunctuationStyleT)r   r   r   r   r  r   PUNCTUATION_STYLE_ALLPUNCTUATION_STYLE_NONE)r2   rR   styles      r4   shouldVerbalizeAllPunctuationz'Utilities.shouldVerbalizeAllPunctuation  sY    C D$9$9#$>
 !++-889TUX33X5T5TUUr6   c                     |}t        t        j                  | j                  |            D ]"  }d| d}t        j                  d|z  ||      }$ |S )Nr   z\%s)r>  r  findallPUNCTUATIONsub)r2   r   rG  symbolcharNames        r4   verbalizeAllPunctuationz!Utilities.verbalizeAllPunctuation  sV    "**T%5%5v>? 	?F6(!}HVVFVOXv>F	? r6   c                    |t        |      z   }t        j                  |||      }|D cg c]  }t        j                  |       }}t	        |D cg c]  }||z
  	 c}d      }t        |      }	|D ]@  }
dt        j                   }|
t        |	      k  r|	|
   j                         r|dz  }||	|
|
 B dj                  |	      S c c}w c c}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)ra   r   r'   )
rF   r   get_all_links_in_rangeget_link_end_offsetsortedr   r   r  r  r   )r2   rR   r  rP  rQ  linkslinkoffsetsr   rU   or   s               r4   adjustForLinkszUtilities.adjustForLinks  s      #d)+	223YOEJKT;2248KKWE6&;.EtTd 	!A(F3v;6!9#4#4#6# F1QK		! wwv LEs   CCc                 0    t        j                  dd|       S )Nz(?<=[a-z])(?=[A-Z])r   )r  r  )r   s    r4   _processMultiCaseStringz!Utilities._processMultiCaseString  s    vv,c6::r6   c                 Z    | j                         s| S dj                  t        |             S )Nr   )	isnumericr   r   )words    r4   _convertWordToDigitszUtilities._convertWordToDigits  s$    ~~KxxT
##r6   c                    |j                  dd      }t        j                  r| j                  |      }| j	                         rt        j                  |      }t        j                  r@| j                  j                  |      }dj                  t        | j                  |            }| j                  |      }t        |      dk(  rF| j                  j!                         s,| j#                         rt        j$                  |      }||k7  r|S t        j&                  s|S d}| j                  j                  |      }dj                  t        t(        j*                  |            }t        j                  r| 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_REr1  r   r   r  adjustForDigitsrF   r/   r6  r  getCharacterNameusePronunciationDictionaryr   getPronunciation)r2   r  wordscharnamenewLines        r4   adjustForPronunciationz Utilities.adjustForPronunciation  s1    ||Hc*00//5D$$&..t4D((MM''-E773t88%@AD##D)t9>$,,"7"7"9dmmo"33D9H422K##D)''#0AA5IJ00227;Gr6   c                    t        |      dk  st        j                  dk  r|S d}|d   x}}t        dt        |            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'   r   r	   )rF   r   r  rJ   r  )r2   r  r  r  lastCharrX   s         r4   adjustForRepeatszUtilities.adjustForRepeats  s    & IMx<<q@K!!W$(q#d)$ 	AAw("47"00'Bq'AwH	 %%gw77r6   c           	         t        t        j                  | j                  |            }t        t        j                  | j                  |            }|D ]l  }|D cg c]&  }t        | j                  j                  |            ( }}t        j                  dj                  |      z  }t        j                  |||      }n |D ]l  }|D cg c]&  }t        | j                  j                  |            ( }}t        j                  dj                  |      z  }t        j                  |||      }n |S c c}w c c}w )zAdjusts 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)r2   r   subscriptedsuperscriptednumberdnew	newStrings           r4   r  zUtilities.adjustForDigits	  s    "**T%7%7@ABJJt';';VDE# 	7FBHIQ3t..44Q78ICI 33bggclBIVVFIv6F	7
 " 	7F@FG13t,,22156GCG 11BGGCL@IVVFIv6F	7
  J
 Hs   +D7+D<c                    t        j                         j                  d      s#t        j                         j                  d      sy|j                  dd      }t	        j
                  d|      }|r|d |j                          }d}t	        j                  d|      D cg c]  }|j                          }}t	        j                  d|      D cg c]  }|j                          }}t        ||z         }|D ]H  \  }}||f|v r|t        j                  ||z
         dz  }+|t        j                  ||z
         dz  }J |S c c}w c c}w )	NonlySpeakDisplayedTextenableSpeechIndentationr'   r  r   z[^ 	]z +z	+)r   r   r  r  r  r  r  finditerspanr  r   spacesCount	tabsCount)	r2   r  r	  rG  mspacestabsspansr  s	            r4   indentationDescriptionz Utilities.indentationDescription5	  s7   &&(334LM"--/::;TU||Hc*ii$'%D$&KKd$;<q!&&(<<"$++eT":;Q;;v}%! 	@LUCs|v%X11#+>?qAAX//e<=Q??		@  =;s   EEc                      ddl m}   | j                         j                         j	                         }|j                         \  }}}}||fS )z0Gets the absolute position of the mouse pointer.r   r   )gi.repositoryr   Window
get_screenget_root_windowget_pointer)r   
rootWindowr  r<   yr  s         r4   absoluteMouseCoordinatesz"Utilities.absoluteMouseCoordinatesK	  sF     	&SZZ\,,.>>@
","8"8":1i!tr6   c                 "    |s| S | s|S | |z   |z   S )zAppends 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      r4   rn   zUtilities.appendStringU	  s$     KNi'))r6   c                 "   |r|sy||k(  ry|j                   |j                   k(  xrj |j                  |j                  k(  xrO |j                  |j                  k(  xr4 |j                  |j                  k(  xr |j                  |j                  k(  S rs   )r   typedetail1detail2rh  )r2   event1event2s      r4   treatAsDuplicateEventzUtilities.treatAsDuplicateEventb	  s    6 V}}- 3v{{*3&..03 &..03 6??2		3r6   c                 $   |j                   j                  d      r|j                  r|j                  syt	        j
                  |j                        syt	        j                  |j                        syt	        j                  |j                        rAt        j                  |j                  dd       t	        j                  |j                        sy| j                         \  }}|dk(  r|j                  dk7  ry|dk(  r|j                  dk7  ry|d	v r| j                  |j                        S | j                         syt        j                  |j                        }|j!                  |j                        rt        j"                  |j                        \  }}}||j                  k(  ry||j                  k(  rR|j!                  |      rA|d
|j%                  |       }|j'                         j!                  |j'                               S y)zReturns 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  
startswithrh  r   r   r  r  r   r   r  r  lastKeyAndModifiersisEditableDescendantOfComboBoxlastInputEventWasPrintableKeyr   r   r  rN  r2  lower)	r2   r   lastKeymodsr   rR  r  r	  	beginnings	            r4   isAutoTextEventzUtilities.isAutoTextEventp	  s    ::  !=>>>**5<<8))%,,7''5$$U\\5:_`"--ell;  446MGT%ENNd$:("u~~'=@@::5<<HH557((6Fu~~.(.(@(@(N%	5#.U^^+	0J &'>I(> ?I$??,55gmmoFFr6   c                 T    |dk(  s|dk(  ry|| j                   j                  v xr |dv S )a  Returns True if we are positioned at the end of a sentence.
        This is determined by checking if the current character is a
        white space character and the previous character is one of the
        normal end-of-sentence punctuation characters.

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

        Returns True if the given character is a sentence delimiter.
        r  Tz!.?:;)r/   r  )r2   currentCharpreviousChars      r4   isSentenceDelimiterzUtilities.isSentenceDelimiter	  s:     $+"5dll555 +7*	+r6   c                 t    || j                   j                  v xs |dv xs || j                   j                  k(  S )zReturns 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   isWordDelimiterzUtilities.isWordDelimiter	  sC     DLL333 E88Et||DDD	Er6   c                     t         j                  j                         }|j                  |       d   }t	        t        t         j                  t        |                  S r  )r   Keymapget_defaultget_entries_for_keycoder   r   keyval_namer>  )keycodekeymapentriess      r4   _allNamesForKeyCodezUtilities._allNamesForKeyCode	  sC    '')009"=CW677r6   c                      t        t        j                  t        j                        syt        j
                  } | r| j                  | j                  fS y)N)r   r   )r   r   lastInputEventr   KeyboardEventlastNonModifierKeyEventhw_coder  )r   s    r4   _lastKeyCodeAndModifiersz"Utilities._lastKeyCodeAndModifiers	  s?    *33[5N5NO22==%//11r6   c                  ,   t        t        j                  t        j                        ret        j
                  rUt        j
                  } | j                  dv r| j                  }n| j                  }t        j                  j                  }||fS d}d}||fS )zConvenience 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   r   r?  r   r@  rA  r9  r  r  )r   eventStrr)  s      r4   r$  zUtilities.lastKeyAndModifiers	  s     j//1J1JK1166E  $;; ,, --,,66D
 $ HD$r6   c                 X   	 ddl m}  |j                  |       \  }} |j                  ||      }|r$|j	                  d      r|j	                  d      r|} t        j                  |       S # t
        $ r5 | j                  dd      } | j                  dd      j                         } Y Rw xY w)	z3Turns a key sequence into a user-presentable label.r   r   +z++<r'   >r   )
r  r   accelerator_parseaccelerator_get_labelr  rl   r  r  r   localizeKeySequence)sequencer   r}  r)  newSequences        r4   labelFromKeySequencezUtilities.labelFromKeySequence	  s    		:)---h7IC3#33C>K((-1E1Ed1K&
 ++H55	  	:''R0H''S1779H	:s   AA+ +;B)(B)c                 V   	 | j                   j                  | j                     |   S # t        $ rH | j                  | j                   j                  vr#i | j                   j                  | j                  <   Y nw xY wt	        j
                  |d      }|sNg d| j                   j                  | j                     |<   | j                   j                  | j                     |   S |j                  d      }t        |      dk(  r|d   }|d   }|d   }n3t        |      dkD  rd}|d   }	 |d   }n# t        $ r d}Y n
w xY wd}d}d}|j                  dd	      j                         }| j                  |      }| j                  |      }| j                  |      }| j                  | j                   j                  vr#i | j                   j                  | j                  <   |||g| j                   j                  | j                     |<   | j                   j                  | j                     |   S )
a2  Gets 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_BINDINGrl   r   get_action_key_bindingr1  rF   r  r  rQ  )r2   rR   
keybindingbindingStringsmnemonicfullShortcutaccelerators          r4   mnemonicShortcutAcceleratorz%Utilities.mnemonicShortcutAccelerator	  s   	C<<..t/?/?@EE 	Ct||'B'BB@B++D,<,<=	C 44S!<
AMDLL''(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<<#>#>><>DLL''(8(89 |[1 	##D$4$45c:||**4+;+;<SAAs"   %( AA98A9'D- -D;:D;c                    	 | j                  d      D cg c]  }|j                          }}|D cg c]"  }t        |j                  d            dk(  s!|$ }}|D cg c]$  }|j                  d      d   j                         & }}t        |D cg c]  }|j                  d       c}      }||gS c c}w c c}w c c}w c c}w # t        $ r g i fcY S w xY w)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.
        rS  rV  rU  r   )r1  r  rF   dictrl   )r   sr  itemkeys
dictionarys         r4   stringToKeysAndDictzUtilities.stringToKeysAndDict+
  s    	(.S(9:1QWWY:E:&+Ids4::c?/Cq/HTIEI;@A4DJJsOA&,,.ADA5A4tzz#ABJ j!! ;IAA 	r6M	sJ   C
 B6C
 "B;B;C
 )C C
 C+C
 6C
 
CCc                     	 t        |       dS # t        $ r& t        j                  t        j                         Y yw xY w)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'   )ordrl   r   printExceptionLEVEL_WARNING)r3  s    r4   unicodeValueStringzUtilities.unicodeValueStringD
  s<    	)nS)* 	  !4!45	s    ,>>c                     g S r~   rt   )r2   rR   r   
layoutModeuseCaches        r4   getLineContentsAtOffsetz!Utilities.getLineContentsAtOffsetT
  r  r6   c                     g S r~   rt   )r2   rR   r   rn  s       r4   getObjectContentsAtOffsetz#Utilities.getObjectContentsAtOffsetW
  r  r6   c                 :    |s| j                         \  }}||dz
  fS Nr	   r   r2   rR   r   	skipSpaces       r4   previousContextzUtilities.previousContextZ
  %    ..0KCFQJr6   c                 :    |s| j                         \  }}||dz   fS rs  rt  ru  s       r4   nextContextzUtilities.nextContext`
  rx  r6   c                 N    t        dt        j                  |      dz
        }||fS Nr   r	   )r  r   get_character_count)r2   r   r   s      r4   lastContextzUtilities.lastContextf
  s(    Q22481<=V|r6   c                 \   t        j                  |      }|r|S d}t        j                  t        j                  |d       t        j                  |      }|t        j                  j                  k(  r"|s | j                  |t        j                        }|t        j                  j                  k(  ry|rwt        j                  |d         t        j                  j                  k(  rD| j                  |d         }t        j                  |      |srfd}| j                  ||      }|S )NzJSCRIPT UTILITIES: Selected children not retrieved via selection interface.Tr   c                 4    t        j                  |       k(  S r~   )r   r   )r<   r   s    r4   r=   z(Utilities.selectedChildren.<locals>.pred{
  s    #,,Q/477r6   )r   get_selected_childrenr   r   rH   r   r   r   r   rb  r   r   r  r   r  r   )r2   rR   childrenr   r   r=   r   s         @r4   r  zUtilities.selectedChildrenj
  s    44S9OZ5++S$7  %5::??"8..sK4K4KLH5::'''H--hqk:ejjooM,,Xa[9H$$S)D8  223=r6   c                      yrs   rt   ru   s     r4   speakSelectedCellRangez Utilities.speakSelectedCellRange
  rw   r6   c                    |sy | j                  |      ry t        j                  |      r|S t        j                  j
                  t        j                  j                  gt        j                  j                  t        j                  j                  gt        j                  j                  t        j                  j                  gt        j                  j                  t        j                  j                  t        j                  j                  gt        j                  j                  t        j                  j                  t        j                  j                  gt        j                  j                  t        j                  j                  t        j                  j                  gi}|j!                  t        j"                  |            fd}t        j$                  ||      S )Nc                 b    rt        j                  |       vryt        j                  |       S rs   )r   r   r  )r<   matchingRoless    r4   isMatchz0Utilities.getSelectionContainer.<locals>.isMatch
  s,    !2!21!5]!J..q11r6   )r  r   r  r   r   r  rp  ICONr   rt  rd  r0  ri  rg  re  rY  r   r   r   )r2   rR   rolemapr  r  s       @r4   getSelectionContainerzUtilities.getSelectionContainer
  s1   ??3&&s+J JJ

 7 78JJOOejj556JJ  5::#6#6"7JJ  5::??EJJ4I4I"JJJ!!EJJ$4$4ejj6K6K#LJJ  5::#3#3UZZ5J5J"K
  H$5$5c$:;	2
 %%c733r6   c                    t        j                  |      syt        j                  |      r!t        j                  |      }t        d|      S t        j                  j                  t        j                  j                  gt        j                  j                  t        j                  j                  git        j                  |      vrt        j                  |      S fd}t        | j                  ||            S )Nr   c                 P    t        j                  |       j                        v S r~   )r   r   r   )r<   r   r  s    r4   r  z/Utilities.selectableChildCount.<locals>.isMatch
  s"    $$Q'7;;t+<<<r6   )r   r  r  r   rK   r  r   r   rt  r   r0  rd  r   rh  rF   r   )r2   rR   rowsr  r   r  s       @@r4   selectableChildCountzUtilities.selectableChildCount
  s    **3/""3'((-Dq$< JJ%**"6"6!7JJOOejj223

   %w++C00	= 4**3899r6   c                     t        j                  |      rt        j                  |      S t	        j
                  |      S r~   )r   r  r   get_selected_row_countr   get_selected_child_countru   s     r4   selectedChildCountzUtilities.selectedChildCount
  s2    ""3'11#6633C88r6   c                     |y t        j                  |t        j                        D cg c]  }| }}|D ]  }t        j                  |      s|c S  y c c}w r~   )r   r   r   is_menu
is_enabled)r2   rR   r   menusr  s        r4   popupMenuForzUtilities.popupMenuFor
  s]    ;$,$:$:3@S@S$TU5UU 	D%%d+	  Vs   	Ac                 Z    t        j                  |      xr t        j                  |      S r~   )r   r  	has_popupru   s     r4   isButtonWithPopupzUtilities.isButtonWithPopup
  s#    $$S)Hk.C.CC.HHr6   c                     t        j                         j                         }||k(  ryt        j                  |      syt        j                  |      }|sy|t        j                  |      k(  S rs   )r   r   r   r   r  r   r   )r2   rR   r   r   s       r4   isPopupMenuForCurrentItemz#Utilities.isPopupMenuForCurrentItem
  s`    ((*==?%<""3'  %x((///r6   c                 T    t        j                  |      xr | j                  |       S r~   )r   r  r  ru   s     r4   isMenuWithNoSelectedChildz#Utilities.isMenuWithNoSelectedChild
  s&    ""3'L0G0G0L,LLr6   c                 V    t        j                  |      xr | j                  |      d uS r~   )r   r  r  ru   s     r4   isMenuButtonzUtilities.isMenuButton
  s(    $$S)Pd.?.?.DD.PPr6   c                 L   |xs" t        j                         j                         }|yt        j                  |      st        j
                  |      ryt        j                  |      st        j                  |      r&t        j                  |t        j
                        d uS yrY  )
r   r   r   r   is_menu_item_of_any_kindr  r  is_separatorr   r   ru   s     r4   inMenuzUtilities.inMenu
  s    D]--/BBD;//48K8KC8P$(@(@(E))#{/B/BC4OOr6   c                     |xs" t        j                         j                         }| j                  |      syt	        j
                  || j                        d uS rs   )r   r   r   r  r   r   isContextMenuru   s     r4   inContextMenuzUtilities.inContextMenu
  sK    D]--/BBD{{3%%c4+=+=>dJJr6   c                 j    t         j                  j                  t         j                  j                  fS r~   )r   r   r   r   r  s    r4   _contextMenuParentRolesz!Utilities._contextMenuParentRoles
  s!    zz!2!222r6   c                     t        j                  |      syt        j                  t        j                  |            | j                         v S rs   )r   r  r   r   r_  r  ru   s     r4   r  zUtilities.isContextMenu
  s=    ""3'  !4!4S!9:d>Z>Z>\\\r6   c                 |    t        j                  |      syt        j                  |      | j	                  |      k(  S rs   )r   r  r   r_  r   ru   s     r4   isTopLevelMenuzUtilities.isTopLevelMenu
  s4    ""3'""3'4+>+>s+CCCr6   c                     t        j                  |      syt        j                  |      syt        j                  |      S rs   )r   r   supports_autocompletionis_single_lineru   s     r4   isSingleLineAutocompleteEntryz'Utilities.isSingleLineAutocompleteEntry
  s5    ##C(2237))#..r6   c                      yrs   rt   ru   s     r4   isEntryCompletionPopupItemz$Utilities.isEntryCompletionPopupItem  rw   r6   c                     t        j                  |      sy t        j                  || j                        D cg c]  }| }}t        |      dk(  r|d   S y c c}w )Nr	   r   )r   r   r   r   isEditableTextArearF   )r2   rR   r<   r  s       r4   getEntryForEditableComboBoxz%Utilities.getEntryForEditableComboBox	  sX    '','55c4;R;RST!ATTx=AA;	 Us   	Ac                 (    | j                  |      d uS r~   )r  ru   s     r4   isEditableComboBoxzUtilities.isEditableComboBox  s    //4D@@r6   c                 z    t        j                  |      syt        j                  |t         j                        d uS rs   )r   r  r   r   r   ru   s     r4   r%  z(Utilities.isEditableDescendantOfComboBox  s1    &&s+%%c;+C+CDDPPr6   c                    t        j                  |      s| j                  |      S | j                  |      }|r| j                  |      S | j                  j
                  j                  |      }|xs9 | j                  j
                  j                  t        j                  |d            }t        |      dk(  r%|d   j                  xs | j                  |d         S | j                  |      S r|  )
r   rh  r*   r  r/   r  r  r`  rF   r   )r2   rR   entryr  s       r4   getComboBoxValuezUtilities.getComboBoxValue  s    '',%%c**005%%e,,<<))::3?bt||55FFxGYGYZ]_`Gabx=AA;##Ft'9'9(1+'FF!!#&&r6   c                      yrs   rt   ru   s     r4   	isPopOverzUtilities.isPopOver+  rw   r6   c                 R    | j                  |      syt        j                  |       S rs   )r  r   is_modalru   s     r4   isNonModalPopOverzUtilities.isNonModalPopOver.  s%    ~~c"'',,,r6   c                      yrs   rt   ru   s     r4   isUselessPanelzUtilities.isUselessPanel3  rw   r6   c                     t        j                  dt         j                        }t        j                  |d|      }|j	                  d      \  }}}t        |      t        |      t        |      fS )Nz
rgb|[^\w,]r'   r  )r  compile
IGNORECASEr  r1  r  )r2   attributeValueregexr   redgreenblues          r4   r  zUtilities.rgbFromString6  sV    

="--8r>2!<<,UD3xUSY..r6   c                      yrs   rt   ru   s     r4   isClickableElementzUtilities.isClickableElement=  rw   r6   c                      yrs   rt   ru   s     r4   hasLongDesczUtilities.hasLongDesc@  rw   r6   c                      yrs   rt   ru   s     r4   
hasDetailszUtilities.hasDetailsC  rw   r6   c                      yrs   rt   ru   s     r4   	isDetailszUtilities.isDetailsF  rw   r6   c                     g S r~   rt   ru   s     r4   
detailsForzUtilities.detailsForI  r  r6   c                      yrs   rt   ru   s     r4   hasVisibleCaptionzUtilities.hasVisibleCaptionL  rw   r6   c                      yr   rt   ru   s     r4   	popupTypezUtilities.popupTypeO  r   r6   c                 8   t        j                  |      syt        j                  |       }t        j                  ||      }	 t        |j                  dd            }|S # t        $ r/ d|d|dg}t        j                  t        j                  |d       Y yw xY w)Nr   level0z-SCRIPT UTILITIES: Exception getting value for()T)r   
is_headingr  r   r   r  r   r  r   rG   rH   )r2   rR   	use_cacher   r~  rU   s         r4   headingLevelzUtilities.headingLevelR  s    %%c*#//44	,,S)<			'3/0E   	EsCQVX[\Fe..=	s   A! !5BBc                 z    t        j                  |d      xs$ t        j                  |t        j                        S )Ntoggle)r   
has_actionr   ACTION_TOGGLEru   s     r4   hasMeaningfulToggleActionz#Utilities.hasMeaningfulToggleActionb  s5    ""31 I""3(9(G(GH	Ir6   c                 x    t        j                  |      r|S t        j                  |t         j                        S r~   )r   is_table_headerr   r   ru   s     r4   containingTableHeaderzUtilities.containingTableHeaderf  s.    &&s+J%%c;+F+FGGr6   c                 ,    t        j                  |      S r~   r   is_indeterminateru   s     r4   setSizeUnknownzUtilities.setSizeUnknownl  rb  r6   c                 ,    t        j                  |      S r~   r  ru   s     r4   rowOrColumnCountUnknownz!Utilities.rowOrColumnCountUnknowno  rb  r6   c                     |yt        j                  |      ryt        j                  |      xs t        j                  |       S rs   )r   r  r   r  r  ru   s     r4   _boundsIncludeChildrenz Utilities._boundsIncludeChildrenr  s?    ;""3''',L0G0G0LMMr6   c                      yrs   rt   ru   s     r4   treatAsEntryzUtilities.treatAsEntry{  rw   r6   c                    |t        j                  |      ryt        j                  |      syt        j                  |      st        j
                  |      ryt        j                  |      r&t        j                  |t        j                        d u S t        j                  |      rt        j                  |      ryt        j                  |      rt        j                  |       S t        j                  |      ryyrY  )r   r  rh  r   is_autocompleter  r   r  r   r  r   is_expandablerA   r  ru   s     r4   _treatAsLeafNodezUtilities._treatAsLeafNode~  s    ;(**3/'',&&s+{/G/G/L##C(++C1E1EF$NNs#(9(9#(>$$S)"..s333  %r6   c                     |syt        j                  |      syt        j                  |      }t	        t        d |j                  d                  }t        |      dkD  S )NFc                 "    | j                         S r~   )r  r;   s    r4   r   z2Utilities.isMultiParagraphObject.<locals>.<lambda>  s    qwwy r6   z

r	   )r   supports_textr   r   r   r  r1  rF   )r2   rR   r   chunkss       r4   isMultiParagraphObjectz Utilities.isMultiParagraphObject  sR    %%c*$$S)f0&,,v2FGH6{Qr6   c           	         t        j                  ||      \  }}}| j                  j                  j	                  dd      \  }}||k7  r|||fS t        j                  ||      \  }}	}
| j                  j                  j	                  d      dk(  r| j                         r|}|}n| j                         r|}|}t        j                  |||      }|j                  dd      }d| d| d	| d
| d	}t        j                  t        j                  |d       |||fS | j                         r.|}|d   j                         s|d   j                         sl|dz  }nf| j                         rV|}||k7  r|	|cxk  r|
k  rn n|	}t        j                  ||dz
  |      }|j                         s|j                         s|dz
  }t        j                  |||      }d|v r2||k(  r-|j                  d      r|dz  }n|j                  d      r|dz  }t        j                  |||      }|j                  dd      }d| d| d	| d
| d	}t        j                  t        j                  |d       |||fS )NpenultimateCursorPositionr  lastTextUnitSpokenr  r  z\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lastInputEventWasNextWordNavry  r  r   r   rH   isspacer  r#  r  )r2   rR   r   r  r  r	  r9  
prevOffsetprevWord	prevStartprevEnddebugStringr   r  s                 r4   $getWordAtOffsetAdjustedForNavigationz.Utilities.getWordAtOffsetAdjustedForNavigation  s   !44S&AeS"ll;;??'5c>## (.'@'@*'U$)W<<((,,-ABfL002 224"''UC8D,,tU3K<VH E=E7!C53  u//d;## ,,. E
 H$$&$r(*:*:*<q..0 C xI$A'$A!
 ++C!VDH$$&(*:*:*<
##C4 4<DH,t$
t$q##C4ll4/8 A}CwauA/ 	 	5++S$7UCr6   c                 
   |d t         j                  j                  fv rt        j                  |||      \  }}}n|t         j                  j
                  k(  rt        j                  |||      \  }}}ns|t         j                  j                  k(  rt        j                  |||      \  }}}n:|t         j                  j                  k(  rt        j                  |||      \  }}}ny|sd||fS |t         j                  j                  k(  r|j                         syt        j                  |||      }t        j                         }	||	_        ||	_        dx|	_        |	_        t%        j&                  ||	      s|dk7  ry|j)                  d      r|dk(  r|||fS |t         j                  j                  k(  r|||fS | j+                  |||t         j                  j                        }
|
d   dk(  r|
d   |
d   z
  dk(  r|
S |||fS )N)r'   r   r   r'   r   r  rU  r	   )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)r2   rR   r<   r  boundaryr   r  r	  r  rectr^  s              r4   r  zUtilities.textAtPoint  s    e44??@@!'!9!9#q!!DFE3//>>>!'!=!=c1a!HFE3//:::!'!9!9#q!!DFE3//444!'!>!>sAq!IFE3uc>!u--888''UC8zz|#$$
T[00$?FdNt$$5#%%u--2225#%%Q5+A+A+F+FG7d?tAwa0A5Kuc!!r6   c                 H   t        j                  |      }d|d| dg}t        j                  t        j                  |d       t        j                  ||j                  |j                  dz         }t        j                  |d      d   }t        d|      }d	|d
| g}t        j                  t        j                  |d       t        j                  |      }t        j                  ||j                  |j                  |j                  z   dz         }|t        j                  |d      d   f t        ||      }	d|d
| dg}t        j                  t        j                  |d       t        j                  ||j                  |j                  |j                  z   dz
        }t        j                  |d      d   }d|d
| dg}t        j                  t        j                  |d       |dk(  r|}|}
t        t        |	|
            }||vr|j                  d|       |S )NzSCRIPT UTILITIES: zhas z rowsTr	   Fr?   r   zSCRIPT UTILITIES: First cell:z(row: zSCRIPT UTILITIES: Next cell:r  zSCRIPT UTILITIES: Last cell:r)  )r   rK   r   rG   rH   r   get_descendant_at_pointr<   r  rI   r  r  r  r   rJ   insert)r2   rR   
table_rectnRowsrU   rY   rV   
startIndex	cell_rect	nextIndexendIndexr  s               r4   visibleRowszUtilities.visibleRows  s   %%c*&tE7%-@A%**FD9223
jllUVFVW**4%HKC[
146#H%**FD9  ((.	22z||i.>.>>BDW))$GJJ
C(	0$&QH%**FD922z||j.?.??!CE**4%HK0$&QH%**FD9"9CE)X./T!KK:&r6   c                    t        j                  |      sg S | j                  |t        j                  |            }|sg S | j                  |      \  }}||k(  rg S g }t        ||      D ]  }g }|D ]  }t        j                  |||      }	|	|s?t        j                  |	      }|r(| j                  |d         r|j                  |d          | j                  |	      sp|j                  |	         |S r9   )r   r  r&  r   r  _getTableRowRangerJ   r   rL   get_column_headersr  rQ   )
r2   rR   r  colStartIndexcolEndIndexr  rW   headersrV   rY   s
             r4   r  zUtilities.getVisibleTableCells9  s    &&s+I[%9%9#%>?I%)%;%;C%@"{K'I4 	'CG '**3S9< &88>G4??71:#>WQZ0??4(LL&'	'$ r6   c                    t        j                  |      }|yt        j                  |d      }d|}}| j                  |      s||fS t	        j
                  |      }t	        j                  ||j                  dz   |j                        }|rt        j                  |d      d   }|}t	        j                  ||j                  |j                  z   dz
  |j                        }|rt        j                  |d      d   }|dz   }||fS )Nr)  r)  Fr   r	   r?   )r   rB   get_column_countr'  r   r  r  r<   r  rI   r  )	r2   rR   r:  columnCountr"  r%  r  rY   r  s	            r4   r(  zUtilities._getTableRowRangeZ  s    !!#&=..ue< +H
%%c*x''##E*225$&&1*dffM11$OPQRFJ225$&&4:::MPQ:QSWSYSYZ11$OPQRFzH8##r6   c                 ~   t        j                  |d      d   }|dk(  rg S t        j                  |      }|rdt        j                  |      }}n| j	                  |      \  }}||k(  rg S g }t        ||      D ]@  }t        j                  |||      }	t        j                  |	      s0|j                  |	       B |S )NFr?   r   r)  )
r   rI   rB   r/  r(  rJ   rL   r   r  rQ   )
r2   rR   forceFullRowrV   r:  r"  r%  r  rX   rY   s
             r4   getShowingCellsInSameRowz"Utilities.getShowingCellsInSameRowq  s    **3GJ"9I!!#&#$g&>&>u&EJ#'#9#9##> J!Iz8, 	#A&&uc15D%%d+T"	#
 r6   c                 d    dd|g}t        j                  t         j                  |d       |rsy t        j                  |      st        j
                  |      ry  fd} ||      r|}nt        j                  ||      }d|dg}t        j                  t         j                  |d       |S )Nz-SCRIPT UTILITIES: Searching for replicant forinTc                 .    j                  | dd      S )NT)r  r  )rP   r  s    r4   isSamez'Utilities.findReplicant.<locals>.isSame  s    $$Q$D$QQr6   zHACK: Returningzas replicant for invalid object)r   rG   rH   r   r  is_embeddedr   r  )r2   r   rR   rU   r7  	replicants   ` `   r4   findReplicantzUtilities.findReplicant  s    A3dS%**FD9%)@)@)F	R $<I 00v>I#Y0QSVW%**FD9r6   c                     t        j                  |t        j                  j                        }|r|j                         S t        j                  |      S r~   )r   rM   r   rD   rE   get_n_targetsrh  rF  s      r4   getFunctionalChildCountz!Utilities.getFunctionalChildCount  sC    ((e.@.@.O.OP))++'',,r6   c                 \   t        j                  |t        j                  j                        }|r|S | j                  |      r| j                  |      S | j                  |      r | j                  | j                  |            S t        j                  |      D cg c]  }| c}S c c}w r~   )r   rC   r   rD   rE   r  r  r  valuesForTermtermForValuer   )r2   rR   siblingrG  r<   s        r4   getFunctionalChildrenzUtilities.getFunctionalChildren  s    ..sE4F4F4U4UVM%%g.,,S11,,W5%%d&7&7&@AA#11#67a777s   	B)c                     t        j                  |t        j                  j                        }|r|j                  d      S t        j                  |      S r9   )r   rM   r   rD   rN   rO   r_  rF  s      r4   getFunctionalParentzUtilities.getFunctionalParent  sE    ((e.@.@.N.NO&&q))""3''r6   c                 8   |yt        j                  |      rU|j                  d      rDt        j                  |      d   }t        j
                  t        j                  |            }||fS t        j                  |      rJ| j                  |      }|r|d   }n1d }| j                  t        j                  ||            }|r|d   }ny| j                  |      }| j                  |      }|dkD  r/|t        j                  |      k(  rt        j                  |      |fS | j                  ||      }	t!        |	      dk  rrt        j"                  |t         j                        sNt$        j&                  j(                  t$        j&                  j*                  gfd}
t-        t/        |
|	            }	|	r||	v sy| j1                  |      r.t-        t/        | j0                  |	            }	t!        |	      dk(  ry|	j3                  |      }t!        |	      }||fS )Nr.  
readingRowr   c                 Z    t        j                  |       xs t        j                  |       S r~   )r   r  is_list_boxr;   s    r4   isMenuz/Utilities.getPositionAndSetSize.<locals>.isMenu  s#    &..q1O[5L5LQ5OOr6   r  c                 `    t        j                  |       xr t        j                  |       vS r~   )r   r^  r   )r<   layoutRoless    r4   isNotLayoutOnlyz8Utilities.getPositionAndSetSize.<locals>.isNotLayoutOnly  s)    ((+W0A0A!0DK0WWr6   r	   )r   rj  r   r   rI   rK   rB   r   r  r   r  rD  r=  r_  r:   rB  rF   r   r   r   rs  rr  r   r  rK  r  )r2   rR   argsrV   rowcountr  rI  rS   r  siblingsrL  positionsetSizerK  s                @r4   getPositionAndSetSizezUtilities.getPositionAndSetSize  s   ;$$S)dhh|.D..s3A6C,,W->->s-CDH= ##C(,,S1HqkP  001I1I#v1VW"1+C!))#.11&9
(*=*=c*B B//4j@@--fc:x=3x'='=c;C[C['\ :://1M1MNKX F?H=>HSH_  %F4#8#8(CDH8}!>>#&h-  r6   c                     | j                  |      sy |r:| j                  |      s)t        j                  |      }|r| j                  |      s)|S r~   )r  r  r   get_previous_siblingru   s     r4   r@  zUtilities.termForValue  sL    005$44S9//4C $44S9 
r6   c                     | j                  |      sg S g }t        j                  |      }|rK| j                  |      r:|j	                  |       t        j                  |      }|r| j                  |      r:|S r~   )r  r   get_next_siblingr  rQ   )r2   rR   valuess      r4   r?  zUtilities.valuesForTerm  so    ))#.I'',d77<MM#++C0C d77< r6   c                 6    t        | j                  |            S r~   )rF   r?  ru   s     r4   getValueCountForTermzUtilities.getValueCountForTerm  s    4%%c*++r6   c                      yr   rt   )r2   rR   	isBrailles      r4   getRoleDescriptionzUtilities.getRoleDescription  r   r6   c           	          | j                   j                  j                  di       }|j                  t        |      d      \  }}}d|d| d| d| dg}t	        j
                  t        j                  |d       |||fS )	NtextSelections)r   r   r'   z&SCRIPT UTILITIES: Cached selection foris 'r   , r  T)r/   r,  r   r  r   rG   rH   )r2   rR   r^  r  r	  r   rU   s          r4   getCachedTextSelectionz Utilities.getCachedTextSelection  s    66::;KRP+//S	:FsF:C4xsSXRYY[\_[``aAbc%**FD9c6!!r6   c           	         | j                   j                  j                  d      rH| j                  |      d   }|s2d| j                   j                  d<   i | j                   j                  d<   | j                   j                  j                  di       }t	        |      |v rc|j                  t	        |            }|j                         D cg c]  }|j                  |      |k(  s| c}D ]  }|j                  |        t        j                  |      \  }}}	d|d| d| d|	 d	g}
t        j                  t        j                  |
d
       ||	|f|t	        |      <   || j                   j                  d<   y c c}w )NrM  r   Fr^  z#SCRIPT UTILITIES: New selection forr_  r   r`  r  T)r/   r,  r   rT  r  poprc  r   rN  r   rG   rH   )r2   rR   selectedTextr^  r~  kr<   r   r  r	  rU   s              r4   updateCachedTextSelectionz#Utilities.updateCachedTextSelection  sg   <<((,,-EF//4Q7LJO--.FGBD--.>?66::;KRP 9&"&&tCy1E!/!4!4!6YA.:L:LQ:OSX:XaY &""1%& $55c:s7VHCPUwVXY\X]]^>_`%**FD9$)3$6tCy!:H%%&67 Zs   E<'E<c                  F   t        j                         j                         }|y t        j                         t        j
                  z
  dk  r(d}t        j                  t        j                  |d       y t        j                         t        _         |j                  |   y )Ng?zDSCRIPT UTILITIES: Clipboard contents change believed to be duplicateT)
r   r   getActiveScriptr  r"   _last_clipboard_updater   r   rH   onClipboardContentsChanged)rM  r3   r   s      r4   rj  z$Utilities.onClipboardContentsChanged  sx    **,<<>>99;999D@XCu//d;+/99;	()))40r6   c                     | j                   y t        j                  j                  t        j
                  j                  dd            }|j                  d| j                        | _         y )N	CLIPBOARDFzowner-change)	r0   r   	Clipboardr   r   Atominternconnectrj  r2   	clipboards     r4   connectToClipboardzUtilities.connectToClipboard(  sR    ##/MM%%chhook5&IJ	#,#4#4D;;$= r6   c                     | j                   y t        j                  j                  t        j
                  j                  dd            }|j                  | j                          y Nrl  F)r0   r   rm  r   r   rn  ro  
disconnectrq  s     r4   disconnectFromClipboardz!Utilities.disconnectFromClipboard0  sH    ##+MM%%chhook5&IJ	T556r6   c                     t         j                  j                  t        j                  j                  dd            }|j                         S ru  )r   rm  r   r   rn  ro  wait_for_textrq  s     r4   getClipboardContentszUtilities.getClipboardContents7  s4    MM%%chhook5&IJ	&&((r6   c                     t         j                  j                  t        j                  j                  dd            }|j                  |d       y )Nrl  Fr)  )r   rm  r   r   rn  ro  set_textr2   rU  rr  s      r4   setClipboardTextzUtilities.setClipboardText;  s5    MM%%chhook5&IJ	4$r6   c                     t         j                  j                  t        j                  j                  dd            }|j                  | j                  |       y ru  )r   rm  r   r   rn  ro  request_text_appendTextToClipboardCallbackr}  s      r4   appendTextToClipboardzUtilities.appendTextToClipboard?  s;    MM%%chhook5&IJ	tBBDIr6   c                 Z    |j                  d      }| | | }|j                  |d       y )Nr  r)  )rstripr|  )r2   rr  rU  r  	separators        r4   r  z(Utilities._appendTextToClipboardCallbackC  s2    {{4 	{7),4$r6   c                     t        t        j                  t        j                        syt        j
                  }|xr% |j                  | j                  j                        S rs   )	r   r   r?  r   r@  rA  isFromApplicationr/   r  r   s     r4   lastInputEventCameFromThisAppz'Utilities.lastInputEventCameFromThisAppH  sF    *33[5N5NO22B001A1ABBr6   c                 x    t         j                  }t        |t        j                        sy|j                         S rs   )r   r?  r   r   r@  isPrintableKeyr   s     r4   r&  z'Utilities.lastInputEventWasPrintableKeyO  s/    ))%!:!:;##%%r6   c                 N    | j                         \  }}|t        j                  z  S r~   r$  r   CTRL_MODIFIER_MASKr2   	keyStringr)  s      r4   lastInputEventWasCommandz"Utilities.lastInputEventWasCommandV  s%    224	4k4444r6   c                     | j                         \  }}|j                         r|t        j                  z  S |dv r|t        j                  z  S y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r6   c                     | j                         \  }}|dvry|t        j                  z  s9|t        j                  z  s&|t        j                  z  s|t        j
                  z  ryy)N)LeftRightr  r   FT)r$  r   r  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r6   c                     | j                         xs4 | j                         xs" | j                         xs | j                         S r~   )lastInputEventWasCharNavlastInputEventWasWordNavlastInputEventWasLineNav lastInputEventWasLineBoundaryNavr  s    r4   lastInputEventWasCaretNavz#Utilities.lastInputEventWasCaretNavq  sH    ,,. 7,,.7,,.7 446	7r6   c                     | j                         \  }}|dvry|t        j                  z  s|t        j                  z  ryy)Nr  r  FT)r$  r   r  r  r  s      r4   r  z"Utilities.lastInputEventWasCharNavw  sB    224	4--+000[222r6   c                 X    | j                         \  }}|dvry|t        j                  z  S )Nr  Fr  r  s      r4   r  z"Utilities.lastInputEventWasWordNav  s1    224	4--k4444r6   c                 Z    | j                         \  }}|dk(  sy|t        j                  z  S )Nr  Fr  r  s      r4   r  z&Utilities.lastInputEventWasPrevWordNav  s0    224	4F"k4444r6   c                 Z    | j                         \  }}|dk(  sy|t        j                  z  S )Nr  Fr  r  s      r4   r  z&Utilities.lastInputEventWasNextWordNav  s0    224	4G#k4444r6   c                     | j                         \  }}|dvry| j                  t        j                         j	                               ry|t
        j                  z   S )N)r  r   Fr$  r%  r   r   r   r   r  r  s      r4   r  z"Utilities.lastInputEventWasLineNav  sV    224	4N*..}/G/G/I/\/\/^_;999::r6   c                 Z    | j                         \  }}|dvry|t        j                  z   S N)HomeEndFr  r  s      r4   r  z*Utilities.lastInputEventWasLineBoundaryNav  s3    224	4O+;999::r6   c                     | j                         \  }}|dvry| j                  t        j                         j	                               ry|t
        j                  z   S r  r  r  s      r4   lastInputEventWasPageNavz"Utilities.lastInputEventWasPageNav  sW    224	444..}/G/G/I/\/\/^_;999::r6   c                 X    | j                         \  }}|dvry|t        j                  z  S r  r  r  s      r4    lastInputEventWasFileBoundaryNavz*Utilities.lastInputEventWasFileBoundaryNav  s0    224	4O+k4444r6   c                 X    | j                         \  }}|t        j                  z  r|dv S y)N)r  r  r  r   r  r  F)r$  r   r  r  s      r4   &lastInputEventWasCaretNavWithSelectionz0Utilities.lastInputEventWasCaretNavWithSelection  s1    224	4+111 NNNr6   c                     | j                         \  }}| j                  |      }d|vry|t        j                  z  r|t        j                  z   S yNzFrC  r=  r   r  r  r2   r:  r)  r   s       r4   lastInputEventWasUndozUtilities.lastInputEventWasUndo  T    557++G4h+000{>>>??r6   c                     | j                         \  }}| j                  |      }d|vry|t        j                  z  r|t        j                  z  S yr  r  r  s       r4   lastInputEventWasRedozUtilities.lastInputEventWasRedo  sQ    557++G4h+000+9999r6   c                     | j                         \  }}| j                  |      }d|vry|t        j                  z  r|t        j                  z   S y)Nr<   Fr  r  s       r4   lastInputEventWasCutzUtilities.lastInputEventWasCut  r  r6   c                     | j                         \  }}| j                  |      }d|vry|t        j                  z  r|t        j                  z   S y)NcFr  r  s       r4   lastInputEventWasCopyzUtilities.lastInputEventWasCopy  r  r6   c                     | j                         \  }}| j                  |      }d|vry|t        j                  z  r|t        j                  z   S y)NvFr  r  s       r4   lastInputEventWasPastez Utilities.lastInputEventWasPaste  r  r6   c                     | j                         \  }}| j                  |      }d|vry|t        j                  z  r|t        j                  z   S y)Nrc   Fr  r  s       r4   lastInputEventWasSelectAllz$Utilities.lastInputEventWasSelectAll  r  r6   c                     | j                         \  }}|dv ry| j                         \  }}| j                  |      }d|vry|t        j                  z  S )N)rF  	KP_DeleteTr  F)r$  rC  r=  r   r  )r2   r  r)  r:  r   s        r4   lastInputEventWasDeletez!Utilities.lastInputEventWasDelete  s^    224	4//557++G4hk4444r6   c                     | j                         \  }}|dvry|t        j                  z  s&|t        j                  z  s|t        j                  z  ryy)N)r  ISO_Left_TabFT)r$  r   r  r  r  r  s      r4   lastInputEventWasTabzUtilities.lastInputEventWasTab  sP    224	433+000[222[333r6   c                 R    t        t        j                  t        j                        S r~   )r   r   r?  r   MouseButtonEventr  s    r4   lastInputEventWasMouseButtonz&Utilities.lastInputEventWasMouseButton  s    *33[5Q5QRRr6   c                     t         j                  }t        |t        j                        r|j
                  dk(  xr |j                  S yN1Fr   r?  r   r   r  buttonpressedr   s     r4   "lastInputEventWasPrimaryMouseClickz,Utilities.lastInputEventWasPrimaryMouseClick  8    ))e[99:<<3&85==8r6   c                     t         j                  }t        |t        j                        r|j
                  dk(  xr |j                  S yN2Fr  r   s     r4   !lastInputEventWasMiddleMouseClickz+Utilities.lastInputEventWasMiddleMouseClick$  r  r6   c                     t         j                  }t        |t        j                        r|j
                  dk(  xr |j                  S yN3Fr  r   s     r4   $lastInputEventWasSecondaryMouseClickz.Utilities.lastInputEventWasSecondaryMouseClick+  r  r6   c                     t         j                  }t        |t        j                        r|j
                  dk(  xr |j                   S yr  r  r   s     r4   $lastInputEventWasPrimaryMouseReleasez.Utilities.lastInputEventWasPrimaryMouseRelease2  ;    ))e[99:<<3&<u}}+<<r6   c                     t         j                  }t        |t        j                        r|j
                  dk(  xr |j                   S yr  r  r   s     r4   #lastInputEventWasMiddleMouseReleasez-Utilities.lastInputEventWasMiddleMouseRelease9  r  r6   c                     t         j                  }t        |t        j                        r|j
                  dk(  xr |j                   S yr  r  r   s     r4   &lastInputEventWasSecondaryMouseReleasez0Utilities.lastInputEventWasSecondaryMouseRelease@  r  r6   c                 B   t         j                  }|syt        j                         }||j                  z
  |kD  ry| j                  j                  j                  dd      }||z
  |k  ryt        |t        j                        r| j                         sXyt        |t        j                        r=|j                  | j                  j                        s| j                         \  }}|dvryt        j                  t!        j"                         j%                               S )NFzlast-table-sort-timeg        )r  spacer   )r   r?  r  r/   r,  r   r   r   r  r  r@  isHandledByleftClickReviewItemr$  r   r  r   r   r   )r2   deltar   nowlastSortTimer  r)  s          r4   lastInputEventWasTableSortz$Utilities.lastInputEventWasTableSortG  s    ))iike#||44889OQTU%e[99:<<>{889$$T\\%E%EF"&":":"<	4$<< **=+C+C+E+X+X+Z[[r6   c                    | j                  |j                  t        j                         j	                               ryt        j                  |j                        st        j                  |j                        ryt        j                  |j                        st        j                  |j                        rt        j                  |j                        S yr   )rP   r   r   r   r   r   r  rH  r   r  r  r   s     r4   !isPresentableExpandedChangedEventz+Utilities.isPresentableExpandedChangedEvent_  s    U\\=+C+C+E+X+X+Z[##ELL1[5L5LU\\5Z##ELL1[5J5J5<<5X))%,,77r6   c                 l   |j                   j                  d      s|j                   j                  d      syt        j                  |j                        s]t        j
                  |j                        s>t        j                  |j                        st        j                  |j                        r(d}t        j                  t        j                  |d       yt        j                  |j                        r_| j                  |j                        ryt        j                  |j                        ryt        j                         j!                         rgyt        j"                  |j                        rGt        j$                  |j                        s(d}t        j                  t        j                  |d       yt        j                         j'                         |j                  t)        j*                  |j                        fv ryd}t        j                  t        j                  |d       y)Nzobject:text-changed:zobject: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)r  r#  r   is_menu_relatedr   	is_slideris_spin_buttonrJ  r   r   rH   r  r   rl  r   r   focus_is_deadrj  r  r   r   r_  r2   r   r   s      r4   ,isPresentableTextChangedEventForLocusOfFocusz6Utilities.isPresentableTextChangedEventForLocusOfFocusk  s   zz$$%;<::(()IJ&&u||4##ELL1((6""5<<0NCu//d;!!%,,/-++ELL9'')779&&u||4[=T=TUZUaUa=bYCu//d;##%88:\\8..u||<=>S5++S$7r6   c                     |j                   j                  d      sy| j                  |j                        ry| j	                         \  }}|dk(  ryy)Nobject:text-changed:deleteFrE  T)r  r#  r  r   r$  )r2   r   r  r)  s       r4   #isBackSpaceCommandTextDeletionEventz-Utilities.isBackSpaceCommandTextDeletionEvent  sK    zz$$%AB==&224	4#r6   c                     |j                   j                  d      sy|j                   j                  d      ry| j                         S )Nr  Fsystem)r  r#  r  r  r   s     r4    isDeleteCommandTextDeletionEventz*Utilities.isDeleteCommandTextDeletionEvent  s<    zz$$%AB::x(++--r6   c                     |j                   j                  d      sy| j                         sy| j                  |j                        \  }}}| S Nr  F)r  r#  r  ra  r   r2   r   r  r	  r   s        r4   isUndoCommandTextDeletionEventz(Utilities.isUndoCommandTextDeletionEvent  sJ    zz$$%AB))+!88FsFzr6   c                     |j                   j                  d      sy| j                         ry| j                  |j                        \  }}}|xr+ |j                         |j                  j                         k(  S r  )r  r#  r  ra  r   r  rh  r  s        r4   isSelectedTextDeletionEventz%Utilities.isSelectedTextDeletionEvent  se    zz$$%AB&&(!88FsFB&,,.ENN,@,@,BBBr6   c                     |j                   j                  d      sy| j                  |j                         | j	                  |j                        \  }}}|xr  ||j
                  k(  xr ||j                  k(  S Nr  F)r  r#  rf  r   ra  rh  r  r  s        r4   isSelectedTextInsertionEventz&Utilities.isSelectedTextInsertionEvent  sg    zz$$%AB&&u||4!88FsFM&ENN2Mu7MMr6   c                 J    | j                         sy| j                  |      ryyrY  )r  r  r   s     r4   isSelectedTextRestoredEventz%Utilities.isSelectedTextRestoredEvent  s%    ))+,,U3r6   c                 Z    |j                   j                  d      sy| j                         S r  )r  r#  r  r   s     r4   %isMiddleMouseButtonTextInsertionEventz/Utilities.isMiddleMouseButtonTextInsertionEvent  s'    zz$$%AB5577r6   c                 |   |j                   j                  d      syt        j                  |j                        rvt        j
                  |j                        sW|j                  t        j                         j                         k7  r(d}t        j                  t        j                  |d       yt        j                  |j                        r#t        j                         j                  d      S t        |j                   j#                               dk(  r#t        j                         j                  d      S y)Nr  FzTSCRIPT UTILITIES: Not echoable text insertion event: focusable source is not focusedTenableKeyEchor	   r  )r  r#  r   r   r   r  r   r   r   r   r   rH   rl  r   r  rF   rh  r  r  s      r4   isEchoableTextInsertionEventz&Utilities.isEchoableTextInsertionEvent  s    zz$$%AB##ELL1))%,,7||}779LLNN3Cu//d;''5#..0;;OLLu~~##%&!+#..0;;<STTr6   c                 P    | j                  |      syt        j                  |      S rs   )r  r   r  ru   s     r4   r  zUtilities.isEditableTextArea  s"    s#&&s++r6   c                 4   |j                   j                  d      sy| j                         r| j                         ry| j	                  |      ryd|j                   v r| j                         ry| j                  |j                        sy| j                         }|sy|j                  |k(  ryt        t        j                  d|j                              t        t        j                  d|            k7  ryd|v r|j                  j                         |v ryy)Nzobject:text-changedFdeleteTz\wr  )r  r#  r  r  r  r  r  r   rz  rh  r  r  r  r  )r2   r   contentss      r4   isClipboardTextChangedEventz%Utilities.isClipboardTextChangedEvent  s    zz$$%:;,,.$2L2L2N33E:uzz!d&A&A&C&&u||4,,.>>X%		%01T"))E8:T5UU
 8 5 5 78 Cr6   c                 p   |xs" t        j                         j                         }|rt        j                  |      ry| j                         }|syt        j                  |      \  }}}|r||v ry| j                  |      xs |}t        j                  |      ry|xr t        j                  |      |v S rY  )
r   r   r   r   r  rz  r   rN  r   r   )r2   rR   r  r   r  r	  s         r4   objectContentsAreInClipboardz&Utilities.objectContentsAreInClipboard  s    D]--/BBDh&&s+,,.#55c:sf('',3C 9x((-99r6   c                     d| j                   j                  d<   d| j                   j                  d<   d| j                   j                  d<   d| j                   j                  d<   y )NFundoredopaster'   last-selection-message)r/   r,  r  s    r4   clearCachedCommandStatez!Utilities.clearCachedCommandState  sS    05%%f-05%%f-16%%g.BD%%&>?r6   c                 P   | j                         r| j                  j                  j                  d      sB| j                  j	                  t
        j                         d| j                  j                  d<   | j                  |j                         y| j                         r| j                  j                  j                  d      sB| j                  j	                  t
        j                         d| j                  j                  d<   | j                  |j                         yy)Nr  Tr  F)r  r/   r,  r   presentMessager   UNDOrf  r   r  REDOr   s     r4   handleUndoTextEventzUtilities.handleUndoTextEvent  s    %%'<<0044V<++HMM:8<--f5**5<<8%%'<<0044V<++HMM:8<--f5**5<<8r6   c                    | j                         ry| j                         rh| j                  j                  j	                  d      sB| j                  j                  t        j                         d| j                  j                  d<   y| j                         rh| j                  j                  j	                  d      sB| j                  j                  t        j                         d| j                  j                  d<   yy)NFr  Tr  )
r  r  r/   r,  r   r  r   r  r  r  r  s    r4   handleUndoLocusOfFocusChangez&Utilities.handleUndoLocusOfFocusChange0  s    --/%%'<<0044V<++HMM:8<--f5%%'<<0044V<++HMM:8<--f5r6   c                 4   | j                         ry| j                         rw| j                  j                  j	                  d      sQ| j                  j                  t        j                  t        j                         d| j                  j                  d<   yy)NFr  T)	r  r  r/   r,  r   r  r   CLIPBOARD_PASTED_FULLCLIPBOARD_PASTED_BRIEFr  s    r4   handlePasteLocusOfFocusChangez'Utilities.handlePasteLocusOfFocusChangeB  ss    --/&&(<<0044W=++22H4S4SU9=--g6r6   c                      yrs   rt   r   s     r4   eventIsCanvasNoisezUtilities.eventIsCanvasNoiseO  rw   r6   c                      yrs   rt   r   s     r4   eventIsSpinnerNoisezUtilities.eventIsSpinnerNoiseR  rw   r6   c                 6   t         j                  s(d}t        j                  t        j                  |d       yt        j
                         t         j                  j
                  z
  }|dkD  r-d|dd}t        j                  t        j                  |d       yy)Nz:SCRIPT UTILITIES: Not user triggered: No last input event.TFr	   z7SCRIPT UTILITIES: Not user triggered: Last input event z.2fzs ago.)r   r?  r   r   rH   r  )r2   r   r   r  s       r4   eventIsUserTriggeredzUtilities.eventIsUserTriggeredU  s~    ((NCu//d;		j77<<<19KERU;V\]Cu//d;r6   c                 H    | j                         ry| j                         ryyr   )r  r#  r  s    r4   presentFocusChangeReasonz"Utilities.presentFocusChangeReasonc  s#    ,,.--/r6   c                    t        j                  |      syt        j                  |      rt        j                  |      syt        j
                  |      st        j                  |      ryt        j                  |      }|t        j                  |      k(  r[t        j                  |d      }t        j                  |      |k7  ryd| d}t        j                  t        j                  |d       yt        j                   |      S )NFr   zSCRIPT UTILITIES: All z! children believed to be selectedT)r   r  r   r  rA   r   r  rh  r   r  get_selected_childr_  r   r   rH   r   all_cells_are_selected)r2   rR   r  r   r   s        r4   allItemsSelectedzUtilities.allItemsSelectedj  s    **3/$$S)+2I2I#2N##C(K,?,?,D--c2
==cBB  223:E""5)S0*:,6WXCu//d;--c22r6   c                 n   | j                   j                  j                  d      }| j                  |      }|r|ry|| j                   j                  d<   | j	                         rQ|rO| j                   j                  t        j                         t        j                         j                  d |d       yy)Nr/  TF)r/   r,  r   r/  r  r  r   CONTAINER_SELECTED_ALLr   r   rs  )r2   rR   allAlreadySelectedallCurrentlySelecteds       r4   handleContainerSelectionChangez(Utilities.handleContainerSelectionChange  s    !\\::>>?QR#44S9"6<P%%&89**,1ELL''(G(GH$$&99$UKr6   c                 >   t        j                  |      sy| j                  |      \  }}}| j                  |       | j                  |      \  }}}| j	                  t        |            ry| j                         s.|r,|s*| j                  j                  t        j                         yg }	t        t        ||            }
t        t        ||            }|
j                  |      sy|
rY|rW|
j                  |      sF|	j                  ||t        j                   g       |	j                  ||t        j"                  g       nt%        |
j'                  |            }|sy|d   |d   dz   }}|
|k  rn|	j                  ||t        j"                  g       |j)                  | j*                        r||k(  rt-        j.                  ||dz
        }| j1                  |d       nh|	j                  ||t        j                   g       |j)                  | j*                        r+t-        j.                  ||dz
        }| j1                  |d       |xr$ t3        j4                         j7                  d       }|	D ]  \  }}}t9        j:                  |||      }|j)                  | j*                        }|r|dz  }| j                  j=                  |||       |r|s| j                  j                  |d       |st-        j.                  ||      }| j1                  ||        y)NFTr   r)  r	   r  )	interrupt)r   r  ra  rf  _speakTextSelectionStaterF   r  r/   speakMessager   SELECTION_REMOVEDr>  rJ   unionintersectionrQ   TEXT_UNSELECTEDTEXT_SELECTEDr  symmetric_differencer  r   r   r[  handleTextSelectionChanger   r   r  r   ry  	sayPhrase)r2   rR   r8  oldStartoldEnd	oldStringnewStartnewEndr  changesoldCharsnewCharschangechangeStart	changeEndr   r  r	  messager   endsWithChilds                        r4   r?  z#Utilities.handleTextSelectionChange  s   
 %%c*&*&A&A#&F#&)&&s+&*&A&A#&F#&)((Y8 ::<S\LL%%h&@&@AuXv./uXv./~~h')>)>x)HNNHfh.F.FGHNNHfh.D.DEFH99(CDF%+AYr
QK("Y8N8NOP%%d&D&DE&T_J_ (;;C!LE225%@Y8P8PQR%%d&D&DE (;;C!LE225%@# W$//1<<=UVV 	#* 	DE3))#uc:F"OOD,J,JKMqLL""3s3M))'U)C#77SA..ulC	D r6   c                 ~    t         j                  t         j                  t         j                  t         j                  gS )!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 	2r6   c                    t        j                         j                  d      ry| j                         \  }}|t        j
                  z  }|t        j                  z  }|dkD  }d}|dk(  r|r|rt        j                  }n|dk(  r|r|rt        j                  }nh|dk(  r*|r(|s&|rt        j                  }nKt        j                  }n9|dk(  r*|r(|s&|rt        j                  }nt        j                  }n
|dk(  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$|rt        j                  }nt        j                   }n|dk(  r(|r&|r$|rt        j"                  }nst        j                  }nb| j%                         rR|rP| j&                  j(                  j+                  d      s*d| j&                  j(                  d<   t        j,                  }ny|sy|| j&                  j(                  j+                  d      k7  r4|| j&                  j(                  d<   | j&                  j/                  |       y)rO  r  Fr   Nr"  r!  r   r	   r  rU  rT  r  r  rM  Tr  )r   r   r  r$  r   r  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   nSelectionsrG  r)  isControlKey
isShiftKeyrd  r  stringss	            r4   r7  z"Utilities._speakTextSelectionState  s    &&(334LM113$k<<<K;;;
"Q#//D)#..D+%:l2244)#L0022& j\99;Gqzqz$J<99;Gqzqz& j\4466%ZL6644,,.<<<00445MNJN--.FG554<<00445MNNFJDLL))*BCLL%%d+r6   c                    d}|+|dz  }t        j                  t         j                  |d       y|6|j                  j	                  d      r| j
                  j                  |      S t        j                        rUt        j                        r@t        j                        r+|dz  }t        j                  t         j                  |d       yt        j                        sUt        j                        st        j                        r+|dz  }t        j                  t         j                  |d       yt        j                        rAt        j                         r+|dz  }t        j                  t         j                  |d       yyfd	}fd
}t        j"                  t$        j&                  j(                  |      r+|dz  }t        j                  t         j                  |d       yt        j"                  t$        j&                  j(                  |      r+|dz  }t        j                  t         j                  |d       yy)Nz<SCRIPT UTILITIES: Not interrupting for locusOfFocus change: zevent is NoneTFz object:active-descendant-changedzsuspected editable cellzsuspected menuitem state changez:old locusOfFocus is ancestor with name of new locusOfFocusc                     | k(  S r~   rt   )targetoldLocusOfFocuss    r4   isOldz=Utilities.shouldInterruptForLocusOfFocusChange.<locals>.isOld;      _,,r6   c                     | k(  S r~   rt   )rf  newLocusOfFocuss    r4   isNewz=Utilities.shouldInterruptForLocusOfFocusChange.<locals>.isNew>  ri  r6   z*new locusOfFocus controls old locusOfFocusz*old locusOfFocus controls new locusOfFocus)r   r   rH   r  r#  r/   #stopSpeechOnActiveDescendantChangedr   rj  r  r  r  is_check_menu_itemis_radio_menu_itemr   is_ancestorr   rC   r   rD   CONTROLLER_FOR)r2   rg  rk  r   r   rh  rl  s    ``    r4   $shouldInterruptForLocusOfFocusChangez.Utilities.shouldInterruptForLocusOfFocusChange  s   L=?"Cu//d;!6!67Y!Z<<CCEJJ$$_5+:M:Mo:^&&7,,Cu//d;**?;..?11/B44Cu//d;A  1SS""5#3#3S$?	-	- (().););)J)JES??Cu//d;(().););)J)JES??Cu//d;r6   c           	          |r|syt        t        d |j                         |j                               j                         d      }d| d| d| d| d	}t	        j
                  t        j                  |d       ||k\  S )	NFrU  z&SCRIPT UTILITIES: Similarity between 'z', 'z': z (threshold: r  T)roundr   r'  ratior   r   rH   )r2   str1str2	threshold
similarityr   s         r4   stringsAreRedundantzUtilities.stringsAreRedundantM  s    ?4tzz|LRRTVWX
4TF$tfC
| T$+Q( 	 	5++S$7Y&&r6   )Tr~   )F)FFT)NN)TrT  )r   r)  rs   )r   )TT)r   T)Nr)  F)r  )g      ?(  __name__
__module____qualname__r  ri  r   ZERO_WIDTH_NO_BREAK_SPACEr  r  r  UNICODEflagsr  r  r   r  r  r  r   rk   r   rW  r  r  r5   r\   rg   r)   rv   r|   r   r   r(   r*   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r
  r  r  r  r  r  r  r  r  r  r  r   r"  r$  r&  r(  r*  r,  r.  r0  r2  r4  r6  r8  r:  r<  r>  r@  rB  rD  rF  rH  rJ  rL  rN  rP  rR  rT  rV  rX  rZ  r\  r^  r`  rb  rd  rf  rh  rj  rl  rn  rp  rr  rt  rv  rx  rz  r|  r~  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  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.  r1  r;  r=  r?  rA  rH  rK  rN  rQ  rW  r\  rk  staticmethodr  r  r  r  r  r  rP   r  rm   r,   r-   r  r  r  r  r  r  r  r|  r  r   r  r  r  ra  r  r  r  r   r  r   r   r   r   rB  rG  rK  rT  rS  ra  rd  rf  ri  rm  r   rq  ru  rt  rV  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rn   r  r+  r0  r4  r=  rC  r$  rQ  r^  re  rk  ro  rq  rw  rz  r~  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r%  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r
  r  r&  r  r(  r3  r:  r=  rB  rD  rR  r@  r?  rY  r\  ra  rf  rj  rs  rw  rz  r~  r  r  r  r&  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r#  r%  r'  r)  r+  r/  r4  r?  rT  r7  rr  rz  rt   r6   r4   r"   r"   H   sM	   &TYY[ ( (	; 	;  JJErzz(E*H bjj1RWW-?%@$A!DeLOBJJ277+;#<"=R@%HM"**Z/K 3&O$NK"MJ	'"3j+ZF6 6&L*EX"&P-\$LP21J:=
V 5D/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 0D HM(,>- 3DB,A\$L$G.A
DL  28R(,V.  &I;EzN
1
-$4L& P1$

)-A&KA38"
(622 ; ; $ $,\"8H2,   
* 
*3(T+&E 8 8
      & 6 6 9Bv " "0  046:,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"$30DL2>@.`
'r6   r"   )2__doc____id____version____date____copyright____license__gir  r  r  difflibr   require_versionr  r   r   r   r'   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   ax_componentr   ax_hypertextr   	ax_objectr   ax_selectionr   ax_tabler   ax_textr   ax_utilitiesr   ax_valuer    r"   rt   r6   r4   <module>r     s   (C
 
5 	  	  #   7E "                   " % %  %   % O@' O@'r6   