Mini Shell

Direktori : /lib/python3.6/site-packages/orca/scripts/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/orca/scripts/__pycache__/default.cpython-36.opt-1.pyc

3

�p5[{�@s,dZdZdZdZdZdZddlZddlZddlj	Z	ddl
jZddlj
Z
ddljZddljZddljZddljZddljZddljZddljZddljZddljZddl j!Z"ddl#j$Z$ddl%j&Z&ddl'j(Z(ddl)j*Z*ddl+j,Z,ddl-j.Z.ddl/j0Z0ddl1j2Z2ddl3j4Z4ddl5j6Z6e,j7�Z8Gdd	�d	e(j9�Z9dS)
z�The default Script for presenting information to the user using
both speech and Braille.  This is based primarily on the de-facto
standard implementation of the AT-SPI, which is the GAIL support
for GTK.z$Id$z
$Revision$z$Date$zOCopyright (c) 2004-2009 Sun Microsystems Inc.Copyright (c) 2010 Joanmarie DiggsZLGPL�Ncs�eZdZdZdZdZdZdZdZdZ	dZ
d	d
�Zdd�Zd
d�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Z�fdd�Z�fdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Z�dtd*d+�Z�dud,d-�Z�dvd.d/�Z�dwd0d1�Z�dxd2d3�Z�dyd4d5�Z d6d7�Z!d8d9�Z"d:d;�Z#d<d=�Z$d>d?�Z%d@dA�Z&dBdC�Z'�dzdEdF�Z(�d{dGdH�Z)�d|dIdJ�Z*�d}dKdL�Z+�d~dMdN�Z,�ddOdP�Z-�d�dQdR�Z.�d�dSdT�Z/�d�dUdV�Z0�d�dWdX�Z1dYdZ�Z2d[d\�Z3�d�d]d^�Z4�d�d_d`�Z5�d�dadb�Z6dcdd�Z7�d�dfdg�Z8dhdi�Z9djdk�Z:dldm�Z;dndo�Z<dpdq�Z=drds�Z>�d�dtdu�Z?dvdw�Z@dxdy�ZAdzd{�ZBd|d}�ZCd~d�ZDd�d��ZEd�d��ZFd�d��ZG�d�d�d��ZHd�d��ZId�d��ZJd�d��ZKd�d��ZLd�d��ZM�d�d�d��ZN�d�d�d��ZO�d�d�d��ZPd�d��ZQd�d��ZRd�d��ZS�d�d�d��ZT�d�d�d��ZU�d�d�d��ZV�d�d�d��ZW�d�d�d��ZX�d�d�d��ZY�d�d�d��ZZ�d�d�d��Z[�d�d�d��Z\�d�d�d��Z]�d�d�d��Z^d�d��Z_d�d��Z`d�d��Za�d�d�d��Zb�d�d�d��Zc�d�d�d��Zdd�d��Zed�dÄZfd�dńZgd�dDŽZhd�dɄZid�d˄Zjd�d̈́Zkd�dτZld�dфZmd�dӄZnd�dՄZod�dׄZpd�dلZqd�dۄZrd�d݄Zsd�d߄Ztd�d�Zud�d�Zvd�d�Zwd�d�Zxd�d�Zyd�d�Zzd�d�Z{d�d�Z|d�d�Z}d�d�Z~d�d��Zd�d��Z�d�d��Z�d�d��Z�d�d��Z�d�d��Z��d��d�d�Z��d��d�d�Z��d�d�Z��d�d�Z��d	�d
�Z��d�d�Z��d��d
�d�Z��d�d�Z��d�d�Z��d�d�Z��d�d�Z��d�d�Z��d�d�Z��d�d�Z��d��d�d�Z��d�d �Z��d��d!�d"�Z��d��d#�d$�Z��d��d%�d&�Z��d'�d(�Z��d)�d*�Z��d+�d,�Z��d-�d.�Z��d/�d0�Z��d1�d2�Z��d��d4�d5�Z�e��d��d6�d7��Z�e��d8�d9��Z�e��d:�d;��Z�e��d<�d=��Z�e��d>�d?��Z�e��d@�dA��Z�e��d��dB�dC��Z�e��d��dD�dE��Z��dF�dG�Z�e��dH�dI��Z�e��dJ�dK��Z�e��d��dM�dN��Z�e��d��dP�dQ��Z�e��d��dR�dS��Z�e��d��dT�dU��Z�e��dV�dW��Z�e��dX�dY��Z�e��d��dZ�d[��Z�e��d\�d]��Z�e��d^�d_��Z��d`�da�Z�e��d��db�dc��Z�e��d��dd�de��Z�e��df�dg��Z��dh�di�Z��d��dj�dk�Z�e��dl�dm��Z��dn�do�Z��dp�dq�Z��dr�ds�Z��Z�S(��Scriptu� ZdisplayedLabel�
displayedText�
keyBindingZnestingLevelZ	nodeLevelZrealActiveDescendantcCs�tjj||�d|_d|_d|_d|_d|_d|_i|_	d|_
ddg|_d|_d|_
d|_d|_d|_g|_|r�|jtjjtjjAtjjAtjjA�dS)z�Creates a new script for the given application.

        Arguments:
        - app: the application to create a script for.
        NF�
0123456789z 	

r�)�scriptr�__init__�flatReviewContext�windowActivateTime�targetCursorCell�justEnteredFlatReviewModeZdigitsZ
whitespaceZattributeNamesDict�lastMouseRoutingTime�oldMouseCoordinates�currentReviewContents�	_lastWord�_lastWordCheckedForSpelling�	_inSayAll�_sayAllIsInterrupted�_sayAllContextsZsetCacheMask�pyatspi�cacheZDEFAULTZCHILDREN�NAMEZDESCRIPTION)�self�app�r�/usr/lib/python3.6/default.pyr	Rs&
zScript.__init__cCs�tjtjtj�|jd<tjtjtj�|jd<tjtj	tj
�|jd<tjtjtj�|jd<tjtj
tj�|jd<tjtjtj�|jd<tjtjtj�|jd<tjtjtj�|jd<tjtjtj�|jd	<tjtjtj�|jd
<tjtjtj�|jd<tjtjtj�|jd<tjtjtj�|jd
<tjtj tj!�|jd<tjtj"tj#�|jd<tjtj$tj%�|jd<tjtj&tj'�|jd<tjtj(tj)�|jd<tjtj*tj+�|jd<tjtj,tj-�|jd<tjtj.tj/�|jd<tjtj0tj1�|jd<tjtj2tj3�|jd<tjtj4tj5�|jd<tjtj6tj7�|jd<tjtj8tj9�|jd<tjtj:tj;�|jd<tjtj<tj=�|jd<tjtj>tj?�|jd<tjtj@tjA�|jd<tjtjBtjC�|jd<tjtjDtjE�|jd <tjtjFtjG�|jd!<tjtjHtjI�|jd"<tjtjJtjK�|jd#<tjtjLtjM�|jd$<tjtjNtjO�|jd%<tjtjPtjQ�|jd&<tjtjRtjS�|jd'<tjtjTtjU�|jd(<tjtjVtjW�|jd)<tjtjXtjYd*�|jd+<tjtjZtj[d*�|jd,<tjtj\tj]�|jd-<tjtj^tj_�|jd.<tjtj`tja�|jd/<tjtjbtjc�|jd0<tjtjdtje�|jd1<tjtjftjg�|jd2<tjthjitjj�|jd3<tjthjktjl�|jd4<tjthjmtjn�|jd5<tjthjotjp�|jd6<tjthjqtjr�|jd7<tjthjstjt�|jd8<tjtjutjv�|jd9<tjtjwtjx�|jd:<tjtjytjz�|jd;<tjtj{tj|�|jd<<tjtj}tj~�|jd=<tjtjtj��|jd><tjtj�tj��|jd?<tjtj�tj��|jd@<tjtj�tj��|jdA<tjtj�tj��|jdB<tjtj�tj��|jdC<tjtj�tj��|jdD<tjtj�tj��|jdE<tjtj�tj��|jdF<tjtj�tj��|jdG<tjtj�tj��|jdH<tjtj�tj��|jdI<tjt�j�j�tj��|jdJ<tjtj�tj��|jdK<tjtj�tj��|jdL<tjtj�tj��|jdM<|jj�t�j�dNS)OzlDefines InputEventHandler fields for this script that can be
        called by the key and braille bindings.ZroutePointerToItemHandlerZleftClickReviewItemHandlerZrightClickReviewItemHandlerZ
sayAllHandlerZflatReviewSayAllHandlerZwhereAmIBasicHandlerZwhereAmIDetailedHandlerZwhereAmILinkHandlerZwhereAmISelectedTextHandlerZgetTitleHandlerZgetStatusBarHandlerZfindHandlerZfindNextHandlerZfindPreviousHandler�toggleFlatReviewModeHandlerZreviewPreviousLineHandler�reviewHomeHandlerZreviewCurrentLineHandlerZreviewSpellCurrentLineHandlerZ reviewPhoneticCurrentLineHandlerZreviewNextLineHandlerZreviewEndHandlerZreviewPreviousItemHandler�reviewAboveHandlerZreviewCurrentItemHandlerZreviewSpellCurrentItemHandlerZ reviewPhoneticCurrentItemHandlerZreviewNextItemHandlerZreviewCurrentAccessibleHandler�reviewBelowHandlerZreviewPreviousCharacterHandlerZreviewEndOfLineHandler�reviewBottomLeftHandlerZreviewCurrentCharacterHandlerZ"reviewSpellCurrentCharacterHandlerZ$reviewUnicodeCurrentCharacterHandlerZreviewNextCharacterHandlerZflatReviewCopyHandlerZflatReviewAppendHandlerZtoggleTableCellReadModeHandlerZreadCharAttributesHandlerF�panBrailleLeftHandler�panBrailleRightHandler�goBrailleHomeHandler�contractedBrailleHandler�processRoutingKeyHandler�processBrailleCutBeginHandler�processBrailleCutLineHandlerZenterLearnModeHandlerZdecreaseSpeechRateHandlerZincreaseSpeechRateHandlerZdecreaseSpeechPitchHandlerZincreaseSpeechPitchHandlerZdecreaseSpeechVolumeHandlerZincreaseSpeechVolumeHandlerZshutdownHandlerZpreferencesSettingsHandlerZappPreferencesSettingsHandlerZtoggleSilenceSpeechHandlerZtoggleSpeechVerbosityHandlerZ-toggleSpeakingIndentationJustificationHandlerZchangeNumberStyleHandlerZ$cycleSpeakingPunctuationLevelHandlerZcycleSettingsProfileHandlerZcycleCapitalizationStyleHandlerZcycleKeyEchoHandlerZcycleDebugLevelHandler�goToPrevBookmark�goToBookmark�goToNextBookmark�addBookmark�
saveBookmarksZtoggleMouseReviewHandlerZpresentTimeHandlerZpresentDateHandlerZbypassNextCommandHandlerN)��input_eventZInputEventHandlerr�routePointerToItem�cmdnamesZROUTE_POINTER_TO_ITEM�inputEventHandlers�leftClickReviewItemZLEFT_CLICK_REVIEW_ITEM�rightClickReviewItemZRIGHT_CLICK_REVIEW_ITEM�sayAllZSAY_ALL�flatReviewSayAllZSAY_ALL_FLAT_REVIEW�
whereAmIBasicZWHERE_AM_I_BASIC�whereAmIDetailedZWHERE_AM_I_DETAILED�whereAmILinkZWHERE_AM_I_LINK�whereAmISelectedTextZWHERE_AM_I_SELECTED_TEXT�presentTitleZ
PRESENT_TITLE�presentStatusBarZPRESENT_STATUS_BAR�orca�showFindGUIZ
SHOW_FIND_GUI�findNextZ	FIND_NEXT�findPreviousZ
FIND_PREVIOUS�toggleFlatReviewModeZTOGGLE_FLAT_REVIEW�reviewPreviousLineZREVIEW_PREVIOUS_LINE�
reviewHomeZREVIEW_HOME�reviewCurrentLineZREVIEW_CURRENT_LINE�reviewSpellCurrentLineZREVIEW_SPELL_CURRENT_LINE�reviewPhoneticCurrentLineZREVIEW_PHONETIC_CURRENT_LINE�reviewNextLineZREVIEW_NEXT_LINE�	reviewEndZ
REVIEW_END�reviewPreviousItemZREVIEW_PREVIOUS_ITEM�reviewAboveZREVIEW_ABOVE�reviewCurrentItemZREVIEW_CURRENT_ITEM�reviewSpellCurrentItemZREVIEW_SPELL_CURRENT_ITEM�reviewPhoneticCurrentItemZREVIEW_PHONETIC_CURRENT_ITEM�reviewNextItemZREVIEW_NEXT_ITEM�reviewCurrentAccessibleZREVIEW_CURRENT_ACCESSIBLE�reviewBelowZREVIEW_BELOW�reviewPreviousCharacterZREVIEW_PREVIOUS_CHARACTER�reviewEndOfLineZREVIEW_END_OF_LINE�reviewBottomLeftZREVIEW_BOTTOM_LEFT�reviewCurrentCharacterZREVIEW_CURRENT_CHARACTER�reviewSpellCurrentCharacterZREVIEW_SPELL_CURRENT_CHARACTER�reviewUnicodeCurrentCharacterZ REVIEW_UNICODE_CURRENT_CHARACTER�reviewNextCharacterZREVIEW_NEXT_CHARACTER�flatReviewCopyZFLAT_REVIEW_COPY�flatReviewAppendZFLAT_REVIEW_APPEND�toggleTableCellReadModeZTOGGLE_TABLE_CELL_READ_MODE�readCharAttributesZREAD_CHAR_ATTRIBUTES�panBrailleLeftZPAN_BRAILLE_LEFT�panBrailleRightZPAN_BRAILLE_RIGHT�
goBrailleHomeZGO_BRAILLE_HOME�setContractedBrailleZSET_CONTRACTED_BRAILLE�processRoutingKeyZPROCESS_ROUTING_KEY�processBrailleCutBeginZPROCESS_BRAILLE_CUT_BEGIN�processBrailleCutLineZPROCESS_BRAILLE_CUT_LINE�enterLearnModeZENTER_LEARN_MODE�speechZdecreaseSpeechRateZDECREASE_SPEECH_RATEZincreaseSpeechRateZINCREASE_SPEECH_RATEZdecreaseSpeechPitchZDECREASE_SPEECH_PITCHZincreaseSpeechPitchZINCREASE_SPEECH_PITCHZdecreaseSpeechVolumeZDECREASE_SPEECH_VOLUMEZincreaseSpeechVolumeZINCREASE_SPEECH_VOLUMEZquitOrcaZ	QUIT_ORCAZshowPreferencesGUIZSHOW_PREFERENCES_GUIZshowAppPreferencesGUIZSHOW_APP_PREFERENCES_GUI�toggleSilenceSpeechZ
TOGGLE_SPEECH�toggleSpeechVerbosityZTOGGLE_SPEECH_VERBOSITY�&toggleSpeakingIndentationJustificationZ+TOGGLE_SPOKEN_INDENTATION_AND_JUSTIFICATION�changeNumberStyleZCHANGE_NUMBER_STYLE�cycleSpeakingPunctuationLevelZCYCLE_PUNCTUATION_LEVEL�cycleSettingsProfileZCYCLE_SETTINGS_PROFILE�cycleCapitalizationStyleZCYCLE_CAPITALIZATION_STYLE�cycleKeyEchoZCYCLE_KEY_ECHO�cycleDebugLevelZCYCLE_DEBUG_LEVELr)ZBOOKMARK_GO_TO_PREVIOUSr*ZBOOKMARK_GO_TOr+ZBOOKMARK_GO_TO_NEXTr,ZBOOKMARK_ADDr-Z
BOOKMARK_SAVE�mouse_reviewZreviewerZtoggleZMOUSE_REVIEW_TOGGLE�presentTimeZPRESENT_CURRENT_TIME�presentDateZPRESENT_CURRENT_DATE�bypassNextCommandZBYPASS_NEXT_COMMAND�update�notification_messages)rrrr�setupInputEventHandlers�s�zScript.setupInputEventHandlerscCs(x"|jj�D]\}}||kr|SqWdS)zaReturns the name of the key that contains an inputEventHadler
        passed as argument
        N)r1�items)rZinputEventHandlerZkeyName�handlerrrr�getInputEventHandlerKey	szScript.getInputEventHandlerKeycCsFtjj|�}|j|d<|j|d<|j|d<|j|d<|j|d<|j|d<|j	|d<|j
|d<|j|d	<|j|d
<|j
|d<|j|d<|j|d
<|j|d<|j|d<|j|d<|j|d<|j|d<|j|d<|j|d<|j|d<|j|d<|j|d<|j|d<|j|d<|j|d<|j|d<|j|d<|j|d<|j|d<|j |d<|S) z<Sets up the AT-SPI event listeners for this script.
        zfocus:zdocument:reloadzdocument:load-completezdocument:load-stoppedzmouse:buttonz&object:property-change:accessible-namezobject:text-caret-movedzobject:text-changed:deletezobject:text-changed:insertz object:active-descendant-changedzobject:children-changedzobject:state-changed:activezobject:state-changed:busyzobject:state-changed:focusedzobject:state-changed:showingzobject:state-changed:checkedzobject:state-changed:pressedz"object:state-changed:indeterminatezobject:state-changed:expandedzobject:state-changed:selectedzobject:state-changed:sensitivezobject:text-attributes-changedzobject:text-selection-changedzobject:selection-changedz'object:property-change:accessible-valuezobject:value-changedzobject:column-reorderedzobject:row-reorderedzwindow:activatezwindow:deactivatez
window:create)!rr�getListeners�onFocus�onDocumentReload�onDocumentLoadComplete�onDocumentLoadStopped�
onMouseButton�
onNameChanged�onCaretMoved�
onTextDeleted�onTextInserted�onActiveDescendantChanged�onChildrenChanged�onActiveChanged�
onBusyChanged�onFocusedChanged�onShowingChanged�onCheckedChanged�onPressedChanged�onIndeterminateChanged�onExpandedChanged�onSelectedChanged�onSensitiveChanged�onTextAttributesChanged�onTextSelectionChanged�onSelectionChanged�onValueChanged�onColumnReordered�onRowReordered�onWindowActivated�onWindowDeactivated�onWindowCreated)rZ	listenersrrrrwsB






























zScript.getListenerscCs&ddlj}tj�}|j|j|j�|S)zReturns an instance of keybindings.KeyBindings that use the
        numeric keypad for focus tracking and flat review.
        rN)Zorca.desktop_keyboardmap�desktop_keyboardmap�keybindings�KeyBindings�load�keymapr1)rr��keyBindingsrrrZ__getDesktopBindings[s
zScript.__getDesktopBindingscCs&ddlj}tj�}|j|j|j�|S)z�Returns an instance of keybindings.KeyBindings that use the
        the main keyboard keys for focus tracking and flat review.
        rN)Zorca.laptop_keyboardmap�laptop_keyboardmapr�r�r�r�r1)rr�r�rrrZ__getLaptopBindingses
zScript.__getLaptopBindingsc
Cs�tjj|�}|j�}x|jD]}|j|�qW|j�}x|jD]}|j|�q>W|j�}x|jD]}|j|�q`Wytj	||�}Wn0d|}t
jt
j|d�t
j
t
j�YnX|S)zkDefines the key bindings for this script.

        Returns an instance of keybindings.KeyBindings.
        z2ERROR: Exception when overriding keybindings in %sT)rr�getKeyBindings�getDefaultKeyBindingsr��add�getToolkitKeyBindings�getAppKeyBindings�_settingsManagerZoverrideKeyBindings�debug�println�
LEVEL_WARNING�printException)rr�Zbindingsr�msgrrrr�os"zScript.getKeyBindingscCsxtj�}tjd�}|tjkr<x<|j�jD]}|j|�q(Wnx|j	�jD]}|j|�qHWddl
j}|j|j
|j�|S)zyReturns the default script's keybindings, i.e. without any of
        the toolkit or application specific commands added.ZkeyboardLayoutrN)r�r�r��
getSetting�settingsZGENERAL_KEYBOARD_LAYOUT_DESKTOP�_Script__getDesktopBindingsr�r��_Script__getLaptopBindingsZorca.common_keyboardmap�common_keyboardmapr�r�r1)rr�Zlayoutrr�rrrr��s


zScript.getDefaultKeyBindingscCsJtjj|�}y�|jd|tjj<|jd|tjj<|jd|tjj<|jd|tjj	<|jd|tjj
<|jd|tjj<|jd|tjj<|jd|tjj
<|jd	|tjj<|jd
|tjj<|jd|tjj<|jd|tjj<Wn\tk
�rd
|}tjtj|d�Yn0d|}tjtj|d�tjtj�YnX|S)z�Defines the braille bindings for this script.

        Returns a dictionary where the keys are BrlTTY commands and the
        values are InputEventHandler instances.
        r"r#rr rrr!r$r%r&r'r(z+DEFAULT: Braille bindings unavailable in %sTz/ERROR: Exception getting braille bindings in %s)rr�getBrailleBindingsr1�brailleZbrlapiZKEY_CMD_FWINLTZKEY_CMD_FWINRTZKEY_CMD_LNUPZKEY_CMD_LNDNZKEY_CMD_FREEZEZKEY_CMD_TOP_LEFTZKEY_CMD_BOT_LEFTZKEY_CMD_HOMEZKEY_CMD_SIXDOTSZ
KEY_CMD_ROUTEZKEY_CMD_CUTBEGINZKEY_CMD_CUTLINE�AttributeErrorr�r��
LEVEL_INFOr��LEVEL_CONFIGURATION)r�brailleBindingsr�rrrr��s,zScript.getBrailleBindingscCsd|_d|_i|_dS)z'Called when this script is deactivated.FN)rr�pointOfReference)rrrr�
deactivate�szScript.deactivatecst�j�|jj�dS)N)�super�registerEventListeners�	utilitiesZconnectToClipboard)r)�	__class__rrr��s
zScript.registerEventListenerscst�j�|jj�dS)N)r��deregisterEventListenersr�ZdisconnectFromClipboard)r)r�rrr��s
zScript.deregisterEventListenersc
Cs,|sdSy|j�}|j�}|j}Wn
dS|jjdi�}||t|�<tjr�ytjj|ttj�<Wn&dtj}tj	tj
|d�YnX||jd<y|j�}WnYn"X|j|t
d|j��|jj|�|jj|�\}}	|	|jd<||jd<t|�|jtj�f|jd<t|�|jtj�f|jd	<dS)
aFSaves some basic information about obj. Note that this method is
        intended to be called primarily (if not only) by locusOfFocusChanged().
        It is expected that accessible event callbacks will update the point
        of reference data specific to that event. The goal here is to weed
        out duplicate events.N�namesz$ERROR: Exception getting name for %sTrZ
lastColumnZlastRow�
checkedChange�selectedChange)�getRole�getState�namer��get�hash�
orca_state�activeWindowr�r�r��	queryText�_saveLastCursorPosition�max�caretOffsetr��updateCachedTextSelectionZcoordinatesForCell�containsrZ
STATE_CHECKED�STATE_SELECTED)
r�obj�role�stater�r�r��text�row�columnrrr�_saveFocusedObjectInfo�s8




zScript._saveFocusedObjectInfoc
Cs�|jj�|stj�t_dS|j�jtj�r0dS|jj	||�rBdSy|j
rNdSWnYnX|jrl|j�tj
s�|r�|jtjjkr�|jj|�t_
tj�|_|j|�|jo�tj�|jdk}|jj||d�}tj||d�|j|�dS)aCalled when the visual object with focus changes.

        Arguments:
        - event: if not None, the Event that caused the change
        - oldLocusOfFocus: Accessible that is the old locus of focus
        - newLocusOfFocus: Accessible that is the new locus of focus
        N�)�priorObj)�	interrupt)r�ZpresentFocusChangeReason�timer�ZnoFocusTimeStampr�r�rZ
STATE_DEFUNCT�isSameObject�findCommandRunr
r@r�Zhost_applicationZactiveScriptr�topLevelObjectr�
updateBraille�speechGenerator�generateSpeechrc�speakr�)r�eventZoldLocusOfFocusZnewLocusOfFocusZshouldNotInterrupt�
utterancesrrr�locusOfFocusChanged
s4	



zScript.locusOfFocusChangedcCs.tj|�tj|jj��tj�tj�dS)z%Called when this script is activated.N)	r�ZloadAppSettingsr�ZsetupKeyRangesr��keysrc�updatePunctuationLevel�updateCapitalizationStyle)rrrr�activate?s
zScript.activatecKs�tjd�r,tjd�r,tjtjdd�dS|s4dS|jj|f|�\}}|sPdS|j�|j�}t	j
|�|j||�|jd�}|r�|j
||�|j|�n
|j|�|jd�dS)zoUpdates the braille display to show the give object.

        Arguments:
        - obj: the Accessible
        �
enableBraille�enableBrailleMonitorzBRAILLE: update disabledTN�extraRegion)r�r�r�r�r��brailleGenerator�generateBraille�clearBraille�getNewBrailleLiner��addLine�addBrailleRegionsToLiner��addBrailleRegionToLine�setBrailleFocus�refreshBraille)rr��args�resultZ
focusedRegion�liner�rrrr�Gs&


zScript.updateBrailleNcCs|jtj�dt_dS)z�Causes the next keyboard command to be ignored by Orca
        and passed along to the current application.

        Returns True to indicate the input event has been consumed.
        T)�presentMessage�messagesZBYPASS_MODE_ENABLEDr�rp)r�
inputEventrrrrpnszScript.bypassNextCommandcCs8tjr
dS|jtj�|jtj�|jtj�dt_dS)z�Turns learn mode on.  The user must press the escape key to exit
        learn mode.

        Returns True to indicate the input event has been consumed.
        T)	r��learnModeEnabledr�r��VERSION�speakMessageZLEARN_MODE_START_SPEECH�displayBrailleMessageZLEARN_MODE_START_BRAILLE)rr�rrrrbyszScript.enterLearnModecCs<tjs
dSt|tj�r&|jdkr&dS|jtj�dt_dS)zcTurns learn mode off.

        Returns True to indicate the input event has been consumed.
        FZEscapeT)	r�r��
isinstancer.�
KeyboardEvent�event_stringr�r�ZLEARN_MODE_STOP)rr�rrr�
exitLearnMode�szScript.exitLearnModecCstj�S)N)r<ZhelpForOrca)rr�rrr�showHelp�szScript.showHelpcCs|dkrtj}tj||�S)N)r��lastNonModifierKeyEventrrZlistNotificationMessages)rr�rrr�listNotifications�szScript.listNotificationsc
Cs�|dkrtj}|s|jdkr:|j�j�}tjt|��}nVy|jj	}Wnt
k
r`tj}YnX|j�j�}|j
|j�j��tjt|�|�}|s�|j|�dS|j�dd�|D�}t|dd�d�tj}tj}tj|d	||f|d
�dS)z1Shows a simple gui listing Orca's bound commands.NZF2TcSs"g|]}|jj|jj|j�f�qSr)ruZfunction�descriptionZasString)�.0Zkbrrr�
<listcomp>�sz,Script.listOrcaShortcuts.<locals>.<listcomp>cSs|dS)N�r)�cmdrrr�<lambda>�sz*Script.listOrcaShortcuts.<locals>.<lambda>)�keyrF)r�r�r�r�ZgetBoundBindingsr�ZshortcutsFoundOrca�lenrr�r�ZAPPLICATION_NO_NAMEr��extendr�ZshortcutsFoundAppr�r��sorted�	guilabelsZKB_HEADER_FUNCTIONZKB_HEADER_KEY_BINDING�commandlistZshowUI)rr�Zbound�titleZappNameZrowsZheader1Zheader2rrr�listOrcaShortcuts�s.
zScript.listOrcaShortcutscCs0tj�}|r$d|_d|_|j|�ntj�dS)a Searches forward for the next instance of the string
        searched for via the Orca Find dialog.  Other than direction
        and the starting point, the search options initially specified
        (case sensitivity, window wrap, and full/partial match) are
        preserved.
        FN)�find�getLastQuery�searchBackwards�
startAtTopr<r=)rr��	lastQueryrrrr>�szScript.findNextcCs0tj�}|r$d|_d|_|j|�ntj�dS)a%Searches backwards for the next instance of the string
        searched for via the Orca Find dialog.  Other than direction
        and the starting point, the search options initially specified
        (case sensitivity, window wrap, and full/or partial match) are
        preserved.
        TFN)rrrrr<r=)rr�rrrrr?�szScript.findPreviouscCs|j�}|j|�dS)zc Add an in-page accessible object bookmark for this key.
        Delegates to Bookmark.addBookmark N)�getBookmarksr,)rr��	bookmarksrrrr,�szScript.addBookmarkcCs|j�}|j|�dS)z_ Go to the bookmark indexed by inputEvent.hw_code.  Delegates to
        Bookmark.goToBookmark N)rr*)rr�rrrrr*�szScript.goToBookmarkcCs|j�}|j|�dS)z� Go to the next bookmark location.  If no bookmark has yet to be
        selected, the first bookmark will be used.  Delegates to
        Bookmark.goToNextBookmark N)rr+)rr�rrrrr+�szScript.goToNextBookmarkcCs|j�}|j|�dS)z� Go to the previous bookmark location.  If no bookmark has yet to
        be selected, the first bookmark will be used.  Delegates to
        Bookmark.goToPrevBookmark N)rr))rr�rrrrr)�szScript.goToPrevBookmarkcCs|j�}|j|�dS)zQ Save the bookmarks for this script. Delegates to
        Bookmark.saveBookmarks N)rr-)rr�rrrrr-szScript.saveBookmarksrcCs$|jrn|j�r*|jjtjj�|j|�n|j|dd�|j�|jj	tjj
�\}}}}}d|_|j|j�n�|j�r�t
jr�|jjt
j�r�t
jj�}|j|jtj�\}	}
}d}|
dkr�|j|
d�}|r�t
jj�tjkr�|j�}
|
jtjj�|j|�n$|j|dd�tj�|jddd�dS)a�Pans the braille display to the left.  If panAmount is non-zero,
        the display is panned by that many cells.  If it is 0, the display
        is panned one full display width.  In flat review mode, panning
        beyond the beginning will take you to the end of the previous line.

        In focus tracking mode, the cursor stays at its logical position.
        In flat review mode, the review cursor moves to character
        associated with cell 0.T)�	panToLeftr�Fr)�	stopFlash)r
�isBrailleBeginningShowing�goBegin�flat_review�Context�LINErP�panBrailleInDirection�0_setFlatReviewContextToBeginningOfBrailleDisplay�
getCurrent�CHARr�updateBrailleReviewr��locusOfFocusr��
isTextArear��getTextAtOffsetr�r�TEXT_BOUNDARY_LINE_START�setCaretOffsetr�Z
ROLE_TERMINAL�getFlatReviewContextr��resetFlashTimerr�)rr��	panAmount�
charString�x�y�width�heightr��
lineString�startOffset�	endOffsetZ
movedCaret�contextrrrr[s8


zScript.panBrailleLeftcCs|j|d�dS)z�Nudges the braille display one character to the left.

        In focus tracking mode, the cursor stays at its logical position.
        In flat review mode, the review cursor moves to character
        associated with cell 0.r�N)r[)rr�rrr�panBrailleLeftOneCharFszScript.panBrailleLeftOneCharcCs�|jrn|j�r*|jjtjj�|j|�n|j|dd�|j�|jj	tjj
�\}}}}}d|_|j|j�nv|j�r�t
jr�|jjt
j�r�t
jj�}|j|jtj�\}	}
}||jkr�|j|�n$|j|dd�tj�|jddd�dS)a�Pans the braille display to the right.  If panAmount is non-zero,
        the display is panned by that many cells.  If it is 0, the display
        is panned one full display width.  In flat review mode, panning
        beyond the end will take you to the beginning of the next line.

        In focus tracking mode, the cursor stays at its logical position.
        In flat review mode, the review cursor moves to character
        associated with cell 0.F)rr�)rT)r
�isBrailleEndShowing�goEndrrrrVrrrr rr!r�r"r�r#r�r$r�rr%�characterCountr&r�r(r�)rr�r)r*r+r,r-r.r�r/r0r1rrrr\Os*


zScript.panBrailleRightcCs|j|d�dS)z�Nudges the braille display one character to the right.

        In focus tracking mode, the cursor stays at its logical position.
        In flat review mode, the review cursor moves to character
        associated with cell 0.r�N)r\)rr�rrr�panBrailleRightOneChar�szScript.panBrailleRightOneCharcCs|jr|j|�Stj|�SdS)z$Returns to the component with focus.N)r
r@r�ZreturnToRegionWithFocus)rr�rrrr]�s
zScript.goBrailleHomecCs|j|�dS)zToggles contracted braille.T)�_setContractedBraille)rr�rrrr^�s
zScript.setContractedBraillecCstj|�dS)zProcesses a cursor routing key.T)r�r_)rr�rrrr_�s
zScript.processRoutingKeycCs4|j|�\}}|dkr0|jj|�|jj||�dS)zcClears the selection and moves the caret offset in the currently
        active text area.
        rT)�getBrailleCaretContextr�ZclearTextSelectionr&)rr�r�r�rrrr`�s
zScript.processBrailleCutBegincCsR|j|�\}}|dkrN|jj||�|j�}|jd�\}}|jj|j||��dS)zExtends the text selection in the currently active text
        area and also copies the selected text to the system clipboard.rT)r9r�ZadjustTextSelectionr�ZgetSelection�setClipboardText�getText)rr�r�r�Ztextir0r1rrrra�szScript.processBrailleCutLinecCs�|jj�|_tj�|_|jr(|jj�nTytjt	j
�WnBytjt	j
�Wn$tj
}tj}|j||�YnXYnXdS)z,Moves the mouse pointer to the current item.T)r�ZabsoluteMouseCoordinatesrr�rr
ZrouteToCurrent�eventsynthesizerZrouteToCharacterr�r"Z
routeToObjectr��LOCATION_NOT_FOUND_FULL�LOCATION_NOT_FOUND_BRIEFr�)rr��full�briefrrrr/�s
zScript.routePointerToItemcCsztj}|j|�|jj|�\}}|rXtj|jj|��|jj	|�}|rXtj|jj
|��|p^|}|rvtj|jj|��dS)zsSpeaks and brailles the contents of the status bar and/or default
        button of the window with focus.
        N)r�r"r�r��frameAndDialogrcr�r�ZgenerateStatusBarZinfoBarr�ZgenerateDefaultButton)rr�r��frame�dialogZinfobar�windowrrrr;�s
zScript.presentStatusBarcCs2|jjtj�}x|D]\}}|j||d�qWdS)z7Speaks and brailles the title of the window with focus.)�voiceN)r�Z
generateTitler�r"r�)rr�r
�stringrErrrr:�szScript.presentTitlecCs�|jjtjdd�\}}}|jjtjd��\}}tt|jj	|��}ddddg}xR|D]J}|j
|�}	|j
|�}
|	|kr||
|kr|qR|	rR|	|
krR|j|jj||	��qRWdS)aSReads the attributes associated with the current text character.
        Calls outCharAttributes to speak a list of attributes. By default,
        a certain set of attributes will be spoken. If this is not desired,
        then individual application scripts should override this method to
        only speak the subset required.
        NTZenabledSpokenTextAttributes�0Z0mmZnoneZfalse)
r�ZtextAttributesr�r"ZstringToKeysAndDictr�r��list�mapZgetAppNameForAttributer�r�ZlocalizeTextAttribute)rr�Zattrs�start�endZuserAttrListZuserAttrDictZ
nullValuesr�valueZ
ignoreIfValuerrrrZ�s


zScript.readCharAttributescCsd|jr|jjd�nLytjtjd�Wn8ytjtjd�Wn|jtj	�YnXYnXdS)z7Performs a left mouse button click on the current item.r�T)
r
�clickCurrentr<�clickCharacterr�r"�clickObjectr�r�r=)rr�rrrr2szScript.leftClickReviewItemcCsp|jr|jjd�nXytjtjd�WnDytjtjd�Wn$tj}tj	}|j
||�YnXYnXdS)z8Performs a right mouse button click on the current item.�T)r
rMr<rNr�r"rOr�r=r>r�)rr�r?r@rrrr3szScript.rightClickReviewItemcCsx|D]}|j|�qWdS)zsSpell the current flat review word or line.

        Arguments:
        - itemString: the string to spell.
        N)�speakCharacter)r�
itemString�	characterrrr�spellCurrentItem)s
zScript.spellCurrentItemr�cCs"|j�}|jtjj�\}}}}}	|jj|d�}
t|tj	��s|sTt
|�sT|dkrbtjt
j�n�|jtjj�\}}}}}	|dkr�tjt
j�n~|j�r�tjt
j�nh|j�r�|dkr�tj||
�nJ|dkr�|j|�n6|dkr�|j|�n"|dk�r|jj|�}tj||
�|j|�||_dS)a,Presents the current item to the user.

        Arguments:
        - inputEvent - the current input event.
        - targetCursorCell - if non-zero, the target braille cursor cell.
        - speechType - the desired presentation: speak (1), spell (2), or
                       phonetic (3).
        )rF�
r�rrPT)r'rrr�WORDr�rEr�r.�BrailleEventrrcr�r��BLANKr�isspace�WHITE_SPACE�isupperrT�phoneticSpellCurrentItemr��adjustForRepeatsr!r)rr�r�
speechTyper2�
wordStringr+r,r-r.rEr/rrr�_reviewCurrentItem3s2


zScript._reviewCurrentItemc	Csb|j�}|jtjj�\}}}}}t|tj�s^|jj	|j
��}|j|jj
|j
�d��tj|�dS)NFT)r'rrr�ZONEr�r.rWr�r�ZgetCurrentAccessibler	�tutorialGenerator�getTutorialrcr�)	rr�r2Z
zoneStringr+r,r-r.r�rrrrNbs


zScript.reviewCurrentAccessiblecCs8|j�}|jtjjtjj�}|r4|j|�|j�|_dS)zxMoves the flat review context to the previous item.  Places
        the flat review cursor at the beginning of the item.T)	r'�
goPreviousrrrV�	WRAP_LINEr`�getBrailleCursorCellr)rr�r2�movedrrrrHrs



zScript.reviewPreviousItemcCs8|j�}|jtjjtjj�}|r4|j|�|j�|_dS)ztMoves the flat review context to the next item.  Places
        the flat review cursor at the beginning of the item.T)	r'�goNextrrrVrer`rfr)rr�r2rgrrrrM�s



zScript.reviewNextItemcCs|j|d�dS)z6Brailles and speaks the current flat review character.r�T)�_reviewCurrentCharacter)rr�rrrrS�szScript.reviewCurrentCharactercCs|j|d�dS)zXBrailles and 'spells' (phonetically) the current flat review
        character.
        rT)ri)rr�rrrrT�sz"Script.reviewSpellCurrentCharactercCs|j|d�dS)zaBrailles and speaks unicode information about the current flat
        review character.
        rPT)ri)rr�rrrrU�sz$Script.reviewUnicodeCurrentCharacterc
Cs�|j�}|jtjj�\}}}}}t|tj�s�|s<t|�rJt	j
tj�nh|jtjj
�\}	}}}}|	dkr�|dkr�t	j
tj�n2|dkr�|j|�n|dkr�|j|�n
|j|�|j�||_dS)a;Presents the current flat review character via braille and speech.

        Arguments:
        - inputEvent - the current input event.
        - speechType - the desired presentation:
                       speak (1),
                       phonetic (2)
                       unicode value information (3)
        rUrPrT)r'rrrr r�r.rWrrcr�r�rXr�speakUnicodeCharacterr\rQr!r)
rr�r^r2r*r+r,r-r.r/rrrri�s 
zScript._reviewCurrentCharactercCs8|j�}|jtjjtjj�}|r4|j|�|j�|_dS)zmMoves the flat review context to the previous character.  Places
        the flat review cursor at character.T)	r'rdrrr rerirfr)rr�r2rgrrrrP�s



zScript.reviewPreviousCharactercCs.|j�}|jtjj�|j|�|j�|_dS)ztMoves the flat review context to the end of the line.  Places
        the flat review cursor at the end of the line.T)r'r5rrrrSrfr)rr�r2rrrrQ�s


zScript.reviewEndOfLinecCs8|j�}|jtjjtjj�}|r4|j|�|j�|_dS)ziMoves the flat review context to the next character.  Places
        the flat review cursor at character.T)	r'rhrrr rerirfr)rr�r2rgrrrrV�s



zScript.reviewNextCharactercCs2|j�}|jtjjtjj�}|r.|j||j�dS)z�Moves the flat review context to the character most directly
        above the current flat review cursor.  Places the flat review
        cursor at character.T)r'ZgoAboverrr rer`r)rr�r2rgrrrrI�s

zScript.reviewAbovecCs2|j�}|jtjjtjj�}|r.|j||j�dS)z�Moves the flat review context to the character most directly
        below the current flat review cursor.  Places the flat review
        cursor at character.T)r'ZgoBelowrrr rer`r)rr�r2rgrrrrO	s

zScript.reviewBelowcCs|j|d�dS)z1Brailles and speaks the current flat review line.r�T)�_reviewCurrentLine)rr�rrrrCszScript.reviewCurrentLinecCs|j|d�dS)z1Brailles and spells the current flat review line.rT)rk)rr�rrrrDszScript.reviewSpellCurrentLinecCs|j|d�dS)z>Brailles and phonetically spells the current flat review line.rPT)rk)rr�rrrrE&sz Script.reviewPhoneticCurrentLinec
Cs�|j�}|jtjj�\}}}}}|jj|d�}	t|tj	�s�|sRt
|�sR|dkr`tjt
j�n||j�rvtjt
j�nf|j�r�|dks�|dkr�tj||	�n@|dkr�|j|�n,|dkr�|j|�n|jj|�}tj||	�|j�||_dS)z�Presents the current flat review line via braille and speech.

        Arguments:
        - inputEvent - the current input event.
        - speechType - the desired presentation: speak (1), spell (2), or
                       phonetic (3)
        )rFrUrrPT)r'rrrrr�rEr�r.rWrrcr�r�rXrYrZr[rTr\r�r]r!r)
rr�r^r2r/r+r,r-r.rErrrrk-s*	
zScript._reviewCurrentLinecCs8|j�}|jtjjtjj�}|r4|j|�|j�|_dS)zLMoves the flat review context to the beginning of the
        previous line.T)	r'rdrrrrerkrfr)rr�r2rgrrrrAVs



zScript.reviewPreviousLinecCs(|j�}|j�|j|�|j�|_dS)zLMoves the flat review context to the top left of the current
        window.T)r'rrkrfr)rr�r2rrrrBes


zScript.reviewHomecCs8|j�}|jtjjtjj�}|r4|j|�|j�|_dS)z�Moves the flat review context to the beginning of the
        next line.  Places the flat review cursor at the beginning
        of the line.T)	r'rhrrrrerkrfr)rr�r2rgrrrrFrs



zScript.reviewNextLinecCs<|j�}|jtjj�|jtjj�|j|�|j�|_	dS)z�Moves the flat review context to the beginning of the
        last line in the window.  Places the flat review cursor at
        the beginning of the line.T)
r'r5rrZWINDOWrrrkrfr)rr�r2rrrrR�s

zScript.reviewBottomLeftcCs(|j�}|j�|j|�|j�|_dS)z�Moves the flat review context to the end of the
        last line in the window.  Places the flat review cursor
        at the end of the line.T)r'r5rkrfr)rr�r2rrrrG�s


zScript.reviewEndcCs|j||d�dS)z1Brailles and speaks the current item to the user.r�T)r`)rr�rrrrrJ�szScript.reviewCurrentItemcCs|j||d�dS)z1Brailles and spells the current item to the user.rT)r`)rr�rrrrrK�szScript.reviewSpellCurrentItemcCs|j||d�dS)z>Brailles and phonetically spells the current item to the user.rPT)r`)rr�rrrrrL�sz Script.reviewPhoneticCurrentItemcCs2|jr"|jj|j�|jtj�n|jtj�dS)z^Copies the contents of the item under flat review to and places
        them in the clipboard.T)r
r�r:rr�r�ZFLAT_REVIEW_COPIED�FLAT_REVIEW_NOT_IN)rr�rrrrW�s
zScript.flatReviewCopycCs2|jr"|jj|j�|jtj�n|jtj�dS)zLAppends the contents of the item under flat review to
        the clipboard.T)r
r�ZappendTextToClipboardrr�r�ZFLAT_REVIEW_APPENDEDrl)rr�rrrrX�s
zScript.flatReviewAppendc	CsV|j�}|j�x@|jtjj�\}}}}}tj|�|jtjjtjj	�}|sPqWdS)NT)
r'rrrrrarcr�rhre)	rr�r2r_r+r,r-r.rgrrrr5�s
zScript.flatReviewSayAllcCs�|ptj}y|j�}WnPtk
rT|jj|�}|j|jj|d��t	j
|�Yn8tk
rfYn&X|dkrv|j}t	j
|j||�|j�dS)NFT)r�r"r��NotImplementedErrorr�r�r	rbrcrcr�r�r�r4�	textLines�_Script__sayAllProgressCallback)rr�r��offsetr�r�rrrr4�s
z
Script.sayAllc	Cs�tjd�}|jr>|r*|tjkr*|jtj�d|_|jt	j
�nH|rX|tjkrX|jtj�|j�}|j
tjj�\}}}}}|j||j�dS)z9Toggles between flat review mode and focus tracking mode.�speechVerbosityLevelNT)r�r�r
r��VERBOSITY_LEVEL_BRIEFr�r�ZFLAT_REVIEW_STOPr�r�r"ZFLAT_REVIEW_STARTr'rrrrVr`r)	rr��	verbosityr2r_r+r,r-r.rrrr@�s
zScript.toggleFlatReviewModecCsttj�tjd�r,tjdd�|jtj�nDtjd�sXtjdd�tj�|jtj�n|jtj	�tjdd�dS)zmToggle the silencing of speech.

        Returns True to indicate the input event has been consumed.
        Z
silenceSpeechF�enableSpeechT)
rc�stopr�r��
setSettingr�r�ZSPEECH_ENABLED�initZSPEECH_DISABLED)rr�rrrrd�s

zScript.toggleSilenceSpeechcCsNtjd�}|tjkr0|jtj�tjdtj�n|jtj	�tjdtj�dS)z9Toggles speech verbosity level between verbose and brief.rqT)
r�r�r�rrr�r�ZSPEECH_VERBOSITY_VERBOSErvZVERBOSITY_LEVEL_VERBOSEZSPEECH_VERBOSITY_BRIEF)rr�rLrrrres


zScript.toggleSpeechVerbositycCsLtjd�}tjd|�tjd�r0tj}tj}ntj}tj}|j||�dS)z6Toggles the speaking of indentation and justification.ZenableSpeechIndentationT)	r�r�rvr�Z!INDENTATION_JUSTIFICATION_ON_FULLZ"INDENTATION_JUSTIFICATION_ON_BRIEFZ"INDENTATION_JUSTIFICATION_OFF_FULLZ#INDENTATION_JUSTIFICATION_OFF_BRIEFr�)rr�rLr?r@rrrrfs

z-Script.toggleSpeakingIndentationJustificationcCs�tjd�}|tjkr(tj}tj}tj}nN|tjkrFtj}tj	}tj
}n0|tjkrdtj}tj}tj
}ntj}tj}tj}tjd|�|j||�tj�dS)z2 Cycle through the punctuation levels for speech. �verbalizePunctuationStyleT)r�r�r��PUNCTUATION_STYLE_NONEZPUNCTUATION_STYLE_SOMEr�ZPUNCTUATION_SOME_FULLZPUNCTUATION_SOME_BRIEFZPUNCTUATION_STYLE_MOSTZPUNCTUATION_MOST_FULLZPUNCTUATION_MOST_BRIEFZPUNCTUATION_STYLE_ALLZPUNCTUATION_ALL_FULLZPUNCTUATION_ALL_BRIEFZPUNCTUATION_NONE_FULLZPUNCTUATION_NONE_BRIEFrvr�rcr�)rr�ZcurrentLevelZnewLevelr?r@rrrrh,s(



z$Script.cycleSpeakingPunctuationLevelcCs�tj�}|o|ds$|jtj�dSdd�}tt||��d}y||j|�d\}}Wn tk
rx|d\}}YnXtj	|dd�t
j�t
j�|j
�|jtj||�dS)z4Cycle through the user's existing settings profiles.rTcSs|dtj�kS)Nr�)r�Z
getProfile)r+rrrrNsz-Script.cycleSettingsProfile.<locals>.<lambda>r�)ZupdateLocale)r�ZavailableProfilesr�r�ZPROFILE_NOT_FOUNDrH�filter�index�
IndexErrorZ
setProfilercZshutdownrwrsZPROFILE_CHANGED)rr�ZprofilesZisMatchZcurrentr�Z	profileIDrrrriFs zScript.cycleSettingsProfilecCs|tjd�}|tjkr(tj}tj}tj}n0|tjkrFtj}tj	}tj
}ntj}tj}tj}tj
d|�|j||�tj�dS)z< Cycle through the speech-dispatcher capitalization styles. �capitalizationStyleT)r�r�r��CAPITALIZATION_STYLE_NONEZCAPITALIZATION_STYLE_SPELLr�ZCAPITALIZATION_SPELL_FULLZCAPITALIZATION_SPELL_BRIEFZCAPITALIZATION_STYLE_ICONZCAPITALIZATION_ICON_FULLZCAPITALIZATION_ICON_BRIEFZCAPITALIZATION_NONE_FULLZCAPITALIZATION_NONE_BRIEFrvr�rcr�)rr�ZcurrentStyleZnewStyler?r@rrrrjas 


zScript.cycleCapitalizationStylec
Cs2d\}}}tjd�}tjd�}tjd�}|||fdkrNd\}}}tj}tj}	n�|||fd	krtd
\}}}tj}tj}	n�|||fdkr�d\}}}tj}tj}	nd|||fd
kr�d\}}}tj	}tj
}	n>|||fdk�r�d\}}}tj}tj}	nd\}}}tj
}tj}	tjd|�tjd|�tjd|�|j||	�dS)NFZ
enableKeyEcho�enableEchoByWord�enableEchoBySentenceT)FFF)FFF)TFF)TFF)FTF)FTF)FFT)FFT)TTF)TTF)FTT)FFF)r�r�r�ZKEY_ECHO_KEY_FULLZKEY_ECHO_KEY_BRIEFZKEY_ECHO_WORD_FULLZKEY_ECHO_WORD_BRIEFZKEY_ECHO_SENTENCE_FULLZKEY_ECHO_SENTENCE_BRIEFZKEY_ECHO_KEY_AND_WORD_FULLZKEY_ECHO_KEY_AND_WORD_BRIEFZKEY_ECHO_WORD_AND_SENTENCE_FULLZ KEY_ECHO_WORD_AND_SENTENCE_BRIEFZKEY_ECHO_NONE_FULLZKEY_ECHO_NONE_BRIEFrvr�)
rr�ZnewKeyZnewWordZnewSentencer�word�sentencer?r@rrrrkws@









zScript.cycleKeyEchocCsFtjd�}|rtj}tj}ntj}tj}tjd|�|j||�dS)z5Changes spoken number style between digits and words.ZspeakNumbersAsDigitsT)	r�r�r�ZNUMBER_STYLE_WORDS_BRIEFZNUMBER_STYLE_WORDS_FULLZNUMBER_STYLE_DIGITS_BRIEFZNUMBER_STYLE_DIGITS_FULLrvr�)rr�ZspeakDigitsr@r?rrrrg�s
zScript.changeNumberStylecCs�|jjtj�}|s"|jtj�dS|jj|�s4d}n|jj|�rFd}nd}t	j
|�}t	j||�|sntj}ntj
}|j|�dS)zjToggles an indicator for whether we should just read the current
        table cell or read the whole row.TZreadFullRowInGUITableZreadFullRowInSpreadSheetZreadFullRowInDocumentTable)r��getTabler�r"r�r�ZTABLE_NOT_IN_AZgetContainingDocumentZisSpreadSheetTabler�r�rvZTABLE_MODE_ROWZTABLE_MODE_CELL)rr��tableZsettingNameZspeakRowr�rrrrY�s 

zScript.toggleTableCellReadModec	Csn|jr|jj�r|jj|�tj}|s,dS|j|�|r@d}nd}tj|jj	|j
j|�d|dddd��dS)znPeforms the whereAmI operation.

        Arguments:
        - inputEvent:     The original inputEvent
        FZ
basicWhereAmIZdetailedWhereAmIT)�alreadyFocused�
formatTypeZ
forceMnemonicZ	forceListZ
forceTutorial)Z
spellcheckZisActiveZpresentErrorDetailsr�r"r�rcr�r�r�r�ZrealActiveAncestor)rr�Z	basicOnlyr�r�rrr�
doWhereAmI�s"



zScript.doWhereAmIcCs|j|d�dS)zGSpeaks basic information about the current object of interest.
        TN)r�)rr�rrrr6�szScript.whereAmIBasiccCs|j|d�dS)zYSpeaks detailed/custom information about the current object of
        interest.
        FN)r�)rr�rrrr7�szScript.whereAmIDetailedcCs�tjdtjdtjdtjdtjdtjdtjdtjdtj	d	g}y|j
tj�d
}Wnd}YnX|t|�krpd}||t_||d}d
|}|j
||�dS)N�allZfinestZfinerZfineZ
configuration�infoZwarningZsevereZoffrrr�zDebug level %s.T)r�Z	LEVEL_ALLZLEVEL_FINESTZLEVEL_FINERZ
LEVEL_FINEr�r�r�ZLEVEL_SEVEREZ	LEVEL_OFFr{Z
debugLevelrr�)rr�ZlevelsZ
levelIndex�briefMessage�fullMessagerrrrl�s(


zScript.cycleDebugLevelcCs:|ptj}|jj|�s$|jtj�ntj|j	j
|��dS)NT)r�r"r�ZisLinkr�r�Z
NOT_ON_A_LINKrcr�r�ZgenerateLinkInfo)rr��linkrrrr8s

zScript.whereAmILinkcCs@|ptj}|jj|�\}}}|s(tj}n
tj|}|j|�dS)NT)r�r"r�ZallSelectedTextr�ZNO_SELECTED_TEXTZSELECTED_TEXT_ISr�)rr�r�r�r0r1r�rrrr9s


zScript.whereAmISelectedTextcCsdS)zTJust here to capture events.

        Arguments:
        - event: the Event
        Nr)rr�rrr�noOp$szScript.noOpcCs�tjtjtjtjg}|jj�|kr�|jr<|jj	|j�r<dS|jj
|jtj�}|rx|jrxd}t
jt
j|d�dt_dS|r�|jr�d}t
jt
j|d�tj�|_tj||j�|jt_|jr�d|_|j�dS)z>Callback for object:state-changed:active accessibility events.Nz4DEFAULT: Event is for active window. Clearing state.Tz0DEFAULT: Updating active window to event source.F)r�
ROLE_FRAME�ROLE_DIALOGZROLE_FILE_CHOOSERZROLE_COLOR_CHOOSER�sourcer��detail1r��canBeActiveWindowr�r�r�r�r�r�r�rr<�setLocusOfFocusr�r)rr�ZframesZsourceIsActiveWindowr�rrrr�,s.
zScript.onActiveChangedcCsZ|js
dS|jj�jtj�r6|jj�jtj�r6dS|j|�rHtj�t	j
||j�dS)zCCallback for object:active-descendant-changed accessibility events.N)�any_datar�r�r�r�
STATE_FOCUSED�#stopSpeechOnActiveDescendantChangedrcrur<r�)rr�rrrr�Ls
z Script.onActiveDescendantChangedcCsdS)z<Callback for object:state-changed:busy accessibility events.Nr)rr�rrrr�[szScript.onBusyChangedcCs�|j}|jj|tj�sdS|j�}|jtj�r2dS|j	�tj
krZ|jj�\}}|dkrZdS|jj
dd	�\}}t|�t|�kr�||jkr�dS|j|�tj|jj|dd��t|�|jf|jd<dS)
z?Callback for object:state-changed:checked accessibility events.N� �spacer�rT)r�)r�r�)Nr)r�r�r�r�r"r�r�rZSTATE_EXPANDABLEr�ZROLE_RADIO_BUTTON�lastKeyAndModifiersr�r�r�r�r�rcr�r�r�)rr�r�r��eventString�mods�oldObj�oldStaterrrr�_s 
zScript.onCheckedChangedcCsdS)z]Called when a child node has changed.

        Arguments:
        - event: the Event
        Nr)rr�rrrr�{szScript.onChildrenChangedc
Cs|jjdd�\}}||jkr>||jkr>d}tjtj|d�dS|jj�}|jt	j
�sxd}tjtj|d�|jj|�sxdS|jt
jko�|jt	j��r|jj|j�}|jjt
j|�r�dt
j|jf}tjtj|d�tj||jd�nd	|t
jf}tjtj|d�|jt
jk�r2d
|jt
jf}tjtj|d�dS|j�rB|j�|jj�}y
|j}Wn$d|j}tjtj|d�dS|j|j|j�|j��r�d}tjtj|d�|jj|j�dS|jj|�\}	}
}|�r�|jj|��r�dSd
}tjtj|d�|j|�dS)z:Callback for object:text-caret-moved accessibility events.�lastCursorPositionNr�z0DEFAULT: Event is for last saved cursor positionTz$DEFAULT: Event source is not showingz,DEFAULT: Updating locusOfFocus from %s to %sFz4DEFAULT: Source window (%s) is not active window(%s)z3DEFAULT: Event source (%s) is not locusOfFocus (%s)z-DEFAULT: Exception getting caretOffset for %sz)DEFAULT: Event source has text selectionsz.DEFAULT: Presenting text at new caret position���)Nr�)r�r�r�r�r�r�r�r�r�rZ
STATE_SHOWINGr�Z presentEventFromNonShowingObjectr�r"r�r�r�r�r<r�r
r@r�r�r��getNSelections�handleTextSelectionChange�getCachedTextSelection�_presentTextAtNewCaretPosition)rr�r�rpr�r�r�r�r�rJrKrFrrrr~�s`




zScript.onCaretMovedcCsdS)z2Callback for document:reload accessibility events.Nr)rr�rrrry�szScript.onDocumentReloadcCsdS)z9Callback for document:load-complete accessibility events.Nr)rr�rrrrz�szScript.onDocumentLoadCompletecCsdS)z8Callback for document:load-stopped accessibility events.Nr)rr�rrrr{�szScript.onDocumentLoadStoppedcCs�|j}|j�}|jj|tj�r4|tjtjgkr4dS|j	j
dd�\}}t|�t|�krd||jkrddS|j
|�tj|jj|dd��t|�|jf|j	d<dS)z@Callback for object:state-changed:expanded accessibility events.NZexpandedChangerT)r�)Nr)r�r�r�r�r�r"rZROLE_TABLE_ROW�ROLE_COMBO_BOXr�r�r�r�r�rcr�r�r�)rr�r�r�r�r�rrrr��s
zScript.onExpandedChangedcCs�|js
dS|j}|jj|tj�s$dS|jjdd�\}}t|�t|�krT||jkrTdS|j	|�t
j|jj
|dd��t|�|jf|jd<dS)zECallback for object:state-changed:indeterminate accessibility events.NZindeterminateChangerT)r�)Nr)r�r�r�r�r�r"r�r�r�r�rcr�r�r�)rr�r�r�r�rrrr��s
zScript.onIndeterminateChangedcCsztj|�}|t_|jsdS|jj�}tj|k}|rF|t_tjd|d�t	j
�|j}|rv|j�j
tj�rvtjd||�dS)z!Callback for mouse:button events.NF)r.ZMouseButtonEventr��lastInputEventZpressedr�r�r<r�rcrur�r�r�rr�)rr�Z
mouseEventrDZ
windowChangedr�rrrr|�s


zScript.onMouseButtoncCs|j}|jjdi�}|jt|��}||jkrHd|}tjtj|d�dS|j�}|t	j
t	jgkrxd}tjtj|d�dS|t	jkr�|t
jkr�d}tjtj|d�dSn"|t
jkr�d}tjtj|d�dS|j|t|�<||jd<|j|�tj|jj|dd��dS)	z;Callback for object:property-change:accessible-name events.r�z.DEFAULT: Old name (%s) is the same as new nameTNz6DEFAULT: Event is redundant notification for this rolez8DEFAULT: Event is for frame other than the active windowz8DEFAULT: Event is for object other than the locusOfFocus)r�)r�r�r�r�r�r�r�r�r�rr��ROLE_TABLE_CELLr�r�r�r"r�rcr�r�r�)rr�r�r��oldNamer�r�rrrr}		s2





zScript.onNameChangedcCs�|j}|jj|tj�sdS|jjdd�\}}t|�t|�krJ||jkrJdS|j	|�t
j|jj
|dd��t|�|jf|jd<dS)z?Callback for object:state-changed:pressed accessibility events.NZ
pressedChangerT)r�)Nr)r�r�r�r�r"r�r�r�r�r�rcr�r�r�)rr�r�r�r�rrrr�)	s
zScript.onPressedChangedcCsF|j}|j�|j�}|jtj�s&dS|jjtj	|�s:dSt
jd�rHdS|jtj�}||j
krvd}tjtj|d�dS|jjdd
�\}}t|�t|�kr�||j
kr�d}tjtj|d�dSd}|jj�\}	}
|	d	kr�d}n |	dko�|o�|j�tjk�r�d}|�sdS|j
�r|jtjdd�n|jtjdd�t|�|j
f|jd<dS)z@Callback for object:state-changed:selected accessibility events.N�onlySpeakDisplayedTextz1DEFAULT: Bogus event: detail1 doesn't match stateTr�rz DEFAULT: Duplicate or spam eventFr��Down�Up)r�)Nr)r�r�)r�Z
clearCacher�r�rr�r�r�r�r"r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�Z
TEXT_SELECTEDZTEXT_UNSELECTED)rr�r�r�Z
isSelectedr�r�r�Z
announceState�	keyStringr�rrrr�8	s@

zScript.onSelectedChangedc
s|j}|j�}|jj�r*tj||jd�n|jtj�r:dS|jj	�\}}|dkrTdS|j
�}|tjkr�|jtj�r�|jj
|j�}|r�|j�jtj�r�dS|jj|�}xX|D]P�tjtj�fdd��r�d�}	tjtj|	d�dS|jj��s�tj|��Pq�WdS)z;Callback for object:selection-changed accessibility events.FNr�cs|�kS)Nr)r+)�childrrr�	sz+Script.onSelectionChanged.<locals>.<lambda>z-DEFAULT: Child %s is ancestor of locusOfFocusT)r�r�r�ZhandlePasteLocusOfFocusChanger<r�r�rZSTATE_MANAGES_DESCENDANTSr�r�r�ZSTATE_EXPANDEDZgetEntryForEditableComboBoxr��selectedChildrenZfindAncestorr�r"r�r�r�ZisLayoutOnly)
rr�r�r�r�r�r��entryr�r�r)r�rr�j	s.

zScript.onSelectionChangedcCsdS)zACallback for object:state-changed:sensitive accessibility events.Nr)rr�rrrr��	szScript.onSensitiveChangedcCsdS)z)Callback for focus: accessibility events.Nr)rr�rrrrx�	szScript.onFocusc

Cs�|js
dS|j}|j�}|jtj�s(dS|jj|�\}}|rT|jj|�rT|rTdSy|j	}|j
�}Wn"d|}tjtj
|d�dS|r�|tjkr�|jj|�}	|	r�|	d}tj||�dS)z?Callback for object:state-changed:focused accessibility events.Nz5DEFAULT: Exception getting childCount and role for %sTr)r�r�r�r�rr�r�rAr��
childCountr�r�r�r�r�r�r<r�)
rr�r�r�rDrCr�r�r�r�rrrr��	s*zScript.onFocusedChangedc	Cs�|j}|j�}|tjkrxtj|jj|��|jj	|�}|jj
||�}djt|jj
|��}|j|tjd�tj|�dS|tjkr�|jj�\}}|dkr�tjd�r�dS|jr�|j|�dStjr�|dkr�tj}|j|�tj|jj||jd��dSdS)z?Callback for object:state-changed:showing accessibility events.r)�	flashTimeNZF1ZpresentToolTips)r�)r�r�rZROLE_NOTIFICATIONrcr�r�r�r�ZisStatusBarNotificationZunrelatedLabels�joinrIrr�r��brailleFlashTimerrZsaveMessageZ
ROLE_TOOL_TIPr�r�r�r��
presentObjectr�r"r�)	rr�r�r�ZvisibleOnlyZlabelsr�r�r�rrrr��	s.




zScript.onShowingChangedcCs�|jj|�sdS|jj|j�}|s:d}tjtj|d�dStjd�r�|j	}|j
||d�j�sf|d8}|jj|j|d�s�|jj|j|d�r�|j
tj�dS)zACallback for object:text-attributes-changed accessibility events.Nz.DEFAULT: Querying non-empty text returned NoneT�speakMisspelledIndicatorr�)r��,isPresentableTextChangedEventForLocusOfFocusZqueryNonEmptyTextr�r�r�r�r�r�r�r;�isalnum�isWordMisspelledr�r��
MISSPELLED)rr�r�r�rprrrr��	s
zScript.onTextAttributesChangedcCsn|jj|�sdS|jj|�tj||jd�|j|j�d\}}|jj|�rpd}tj	tj
|d�tjtj
}}n&|jj|�r�d}tj	tj
|d�tj}|s�|r�|j||�|jj|j�dS|jj|�}|jj|��r�d}tj	tj
|d�|jj|j�}n<|jj|��rd}tj	tj
|d�nd	}tj	tj
|d�dSt|�d
k�rP|j|�n|jj|d�}tj||�dS)
z=Callback for object:text-changed:delete accessibility events.NFrz8DEFAULT: Deletion is believed to be due to clipboard cutTzADEFAULT: Deletion is believed to be due to deleting selected textz9DEFAULT: Deletion is believed to be due to Delete commandz<DEFAULT: Deletion is believed to be due to BackSpace commandz7INFO: Event is not being presented due to lack of causer�)rF)rr)r�r��handleUndoTextEventr<r�r�r��isClipboardTextChangedEventr�r�r�r��CLIPBOARD_CUT_FULL�CLIPBOARD_CUT_BRIEFZisSelectedTextDeletionEventZSELECTION_DELETEDr�r�ZdeletedTextZ isDeleteCommandTextDeletionEventZgetCharacterAtOffsetZ#isBackSpaceCommandTextDeletionEventrrQr�rErcr�)rr�r?r@r�rFrErrrr�	sBzScript.onTextDeletedcCsP|jj|�sdS|jj|�|jtjkr@|jj|�r@|j|j�tj	||jd�|j
|j�d\}}|jj|�r�d}tj
tj|d�tjtj}}n&|jj|�r�d}tj
tj|d�tj}|s�|r�|j||�|jj|j�dSd}|jj|�}|jj��rd}tj
tj|d�n�|jj|��r6d}tj
tj|d�n�|jj|��rZd	}tj
tj|d�np|jj|��r~d
}tj
tj|d�nL|jj|��r�d}tj
tj|d�t|j�|jd<nd
}tj
tj|d�d}|�rt|�dk�r�|j|�n|jj |d�}t!j"||�t|�dk�rdSt#j$d��r4|j%|j��r4dSt#j$d��rL|j&|j�dS)z=Callback for object:text-changed:insert accessibility events.NFrz;DEFAULT: Insertion is believed to be due to clipboard pasteTzCDEFAULT: Insertion is believed to be due to restoring selected textz3DEFAULT: Insertion is believed to be due to commandz?DEFAULT: Insertion is believed to be due to middle mouse buttonz-DEFAULT: Insertion is believed to be echoablez4DEFAULT: Insertion is believed to be auto text eventz#DEFAULT: Insertion is also selectedZlastAutoCompletez:DEFAULT: Not speaking inserted string due to lack of causer�)rFr�r)rr)'r�r�r�r�r�r"ZisAutoTextEventr�r<r�r�r�r�r�r�r�ZCLIPBOARD_PASTED_FULLZCLIPBOARD_PASTED_BRIEFZisSelectedTextRestoredEventZSELECTION_RESTOREDr�r�ZinsertedTextZlastInputEventWasCommandZ%isMiddleMouseButtonTextInsertionEventZisEchoableTextInsertionEventZisSelectedTextInsertionEventr�r�rrQr�rErcr�r�r��echoPreviousSentence�echoPreviousWord)rr�r?r@r�ZspeakStringrFrErrrr�
sjzScript.onTextInsertedcCs |j}|jj|�|j|�dS)z@Callback for object:text-selection-changed accessibility events.N)r�r�r�r�)rr�r�rrrr�\
szScript.onTextSelectionChangedcCsD|jj�sdS|j|jjtj�kr&dStj�|jd<|jt	j
�dS)z:Callback for object:column-reordered accessibility events.Nzlast-table-sort-time)r��lastInputEventWasTableSortr�r�r�r"r�r�r�r�ZTABLE_REORDERED_COLUMNS)rr�rrrr�h
s
zScript.onColumnReorderedcCsD|jj�sdS|j|jjtj�kr&dStj�|jd<|jt	j
�dS)z7Callback for object:row-reordered accessibility events.Nzlast-table-sort-time)r�r�r�r�r�r"r�r�r�r�ZTABLE_REORDERED_ROWS)rr�rrrr�t
s
zScript.onRowReorderedcCsJ|j}|j�}y|j�}|j}WnLtk
rLd|}tjtj|d�dSd|}tjtj|d�dSd|jkr�||jdkr�dS|j	j
||�\}}d||f}tjtj|d�|r�|tjkr�dtj}tjtj|d�dS|t
jk�r�|j|j�||jd<|j||d�tj|jj|d|d	��|j|jj|d|d	��dS)
z�Called whenever an object's value changes.  Currently, the
        value changes for non-focused objects are ignored.

        Arguments:
        - event: the Event
        z&ERROR: %s doesn't implement AtspiValueTNz-ERROR: Exception getting current value for %sZoldValuez'DEFAULT: Is progress bar update: %s, %sz$DEFAULT: Source != locusOfFocus (%s))�isProgressBarUpdate)r�r�)r�r�Z
queryValue�currentValuermr�r�r�r�r�r�r�r"rZROLE_SPIN_BUTTONr�r�rcr�r�r��
_Script__playZsoundGeneratorZ
generateSound)rr�r�r�rLr�r�r�rrrr��
s>





zScript.onValueChangedc
Cs�|jj|j�sdS|jj|jtj�r<d}tjtj|d�dSi|_	t
j
�|_|jt_y|jj}|jdj
�}WnYn*X|dkr�|tjkr�tj||jd�dStj||j�dS)zgCalled whenever a toplevel window is activated.

        Arguments:
        - event: the Event
        Nz$DEFAULT: Event is for active window.Trr�)r�r�r�r�r�r�r�r�r�r�r�rr�r�r�	ROLE_MENUr<r�)rr�r�r�Z	childRolerrrr��
s$
zScript.onWindowActivatedcCsdS)z0Callback for window:create accessibility events.Nr)rr�rrrr��
szScript.onWindowCreatedc	Cs�i|_tjtjtjtjg}ytjj�}WnYnX||krBdStjr�tjj	�|j
j	�kr�tj�|j
�|jr�d|_|jtj�|j
tjkr�tj|d�dt_dt_dt_dS)ziCalled whenever a toplevel window is deactivated.

        Arguments:
        - event: the Event
        NF)r�rr�ZROLE_MENU_ITEMZROLE_CHECK_MENU_ITEMZROLE_RADIO_MENU_ITEMr�r"r�ZgetApplicationr�rcrur�r
r�r�r<r�ZlistNotificationsModeEnabledr�)rr�Z	menuRolesr�rrrr��
s0zScript.onWindowDeactivatedc
Gs�|jr
dS|jj�sdS|jj�s&dS|jj�rD|jtjtj�dS|jj	�sRdSyt
jj�}Wn&dt
j}t
jt
j|d�YnX|jtj�r�dS|jtjtj�dS)Nz$ERROR: Exception getting state of %sT)r
r�ZobjectContentsAreInClipboardZ topLevelObjectIsActiveAndCurrentZlastInputEventWasCopyr�r�ZCLIPBOARD_COPIED_FULLZCLIPBOARD_COPIED_BRIEFZlastInputEventWasCutr�r"r�r�r�r�r�rZSTATE_EDITABLEr�r�)rr�r�r�rrr�onClipboardContentsChangeds&




z!Script.onClipboardContentsChangedcCst|p|j}|j|�|jrdS|jj�rJd}tjtj|d�|j|�dS|jj	�rvd}tjtj|d�|j
|�dS|jj�r�d}tjtj|d�|j|�dS|jj
�r�d}tjtj|d�|j|�dS|jj�r�d}tjtj|d�|j|�dS|jj��r(d}tjtj|d�|j|�dS|jj��rp|jj|j�\}}}|�spd}tjtj|d�|j|�dSdS)	Nz&DEFAULT: Presenting result of line navTz&DEFAULT: Presenting result of word navz&DEFAULT: Presenting result of char navz&DEFAULT: Presenting result of page navz/DEFAULT: Presenting result of line boundary navz/DEFAULT: Presenting result of file boundary navz:DEFAULT: Presenting result of primary mouse button release)r�� updateBrailleForNewCaretPositionrr�ZlastInputEventWasLineNavr�r�r��sayLineZlastInputEventWasWordNav�sayWordZlastInputEventWasCharNav�sayCharacterZlastInputEventWasPageNavZ lastInputEventWasLineBoundaryNavZ lastInputEventWasFileBoundaryNavZ$lastInputEventWasPrimaryMouseReleaser�)rr�ZotherObjr�r�rJrKrFrrrr�5sR













z%Script._presentTextAtNewCaretPosition�
cCs�tjd�sdS|jj|�}|jd|�|_x&|jrP|jj�}|j|j|kr,Pq,Wy|jj�}WnYn Xt	j
d|jdd�|j|j�|jd|j|j�dS)N�rewindAndFastForwardInSayAllFr)�notifyScriptT)
r�r�rr{�popr1r0r�r�r<r�r&r4)rr2ZminCharCountr{r�rrr�
_rewindSayAllgs 

zScript._rewindSayAllcCs^tjd�sdSy|jj�}WnYn Xtjd|jdd�|j|j�|jd|j|j�dS)Nr�F)r�T)	r�r�r�r�r<r�r&r1r4)rr2r�rrr�_fastForwardSayAll}s
zScript._fastForwardSayAllcCsy"|jj�}|j|j|jd�}Wn
dS||jkr<dS|tjjkrLdS|tjjkr�t	t
jtj
�r�d|_t
jj}|dkr�|j|�r�dS|dkr�|j|�r�dSd|_g|_|j|j�n*|tjjkr�tjd|jdd�|j|j�|j��r|jd|j|j�dS)Nr�Tr�r�F)r�r)r�r�r;Z
currentOffset�EMBEDDED_OBJECT_CHARACTER�speechserver�
SayAllContextZPROGRESSZINTERRUPTEDr�r�r�r.r�rr�r�r�rrr&Z	COMPLETEDr<r�r�ZsetSelection)rr2ZprogressTyper��char�lastKeyrrrZ__sayAllProgressCallback�s2


zScript.__sayAllProgressCallbackcCsT|jrd}tjtj|d�dS|jr<d}tjtj|d�dSd}tjtj|d�dS)NzDEFAULT: In SayAllTzDEFAULT: SayAll is interruptedzDEFAULT: Not in SayAllF)rr�r�r�r)rr�rrr�inSayAll�szScript.inSayAllc

Cs4y|j�}Wntk
r dSX|jd}|jd}|dksF|dkrJdS|j|tj�\}}}|j|tj�\}}}|jj||�s�dS|jd}	|	}
xR|
dkr�|j|
tj�\}}}|j|
dtj�\}}}|jj||�r�Pq�|
d8}
q�W|
|	kr�dS|jj||
d|	d�}|j	j
|d�}|jj|�}tj
||�dS)aSpeaks the sentence prior to the caret, as long as there is
        a sentence prior to the caret and there is no intervening sentence
        delimiter between the caret and the end of the sentence.

        The entry condition for this method is that the character
        prior to the current caret position is a sentence delimiter,
        and it's what caused this method to be called in the first
        place.

        Arguments:
        - obj: an Accessible object that implements the AccessibleText
        interface.
        Fr�rr)rFT)r�rmr�r$r�TEXT_BOUNDARY_CHARr�ZisSentenceDelimiter�	substringr�rEr]rcr�)
rr�r�rpZpreviousOffsetZcurrentCharr0r1ZpreviousCharZsentenceEndOffsetZsentenceStartOffsetr�rErrrr��s<





zScript.echoPreviousSentencec
Csy|j�}Wntk
r dSX|sB|jdkr8|j}n
|jd}|dkrNdS|j|tj�\}}}|jj|�srdS|d}|}x8|dkr�|j|tj�\}}}|jj|�r�Pq�|d8}q�W||kr�dS|jj	||d|d�}	|j
j|	d�}
|jj|	�}	t
j|	|
�dS)avSpeaks the word prior to the caret, as long as there is
        a word prior to the caret and there is no intervening word
        delimiter between the caret and the end of the word.

        The entry condition for this method is that the character
        prior to the current caret position is a word delimiter,
        and it's what caused this method to be called in the first
        place.

        Arguments:
        - obj: an Accessible object that implements the AccessibleText
               interface.
        - offset: if not None, the offset within the text to use as the
                  end of the word.
        Fr�r)rFTr�)r�rmr�r6r$rr�r��isWordDelimiterr�r�rEr]rcr�)rr�rpr�r�r0r1Z
wordEndOffsetZwordStartOffsetr�rErrrr�s@


zScript.echoPreviousWordcCs�|j�}|j}|jj�\}}|tj@r6|dkr6|d8}|j|tj�\}}}|sX|dkr\d}t	j
d�}	|dkr�|jtd|�tj�}
|
ds�|
ddkr�|	r�|j
tjdd	�d
S|d
kr�|	r�|j
tjdd	�d
S|j||�|j|�d
S)z�Speak the character at the caret.

        Arguments:
        - obj: an Accessible object that implements the AccessibleText
               interface
        �Rightr�r��
rU�speakBlankLinesrF)r�N�
)r�r�)rUr�)r�r�r�r�r�ZSHIFT_MODIFIER_MASKr$rr�r�r�r�r%r�r�rXr�rQ)rr�r�rpr�r�rSr0r1r�r�rrrr�Ws.

zScript.sayCharactercCs�|j|�\}}}t|�r�|dkr�|jj|�}|r:|j|�|jj|d�}|jj|||�}|jj|�}|g}|j	|�t
j|�n
|j|�dS)z�Speaks the line of an AccessibleText object that contains the
        caret, unless the line is empty in which case it's ignored.

        Arguments:
        - obj: an Accessible object that implements the AccessibleText
               interface
        rU)rFN)
�getTextLineAtCaretrr��indentationDescriptionr�r�rE�adjustForLinksr]r	rcr�r�)rr�r�r�r0r�rE�	utterancerrrr��s	

zScript.sayLinecCs�|jj|||�}|sdSt|�dks,|j�r||jj|�}|rF|j|�|jj|d�}|jj|�}|g}|j	|�t
j|�n
|j|�dS)a^Speaks the text of an Accessible object between the start and
        end offsets, unless the phrase is empty in which case it's ignored.

        Arguments:
        - obj: an Accessible object that implements the AccessibleText
               interface
        - startOffset: the start text offset.
        - endOffset: the end text offset.
        Nr�)rF)
r�Z
expandEOCsrr�r�r�r�rEr]r	rcr�r�)rr�r0r1�phraser�rEr�rrr�	sayPhrase�s

zScript.sayPhrasecCs|j�}|j}|jj�\}}|j}|j|tj�\}}}	|sH|j|�dS|dkr�t	|�dkr�|t	|�d}
|
dkr�||kr�|j
d�|dkr�t	|�dkr�|t	|�d}
|
dkr�||kr�|j
d�|j||�|jj
|d�}|jj|�}||_tj||�dS)z�Speaks the word at the caret.

        Arguments:
        - obj: an Accessible object that implements the AccessibleText
               interface
        Nr�rr�rUZLeft)rF)r�r�r�r�rr$r�TEXT_BOUNDARY_WORD_STARTr�rrQr�r�rEr]rcr�)rr�r�rpr�r�ZlastWordr�r0r1ZlastCharrErrrr��s,


zScript.sayWordcKs<|jdd�}|j|f|�|jj|f|�}tj||d�dS)Nr�F)r�)r�r�r�r�rcr�)rr�r�r�r�rrrr��szScript.presentObjectcCst|js
dStj|jkrL|jjdi�}|jttj�d�}|sH|jj|krLdS|jtjkof|jjknrpdSdS)z�Whether or not speech should be stopped prior to setting the
        locusOfFocus in onActiveDescendantChanged.

        Arguments:
        - event: the Event

        Returns True if speech should be stopped; False otherwise.
        Tr�rF)	r�r�r"r�r�r�r�r��parent)rr�r�r�rrrr��s

 z*Script.stopSpeechOnActiveDescendantChangedcCs(|js"tj|�|_d|_|j�|_|jS)z;Returns the flat review context, creating one if necessary.T)r
rrr
rfr)rrrrr'
s

zScript.getFlatReviewContextcCs�tjd�r,tjd�r,tjtjdd�dS|j�}|j�\}}|sLg}d}|j�}|j||�t	j
|g�|j|d�|r�|j|j
|j�|jr�|jd|j�d|_n|jd|�dS)aAObtains the braille regions for the current flat review line
        and displays them on the braille display.  If the targetCursorCell
        is non-0, then an attempt will be made to position the review cursor
        at that cell.  Otherwise, we will pan in display-sized increments
        to show the review cursor.r�r�zBRAILLE: update review disabledTNF)r�r�r�r�r�r'�getCurrentBrailleRegionsr�r�r�ZsetLinesr��panBrailleToOffset�
brailleOffset�cursorOffsetr
r�r)rrr2�regions�regionWithFocusr�rrrr!
s(
zScript.updateBrailleReviewc	Cs�|j�}|j�\}}x�|D]�}|jt|j�tjdkrt|tj�sPt|tj	�rt
|jtjd�}||j}|jtjd|_|jj
|�\}}|r�|jj|jjj|jj|j|�n|jj|jjj|jjdd�PqWdS)zqSets the character of interest to be the first character showing
        at the beginning of the braille display.rN)r'r�r�rrFr�Zviewportr�Z
ReviewTextZReviewComponentr�rZzoneZgetWordAtOffsetr
�
setCurrentr�r{)	rr2r�r��regionZpositionrpr�Z
charOffsetrrrr?
s0

z7Script._setFlatReviewContextToBeginningOfBrailleDisplaycCsh|stj�}|rd|j�}|j||j�}|s8|jtj�n,|j|j	|j
|j|j�|j
d�|j�|_dS)z�Searches for the specified query.  If no query is specified,
        it searches for the query specified in the Orca Find dialog.

        Arguments:
        - query: The search query to find.
        N)rrr'Z	findQueryr
r�r�ZSTRING_NOT_FOUNDr�Z	lineIndexZ	zoneIndexZ	wordIndex�	charIndexrJrfr)rZqueryr2�locationrrrr]
s
zScript.findccsTd|_y|j�}Wnd|_g|_dSd|_|j}|dkrD|j}tjd�}|tj	kr`t
j}n|tjkrrt
j
}nt
j
}|}d}�x�|�s&tj|jj||d��d}	�x||k�r�|j||�\}
}}|
s�t
j
}|j||�\}
}}||jk�rd||j|||f}
tjtj|
d�|j}||	k�r8t|d|	d�}|}	q�|}	|}|jj|
d�}|�rht|t��rh|d	}|jj||
|�}
|jj|
�}
tj||
||�}|jj|�||gVq�Wd}|j �}x`|D]X}|j!�t
j"k�r�|}|j#d	�}y|j�}Wnt$k
�rdSX|j}d	}d}P�q�W|s�d}q�Wd|_g|_d
}
tjtj|
d�|j%�dS)a�Creates a generator that can be used to iterate over each line
        of a text object, starting at the caret offset.

        Arguments:
        - obj: an Accessible that has a text specialization

        Returns an iterator that produces elements of the form:
        [SayAllContext, acss], where SayAllContext has the text to be
        spoken and acss is an ACSS instance for speaking the text.
        FNT�sayAllStyle)r�r�z_WARNING: endOffset: %i > characterCount: %i  resulting from text.getTextAtOffset(%i, %s) for %s)rFrz4DEFAULT: textLines complete. Verifying SayAll statusr�)&rr�rrr6r�r�r�r�ZSAYALL_STYLE_SENTENCErZTEXT_BOUNDARY_SENTENCE_STARTZSAYALL_STYLE_LINEr%rcr�r�ZgenerateContextr$r�r�r�r�rEr�rHr�r�r]r�r��appendZgetRelationSetZgetRelationTypeZRELATION_FLOWS_TOZ	getTargetrmr�)rr�rpr�Zlengthr��moder��doneZ
lastEndOffsetr/r0r1r�rEr2Z	moreLinesZ	relationsZrelationrrrrnr
s�






zScript.textLinesc	Cs�y|j�}Wntk
r&dddgSX|j|jkrVtd|jd�}|j||d�}n
|j}d}|j|jkr~|dkr~d}|}nl|jdkr�|j||d�}|}n8|dkr�|j}y|j|tj�\}}}WndddgS|j	d�}|j	d�}||j|gS)z<To-be-removed. Returns the string, caretOffset, startOffset.rrr�NrUr�r�)
r�rmr�r6r�r;r$rr%�rstrip)	rr�rpr0r1r�r�rSr/rrrr��
s4

	

zScript.getTextLineAtCaretcCsBx<t|�D]0\}}|jj|d�}tj|j��}tj||�q
WdS)z�Phonetically spell the current flat review word or line.

        Arguments:
        - itemString: the string to phonetically spell.
        )rFN)�	enumerater�rE�	phonnamesZgetPhoneticName�lowerrcr�)rrRr�rSrEZphoneticStringrrrr\)szScript.phoneticSpellCurrentItemcCs||g|jd<dS)z�Save away the current text cursor position for next time.

        Arguments:
        - obj: the current accessible
        - caretOffset: the cursor position within this object
        r�N)r�)rr�r�rrrr�5szScript._saveLastCursorPositioncCstd�dS)z�Rings the system bell. This is really a hack. Ideally, we want
        a method that will present an earcon (any sound designated for the
        purpose of representing an error, event etc)
        �N)�print)rrrr�
systemBeep?szScript.systemBeepc	Cs�tjd�r�y|j�}Wn
dS|j|tj�}|dj�sN|jj|d�r\|d|_	dS|j|tj
�}|jj||�r�|d|j	kr�|jt
j�|d|_	dS)aSpeaks an announcement indicating that a given word is misspelled.

        Arguments:
        - obj: An accessible which implements the accessible text interface.
        - offset: Offset in the accessible's text for which to retrieve the
          attributes.
        r�Nr)r�r�r�r$rr��stripr�r�rr�r�r�r�r�)rr�rpr�ZcharAndOffsetsZwordAndOffsetsrrrr�Gs	

zScript.speakMisspelledIndicatorcCstj�tj�dS)zbConvenience method to interrupt presentation of whatever is being
        presented at the moment.N)rcrur�Z	killFlash)rrrr�presentationInterruptpszScript.presentationInterruptc
CsP|j�sd|_|jj�tjs4|jdks0|j�r4dSytjj	�}Wn
dS|t
jt
jt
j
gkr�|jjtj�}|r�tjd|d�|j	�}|t
jkr�|j�r�dS|j�s�dStj|�|j�o�|j�}|j�r�|r�dStj�r
|j��r
|j�dk�r
|j|j�dSd}|j��r|j}d}tjtj|d�|jj |d�}t!j"||�dS)z{Convenience method to present the KeyboardEvent event. Returns True
        if we fully present the event; False otherwise.FNrTz"DEFAULT: Presenting keyboard event)rF)#ZisPressedKeyrr�ZclearCachedCommandStater�r�Z
shouldEchoZisOrcaModifiedr"r�rr�r�ZROLE_WINDOW�
focusedObjectr�r<r�ZROLE_PASSWORD_TEXTZisLockingKeyr�ZdisplayKeyEventZisOrcaModifierZisCharacterEchoableZisPrintableKeyZ
getClickCountr\r�r�r�r�r�rErcZ
speakKeyEvent)rr�r�r�ZorcaModifierPressedrFr�rErrr�presentKeyboardEventwsF


zScript.presentKeyboardEventTcCs�|sdS|dkr|}tjd�rFtjd�s.|}n|}|rF|j|||d�tjd�sZtjd�r�tjd�r�tjd�st|}n|}|s�dSt|d	t�r�|d	}t|t�r�d
d�|D�}dj|�}tjd
�r�d}n
tjd�}tj||d�dS)a�Convenience method to speak a message and 'flash' it in braille.

        Arguments:
        - fullMessage: This can be a string or a list. This will be presented
          as the message for users whose flash or message verbosity level is
          verbose.
        - briefMessage: This can be a string or a list. This will be presented
          as the message for users whose flash or message verbosity level is
          brief. Note that providing no briefMessage will result in the full
          message being used for either. Callers wishing to present nothing as
          the briefMessage should set briefMessage to an empty string.
        - voice: The voice to use when speaking this message. By default, the
          "system" voice will be used.
        NrtZmessagesAreDetailed)rE�resetStylesr�r�ZenableFlashMessagesZflashIsDetailedrcSsg|]}t|t�r|�qSr)r��str)r�irrrr�sz)Script.presentMessage.<locals>.<listcomp>r�ZflashIsPersistentr�r�)r�r�)r�r�r�r�rHr�r��displayMessage)rr�r�rEr��messageZdurationrrrr��s6









zScript.presentMessagecCs^|sdSt|t�s|g}tj�}|j|d|�x(tdt|��D]}tj||dd�q@WdS)Nrr�F)r�)r�rH�soundZ	getPlayerZplay�ranger)Zsoundsr�ZiconZ_playerr�rrrZ__play�s
z
Script.__playcCs|j|�dS)z�Adds the braille region to the line.

        Arguments:
        - region: a braille.Region (e.g. what is returned by the braille
          generator's generateBraille() method.
        - line: a braille.Line
        N)�	addRegion)r�r�rrrr��s
zScript.addBrailleRegionToLinecCs|j|�dS)aAdds the braille region to the line.

        Arguments:
        - regions: a series of braille.Region instances (a single instance
          being what is returned by the braille generator's generateBraille()
          method.
        - line: a braille.Line
        N)Z
addRegions)r�r�rrrr��szScript.addBrailleRegionsToLinecCs|jtj|��dS)z�Creates a Braille Region out of string and adds it to the line.

        Arguments:
        - string: the string to be displayed
        - line: a braille.Line
        N)rr��Region)rFr�rrr�addToLineAsBrailleRegions	zScript.addToLineAsBrailleRegioncCs&g}x|D]}|jtj|��q
W|S)z�Creates a list of braille regions from the list of strings.

        Arguments:
        - strings: a list of strings from which to create the list of
          braille Region instances

        Returns the list of braille Region instances
        )r�r�r)ZstringsZbrailleRegionsrFrrr�brailleRegionsFromStringss
z Script.brailleRegionsFromStringscCstj�dS)zfClears the logical structure, but keeps the Braille display as is
        (until a refresh operation).N)r��clearrrrrr�szScript.clearBraillecCs>tjd�r,tjd�r,tjtjdd�dStj|||�dS)a[Displays a single line, setting the cursor to the given position,
        ensuring that the cursor is in view.

        Arguments:
        - message: the string to display
        - cursor: the 0-based cursor position, where -1 (default) means no
          cursor
        - flashTime:  if non-0, the number of milliseconds to display the
          regions before reverting back to what was there before. A 0 means
          to not do any flashing.  A negative number means to display the
          message until some other message comes along or the user presses
          a cursor routing key.
        r�r�z!BRAILLE: display message disabledTN)r�r�r�r�r�r�r)rZcursorr�rrrr�&s
zScript.displayBrailleMessagecCs<tjd�r,tjd�r,tjtjdd�dStj||�dS)a�Displays a list of regions on a single line, setting focus to the
        specified region.  The regionInfo parameter is something that is
        typically returned by a call to braille_generator.generateBraille.

        Arguments:
        - regionInfo: a list where the first element is a list of regions
          to display and the second element is the region with focus (must
          be in the list from element 0)
        - flashTime:  if non-0, the number of milliseconds to display the
          regions before reverting back to what was there before. A 0 means
          to not do any flashing. A negative number means to display the
          message until some other message comes along or the user presses
          a cursor routing key.
        r�r�z!BRAILLE: display regions disabledTN)r�r�r�r�r�r�ZdisplayRegions)Z
regionInfor�rrr�displayBrailleRegions=s
zScript.displayBrailleRegionscCs|jj|�}|j|�dS)z�Convenience method for scripts combining the call to the braille
        generator for the script with the call to displayBrailleRegions.

        Arguments:
        - obj: the accessible object to display in braille
        N)r�r�r	)rr�r�rrr�displayBrailleForObjectUszScript.displayBrailleForObjectcCs
tj|�S)ahGets the accesible and caret offset associated with the given
        event.  The event should have a BrlAPI event that contains an
        argument value that corresponds to a cell on the display.

        Arguments:
        - event: an instance of input_event.BrailleEvent.  event.event is
          the dictionary form of the expanded BrlAPI event.
        )r�ZgetCaretContext)r�rrrr9`szScript.getBrailleCaretContextcCstjS)zzReturns the value of position of the braille cell which has the
        cursor. A value of 0 means no cell has the cursor.)r�Z
cursorCellrrrrrfmszScript.getBrailleCursorCellFcCs&|rtj�tj�}|r"tj|�|S)z�Creates a new braille Line.

        Arguments:
        - clearBraille: Whether the display should be cleared.
        - addLine: Whether the line should be added to the logical display
          for painting.

        Returns the new Line.
        )r�rZLiner�)r�r�r�rrrr�ts
zScript.getNewBrailleLinercCstj|||||�S)aBCreates a new braille Component.

        Arguments:
        - accessible: the accessible associated with this region
        - string: the string to be displayed
        - cursorOffset: a 0-based index saying where to draw the cursor
          for this Region if it gets focus

        Returns the new Component.
        )r�Z	Component)�
accessiblerFr�Z	indicator�expandOnCursorrrr�getNewBrailleComponent�s
zScript.getNewBrailleComponentcCstj|||�S)z�Creates a new braille Region.

        Arguments:
        - string: the string to be displayed
        - cursorOffset: a 0-based index saying where to draw the cursor
          for this Region if it gets focus

        Returns the new Region.
        )r�r)rFr�rrrr�getNewBrailleRegion�szScript.getNewBrailleRegioncCstj|||||�S)a"Creates a new braille Text region.

        Arguments:
        - accessible: the accessible associated with this region and which
          implements AtkText
        - label: an optional label to display
        - eol: the endOfLine indicator

        Returns the new Text region.
        )r��Text)rZlabelZeolr0r1rrr�getNewBrailleText�szScript.getNewBrailleTextcCstjS)zMIf True, the beginning of the line is showing on the braille
        display.)r�ZbeginningIsShowingrrrrr�sz Script.isBrailleBeginningShowingcCstjS)z?If True, the end of the line is showing on the braille display.)r�ZendIsShowingrrrrr4�szScript.isBrailleEndShowingcCs|rtj|�Stj|�SdS)aiPans the display to the left, limiting the pan to the beginning
        of the line being displayed.

        Arguments:
        - panAmount: the amount to pan.  A value of 0 means the entire
          width of the physical display.
        - panToLeft: if True, pan to the left; otherwise to the right

        Returns True if a pan actually happened.
        N)r�ZpanLeftZpanRight)r)rrrrr�s

zScript.panBrailleInDirectioncCstj|�dS)zSAutomatically pan left or right to make sure the current offset
        is showing.N)r�ZpanToOffset)rprrrr��szScript.panBrailleToOffsetcCs6tj�}x |D]}|jtjd|��qWtj�dS)z�Method to braille a list of items. Scripts should call this
        method rather than handling the creation and displaying of a
        braille line directly.

        Arguments:
        - items: a list of strings to be presented
        r�N)r��getShowingLinerr�refresh)rtr��itemrrr�presentItemsInBraille�s

zScript.presentItemsInBraillecCs�tjd�r,tjd�r,tjtjdd�dSd}tj�}x<|jD]2}t|tj	�r@|j
|kr@|j�rp|jd�d}Pq@W|r�|j
|�dS)z@Try to reposition the cursor without having to do a full update.r�r�zBRAILLE: update caret disabledTNF)r�r�r�r�r�r�rr�r�rrZrepositionCursorr�r�)rr�ZbrailleNeedsRepaintingr�r�rrrr��s
z'Script.updateBrailleForNewCaretPositioncCstj||||�dS)a�This is the method scripts should use to refresh braille rather
        than calling self.refreshBraille() directly. The intent is to centralize
        such calls into as few places as possible so that we can easily and
        safely not perform braille-related functions for users who do not
        have braille and/or the braille monitor enabled.

        Arguments:

        - panToCursor: if True, will adjust the viewport so the cursor is
          showing.
        - targetCursorCell: Only effective if panToCursor is True.
          0 means automatically place the cursor somewhere on the display so
          as to minimize movement but show as much of the line as possible.
          A positive value is a 1-based target cell from the left side of
          the display and a negative value is a 1-based target cell from the
          right side of the display.
        - getLinkMask: Whether or not we should take the time to get the
          attributeMask for links. Reasons we might not want to include
          knowing that we will fail and/or it taking an unreasonable
          amount of time (AKA Gecko).
        - stopFlash: if True, kill any flashed message that may be showing.
        N)r�r)ZpanToCursorr�getLinkMaskrrrrr�szScript.refreshBraillecCstj|||�dS)a[Specififes the region with focus.  This region will be positioned
        at the home position if panToFocus is True.

        Arguments:
        - region: the given region, which much be in a line that has been
          added to the logical display
        - panToFocus: whether or not to position the region at the home
          position
        - getLinkMask: Whether or not we should take the time to get the
          attributeMask for links. Reasons we might not want to include
          knowning that we will fail and/or it taking an unreasonable
          amount of time (AKA Gecko).
        N)r�ZsetFocus)r�Z
panToFocusrrrrr�szScript.setBrailleFocuscCstj|�dS)z�Turns contracted braille on or off based upon the event.

        Arguments:
        - event: an instance of input_event.BrailleEvent.  event.event is
          the dictionary form of the expanded BrlAPI event.
        N)r�r^)r�rrrr80s	zScript._setContractedBraillecCs(|jj|d�}tj|�}tj||�dS)z~Method to speak a single character. Scripts should use this
        method rather than calling speech.speakCharacter directly.)rFN)r�rE�chnamesZgetCharacterNamercrQ)rrSrEZspokenCharacterrrrrQBs
zScript.speakCharacterc	Cs�tjd�stjd�rdStjd�}|jtj�}|p6|}||kr�|r�tjd�}tjdtj�tj�tjd�}tjdtj	�tj
�tj|||�||kr�|r�tjd|�tj�tjd|�tj
�dS)arMethod to speak a single string. Scripts should use this
        method rather than calling speech.speak directly.

        - string: The string to be spoken.
        - voice: The voice to use. By default, the "system" voice will
          be used.
        - interrupt: If True, any current speech should be interrupted
          prior to speaking the new text.
        rtr�N�voicesr}rx)r�r�r�r�ZSYSTEM_VOICErvr~rcr�ryr�r�)	rrFrEr�r�rZsystemVoiceZcapStyleZ
punctStylerrrr�Js&



zScript.speakMessagecCs*g}x|D]}|j|�q
Wtj|�dS)z�Method to speak a list of items. Scripts should call this
        method rather than handling the creation and speaking of
        utterances directly.

        Arguments:
        - items: a list of strings to be presented
        N)r�rcr�)rtr�rrrr�presentItemsInSpeechos

zScript.presentItemsInSpeechcCstjtj|jj|��dS)a Speaks some information about an unicode character.
        At the moment it just announces the character unicode number but
        this information may be changed in the future

        Arguments:
        - character: the character to speak information of
        N)rcr�r��UNICODEr�ZunicodeValueString)rrSrrrrjszScript.speakUnicodeCharactercCs(tjd�}tj|tj��}|j|�dS)z Presents the current time. ZpresentTimeFormatT)r�r�r��strftime�	localtimer�)rr�Z
timeFormatrrrrrn�s

zScript.presentTimecCs(tjd�}tj|tj��}|j|�dS)z Presents the current date. ZpresentDateFormatT)r�r�r�rrr�)rr�Z
dateFormatrrrrro�s

zScript.presentDate)N)N)N)N)N)N)Nr)N)Nr)N)N)N)N)N)N)N)N)N)N)rr�)r�)r�)r)r)r)NN)N)N)N)N)N)N)N)N)N)N)N)NN)NN)N)r�)N)r)N)N)NNN)NNT)Tr�)r�r)r)FF)rrF)rF)rrNN)rT)TrTT)TT)NTT)��__name__�
__module__�__qualname__r�ZNO_BREAK_SPACE_CHARACTERZDISPLAYED_LABELZDISPLAYED_TEXTZKEY_BINDINGZ
NESTING_LEVELZ
NODE_LEVELZREAL_ACTIVE_DESCENDANTr	rsrvrwr�r�r�r�r�r�r�r�r�r�r�r�rprbr�r�rrr>r?r,r*r+r)r-r[r3r\r7r]r^r_r`rar/r;r:rZr2r3rTr`rNrHrMrSrTrUrirPrQrVrIrOrCrDrErkrArBrFrRrGrJrKrLrWrXr5r4r@rdrerfrhrirjrkrgrYr�r6r7rlr8r9r�r�r�r�r�r�r~ryrzr{r�r�r|r}r�r�r�r�rxr�r�r�rr�r�r�r�r�r�r�r�r�r�r�r�ror�r�r�r�r�r�r�r�r�r'r!rrrnr�r\r�r�r�r�r�r��staticmethodr�r�r�rrr�r�r	r
r9rfr�r
rrrr4rr�rr�r�r�r8rQr�rrjrnro�
__classcell__rr)r�rrDs�1	G

)62'#@	2	

.		')


% = 2%-H. @"2(HL.- !x?
)15


%r):�__doc__Z__id__�__version__Z__date__Z
__copyright__Z__license__r�rZorca.brailler�Zorca.chnamesrZ
orca.cmdnamesr0Z
orca.debugr�Zorca.eventsynthesizerr<Z	orca.findrZorca.flat_reviewrZorca.guilabelsrZorca.input_eventr.Zorca.keybindingsr�Z
orca.messagesr�Z	orca.orcar<Zorca.orca_gui_commandlistZorca_gui_commandlistrZorca.orca_stater�Zorca.phonnamesr�Zorca.scriptrZ
orca.settingsr�Zorca.settings_managerZsettings_managerZ
orca.soundrZorca.speechrcZorca.speechserverr�Zorca.mouse_reviewrmZorca.notification_messagesrrZ
getManagerr�rrrrr�<module>s@