%PDF- %PDF-
Mini Shell

Mini Shell

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

�

g
f�#����dZdZdZdZdZdZddlZddlZddlZddl	Z	ddl
mZd	d
lm
Z
d	dlmZd	dlmZd	d
lmZd	dlmZd	dlmZd	dlmZd	dlmZd	dlmZd	dlmZd	dlmZd	dlmZej<�ZejAd�Z!da"	dZ#ejHejJe#d�ddl&Z&da'dZ(da)da*de&gZ+ejXejJe+d�	dZ#ejHejJe#d�ddl/Z/de/gZ+ejXejJe+d�degZ+ejXejJe+d�es#dZ#ejHejJe#d�dZ/		d	d!lm0Z0gZ2e(rZe&jfe&jhe&jje&jle&jne&jpe&jre&jtgZ2iZ;e(�r�ejxe;e&jf<ejxe;e&jj<ejxe;e&jn<ejze;e&jh<ejze;e&jl<ejze;e&jp<ej|e;e&jr<ej~e;e&jt<ej�e;e&j�<ej�e;e&j�<ej�e;e&j�<ej�e;e&j�<ej�e;e&j�<ej�e;e&j�<ej�e;e&j�<ej�e;e&j�<d"ZPePd	gaQgaRdaSd#aTddgaUdaVdaWdaXdaYdaZda[da\dZ]d$Z^d%Z_e^a`id&e
j��d'e
j��d(e
j��d)e
j��d*e
j��d+e
j��d,e
j��d-e
j��d.e
j��d/e
j��d0e
j��d1e
j��d2e
j��d3e
j��d4e
j��d5e
j��d6e
j��e
j�e
j�e
j�e
j�e
j�e
j�e
j�e
j�e
j�e
j�e
j�e
j�e
j�e
j�e
�jd7��Z�d8�Z�d9�Z�e/r)e��Z�d:e�gZ+ejXejJe+d�Gd;�d<�Z�Gd=�d>e��Z�Gd?�d@e��Z�GdA�dBe��Z�GdC�dDe��Z�GdE�dFe��Z�GdG�dH�Z�dI�Z�dJ�Z�dK�Z�dL�Z�dM�Z�dN�Z�dkdO�Z�dP�Z�dQ�Z�dR�Z�dS�Z�dT�Z�dldU�Z�dV�Z�dmdW�Z�dX�Z�dY�Z�dndZ�Z�dod[�Z�d\�Z�d]�Z�d^�Z�dnd_�Z�dnd`�Z�da�Z�dpdb�Z�dc�Z�dd�Z�de�Z�df�Z�dg�Z�e^fdh�Z�dpdi�Z�dj�Z�y#e-$r(dZ#ejHej\e#d�dZ(da)Y��PwxYw#e-$r&d Z#ejHej\e#d�dZ/Y���wxYw#e-$rde_1Y���wxYw)qa�A very experimental approach to the refreshable Braille display.  This
module treats each line of the display as a sequential set of regions, where
each region can potentially backed by an Accessible object.  Depending upon
the Accessible object, the cursor routing keys can be used to perform
operations on the Accessible object, such as invoking default actions or
moving the text caret.
z$Id$z
$Revision$z$Date$z-Copyright (c) 2005-2009 Sun Microsystems Inc.�LGPL�N)�GLib�)�
brltablenames)�cmdnames)�debug)�logger)�script_manager)�settings)�settings_manager)�AXEventSynthesizer)�AXHypertext)�AXObject)�AXText)�	tablesdir�braillez BRAILLE: About to import brlapi.TFzBRAILLE: brlapi importedz!BRAILLE: Could not import brlapi.zBRAILLE: About to import louis.zBRAILLE: liblouis importedzBRAILLE: tables location:zzBRAILLE: Disabling liblouis due to unknown table location.This usually means orca was built before liblouis was installed.z"BRAILLE: Could not import liblouis)�brlmon� �Nrrr�2�FzCz-Cz-g1zEs-Es-g1zFr-Ca-g2zFr-Fr-g2zLv-Lv-g1zNl-Nl-g1zNo-No-g0zNo-No-g1zNo-No-g2zNo-No-g3zPl-Pl-g1zPt-Pt-g1zSe-Se-g1zar-ar-g1zcy-cy-g1zcy-cy-g2zde-de-g0)zde-de-g1zde-de-g2zen-GB-g2zen-gb-g1zen-us-g1zen-us-g2zfr-ca-g1zfr-fr-g1zgr-gr-g1zhi-in-g1zhu-hu-comp8zhu-hu-g1zhu-hu-g2zit-it-g1znl-be-g1c��i}	tjt�D]J}|dddvs�|dd}tjj	t|�|t
j
||�<�L	|S#t$rY|SwxYw)N����z.utbz.ctb)�os�listdirr�path�join�TABLE_NAMES�get�OSError)�tables�fname�aliass   �./usr/lib/python3/dist-packages/orca/braille.py�
listTablesr&�s���
�F�
��Z�Z�	�*�	3�E��R�S�z�-�-��c�r�
���G�G�L�L��E�2��{���u�e�4�5�	3��M���
���M�
�s�#A-�AA-�-	A:�9A:c�X�	�
�tjtj�d}d|g}tjtj
|d�|dvr@tj�d}d|g}tjtj
|d�|dvr*d}tjtj
|d�d�
n.dj|jd	��j��
	tjt�D�cgc]}|d
ddvs�|��}}ddg�	gd�}�	�
fd�}tt!||��}dt#|�ddj|�g}tjtj
|d�|sy
|D]5}|D].}||vs�tj$jt|�ccS�7tj$jt|d�Scc}w#t$r0dtg}tjtj
|d�Yy
wxYw)NrzBRAILLE: User locale isT)N�CzBRAILLE: Default locale isz=BRAILLE: Locale cannot be determined. Falling back on 'en-us'zen-us�-�_rrz)BRAILLE: Exception calling os.listdir for��	interline�mathtext)�g1�g2�comp6�comp8c�V����j��xrt�fd��D��S)Nc3�&�K�|]}|�v���
y�w�N�)�.0�e�ts  �r%�	<genexpr>z7getDefaultTable.<locals>.isCandidate.<locals>.<genexpr>'s�����1J�Q�!�q�&�1J�s�)�
startswith�any)r8�exclude�languages`��r%�isCandidatez$getDefaultTable.<locals>.isCandidate&s%����|�|�H�%�J�c�1J�'�1J�.J�*J�J�zBRAILLE:z"candidate tables for locale found:�, )�locale�	getlocale�LC_MESSAGESr�printTokens�
LEVEL_INFO�getdefaultlocale�printMessager�split�lowerrrrr!�list�filter�lenr)�
userLocale�tokens�msg�xr"�preferr>�p�tabler<r=s         @@r%�getDefaultTablerTs�����!�!�&�"4�"4�5�a�8�J�'��
4�F�	���e�&�&���5��[� ��,�,�.�q�1�
�.�
�;��
���%�*�*�F�D�9��[� �M��
���5�+�+�S�$�7����8�8�J�,�,�S�1�2�8�8�:����Z�Z�	�2�Q��a���f�@P�6P�!�Q��Q��J�'�G�,�F�K��&��f�-�
.�F��#�f�+�'K�T�Y�Y�W]�M^�
_�F�	���e�&�&���5���
�6���	6�E��E�z��w�w�|�|�I�u�5�5�	6�6��7�7�<�<�	�6�!�9�-�-��AR����=�y�I��
���%�*�*�F�D�9���s*�3G0�G+�G+�G0�+G0�06H)�(H)z&BRAILLE: Default contraction table is:c�R�eZdZdZd
d�Zd�Zd�Zdd�Zd�Zd
d�Z	d�Z
d	�Zd
�Zd�Z
y)�RegionzpA Braille region to be displayed on the display.  The width of
    each region is determined by its string.
    c���|sd}tjxrtdu|_||_|jd�|_|jr�tjxst|_	|j�r5d|d|jg}tjtj|d�|j|j||�\|_|_|_|_y|j�rftjs,d|�d�}tj$tj|d�n*d|d	g}tjtj&|d�|j|_||_y)
z�Creates a new Region containing the given string.

        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.
        r+N�
zBRAILLE: Contracting 'z' with tableTzBRAILLE: Not contracting 'z,' because contracted braille is not enabled.z' due to problem with liblouis.)r�enableContractedBraille�louis�
contracted�expandOnCursor�strip�rawLine�brailleContractionTable�_defaultContractionTable�contractionTablerrDrE�contractLine�string�inPos�outPos�cursorOffsetrG�
LEVEL_WARNING)�selfrcrfr\rNrOs      r%�__init__zRegion.__init__BsC����F�#�:�:�P�u�D�?P���,����|�|�D�)����?�?�$,�$D�$D�$`�H`�D�!��|�|�~�2�F�N�D�La�La�b���!�!�%�"2�"2�F�D�A��*�*�4�<�<�+7��I�
D�D�K���T�[�$�2C��|�|�~��7�7�4�V�H�=E�F���&�&�u�'7�'7��d�C�:�F�?�A�F��%�%�e�&9�&9�6�4�H��,�,�D�K� ,�D�r?c�8�d|j|jfzS)NzRegion: '%s', %d�rcrf�rhs r%�__str__zRegion.__str__ps��!�T�[�[�$�2C�2C�$D�D�Dr?c��y)�Processes a cursor routing key press on this Component.  The offset
        is 0-based, where 0 represents the leftmost character of string
        associated with this region.  Note that the zeroeth character may have
        been scrolled off the display.Nr5�rh�offsets  r%�processRoutingKeyzRegion.processRoutingKeyss��
	
r?c�2�dt|j�zS)�Creates a string which can be used as the attrOr field of brltty's
        write structure for the purpose of indicating text attributes, links,
        and selection.

        Arguments:
        - 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).
        �)rLrc�rh�getLinkMasks  r%�getAttributeMaskzRegion.getAttributeMaskzs����D�K�K�(�(�(r?c��|jrK|j|j|j|j�\|_|_|_|_yy)z:Reposition the cursor offset for contracted mode.
        N�r[rbr^rfr\rcrdrerls r%�repositionCursorzRegion.repositionCursor�sM���?�?��(�(����)-�):�):�)-�)<�)<�>�
D�D�K���T�[�$�2C�r?c� �	||dk(}|r|rd}ntj}tj|jg|||��\}}}}	|t|�k\rt|�}	nt
|	t|��}	||||	fS#t$rd}Y��wxYw)a*Contract the given line. Returns the contracted line, and the
        cursor position in the contracted line.

        Arguments:
        - line: Line to contract.
        - cursorOffset: Offset of cursor,defaults to 0.
        - expandOnCursor: Expand word under cursor, False by default.
        � Fr)�	cursorPos�mode)�
IndexErrorrZ�compbrlAtCursor�	translaterarL�min)
rh�linerfr\�
cursorOnSpacerr[rdrer~s
          r%rbzRegion.contractLine�s���	"� ��.�#�5�M����D��(�(�D�
�O�O�T�2�2�3� �&2�!%�
'�	-�
�E�6�9��3�t�9�$��J��I��I�s�:��7�I��5�&�)�3�3��/�	"�!�M�	"�s�A?�?B
�B
c��	|j|}|S#t$rt|j�}Y|St$r|}Y|SwxYwr4)rdr�rLr^�AttributeError�rh�display_offsetrqs   r%�displayToBufferOffsetzRegion.displayToBufferOffset�sV��	$��Z�Z��/�F��
���	'�����&�F�
�
�	�	$�#�F��
�		$�s��A�
A�Ac��|r.tjxst|_|j	�y|j�yr4)rr_r`ra�contractRegion�expandRegion�rhr[s  r%�setContractedBraillezRegion.setContractedBraille�s1���$,�$D�$D�$`�H`�D�!����!����r?c��|jry|j|j|j|j�\|_|_|_|_d|_y)NTrzrls r%r�zRegion.contractRegion�sR���?�?���&�&�t�|�|�'+�'8�'8�'+�':�':�<�	@���T�Z���d�.?���r?c���|jsy|j|_	|j|j|_d|_y#t
$r$t
|j�|_Yd|_ywxYw)NF)r[r^rcrdrfr�rLrls r%r�zRegion.expandRegion�se�������l�l���	1� $�
�
�4�+<�+<� =�D�� �����	1� #�D�K�K� 0�D�����	1�s�A�#A3�2A3N)rF�T)�__name__�
__module__�__qualname__�__doc__rirmrrrxr{rbr�r�r�r�r5r?r%rVrV=s<���,-�\E�
�)� >�#4�J
� �� r?rVc�.�eZdZdZ		dd�Zd�Zd�Zd�Zy)�	Componentz�A subclass of Region backed by an accessible.  This Region will react
    to any cursor routing key events and perform the default action on the
    accessible, if a default action exists.
    c��tj||||�|r2|jr|dz|jz|_||_y||_||_y)aCreates a new Component.

        Arguments:
        - accessible: the accessible
        - string: the string to use to represent the component
        - cursorOffset: a 0-based index saying where to draw the cursor
                        for this Region if it gets focus.
        r}N)rVrirc�
accessible)rhr�rcrf�	indicatorr\s      r%rizComponent.__init__�sM��	����f�l�N�C���{�{�'�#�o����;���%���(���$��r?c�8�d|j|jfzS)NzComponent: '%s', %drkrls r%rmzComponent.__str__�s��$����T�5F�5F�'G�G�Gr?c��y)��Returns the caret position of the given offset if the object
        has text with a caret.  Otherwise, returns -1.

        Arguments:
        - offset: 0-based offset of the cell on the physical display
        ���r5rps  r%�getCaretOffsetzComponent.getCaretOffset�s��r?c�,�tj�j�}|rE|jj	|j
|�rt
j|j
�t
j|j
d�ry	tj|j
d�}|s(d}tjtj|d�yy#t$r3}d|g}tjtj|d�Yd}~yd}~wwxYw)rorNrz#INFO: Processing routing key failedTz%ERROR: Could not process routing key:)r
�
getManager�getActiveScript�	utilities�grabFocusBeforeRoutingr�r�
grab_focus�	do_actionr
�click_objectrrGrE�	ExceptionrD)rhrq�script�resultrO�errorrNs       r%rrzComponent.processRoutingKeys��� �*�*�,�<�<�>���f�&�&�=�=�d�o�o�v�V�������0����d�o�o�q�1��
	@�'�4�4�T�_�_�a�H�F�
�;���"�"�5�#3�#3�S�$�?���	�	>�=�u�E�F����e�.�.���=�=��	>�s� C�	D� )D�DN)rr+F�r�r�r�r�rirmr�rrr5r?r%r�r��s%���
9:�.3�%�(H��@r?r�c�&�eZdZdZdd�Zd�Zdd�Zy)�Linkz�A subclass of Component backed by an accessible.  This Region will be
    marked as a link by dots 7 or 8, depending on the user's preferences.
    c�8�tj||||dd�y)zlInitialize a Link region. similar to Component, but here we always
        have the region expand on cursor.r+TN)r�ri)rhr�rcrfs    r%riz
Link.__init__#s��	���4��V�\�2�t�Lr?c�8�d|j|jfzS)NzLink: '%s', %drkrls r%rmzLink.__str__(����4�;�;��0A�0A�"B�B�Br?c�`�ttj�t|j�zS)a�Creates a string which can be used as the attrOr field of brltty's
        write structure for the purpose of indicating text attributes and
        selection.
        Arguments:

        - 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).
        )�chrr�brailleLinkIndicatorrLrcrvs  r%rxzLink.getAttributeMask+s#���8�0�0�1�C����4D�D�Dr?N�rr�)r�r�r�r�rirmrxr5r?r%r�r�s���M�
C�Er?r�c�P�eZdZdZ		dd�Zd�Zd�Zd�Zd�Zd
d�Z	dd	�Z
d
�Zd�Zy)�TextajA subclass of Region backed by a Text object.  This Region will
    react to any cursor routing key events by positioning the caret in
    the associated text object. The line displayed will be the
    contents of the text object preceded by an optional label.
    [[[TODO: WDW - need to add in text selection capabilities.  Logged
    as bugzilla bug 319754.]]]Nc��||_d}d|_d|_|jrPtj�j�}|r,|j
|j||��\}|_|_	||jz
}	||jz
|_	||j|}|xj|jzc_t|j|jz
t|��}|jt|�z|_||_|r|dz|_
nd|_
|j|z}|t|j�z
}tj|||d�|j s0t"j$s |xj&|jz
c_yt"j$r|xj&dz
c_yy#t$rt|�}Y��`wxYw#t$rd|_	Y��bwxYw)z�Creates a new Text region.

        Arguments:
        - accessible: the accessible that implements AccessibleText
        - label: an optional label to display
        r+r)�startOffset�	endOffsetr}TN)r��caretOffset�
lineOffsetr
r�r��getTextLineAtCaret�	TypeErrorrLr�r��_maxCaretOffset�eol�labelrVrir[r�disableBrailleEOLrc)	rhr�r�r�r�r�rcr�rfs	         r%riz
Text.__init__Cs���%������������?�?�#�.�.�0�@�@�B�F���.�.����k�Y�/�X�<���)�4�?�	$�!�D�O�O�3�I�	!�*�T�_�_�<�D����(�(��3�����D�,�,�,���4�+�+�d�o�o�=�s�6�{�K��#����V��<����������D�J��D�J����f�$����D�J�J��'������f�l�D�9����x�'A�'A��K�K�4�8�8�#�K�
�
'�
'�
�K�K�3��K�	(��?�	$��F��I�	$��
�	!� �D��	!�s$�5G
�G(�
G%�$G%�(G<�;G<c�8�d|j|jfzS)NzText: '%s', %drkrls r%rmzText.__str__~r�r?c��tsytj�j�}|j	|j
�\}}}t
||z
t|��}||jk7ry||_	||_|t|j�z
}|jr1|j|j|d�\|_|_|_}||_y)z�Attempts to reposition the cursor in response to a new
        caret position.  If it is possible (i.e., the caret is on
        the same line as it was), reposition the cursor and return
        True.  Otherwise, return False.
        FT)�_regionWithFocusr
r�r�r�r�r�rLr�r�r�r[rbr^rcrdrerf)rhr�rcr�r�rfs      r%r{zText.repositionCursor�s��� ���*�*�,�<�<�>��,2�,E�,E�d�o�o�,V�)���j��;��3�S��[�A������(��&���$�����D�J�J��'���?�?��(�(����|�T�J�
?�D�K���T�[�,�)���r?c�v�|j|�}|dkryt|j|z|j�S�r�rr�)r�r�r�r�rps  r%r�zText.getCaretOffset�s:���+�+�F�3���A�:���4�?�?�V�+�T�-A�-A�B�Br?c���|j|�}|dkrytj�j�}|jj|j|�y)aProcesses a cursor routing key press on this Component.  The offset
        is 0-based, where 0 represents the leftmost character of text
        associated with this region.  Note that the zeroeth character may have
        been scrolled off the display.
        rN�r�r
r�r�r��setCaretOffsetr��rhrqr�r�s    r%rrzText.processRoutingKey�sO���)�)�&�1����?���*�*�,�<�<�>�����'�'�����Er?c��tj|j�ryt|j�t|j
�z
}|j|z}tjg|z}tj}tj}tj}tj�j�}|�(d}	tj tj"|	d�y|r�|tjk7r�t%j&|j�}
|
D]|}t%j(|�}t%j*|�}
t-||jz
d�}t/|
|jz
|�}t1||�D]}||xx|zcc<��~|�r|j2j5tj6�\}}|j}||kr�tj8|j|�\}}}
|
|krn�tj}|
}|D]'}|j;|d�dk7s�||||k7s�%|}n|tjk7rPt-||jz
d�}t/|
|jz
|�}t1||�D]}||xx|zcc<�||kr��|rytj<|j�}|D]U\}}
t-||jz
d�}t/|
|jz
|�}t1||�D]}||xx|zcc<��W|j>r�dgt|j�z}|j@t|j
�d}|j
r)|D�cgc]}|t|j
�z
dz
��c}}tC|�D]\}}	|||xx|zcc<�|dt|jF�}|dgt|jH�zz
}|j
rdgt|j
�z|z}djKtMtN|��Scc}w#tD$rY��wxYw)rtr+Nz9BRAILLE: Cannot get attribute mask without active script.Trr)(r�is_whitespace_or_emptyr�rLr^r�r�r�BRAILLE_UNDERLINE_NONE�textAttributesBrailleIndicator�brailleSelectorIndicatorr�r
r�r�rrGrEr�
get_all_links�get_link_start_offset�get_link_end_offset�maxr��ranger��stringToKeysAndDict�enabledBrailledTextAttributes�get_text_attributes_at_offsetr �get_selected_rangesr[re�	enumerater�rcr�r�mapr�)rhrw�stringLength�
lineEndOffset�
regionMask�
attrIndicator�selIndicator�
linkIndicatorr�rO�links�linkr�r��	maskStart�maskEnd�i�keys�enabledAttributesrq�
attributes�mask�attrib�
selections�contractedMaskre�ms                           r%rxzText.getAttributeMask�s���(�(����9���4�<�<�(�3�t�z�z�?�:�����,�6�
��5�5�6�|�C�
� �?�?�
��8�8�� �5�5�
��*�*�,�<�<�>���>�M�C����u�/�/��d�;���=�H�,K�,K�K��-�-�d�o�o�>�E��
1��)�?�?��E��'�;�;�D�A�	���d�o�o� =�q�A�	��i�$�/�/�9�<�H���y�'�2�1�A��Q�-�=�0�-�1�
1��&,�&6�&6�&J�&J��6�6�'8�#�D�#��_�_�F��=�(��8�8����&�Q�3�
�K����&���6�6��"��(�"�F�(�,�,�V�R�8�B�>�,�V�4�
�6�8J�J�#0�D�!�	"�
�8�:�:�:� #�K�$�/�/�$A�1� E�I�!�)�d�o�o�"=�|�L�G�"�9�g�6�7��"�1�
��6�
�7��=�(�$��3�3�D�O�O�D�J�*4�
2�&��Y���d�o�o� =�q�A�	��i�$�/�/�9�<�H���y�'�2�2�A��q�M�\�1�M�2�
2��?�?��S�3�t�|�|�#4�4�N��[�[��T�Z�Z��!1�2�F��z�z�DJ�J����T�Z�Z��0�1�4�J��!�*�-�
���1��"�6�!�9�-��2�-�
�
(�(9��T�[�[�)9�:�J�
	�q�c�#�d�h�h�-�'�'�
��:�:���S����_�,�z�9�J��w�w�s�3�
�+�,�,��!K��"����s�"Q�:Q�	Q�Qc�b�tj||||�\}}}}||jz|||fSr4)rVrbr�)rhr�rfr\r[rdrer~s        r%rbzText.contractLines>��/5�/B�/B��$��n�06�,�
�E�6�9��D�H�H�$�e�V�Y�>�>r?c��tj||�}||jz
}|t|j�z}|Sr4)rVr�r�rLr�r�s   r%r�zText.displayToBufferOffset!s;���-�-�d�N�C���$�"�"�"���#�d�j�j�/�!���
r?c�t�tj||�|s |xj|jz
c_yyr4)rVr�rcr�r�s  r%r�zText.setContractedBraille's,���#�#�D�*�5���K�K�4�8�8�#�K�r?)r+r+NNr�)rT)
r�r�r�r�rirmr{r�rrrxrbr�r�r5r?r%r�r�;sB��"�24�-1�9�vC��<C�
F�]-�~?��$r?r�c��eZdZdZd�Zd�Zy)�ReviewComponentz@A subclass of Component that is to be used for flat review mode.c�F�tj||||d��||_y)a_Creates a new Component.

        Arguments:
        - accessible: the accessible
        - string: the string to use to represent the component
        - cursorOffset: a 0-based index saying where to draw the cursor
                        for this Region if it gets focus.
        - zone: the flat review Zone associated with this component
        T�r\N)r�ri�zone)rhr�rcrfr�s     r%rizReviewComponent.__init__/s)��	���4��V�'��	�	>���	r?c�8�d|j|jfzS)NzReviewComponent: %s, %d�r�rfrls r%rmzReviewComponent.__str__=s��(�D�I�I�t�7H�7H�+I�I�Ir?N)r�r�r�r�rirmr5r?r%r�r�,s��J��Jr?r�c�(�eZdZdZd�Zd�Zd�Zd�Zy)�
ReviewTextaA subclass of Region backed by a Text object.  This Region will
    does not react to the caret changes, but will react if one updates
    the cursorPosition.  This class is meant to be used by flat review
    mode to show the current character position.
    c�^�tj||d��||_||_||_y)aICreates a new Text region.

        Arguments:
        - accessible: the accessible that implements AccessibleText
        - string: the string to use to represent the component
        - lineOffset: the character offset into where the text line starts
        - zone: the flat review Zone associated with this component
        Tr�N)rVrir�r�r�)rhr�rcr�r�s     r%rizReviewText.__init__Gs+��	����f�T��:�$���$�����	r?c�8�d|j|jfzS)NzReviewText: %s, %dr�rls r%rmzReviewText.__str__Us��#�t�y�y�$�2C�2C�&D�D�Dr?c�N�|j|�}|dkry|j|zSr�)r�r�rps  r%r�zReviewText.getCaretOffsetXs-���+�+�F�3���A�:������'�'r?c��|j|�}tj�j�}|jj|j|�y)z�Processes a cursor routing key press on this Component.  The offset
        is 0-based, where 0 represents the leftmost character of text
        associated with this region.  Note that the zeroeth character may have
        been scrolled off the display.Nr�r�s    r%rrzReviewText.processRoutingKeyfsE���)�)�&�1���*�*�,�<�<�>�����'�'�����Er?Nr�r5r?r%r�r�@s����E�(�Fr?r�c�>�eZdZdZd
d�Zd�Zd�Zdd�Zd�Zd�Z	d	�Z
y)�LinezaA horizontal line on the display.  Each Line is composed of a sequential
    set of Regions.
    Nc�H�g|_d|_|r|j|�yy)Nr+)�regionsrc�	addRegion�rh�regions  r%riz
Line.__init__us$����������N�N�6�"�r?c�:�|jj|�yr4)r�appendrs  r%rzLine.addRegion{s�������F�#r?c�:�|jj|�yr4)r�extend)rhrs  r%�
addRegionszLine.addRegions~s�������G�$r?c	��d}d}d}g}|jD]G}|tk(rt|�}|jr||jz
}|j	|�}||z
}�Itjd|�D�cgc]}|j���}	}g}
|	D]�\}}|
r%||
dz
tdkDr|j|
�g}
|
s�||z
}
|
tdkDrm|
tdz}|rit|�D]2}|j||tdzz||dztdzzg��4|
tdzr||tdzz|g}
n��||g}
n||
d<||k(s��|j|
�g}
��|
r|j|
�||||gScc}w)a+Computes the complete string for this line as well as a
        0-based index where the focused region starts on this line.
        If the region with focus is not on this line, then the index
        will be -1.

        Arguments:
        - 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).

        Returns [string, offsetIndex, attributeMask, ranges]
        r+r�z
(^\s+|\S+\s*)rr)rr�rLrcrx�re�finditer�span�_displaySizerr�)rhrwrc�focusOffset�
attributeMask�rangesrr��word�wordsr�start�end�
wordLength�
displayWidthsr�s                r%�getLineInfozLine.getLineInfo�s��������
����l�l�	"�F��)�)�!�&�k���}�}��&�-�-�'���*�*�;�7�D��T�!�M�
	"�*,���5E�v�)N�O������O��O����	$�J�E�3���d�1�g�
��Q��7��
�
�d�#���� �5�[�
���Q��/�$.�,�q�/�$A�M�$�!&�}�!5�N�A�"�M�M�5�1�|�A��3F�+F�,1�Q�q�S�L��O�4K�,K�+M�N�N�&��Q��7�$)�M�L��O�,K�$K�S�#Q�D�$�!�3�<�D���Q���k�!��
�
�d�#���/	$�2��
�
�d�#���]�F�;�;��=Ps�7E?c��d}d}d}|jD].}|}||jz}t|�|kDrn
t|�}�0|t|�k\rddgS|||z
gS)a5Finds the Region at the given 0-based offset in this line.

        Returns the [region, offsetinregion] where the region is
        the region at the given offset, and offsetinregion is the
        0-based offset from the beginning of the region, representing
        where in the region the given offset is.Nr+rr�)rrcrL)rhrq�foundRegionrc�posrs      r%�getRegionAtOffsetzLine.getRegionAtOffset�sx���������l�l�	"�F� �K��f�m�m�+�F��6�{�V�#���&�k��
	"��S��[� ��"�:����#��.�.r?c�T�|j|�\}}|r|j|�yy)z�Processes a cursor routing key press on this Component.  The offset
        is 0-based, where 0 represents the leftmost character of string
        associated with this line.  Note that the zeroeth character may have
        been scrolled off the display.N)rrr)rhrqr�regionOffsets    r%rrzLine.processRoutingKey�s/��"&�!7�!7��!?������$�$�\�2�r?c�H�|jD]}|j|��yr4)rr�)rhr[rs   r%r�zLine.setContractedBraille�s#���l�l�	4�F��'�'�
�3�	4r?r4r�)r�r�r�r�rirrrrrrr�r5r?r%rrps+���#�$�%�9<�v/�83�4r?rc��tt�dkDr0|dz
tdz}td}t|j|�SddgS)aBGiven a 1-based cell offset, return the braille region
    associated with that cell in the form of [region, offsetinregion]
    where 'region' is the region associated with the cell and
    'offsetinregion' is the 0-based offset of where the cell is
    in the region, where 0 represents the beginning of the region.
    rrNr�)rL�_lines�viewportr)�cellrq�lineNums   r%�getRegionAtCellr'�sI���6�{�Q����(�h�q�k�)���1�+���g��0�0��8�8��b�z�r?c���|jd}t|dz�\}}|rAt|t�st|t�r!|j
}|j
|�}||gSd}d}||gS)aNGets 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.
    �argumentrNr�)�eventr'�
isinstancer�r�r�r�)r*rqrr r�r�s      r%�getCaretContextr,�sy���[�[��
$�F�,�V�a�Z�8��V�\�
�:�f�d�+�z�&�*�/M��&�&�
��+�+�L�9��

��$�$��
�����$�$r?c��gadaddgay)zgClears the logical structure, but keeps the Braille display as is
    (until a refresh operation).
    Nr)r#r�r$r5r?r%�clearr.
s���F����1�v�Hr?c��|ayr4)r#)�liness r%�setLinesr1s��
�Fr?c�V�tj|�tt�|_y)a/Adds a line to the logical display for painting.  The line is added to
    the end of the current list of known lines.  It is necessary for the
    viewport to be over the lines and for refresh to be called for the new
    line to be painted.

    Arguments:
    - line: an instance of Line to add.
    N)r#rrL�_index)r�s r%�addLiner4s���M�M�$���f�+�D�Kr?c�Z�tt�dkDrttdSt�S)zEReturns the Line that is currently being painted on the display.
    rr)rLr#r$rr5r?r%�getShowingLiner6(s%���6�{�Q���h�q�k�"�"��v�
r?c�~�|a|rtsyd}d}tD]2}|jD]}|tk(s�
|td<d}n|rn|dz
}�4ttd}|j	|�\}}}	}
tj
tdk\r |tj
tdz
dzz
}td|�td<y)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
      knowing that we will fail and/or it taking an unreasonable
      amount of time (AKA Gecko).
    NrFrT)r�r#rr$rrfrr�)r�
panToFocusrwr&�doner��regrcrqrrs           r%�setFocusr;0s���"���.���G��D��	���<�<�	�C��&�&�%�������		�
���q�L�G�	��(�1�+��D�.2�.>�.>�{�.K�+�V�V�]�F�
�$�$��Q��7��"�/�/�,�q�/�A�A�E�E���a��.�H�Q�Kr?c��ts�	d}tjtj|d�tjtjddt�dad}tjtj|d�tStS#t$r/d}tjtj|d�YtSwxYw)zjTry to hand off control to other screen readers without completely
    shutting down the BrlAPI connectionz$BRAILLE: Attempting to idle braille.TrFz"BRAILLE: Idling braille succeeded.z=BRAILLE: Idling braille failled. This requires BrlAPI >= 0.8.)
�idlerrGrE�_brlAPI�setParameter�brlapi�PARAM_CLIENT_PRIORITY�BRLAPI_PRIORITY_IDLEr��rOs r%�_idleBraillerDes����	<�8�C����u�/�/��d�;�� � ��!=�!=�q�%�I]�^��D�7�C����u�/�/��d�;��K�4�K���	�Q�C����u�/�/��d�;��
�K�	�s�AB�0C�Cc��tstt�tr"	tj	dd�t�yy#t$r4d}tjtj|d�t�YywxYw)zzClear Braille output, hand off control to other screen readers, without
    completely shutting down the BrlAPI connectionr+r�*BRAILLE: BrlTTY seems to have disappeared.TN)�_brlAPIRunning�init�	_callbackr>�	writeTextrDr�rrGrg�shutdownrCs r%�
_clearBraillerL{sc����Y���	����b�!�$��N����	�>�C����u�2�2�C��>��J�	�s� ?�:A<�;A<c��dtg}tjtj|d�ts6d}tjtj|d�tt�tr�tr�d}tjtj|d�	d}tjtj|d�tjtjddt�dad}tjtj|d�y
y
y
#t$r*d	}tjtj|d�Yy
wxYw)z<Re-enable Braille output after making it idle or clearing itz*BRAILLE: Enabling braille. BrlAPI running:Tz"BRAILLE: Need to initialize first.z BRAILLE: Is running, but idling.z'BRAILLE: Attempting to de-idle braille.rFzBRAILLE: De-idle succeeded.z#BRAILLE: could not restore priorityN)rGrrDrErGrHrIr=r>r?r@rA�brlapi_priorityr�rg�rNrOs  r%�_enableBraillerP�s��;�N�
K�F�	���e�&�&���5��2��
���5�+�+�S�$�7��Y����4�C����u�/�/��d�;�
@�?���"�"�5�#3�#3�S�$�?��$�$�V�%A�%A�1�e�_�]���
4���"�"�5�#3�#3�S�$�?�����
C�;���"�"�5�#6�#6��T�B�
C�s�AD�0E�
Ec��dtg}tjtj|d�tr�ts�d}tj
tj|d�t
�sVtj�jd�s2d}tj
tj|d�t�yyyyy)z[Hand off control to other screen readers, shutting down the BrlAPI
    connection if neededz+BRAILLE: Disabling braille. BrlAPI running:Tz%BRAILLE: BrlApi running and not idle.�
enableBraillez0BRAILLE: could not go idle, completely shut downN)rGrrDrEr=rGrDrr��
getSettingrKrOs  r%�disableBraillerT�s���<�^�
L�F�	���e�&�&���5��d�5��
���5�+�+�S�$�7��~�&6�&A�&A�&C�&N�&N��&_�D�C����u�/�/��d�;��J�	'`�~�	#�~r?c��d}tjtj|d�tj�jd�st
�yy)z5Disable Braille if it got disabled in the preferencesz"BRAILLE: Checking braille setting.TrRN)rrGrErr�rSrTrCs r%�checkBrailleSettingrV�sD��/�C�	���u�'�'��d�3��&�&�(�3�3�O�D���Er?c	���d|�d|��}tjtj|d�|rtd��t	j
�j
d�s]t	j
�j
d�s:tr1d}tjtj|d�t�d	a	y
tt�dk(r
t�d	a	y
t\}}}}d|d
|�d|�d|�d�g}	tjtj|	d�trEttt �r1tj"}
tj$}tj&}nd
}
d}d}|
xr|
|k(xr||k(}
d|
d
|�d|�d�t)|
�g}	tjtj|	d�|dkr9t*d|zdz}d|��}tjtj|d�|�rE|dk(�r?|
�r<|dk(r)d}tjtj|d��n||k(r*|}d}tjtj|d�n�||krr|||z
z}|t*dkr-d|��}tjtj|d�|}n�d}tjtj|d�t*d}nh||kDrc|||z
z
}|dk\r-d|��}tjtj|d�|}n)d}tjtj|d�d}tt,d}|j/|�\}}}}dt,d�d|�d|�d|��}tjtj|d�d}|dk\r=|tj0z}d|��}tjtj|d�|�r!|dk\�rt|�t*dkr@|t*dkr4d t,d�d!�}tjtj|d��n�|rMt3d||z
dz�t,d<d"t,d�d#�}tjtj|d��nw|t,dkrGt3d|�t,d<d"t,d�d$�}tjtj|d��n$|t,dt*dzk\rSt3d|t*dz
dz�t,d<d"t,d�d%�}tjtj|d�n�t5|�}t3d|d�t,d<d"t,d�d&�}tjtj|d�|t,dt*dzk\rRt3d|t*dz
dz�t,d<d't,d�d%�}tjtj|d�t7|�\}}|t,d<||z
at8dkst8t*dk\rdan	t8dz
ad(|�d)�}tjtj|d�t:j=|�d*|||�d+t8��}tjtj|d�t:j=|�|||}|r|||}nd,}|d-t|�t|�z
zz
}t	j
�j
d�r
t?�t	j
�j
d�r�tr�tAjB�}d|_"t|�|_#|jFt*dkr8|dz
}|r|d-z
}|xjFdz
c_#|jFt*dkr�8||_$t8|_%|r||_&	tNjQ|�tVjXrctZs1	t]j^t*d�a-tZja�|r|||}nd
}tZr8tZjct8||�ntZrtZje�d
a-|dk(a3|t|�k\a4trIttt �r5tj"tj$tj&t8fa	y
d	a	y
#tR$r5d.}tjtjT|d�t�Y��1wxYw#tR$r*tjtjTd/�d
a-Y�� wxYw)0a\Repaints the Braille on the physical display.  This clips the entire
    logical structure by the viewport and also sets the cursor to the
    appropriate location.  [[[TODO: WDW - I'm not sure how BrlTTY handles
    drawing to displays with more than one line, so I'm only going to handle
    drawing one line right now.]]]

    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.
    zBRAILLE: Refresh. Pan: z	 target: TF)�restoreSavedrR�enableBrailleMonitorz>BRAILLE: FIXME - Braille disabled, but not properly shut down.rNrzBRAILLE: Last text object:z(Caret: z, Line: z, Cell: �)zBRAILLE: Current text object:z). On same line:rz'BRAILLE: Adjusted targetCursorCell to: zGBRAILLE: Not adjusting targetCursorCell. User panned caret out of view.zHBRAILLE: Setting targetCursorCell to previous value. Caret hasn't moved.z3BRAILLE: Setting targetCursorCell based on offset: z4BRAILLE: Setting targetCursorCell to end of display.z6BRAILLE: Setting targetCursorCell to start of display.zBRAILLE: Line z: 'z' focusOffset: r}r�z*BRAILLE: Cursor offset in line string is: zBRAILLE: Not adjusting offset z . Cursor offset fits on display.zBRAILLE: Adjusting offset to z based on targetCursorCell.z (cursor on left)z (cursor beyond display end)z (unhandled condition)zBRAILLE: Readjusting offset to zBRAILLE LINE:  '�'z     VISIBLE:  'z
', cursor=r+rurFz
brlmon failed)5rrGrE�	killFlashrr�rSrGrK�
_lastTextInforLr#rLrDr�r+r�r�r�r��boolrr$rrfr��_getRangeForOffset�_adjustForWordWrap�
cursorCell�log�inforPr@�WriteStruct�regionBegin�
regionSize�text�cursor�attrOrr>�writer�rgrrY�_monitorr�BrlMon�show_allrJ�destroy�beginningIsShowing�endIsShowing)�panToCursor�targetCursorCellrw�	stopFlashrO�lastTextObj�lastCaretOffset�lastLineOffset�lastCursorCellrN�currentTextObj�currentCaretOffset�currentLineOffset�
onSameLine�newLocationr�rcrrrrf�rangeForOffset�startPos�endPos�logLine�	substring�submask�writeStruct�subMasks                             r%�refreshr��s���<
$�K�=�	�:J�9K�
L�C�	���u�'�'��d�3���u�%��&�&�(�3�3�O�D��*�*�,�7�7�8N�O��R�C����u�/�/��d�;��J�'�
��
�6�{�a����'�
��CP�@�K��.�.�*�K���)��.�1A��.�IY�YZ�[�]�F�	���e�&�&���5��J�'7��>�)�4�4��-�9�9��,�7�7���������0�N�k�$A�0���/��.�~��+�,�H�5F�4G�GW�X��:�� �F�
���e�&�&���5��!��'��?�-=�=��A��7�8H�7I�J��
���5�+�+�S�$�7��'�1�,���Q��[�C����u�/�/��d�;�
� 2�
2�-��\�C����u�/�/��d�;�
�1�
1�(�,>��,P�Q�K��l�1�o�-�K�K�=�Y���"�"�5�#3�#3�S�$�?�#.� �L���"�"�5�#3�#3�S�$�?�#/��?� �
�1�
1�(�O�>P�,P�Q�K��a��K�K�=�Y���"�"�5�#3�#3�S�$�?�#.� �N���"�"�5�#3�#3�S�$�?�#$� ��(�1�+��D�37�3C�3C�K�3P�0�V�[�-���8�A�;�-�s�6�(�/�+��a�PV�x�
X�C�	���u�'�'��d�3��L��a��"�%5�%B�%B�B��:�<�.�I��
���5�+�+�S�$�7����)��v�;�,�q�/�)�l�\�!�_�.L�2�8�A�;�-�?_�`�C����u�/�/��d�;�
��a��0@�!@�1�!D�E�H�Q�K�1�(�1�+��>Y�Z�C����u�/�/��d�;�
�H�Q�K�
'��a��.�H�Q�K�1�(�1�+��>O�P�C����u�/�/��d�;�
�h�q�k�L��O�;�
<��a���Q��!?�!�!C�D�H�Q�K�1�(�1�+��>Z�[�C����u�/�/��d�;�/��=�N��a���!2�3�H�Q�K�1�(�1�+��>T�U�C����u�/�/��d�;�����l�1�o� =�>�!�!�\�L��O�%C�a�%G�H����7����}�D`�a���"�"�5�#3�#3�S�$�?�)�*:�;��H�f��H�Q�K�
��(�J��Q��J�,�q�/�9��
��a��
� ����*�G�	���u�'�'��$�7��H�H�W�� ����!8� 9��J�<�P�G�	���u�'�'��$�7��H�H�W���x��'�I�����0�����v��Y��#�g�,�6�7�7�G��"�"�$�/�/��@����"�"�$�/�/��@�^��(�(�*��"#���!$�Y�����$�$�|�A��6����I���6�!���"�"�a�'�"�	�$�$�|�A��6�
%���'���"�!(�K��	��M�M�+�&��$�$��
 �!�=�=��a��9���!�!�#��#�H�V�4�G��G�����z�9�g�>�	�������!�Q����S��[�(�L��J�'7��>�)�4�4�)�5�5�)�4�4�#�%�
�
(�
��E�	�>�C����u�2�2�C��>��J�	���
 ��"�"�5�#6�#6��H���
 �s$�%c.�0d/�.:d,�+d,�//e"�!e"c�D�trt\aaa}tdd��day)NF�rqrsr)�_flashEventSourceId�_savedr#r�r$r���	flashTimes r%�_flashCallbackr��s)���:@�7��!�8�Y��E�U�3���r?c��tr?tdkDrtjt�|rt\aaa}tdd��dayy)NrFr�)r�r�
source_remover�r#r�r$r�)rXr�s  r%r\r\�sE��
���"����2�3��>D�;�V�%�x�����7���
r?c��tdkDr=tjt�td}tj|t
�ayy)Nr�)r�rr�r��timeout_addr�r�s r%�resetFlashTimerr��s:���Q�����.�/��1�I�	�"�.�.�y�.�I��r?c���tr%tdkDrtjt�danttt
|fa|dkDrtj|t�ay|dkrdayy)a�Sets up the state needed to flash a message or clears any existing
    flash if nothing is to be flashed.

    Arguments:
    - 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 display the message until some other message
                  comes along or the user presses a cursor routing key.
    rif���N)	r�rr�r#r�r$r�r�r�r�s r%�
_initFlashr��s_�����"����2�3����*�H�i�@���1�}�"�.�.�y�.�I��	�Q��"��
r?c���t|�|d}|d}t�t�}|D]}|j|��t	|�t|�t
d��y)aDisplays 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 display the message until some other message
                  comes along or the user presses a cursor routing key.
    rrF�rsN)r�r.rrr4r;r�)�
regionInfor�r�
focusedRegionr��items      r%�displayRegionsr�s\�� �y����m�G��q�M�M�	�G��6�D�������t����D�M��]���e�r?c��t|�t�t||�}tt	|��t|�t
dd��y)aVDisplays 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 display the message until some other message
                  comes along or the user presses a cursor routing key.
    TFr�N)r�r.rVr4rr;r�)�messagerhr�rs    r%�displayMessager�s;���y��	�G�
�G�V�
$�F��D��L���V���D�E�"r?c��|j�}|r3|j�}|�d|��}t|tj��yy)z^Displays a KeyboardEvent. Typically reserved for locking keys like
    Caps Lock and Num Lock.r}r�N)�getLockingStateString�
getKeyNamer�r�brailleFlashTime)r*�lockingStateString�keynamerOs    r%�displayKeyEventr�3sK���4�4�6����"�"�$���	��-�.�/���s�h�&?�&?�@�r?c�n���td��tdz}d��d|�d���}tjtj|d�t
rtjs�|fSt
td}|j�\}}}}tt��fd�|��}|r�d|dd�d|d	d�d
�}tjtj|d�|d	d|ddz
tdkDr+d}tjtj|d��|fS|dd|d	dc�}�|fS)NrzBRAILLE: Current range: (r@z). Target cell: Trc�6��|d��zcxkxr|dkScS)Nrrr5)rPr~rrs ��r%�<lambda>z$_adjustForWordWrap.<locals>.<lambda>Hs$���1�Q�4�8�6F�+F�#M��1��#M��#M�r?zBRAILLE: Adjusted range: (r�rZz?BRAILLE: Not adjusting range which is greater than display size)r$rrrGrEr#r�enableBrailleWordWraprrJrK)	rrrrOr��
lineStringrrrr~s	`       @r%r`r`=sM�����{�H�
��Q��
'�F�%�h�Z�r�&��9I�JZ�I[�
\�C�	���u�'�'��d�3���7�7������(�1�+��D�59�5E�5E�5G�2�J��]�F�
�&�M�v�V�
W�F�
�*�6�!�9�Q�<�.��6�"�:�a�=�/��K��
���5�+�+�S�$�7��"�:�a�=�6�!�9�Q�<�'�,�q�/�9�S�C����u�/�/��d�;��V��� &�a�y��|�V�B�Z��]��H�f��V��r?c��ttdj�\}}}}|D]}|d|cxkr|dks�|cS�|D]}||dk(s�|cSddgS)Nrr)r#r$r)rqrcrrr�rs      r%r_r_Ts|��17����1D�1P�1P�1R�.�F�K���
����Q�4�6� �A�a�D� ��H�!������Q�q�T�>��H��
�q�6�Mr?c�l�td}|dk(rFt|�\}}t|tdz
�\}}tdt	||z
td��}tdtd|z
�td<d|�d|�dtd�d�}tjt
j|d�|tdk7S)aPans 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.

    Returns True if a pan actually happened.
    rzBRAILLE: Panning left. Amount: � (from � to rZT)r$r_rr�r�rrGrE)�	panAmount�oldX�oldStart�oldEnd�newStart�newEndrOs       r%�panLeftr�_s����A�;�D��A�~�-�d�3���&�-�h��a��.H�I���&���3�x�(�2�L��O�D�E�	��a��!��y�0�1�H�Q�K�+�I�;�g�d�V�4��QR��}�TU�
V�C�	���u�'�'��d�3��8�A�;��r?c���td}|dk(r<t|�\}}t|�\}}tdt||z
td��}tt�dkDrHtd}td|z}t|j�\}}	}
}|t|�kr	|td<d|�d|�dtd�d�}tjtj|d�|tdk7S)aPans the display to the right, limiting the pan to the length
    of the line being displayed.

    Arguments:
    - panAmount: the amount to pan.  A value of 0 means the entire
                 width of the physical display.

    Returns True if a pan actually happened.
    rrz BRAILLE: Panning right. Amount: r�r�rZT)r$r_r�r�rrLr#rrrGrE)
r�r�r�r�r�r�r&�newXrcrrrrOs
             r%�panRightr�us����A�;�D��A�~�-�d�3���&�-�f�5���&���3�x�(�2�L��O�D�E�	�
�6�{�Q���1�+����{�Y�&��5;�G�_�5P�5P�5R�2���]�F��#�f�+���H�Q�K�,�Y�K�w�t�f�D��RS��
�UV�
W�C�	���u�'�'��d�3��8�A�;��r?c�&�d|�dtd��}tjtj|d�|tdkrt	�sn
|tdkr�|tdt
dzk\r#t
�sy|tdt
dzk\r�"yy)zOAutomatically pan left or right to make sure the current offset is
    showing.zBRAILLE: Panning to offset z. Current offset: rTN)r$rrGrEr�rr�)rqrOs  r%�panToOffsetr��s���
(��x�/A�(�1�+��
O�C�	���u�'�'��d�3�
�8�A�;�
��y���8�A�;�
��X�a�[�<��?�2�
3��z���X�a�[�<��?�2�
3r?c�8�tt�td�y)z�Pans the display so the region with focus is displayed.

    Arguments:
    - inputEvent: the InputEvent instance that caused this to be called.

    Returns True to mean the command should be consumed.
    T)r;r�r�)�
inputEvents r%�returnToRegionWithFocusr��s��
�
���D�M�r?c���|jdtjzdk7t_t
D]!}|j
tj��#t�y)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.
    �flagsrN)r*r@�KEY_FLG_TOGGLE_ONrrYr#r�r�)r*r�s  r%r�r��sR��
���W�	�� 8� 8�	8�Q�>�
�$��D���!�!�(�"B�"B�C�D��Ir?c���trt�y|jd}tt�dkDr-|t
dz}t
d}t|j
|�y)z�Processes a cursor routing key event.

    Arguments:
    - event: an instance of input_event.BrailleEvent.  event.event is
    the dictionary form of the expanded BrlAPI event.
    Nr)rrT)r�r\r*rLr#r$rr)r*r%rhr&s    r%rrrr�sT�������;�;�z�"�D�
�6�{�Q������#���1�+���w��)�)�&�1�r?c���d|g}tjtj|d�tj�j�}|r|dtvr|jd��d}tjrhtjdkDrUtjtjtj�tjtj�tr	t|�}tjr(tjdkDrtjd�|S#t$r6}d|��}tj tj"|d�d}Yd}~�td}~wwxYw)	z�Handles BrlTTY command events.  This passes commands on to Orca for
    processing.

    Arguments:
    - event: the BrlAPI input event (expanded)
    zBRAILLE: Processing eventT�commandF)r\rz*WARNING: Could not process braille event: N)rrDrEr
r�r��dontInteruptSpeechKeys�presentationInterruptr�timeoutCallback�timeoutTime�signal�SIGALRM�alarmrIr�rGrg)r*rNr��consumedr�rOs      r%�_processBrailleEventr��s��*�5�
1�F�	���e�&�&���5�
�
&�
&�
(�
8�
8�
:�F�
�%�	�"�*@�@�
	�$�$�u�$�5��H����X�%9�%9�A�%=��
�
�f�n�n�h�&>�&>�?����X�)�)�*��	�!��'�H����X�%9�%9�A�%=����Q���O���	�>�u�g�F�C����u�2�2�C��>��H��	�s�,D1�1	E0�:,E+�+E0c��	tjd�}|rttj|��tS#t$r>}d|��}tjtj
|d�t
�Yd}~yd}~wwxYw)z\Method to read a key from the BrlAPI bindings.  This is a
    gobject IO watch handler.
    Fz$WARNING: Could not read BrlApi key: TN)
r>�readKeyr�rrGrgrKr��
expandKeyCoderG)�source�	condition�keyr�rOs     r%�_brlAPIKeyReaderr��sq����o�o�e�$����W�2�2�3�7�8������4�U�G�<��
���5�.�.��T�:��
���	�s�=�	B�4A?�?Bc�8�d}tjtj|d�tst	t
�ts(d}tjtj|d�yd}tjtj|d�tjtjdg�tjtjzg}d}tjtj|d�|D]$}|jtj|z��&d}tjtj|d�tjtj|�d	}tjtj|d�y)
z�Hacky method to tell BrlTTY what to send and not send us via
    the readKey method.  This only works with BrlTTY v3.8 and better.

    Arguments:
    -keys: a list of BrlAPI commands.
    zBRAILLE: Setting up key ranges.Tz7BRAILLE: Not setting up key ranges: BrlAPI not running.Nz!BRAILLE: Ignoring all key ranges.rzBRAILLE: Enabling commands:z BRAILLE: Sending keys to BrlAPI.zBRAILLE: Key ranges set up.)rrGrErGrHrIr>�
ignoreKeysr@�
rangeType_all�KEY_TYPE_CMD�
KEY_CMD_ROUTEr�
acceptKeys�rangeType_command)r�rO�keySetr�s    r%�setupKeyRangesr�s1��,�C�	���u�'�'��d�3���Y���G��
���5�+�+�S�$�7��
-�C�	���u�'�'��d�3����v�+�+�a�S�1��!�!�F�$8�$8�8�
9�F�
'�C�	���u�'�'��d�3��1���
�
�f�)�)�C�/�0�1�-�C�	���u�'�'��d�3����v�/�/��8�
'�C�	���u�'�'��d�3r?c�6�tr)tr#tj�j	d�syt
r*d}t
jtj|d�|a	y	d|g}t
jtj|d�tjtjdd|�d}t
jtj|d�|a	y#t$r4}d	|��}t
jtj |d�Yd}~yd}~wwxYw)
zuSet BRLAPI priority

    Arguments:
    -level: the priority level to apply, default to braille.PRIORITY_DEFAULT
    rRNz7BRAILLE: Braille is idle, don't change BRLAPI priority.TzBRAILLE: Setting priority to:rFzBRAILLE: Priority set.zBRAILLE: Cannot set priority: )�_brlAPIAvailablerGrr�rSr=rrGrErNrDr>r?r@rAr�rg)�levelrOrNr�s    r%�setBrlapiPriorityr�1s����>��)�)�+�6�6��G���G��
���5�+�+�S�$�7����
 �1�5�9��
���%�*�*�F�D�9����V�9�9�1�e�U�K�
'��
���5�+�+�S�$�7����
�;�.�u�g�6��
���5�.�.��T�:�:��;�s�"AC�	D�$*D�Dc�	�tjsyd|g}tjtj|d�t
r(d}tjtj|d�y|adtjjd�g}tjtj|d�dtjjd�g}tjtj|d�	d	}tjtj|d�tj�a
d
tg}tjtj|d�d}tjtj|d�tj�d}tjtj|d�datj\}}d
|�d|�d�}tjtj|d�|dk(r-d}tjtj |d�t"�t%j&tj(t$j*t$j,t.�a|dgat:rt:j=�dat?�tAd�d}tjtj|d�y#t2$r*d}tjtj |d�Yyt"$�rw}d|��}tjtj |d�datsYd}~y	d}tjtj|d�tj5�d}tjtj|d�n6#t"$r*d}tjtj|d�YnwxYw	d}tjtj|d�tj7�d}tjtj|d�n6#t"$r*d}tjtj|d�YnwxYwda
Yd}~yd}~wwxYw)z�Initializes the braille module, connecting to the BrlTTY driver.

    Arguments:
    - callback: the method to call with a BrlTTY input event.
    Returns False if BrlTTY cannot be accessed or braille has
    not been enabled.
    Fz BRAILLE: Initializing. Callback:Tz#BRAILLE: BrlAPI is already running.zBRAILLE: WINDOWPATH=�
WINDOWPATHzBRAILLE: XDG_VTNR=�XDG_VTNRz+BRAILLE: Attempting connection with BrlAPI.z,BRAILLE: Connection established with BrlAPI:z&BRAILLE: Attempting to enter TTY mode.zBRAILLE: TTY mode entered.zBRAILLE: Display size: (�,rZrz@BRAILLE: Error - 0 cells suggests display is not yet plugged in.z6BRAILLE: Initialization failed: BrlApi is not defined.z(WARNING: Braille initialization failed: N�&BRAILLE: Attempting to leave TTY mode.zBRAILLE: TTY mode exited.�$BRAILLE: Exception leaving TTY mode.�(BRAILLE: Attempting to close connection.zBRAILLE: Connection closed.�&BRAILLE: Exception closing connection.rzBRAILLE: Initialized)!rrRrrDrErGrGrIr�environr r@�
Connectionr>�enterTtyModeWithPath�displaySizergr�r�io_add_watch�fileDescriptor�PRIORITY_DEFAULT�IO_INr��_brlAPISourceId�	NameError�leaveTtyMode�closeConnectionrrkrnr.r�)�callbackrNrOrP�yr�s      r%rHrHPs����!�!��1�(�
;�F�	���e�&�&���5��3��
���5�+�+�S�$�7���I�$�b�j�j�n�n�\�&B�
C�F�	���e�&�&���5�"�B�J�J�N�N�:�$>�
?�F�	���e�&�&���5�A�;��
���5�+�+�S�$�7��#�#�%��@�'�J��
���%�*�*�F�D�9�6��
���5�+�+�S�$�7��$�$�&�*��
���5�+�+�S�$�7����$�$���A�(���1�Q�C�q�1��
���5�+�+�S�$�7���6�T�C����u�2�2�C��>��O��+�+�G�,B�,B�,0�,A�,A�,0�J�J�,<�>��R�q�6�L��������	�G��D�M�
 �C�	���u�'�'��d�3���a��F��
���5�.�.��T�:����8���@��
���5�.�.��T�:�����	<�:�C����u�/�/��d�;�� � �"�-�C����u�/�/��d�;���	<�8�C����u�/�/��d�;�	<��	<�<�C����u�/�/��d�;��#�#�%�/�C����u�/�/��d�;���	<�:�C����u�/�/��d�;�	<������=�si�8FK�0R�	R�2R�
A"N0�/R�00O#� R�"O#�#R�'A"Q
�	R�
0Q=�:R�<Q=�=R�Rc�:�d}tjtj|d�t�r1dad}tjtj|d�t	j
t�da	d}tjtj|d�tj�d}tjtj|d�	d	}tjtj|d�tj�d
}tjtj|d�datrtj�datd
gan(d}tjtj|d�yd}tjtj|d�y#t$r+d}tjtj|d�Y��
wxYw#t$r*d}tjtj|d�Y��wxYw)zYShuts down the braille module.   Returns True if the shutdown procedure
    was run.
    z%BRAILLE: Attempting braille shutdown.TFz#BRAILLE: Removing BrlAPI Source ID.rr�z$BRAILLE: Leaving TTY mode succeeded.r�r�z&BRAILLE: Closing connection succeeded.r�Nrz!BRAILLE: Braille was not running.z#BRAILLE: Braille shutdown complete.)rrGrErGrr�r�r>r�r�rgr�rkrn�DEFAULT_DISPLAY_SIZErrCs r%rKrK�s���
2�C�	���u�'�'��d�3����3��
���5�+�+�S�$�7����?�+���		<�:�C����u�/�/��d�;�� � �"�
9�C����u�/�/��d�;�		<�<�C����u�/�/��d�;��#�#�%�
;�C����u�/�/��d�;���������H�,�a�0��1��
���5�+�+�S�$�7��
/�C�	���u�'�'��d�3���?�	?�8�C����u�2�2�C��>�	?���	?�:�C����u�2�2�C��>�	?�s$�4;F0�;G'�00G$�#G$�'0H�H)TT)TrTTr�r�)r�rr4)�r��__id__�__version__�__date__�
__copyright__�__license__rAr�rr
�
gi.repositoryrr+rrrr	r
rr�ax_event_synthesizerr
�ax_hypertextr�	ax_objectr�ax_textr�
orca_platformr�	getLogger�_logger�newLogrbrkrOrGrEr@r>r�rGr�rNrDr�rgrZrrYr��KEY_CMD_HWINLT�KEY_CMD_HWINRT�KEY_CMD_FWINLT�KEY_CMD_FWINRT�KEY_CMD_FWINLTSKIP�KEY_CMD_FWINRTSKIP�KEY_CMD_LNUP�KEY_CMD_LNDN�command_name�BRAILLE_LINE_LEFT�BRAILLE_LINE_RIGHT�BRAILLE_LINE_UP�BRAILLE_LINE_DOWN�BRAILLE_FREEZE�KEY_CMD_FREEZE�BRAILLE_TOP_LEFT�KEY_CMD_TOP_LEFT�BRAILLE_BOTTOM_LEFT�KEY_CMD_BOT_LEFT�BRAILLE_HOME�KEY_CMD_HOME�BRAILLE_SIX_DOTS�KEY_CMD_SIXDOTS�BRAILLE_ROUTE_CURSORr��BRAILLE_CUT_BEGIN�KEY_CMD_CUTBEGIN�BRAILLE_CUT_LINE�KEY_CMD_CUTLINEr�rr#r�r]r$rIrprorar�r�r=rB�BRLAPI_PRIORITY_DEFAULT�BRLAPI_PRIORITY_HIGHrN�CZ_CZ_G1�ES_ES_G1�FR_CA_G2�FR_FR_G2�LV_LV_G1�NL_NL_G1�NO_NO_G0�NO_NO_G1�NO_NO_G2�NO_NO_G3�PL_PL_G1�PT_PT_G1�SE_SE_G1�AR_AR_G1�CY_CY_G1�CY_CY_G2�DE_DE_G0�DE_DE_G1�DE_DE_G2�EN_GB_G2�EN_GB_G1�EN_US_G1�EN_US_G2�FR_CA_G1�FR_FR_G1�GR_GR_G1�HI_IN_G1�
HU_HU_8DOT�HU_HU_G1�HU_HU_G2�IT_IT_G1�NL_BE_G1rr&rTr`rVr�r�r�r�r�rr'r,r.r1r4r6r;rDrLrPrTrVr�r�r\r�r�r�r�r�r`r_r�r�r�r�r�rrr�r�r�r�rHrKr5r?r%�<module>rEse��(�������?�
���
�
�	�	���������4�%���$�
�&�
�
�
��
�n�n�Y�����6�
,�C��E���u�'�'��d�3���G����N��O�)�&�
1�F��E���e�&�&���5��
+�C��E���u�'�'��d�3��+�E�
2�F��E���e�&�&���5�)�9�
5�F��E���e�&�&���5��Q������5�+�+�S�$�7���*��������v�4�4����v�4�4��!�!�6�#<�#<����V�0�0�	2�����.6�.H�.H�L��&�&�'�.6�.H�.H�L��&�&�'�.6�.H�.H�L��*�*�+�.6�.I�.I�L��&�&�'�.6�.I�.I�L��&�&�'�.6�.I�.I�L��*�*�+�.6�.F�.F�L��$�$�%�.6�.H�.H�L��$�$�%�.6�.E�.E�L��&�&�'�.6�.G�.G�L��(�(�)�.6�.J�.J�L��(�(�)�.6�.C�.C�L��$�$�%�.6�.G�.G�L��'�'�(�.6�.K�.K�L��%�%�&�.6�.H�.H�L��(�(�)�.6�.G�.G�L��'�'�(���$�a�(��

���� �
�
�q�6��

�	�
����
�
���
��
��������*��3�z�=�1�1�3��=�1�1�3��=�1�1�3��=�1�1�3��=�1�1�	3�
�=�1�1�3��=�1�1�
3��=�1�1�3��=�1�1�3��=�1�1�3��=�1�1�3��=�1�1�3��=�1�1�3��=�1�1�3��=�1�1�3��=�1�1�3� �=�1�1�!3�")�1�1�(�1�1�(�1�1�(�1�1�(�1�1�(�1�1�(�1�1�(�1�1�(�1�1�(�1�1�+�6�6�(�1�1�(�1�1�(�1�1�(�1�1�?3��B�2.�h	�.�0��6�8P�
Q�F��E���e�&�&���5�_ �_ �B>@��>@�@E�9�E�:o$�6�o$�bJ�i�J�(.F��.F�`t4�t4�l
�%�*����3!�j�,�"@�:�&�(�B� �J�#�6�8#�*A��.	��,�8
����.'�R
�$4�L4� �>r�h:��A<��
-�C��E���u�*�*�C��6����N�	����
.�C��E���u�*�*�C��6��E���(�*�$)�H�!�*�s6�,X�$X2�-Y �)X/�.X/�2'Y�Y� Y0�/Y0

Zerion Mini Shell 1.0