%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__/ax_text.cpython-312.pyc

�

g
f����dZdZdZdZdZdZddlZejdd	�dd
lm	Z	ddl
mZdd
lm
Z
ddlmZGd�d�Zy)a�
Utilities for obtaining information about accessible text.
These utilities are app-type- and toolkit-agnostic. Utilities that might have
different implementations or results depending on the type of app (e.g. terminal,
chat, web) or toolkit (e.g. Qt, Gtk) should be in script_utilities.py file(s).

N.B. There are currently utilities that should never have custom implementations
that live in script_utilities.py files. These will be moved over time.
z$Id$z
$Revision$z$Date$zGCopyright (c) 2024 Igalia, S.L.Copyright (c) 2024 GNOME Foundation Inc.�LGPL�N�Atspiz2.0)r�)�debug)�AXObject)�AXUtilitiesc�n�eZdZdZed7d��Zed��Zed7d��Zed7d��Zed��Z	ed7d��Z
ed7d	��Zed
��Zed7d��Z
ed7d��Zed
��Zed7d��Zed��Zed7d��Zed��Zed7d��Zed��Zed��Zed��Zed��Zed��Zed��Zed��Zed��Zed��Zed��Zed��Zed��Z ed��Z!ed ��Z"ed!��Z#ed"��Z$ed#��Z%ed$��Z&ed8d%��Z'ed&��Z(ed7d'��Z)ed9d(��Z*ed)��Z+ed7d*��Z,ed+��Z-ed,��Z.ed-��Z/ed.��Z0ed/��Z1ed0��Z2ed7d1��Z3ed2��Z4ed3��Z5ed4��Z6ed5��Z7ed6��Z8y):�AXTextz:Utilities for obtaining information about accessible text.Nc	���tj|�}|sy|�tj|�}d|cxkr|ks.nd|�d�}tjtj
|d�y	tjj||tjj�}|jjd	d
�}d|�d�|d
|�d|j �d|j"�d�g}tj$tj
|d�|j|j |j"fS#t$r�}	tjj||tjj�}d|��}tjtj
|d�nD#t$r8}d|��}tjtj
|d�Yd}~Yd}~yd}~wwxYwYd}~��Cd}~wwxYw)zJReturns the character, start, and end for the current or specified offset.��rrNrzWARNING: Offset z, is not valid. No character can be provided.T�<WARNING: String at offset failed; text at offset succeeded: z.AXText: Exception in get_character_at_offset: �
�\nzAXText: Character at offset � in�'�' (�-�))r
�get_character_count�get_caret_offsetr�printMessage�
LEVEL_INFOr�Text�get_string_at_offset�TextGranularity�CHAR�	Exception�get_text_at_offset�TextBoundaryType�content�replace�start_offset�
end_offset�printTokens)	�obj�offset�length�msg�result�error�error2�debug_string�tokenss	         �./usr/lib/python3/dist-packages/orca/ax_text.py�get_character_at_offsetzAXText.get_character_at_offset2s����+�+�C�0�����>��,�,�S�1�F��F�$�f�$�$�V�H�,X�Y�C����u�/�/��d�;��	@��Z�Z�4�4�S�&�%�BW�BW�B\�B\�]�F��~�~�-�-�d�E�:��0����<�c��l�^�3�v�':�':�&;�1�V�=N�=N�<O�q�Q�S��
���%�*�*�F�D�9��~�~�v�2�2�F�4E�4E�E�E��!�
	@�	
@����6�6�s�F�E�DZ�DZ�D_�D_�`��U�UZ�T[�\���"�"�5�#3�#3�S�$�?���
 �F�v�h�O���"�"�5�#3�#3�S�$�?��x��
 ��@��
	@�s<�*9D.�.	G+�89F�1+G&�	G�%*G�G&�G�G&�&G+c��tj|||�}d|cxkrtj|�ksyytj||�S)z=Returns the character, start, and end at the specified point.rr)r
�get_offset_at_pointrr0�r&�x�yr's    r/�get_character_at_pointzAXText.get_character_at_pointV�N���+�+�C��A�6���F�<�V�7�7��<�<��=���-�-�c�6�:�:�c#�K�|�tj|�}d}tj|�}||krKtj||�\}}}|�|sy|r|||f|k7r|||f��t	||dz�}|||f}||kr�Jyy�w)zOGenerator to iterate by character in obj starting with the character at offset.Nr)r
rrr0�max)r&r'�last_resultr(�	character�start�ends       r/�iter_characterzAXText.iter_character`������>��,�,�S�1�F����+�+�C�0���v�o�$*�$B�$B�3��$O�!�I�u�c��"�9���i���4��C����+�+���f�q�j�)�F�#�U�C�/�K��v�o���A=B�Bc	�x�tj|�}|sy|�tj|�}tt	d|�|dz
�}	t
jj||t
jj�}d|�d	�|d
|j"�d|j$�d|j&�d
�g}tj(tj |d�|j"|j$|j&fS#t$r�}	t
jj||t
jj�}d|��}tjtj |d�nD#t$r8}d|��}tjtj |d�Yd}~Yd}~yd}~wwxYwYd}~��1d}~wwxYw)zEReturns the word, start, and end for the current or specified offset.rNrrrTz)AXText: Exception in get_word_at_offset: zAXText: Word at offset rrrrr)r
rr�minr:rrrr�WORDrrr �
WORD_STARTrrrr!r#r$r%�r&r'r(r*r+r)r,r.s        r/�get_word_at_offsetzAXText.get_word_at_offsetrs����+�+�C�0�����>��,�,�S�1�F��S��F�^�V�a�Z�0��
	@��Z�Z�4�4�S�&�%�BW�BW�B\�B\�]�F�,�F�8�3�7���f�n�n�%�S��)<�)<�(=�Q�v�?P�?P�>Q�QR�S�U��
���%�*�*�F�D�9��~�~�v�2�2�F�4E�4E�E�E��!�	@�

@����6�6����!7�!7�!B�!B�D��U�UZ�T[�\���"�"�5�#3�#3�S�$�?���
 �A�&��J���"�"�5�#3�#3�S�$�?��x��
 ��@��	@��<�
9C<�<	F9�9E*�?+F4�*	F+�3*F&�F4�&F+�+F4�4F9c��tj|||�}d|cxkrtj|�ksyytj||�S)z8Returns the word, start, and end at the specified point.rr)r
r2rrGr3s    r/�get_word_at_pointzAXText.get_word_at_point��N���+�+�C��A�6���F�<�V�7�7��<�<��=���(�(��f�5�5r8c#�K�|�tj|�}d}tj|�}||krKtj||�\}}}|�|sy|r|||f|k7r|||f��t	||dz�}|||f}||kr�Jyy�w)zEGenerator to iterate by word in obj starting with the word at offset.Nr)r
rrrGr:)r&r'r;r(�wordr=r>s       r/�	iter_wordzAXText.iter_word�������>��,�,�S�1�F����+�+�C�0���v�o�%�8�8��f�E��D�%���"�4����u�c�*�k�9��E�3�&�&���f�q�j�)�F���s�*�K��v�o�rAc	���tj|�}|sy|�tj|�}tj|�stt
d|�|dz
�}nt
d|�}	tjj||tjj�}|j&j)dd	�}d
|�d�|d|�d
|j*�d|j,�d�g}t!j.t j$|d�|j&|j*|j,fS#t$r�}	tjj||tjj�}d|��}t!j"t j$|d�nD#t$r8}d|��}t!j"t j$|d�Yd}~Yd}~yd}~wwxYwYd}~��Cd}~wwxYw)zEReturns the line, start, and end for the current or specified offset.rNrrrTz)AXText: Exception in get_line_at_offset: rrzAXText: Line at offset rrrrr)r
rrr�
is_multi_linerCr:rrrr�LINErrr �
LINE_STARTrrrr!r"r#r$r%)	r&r'r(r*r+r)r,r-r.s	         r/�get_line_at_offsetzAXText.get_line_at_offset�s����+�+�C�0�����>��,�,�S�1�F��(�(��-���Q����!��4�F���F�^�F�
	@��Z�Z�4�4�S�&�%�BW�BW�B\�B\�]�F��~�~�-�-�d�E�:��+�F�8�3�7���l�^�3�v�':�':�&;�1�V�=N�=N�<O�q�Q�S��
���%�*�*�F�D�9��~�~�v�2�2�F�4E�4E�E�E��#�	@�

@����6�6����!7�!7�!B�!B�D��U�UZ�T[�\���"�"�5�#3�#3�S�$�?���
 �A�&��J���"�"�5�#3�#3�S�$�?��x��
 ��@��	@�s<�,9D0�0	G-�:9F�3+G(�	G�'*G�G(�G�G(�(G-c��tj|||�}d|cxkrtj|�ksyytj||�S)z8Returns the line, start, and end at the specified point.rr)r
r2rrTr3s    r/�get_line_at_pointzAXText.get_line_at_point�rKr8c#�K�|�tj|�}d}tj|�}||krKtj||�\}}}|�|sy|r|||f|k7r|||f��t	||dz�}|||f}||kr�Jyy�w)zEGenerator to iterate by line in obj starting with the line at offset.Nr)r
rrrTr:)r&r'r;r(�liner=r>s       r/�	iter_linezAXText.iter_line�rOrAc	�x�tj|�}|sy|�tj|�}tt	d|�|dz
�}	t
jj||t
jj�}d|�d	�|d
|j"�d|j$�d|j&�d
�g}tj(tj |d�|j"|j$|j&fS#t$r�}	t
jj||t
jj�}d|��}tjtj |d�nD#t$r8}d|��}tjtj |d�Yd}~Yd}~yd}~wwxYwYd}~��1d}~wwxYw)zIReturns the sentence, start, and end for the current or specified offset.rNrrrTz-AXText: Exception in get_sentence_at_offset: zAXText: Sentence at offset rrrrr)r
rrrCr:rrrr�SENTENCErrr �SENTENCE_STARTrrrr!r#r$r%rFs        r/�get_sentence_at_offsetzAXText.get_sentence_at_offset�s����+�+�C�0�����>��,�,�S�1�F��S��F�^�V�a�Z�0��
	@��Z�Z�4�4�S�&�%�BW�BW�B`�B`�a�F�0��x�s�;�S��f�n�n�%�S��)<�)<�(=�Q�v�?P�?P�>Q�QR�S�U��
���%�*�*�F�D�9��~�~�v�2�2�F�4E�4E�E�E��!�	@�

@����6�6����!7�!7�!F�!F�H��U�UZ�T[�\���"�"�5�#3�#3�S�$�?���
 �E�f�X�N���"�"�5�#3�#3�S�$�?��x��
 ��@��	@�rHc��tj|||�}d|cxkrtj|�ksyytj||�S)z<Returns the sentence, start, and end at the specified point.rr)r
r2rr]r3s    r/�get_sentence_at_pointzAXText.get_sentence_at_pointsN���+�+�C��A�6���F�<�V�7�7��<�<��=���,�,�S�&�9�9r8c#�K�|�tj|�}d}tj|�}||krKtj||�\}}}|�|sy|r|||f|k7r|||f��t	||dz�}|||f}||kr�Jyy�w)zMGenerator to iterate by sentence in obj starting with the sentence at offset.Nr)r
rrr]r:)r&r'r;r(�sentencer=r>s       r/�
iter_sentencezAXText.iter_sentences������>��,�,�S�1�F����+�+�C�0���v�o�#)�#@�#@��f�#M� �H�e�S��"�8���X�u�c�2�k�A���s�*�*���f�q�j�)�F�"�E�3�.�K��v�o�rAc���tj|�sytj|d�\}}}|xrd|cxkxr|knc}d|d|��g}t	j
tj|d�|S)z7Returns True if sentence iteration is supported on obj.Frz'AXText: Sentence iteration supported on�: T)r�
supports_textr
r]rr%r�r&�stringr=r>r*r.s      r/�supports_sentence_iterationz"AXText.supports_sentence_iteration+sq���%�%�c�*��#�:�:�3��B����s��,�A��,��,��;�S�B�v�h�-�P��
���%�*�*�F�D�9��
r8c	�x�tj|�}|sy|�tj|�}tt	d|�|dz
�}	t
jj||t
jj�}d|�d�|d	|j�d
|j�d|j �d�g}tj"tj|d�|j|j|j fS#t$r4}d|��}tjtj|d�Yd}~yd}~wwxYw)
zJReturns the paragraph, start, and end for the current or specified offset.rNrrz.AXText: Exception in get_paragraph_at_offset: TzAXText: Paragraph at offset rrrrr)r
rrrCr:rrrr�	PARAGRAPHrrrrr!r#r$r%)r&r'r(r*r+r)r.s       r/�get_paragraph_at_offsetzAXText.get_paragraph_at_offset8s ���+�+�C�0�����>��,�,�S�1�F��S��F�^�V�a�Z�0��	��Z�Z�4�4�S�&�%�BW�BW�Ba�Ba�b�F�1����<�c��f�n�n�%�S��)<�)<�(=�Q�v�?P�?P�>Q�QR�S�U��
���%�*�*�F�D�9��~�~�v�2�2�F�4E�4E�E�E���	�B�5�'�J�C����u�/�/��d�;���	�s�
9C<�<	D9�*D4�4D9c��tj|||�}d|cxkrtj|�ksyytj||�S)z=Returns the paragraph, start, and end at the specified point.rr)r
r2rrkr3s    r/�get_paragraph_at_pointzAXText.get_paragraph_at_pointPr7r8c#�K�|�tj|�}d}tj|�}||krKtj||�\}}}|�|sy|r|||f|k7r|||f��t	||dz�}|||f}||kr�Jyy�w)zOGenerator to iterate by paragraph in obj starting with the paragraph at offset.Nr)r
rrrkr:)r&r'r;r(�	paragraphr=r>s       r/�iter_paragraphzAXText.iter_paragraphZr@rAc���tj|�sytj|d�\}}}|xrd|cxkxr|knc}d|d|��g}t	j
tj|d�|S)z8Returns True if paragraph iteration is supported on obj.Frz(AXText: Paragraph iteration supported onrdT)rrer
rkrr%rrfs      r/�supports_paragraph_iterationz#AXText.supports_paragraph_iterationlsq���%�%�c�*��#�;�;�C��C����s��,�A��,��,��<�c�R��x�=�Q��
���%�*�*�F�D�9��
r8c�N�tj|�sy	tjj	|�}d|d|�d�g}t
jtj|d�|S#t
$r4}d|��}t
jtj|d�Yd}~yd}~wwxYw)z#Returns the character count of obj.rz*AXText: Exception in get_character_count: TN�AXText:�reports z characters.)
rrerrrrrrrr%)r&�countr+r)r.s     r/rzAXText.get_character_countys����%�%�c�*��	��J�J�2�2�3�7�E��S�H�U�G�<�"@�A��
���%�*�*�F�D�9�����	�>�u�g�F�C����u�/�/��d�;���	���A'�'	B$�0*B�B$c�N�tj|�sy	tjj	|�}d|d|�d�g}t
jtj|d�|S#t
$r4}d|��}t
jtj|d�Yd}~yd}~wwxYw)z Returns the caret offset of obj.���z'AXText: Exception in get_caret_offset: TNrtzreports caret offset of �.)
rrerrrrrrrr%)r&r'r+r)r.s     r/rzAXText.get_caret_offset�s����%�%�c�*��	��Z�Z�0�0��5�F��S�$<�V�H�A�"F�G��
���%�*�*�F�D�9��
���	�;�E�7�C�C����u�/�/��d�;���	�rwc�V�tj|�sy	tjj	||�}d|�d�|d|��g}t
jtj|d�|S#t
$r4}d|��}t
jtj|d�Yd}~yd}~wwxYw)�PReturns False if we definitely failed to set the offset. True cannot be trusted.Fz'AXText: Exception in set_caret_offset: TNz-AXText: Reported result of setting offset to rrd)
rrerr�set_caret_offsetrrrrr%�r&r'r*r+r)r.s      r/r}zAXText.set_caret_offset�s����%�%�c�*��	��Z�Z�0�0��f�=�F�B�&���M�s�VX�Y_�X`�Ta�b��
���%�*�*�F�D�9��
���	�;�E�7�C�C����u�/�/��d�;���	�s� A+�+	B(�4*B#�#B(c�.�tj|d�S)r|r)r
r}�r&s r/�set_caret_offset_to_startz AXText.set_caret_offset_to_start�s���&�&�s�A�.�.r8c�T�tj|tj|��S)r|)r
r}rr�s r/�set_caret_offset_to_endzAXText.set_caret_offset_to_end�s"���&�&�s�F�,F�,F�s�,K�L�Lr8c	�^�tj|�sy	tjj	|||�}d|d|�d|�d|�d	�g}t
jtj|d�|S#t
$r4}d|��}t
jtj|d�Yd}~yd}~wwxYw)
z5Returns the text of obj within the specified offsets.r
z$AXText: Exception in get_substring: TN�AXText: Text of�(rz): 'r)
rrerr�get_textrrrrr%)r&r#r$r*r+r)r.s       r/�
get_substringzAXText.get_substring�s����%�%�c�*��	��Z�Z�(�(��l�J�G�F�$�S�A�l�^�1�Z�L��V�H�TU�*V�W��
���%�*�*�F�D�9��
���	�8���@�C����u�/�/��d�;���	�s�!A/�/	B,�8*B'�'B,c��tj|�}|sy	tjj	|d|�}|j�}t|�dkDr,dj|dd��d	dj|d
d���}n|}|jdd�}d
|d|�d�g}t
jtj|d�|S#t
$r4}d|��}t
jtj|d�Yd}~yd}~wwxYw)z Returns the text content of obj.r
rz#AXText: Exception in get_all_text: TN�
� �� ... ���rrr�r)r
rrrr�rrrr�split�len�joinr"r%)r&r(r*r+r)�wordsr-r.s        r/�get_all_textzAXText.get_all_text�s���+�+�C�0����	��Z�Z�(�(��a��8�F�������u�:��?�!�h�h�u�R�a�y�1�2�%�����r�s��8L�7M�N�L�!�L�#�+�+�D�%�8��#�S�A�l�^�1�*=�>��
���%�*�*�F�D�9��
���	�7��w�?�C����u�/�/��d�;���	�s�!C	�		D�*D�Dc�N�tj|�sy	tjj	|�}d|d|�d�g}t
jtj|d�|S#t
$r4}d|��}t
jtj|d�Yd}~yd}~wwxYw)z:Returns the number of reported selected substrings in obj.rz(AXText: Exception in _get_n_selections: TNrtruz selection(s).)
rrerr�get_n_selectionsrrrrr%)r&r*r+r)r.s     r/�_get_n_selectionszAXText._get_n_selections�s����%�%�c�*��	��Z�Z�0�0��5�F��S�H�V�H�N�"C�D��
���%�*�*�F�D�9��
���	�<�U�G�D�C����u�/�/��d�;���	�rwc���tj|�sy	tjj	||�y#t
$r4}d|��}t
jtj|d�Yd}~yd}~wwxYw)z+Attempts to remove the specified selection.Nz(AXText: Exception in _remove_selection: T)	rrerr�remove_selectionrrrr)r&�selection_numberr+r)s    r/�_remove_selectionzAXText._remove_selection�sf���%�%�c�*��	��J�J�'�'��-=�>���	�<�U�G�D�C����u�/�/��d�;���	�s� 9�	A6�*A1�1A6c�>�ttj|��S)z&Returns True if obj has selected text.)�boolr
�get_selected_rangesr�s r/�has_selected_textzAXText.has_selected_texts���F�.�.�s�3�4�4r8c��tj|�}|sytj|�}|sy|dddk(xr|dd|k(S)z0Returns True of all the text in obj is selected.Frryr)r
rr�)r&r(�rangess   r/�is_all_text_selectedzAXText.is_all_text_selected
sU���+�+�C�0�����+�+�C�0�����a�y��|�q� �<�V�B�Z��]�f�%<�<r8c�v�ttj|��D]}tj||��y)z$Attempts to clear the selected text.N)�ranger
r�r�)r&�is  r/�clear_all_selected_textzAXText.clear_all_selected_texts3���v�/�/��4�5�	-�A��$�$�S�!�,�	-r8c�B�tj|�}|r|ddSy)z1Returns the leftmost offset of the selected text.rry�r
r��r&r�s  r/�get_selection_start_offsetz!AXText.get_selection_start_offset"s(���+�+�C�0����!�9�Q�<��r8c�B�tj|�}|r|ddSy)z2Returns the rightmost offset of the selected text.ryrr�r�s  r/�get_selection_end_offsetzAXText.get_selection_end_offset,s(���+�+�C�0����"�:�a�=� �r8c��tj|�}|sgSg}t|�D]m}	tjj||�}d|jcxkr|jks�Dn�G|j|j|jf��od|d|��g}tjtj|d�|S#t$r5}d|��}tjtj|d�Yd}~�hd}~wwxYw)zQReturns a list of (start_offset, end_offset) tuples reflecting the selected text.z*AXText: Exception in get_selected_ranges: TNrrtzreports selected ranges: )r
r�r�rr�
get_selectionrrrrr#r$�appendr%)r&rv�
selectionsr�r*r+r)r.s        r/r�zAXText.get_selected_ranges6s����(�(��-����I��
��u��	L�A�
����1�1�#�q�9��
�F�'�'�;�&�*;�*;�;��!�!�6�#6�#6��8I�8I�"J�K�	L��S�$=�j�\�"J�K��
���%�*�*�F�D�9�����
�B�5�'�J���"�"�5�#3�#3�S�$�?���
�s� C�	D�*C?�?Dc	��tj|�}|syg}d}d}tt|��D]4}|j	tj
|g|����|d}|��0|d}�6dj
|�}|j�}t|�dkDr,dj
|dd��ddj
|d	d���}n|}d
|d|�d|�d
|�d�g}	tjtj|	d�|||fS)z4Returns the selected string, start, and end for obj.rNrrr�r�r�r�r�zAXText: Selected text ofrrrrT)r
r��sorted�setr�r�r�r�r�rr%r)
r&r��stringsr#r$�	selection�textr�r-r.s
          r/�get_selected_textzAXText.get_selected_textMs���/�/��4�
��������
���J��0�	,�I��N�N�6�/�/��@�i�@�A�"�1��J��#�(��|��		,��x�x�� ���
�
����t�9�r�>�!�h�h�u�R�a�y�1�2�%�����r�s��8L�7M�N�L��L�,�c��l�^�3�|�n�A�j�\��C�E��
���%�*�*�F�D�9��\�:�-�-r8c��tj|�sy	tjj	|||�}|S#t
$r4}d|��}t
jtj|d�Yd}~yd}~wwxYw)z7Creates a new selection for the specified range in obj.Fz%AXText: Exception in _add_selection: TN)	rrerr�
add_selectionrrrr)r&r#r$r*r+r)s      r/�_add_new_selectionzAXText._add_new_selectionjsr���%�%�c�*��	��Z�Z�-�-�c�<��L�F��
���	�9�%��A�C����u�/�/��d�;���	�s�!;�	A8�*A3�3A8c��tj|�sy	tjj	||||�}|S#t
$r4}d|��}t
jtj|d�Yd}~yd}~wwxYw)z;Modifies specified selection in obj to the specified range.Fz(AXText: Exception in set_selected_text: TN)	rrerr�
set_selectionrrrr)r&r#r$r�r*r+r)s       r/�_update_existing_selectionz!AXText._update_existing_selectionzsv���%�%�c�*��	��Z�Z�-�-�c�3C�\�S]�^�F��
���	�<�U�G�D�C����u�/�/��d�;���	�s�"<�	A9�*A4�4A9c��tj|�dkDrtj|||�}ntj|||�}|r|tj
tjk\r[tj|||�}tj|�d}||k7r'd}t	jtj
|d�|S)zSReturns False if we definitely failed to set the selection. True cannot be trusted.rz1AXText: Substring and selected text do not match.T)
r
r�r�r�rr�
debugLevelr�r�r)r&r#r$r*�	substringr�r)s       r/�set_selected_textzAXText.set_selected_text�s����#�#�C�(�1�,��6�6�s�L�*�U�F��.�.�s�L�*�M�F��e�&�&�%�*:�*:�:��,�,�S�,�
�K�I��0�0��5�a�8�I��I�%�I���"�"�5�#3�#3�S�$�?��
r8c��tj|�siddfS|�tj|�}	tj
j
||d��}d|d|�d|��g}tjtj|d�|dxsi|d	xsd|d
xstj|�fS#t$rL}d|��}tjtj|d�idtj|�fcYd}~Sd}~wwxYw)zCReturns a (dict, start, end) tuple for attributes at offset in obj.rNT)�include_defaultsz4AXText: Exception in get_text_attributes_at_offset: zAXText: Attributes forz
at offset z : r�)
rrer
rrr�get_attribute_runrrrrrr%r~s      r/�get_text_attributes_at_offsetz$AXText.get_text_attributes_at_offset�s���%�%�c�*��q�!�8�O��>��,�,�S�1�F�	:��Z�Z�1�1�#�v�PT�1�U�F�+�C�:�f�X�S���1Q�R��
���%�*�*�F�D�9��a�y��B��q�	��Q��q�	�0\�V�=W�=W�X[�=\�\�\���	:�H���P�C����u�/�/��d�;��q�&�4�4�S�9�9�9��	:�s�"B2�2	D�;AD�<D�Dc�B�tj|�sgS|dk(rtj|�}d|d|�d|��g}t	j
tj|d�g}|}||kr�tj||�\}}}||kr|jt||�||f�n-d|�d|��}	t	jtj|	d�t||dz�}||kr��d	t|��d
�}	t	jtj|	d�|S)z:Returns a list of (start, end, attrs dict) tuples for obj.ryzAXText: Getting attributes forzchars: rTzAXText: Start offset z > end offset rzAXText: z attribute ranges found.)rrer
rrr%rr�r�r:rr�)
r&r#r$r.�rvr'�attrsr=r>r)s
          r/�get_all_text_attributeszAXText.get_all_text_attributes�s'���%�%�c�*��I�����3�3�C�8�J�2�C�7�<�.�PQ�R\�Q]�9^�_��
���%�*�*�F�D�9�
�����z�!� &� D� D�S�&� Q��E�5�#���|��	�	�3�u�f�-�s�E�:�;�.�e�W�N�3�%�H���"�"�5�#3�#3�S�$�?���f�q�j�)�F��z�!���R��	�!9�:��
���5�+�+�S�$�7��	r8c��tj|�sy	tjj	|||tj
j�}d|d|�d|�d|��g}tjtj|d�|S#t$r4}d|��}tjtj|d�Yd}~yd}~wwxYw)	z;Returns the character offset in obj at the specified point.ryz*AXText: Exception in get_offset_at_point: TNzAXText: Offset inzat �, z is )rrerrr2�	CoordType�WINDOWrrrrr%)r&r4r5r'r+r)r.s       r/r2zAXText.get_offset_at_point�s����%�%�c�*��	��Z�Z�3�3�C��A�u���?U�?U�V�F�&�s�c�!��B�q�c��f�X�,F�G��
���%�*�*�F�D�9��
���	�>�u�g�F�C����u�/�/��d�;���	�s�:B�	C�*B?�?Cc��tj|�stj�S|�tj|�}	tjj||tjj�}d|�d�|d|g}tjtj|d�|S#t$rH}d|��}tjtj|d�tj�cYd}~Sd}~wwxYw)zGReturns the Atspi rect of the character at the specified offset in obj.Nz)AXText: Exception in get_character_rect: TzAXText: Offset r�has rect)rrer�Rectr
rr�get_character_extentsr�r�rrrrr%)r&r'�rectr+r)r.s      r/�get_character_rectzAXText.get_character_rect�s����%�%�c�*��:�:�<���>��,�,�S�1�F�	 ��:�:�3�3�C�����AW�AW�X�D�$�F�8�3�/��j�$�G��
���%�*�*�F�D�9�����	 �=�e�W�E�C����u�/�/��d�;��:�:�<���	 �s�9B,�,	C=�5=C8�2C=�8C=c���tj|�stj�S	tjj|||tjj�}d|�d|�d�|d|g}tjtj|d�|S#t$rK}d|d|��g}tjtj|d�tj�cYd}~Sd}~wwxYw)	zCReturns the Atspi rect of the string at the specified range in obj.z'AXText: Exception in get_range_rect for�:TNzAXText: Range rrr�)rrerr�r�get_range_extentsr�r�rrr%r)r&r=r>r�r+r.s      r/�get_range_rectzAXText.get_range_rect�s����%�%�c�*��:�:�<��	 ��:�:�/�/��U�C����AW�AW�X�D�#�5�'��3�%�s�3�S�*�d�K��
���%�*�*�F�D�9�����	 �?���5��l�S�F����e�.�.���=��:�:�<���	 �s�:B�	C-�"AC(�"C-�(C-c�>�|j|jkxr�|j|jkxrh|j|jz|j|jzk\xr3|j|jz|j|jzk\S)z1Returns true if rect1 is fully contained in rect2)r4r5�width�height)�rect1�rect2s  r/�_rect_is_fully_contained_inz"AXText._rect_is_fully_contained_in
s���w�w�%�'�'�!�A�e�g�g����&8�A����%�+�+�%����5�;�;�)>�>�A����%�,�,�&�%�'�'�E�L�L�*@�@�	Ar8c��td|j�|_|j|jdzz|jkry|j|jdzz|j|jzkDryy)zFReturns -1 (line above), 1 (line below), or 0 (line inside) clip_rect.rr�ryr)r:r5r�)�	line_rect�	clip_rects  r/�_line_comparisonzAXText._line_comparisonsj��
�!�Y�[�[�)�	���;�;��)�)�A�-�-�	���;���;�;��)�)�A�-�-�	���i�>N�>N�0N�N��r8c	��d|d|g}tjtj|d�tj	||�\}}}|jdd�}d|d|�d|�d	|�d
�g}tjtj|d�|||fg}|}tj
||�D]L\}}}tj|||�}	tj|	|�dkDrn|j|||f��N|d\}}}|jdd�}d
|d|�d|�d	|�d
�g}tjtj|d�|S)zIReturns a list of (string, start, end) for lines of obj inside clip_rect.z!AXText: Getting visible lines for�insideTrrzAXText: First visible line inzis: 'rrrrryzAXText: Last visible line in)
rr%rr
�find_first_visible_liner"rYr�r�r�)
r&r�r.rXr=r>r-r*r'r�s
          r/�get_visible_lineszAXText.get_visible_lines!sm��6�s�H�i�P��
���%�*�*�F�D�9�!�9�9�#�y�I���e�S��|�|�D�%�0��1�3�%��~�S�QV�PW�WX�Y\�X]�]^�8_�`��
���%�*�*�F�D�9����$�%���� &� 0� 0��f� =�	.��D�%���-�-�c�5�#�>�I��&�&�y�)�<�q�@���M�M�4���,�-�		.�"�"�:���e�S��|�|�D�%�0��0�#��|�n�C�PU�w�VW�X[�W\�\]�7^�_��
���%�*�*�F�D�9��
r8c��d}tj|�}d|}}||k�r ||zdz}tj||�\}}}	|dk(r|||	fS|dkr/d|g}
tjtj
|
d�|dz}�f|||	f}tj||dz
�\}}}
|dkr|
dkr|Stj
|||	�}tj||�dkr|dz}��tj||�dkDr|}��tj
|||
�}tj||�dk7r|S|||
f}|}||kr�� |S)zLReturns the first (string, start, end) visible line of obj inside clip_rect.rrr�z(AXText: Treating invalid offset as aboveTr�r
rrTrr%rr�r�)r&r�r*r(�low�high�midrXr=r>r.�
previous_line�previous_start�previous_end�	text_rect�
previous_rects                r/r�zAXText.find_first_visible_line;s|�����+�+�C�0���v�T���D�j���:�!�#�C�%�8�8��c�B��D�%����z��U�C�'�'��q�y�D�i�P���!�!�%�"2�"2�F�D�A��A�g����5�#�%�F�:@�:S�:S�TW�Y^�ab�Yb�:c�7�M�>�<���"�|�q�'8��
��-�-�c�5�#�>�I��&�&�y�)�<�q�@��A�g����&�&�y�)�<�q�@����"�1�1�#�~�|�T�M��&�&�}�i�@�A�E��
�"�N�L�@�F��D�?�D�j�B�
r8c��d}tj|�}d|}}||k�r||zdz}tj||�\}}}	|	|k\r|||	fS|	dkr,d|g}
tjtj
|
d�|}�c|||	f}tj||	�\}}}
|dkr|
dkr|Stj
|||	�}tj||�dkr|dz}��tj||�dkDr|}��tj
|||
�}tj||�dk7r|S|||
f}|dz}||kr��|S)zKReturns the last (string, start, end) visible line of obj inside clip_rect.rrr�z(AXText: Treating invalid offset as belowTrr�)r&r�r*r(r�r�r�rXr=r>r.�	next_line�
next_start�next_endr��	next_rects                r/�find_last_visible_linezAXText.find_last_visible_lineesr�����+�+�C�0���v�T���D�j���:�!�#�C�%�8�8��c�B��D�%���f�}��U�C�'�'��a�x�D�i�P���!�!�%�"2�"2�F�D�A�����5�#�%�F�.4�.G�.G��S�.Q�+�I�z�8��Q��8�q�=��
��-�-�c�5�#�>�I��&�&�y�)�<�q�@��A�g����&�&�y�)�<�q�@�����-�-�c�:�x�H�I��&�&�y�)�<��A��
��
�H�4�F���'�C�?�D�j�B�
r8c��tj||�d}|jd�dk(ry|jd�dk(ry|jd�dvryy	)
z>Returns True if the text attributes indicate a spelling error.r�invalid�spellingTz
text-spelling�
misspelled�	underline)r+r�F)r
r��get)r&r'�
attributess   r/�is_word_misspelledzAXText.is_word_misspelled�s[���9�9�#�v�F�q�I�
��>�>�)�$�
�2���>�>�/�*�l�:���>�>�+�&�*?�?��r8c��|dk(S)u@Returns True if character is an embedded object character ().u�)r<s r/�is_eocz
AXText.is_eoc�s���H�$�$r8c�T�tjtj||��S)uGReturns True if character in obj is an embedded object character ().)r
rr0)r&r's  r/�character_at_offset_is_eocz!AXText.character_at_offset_is_eoc�s ���}�}�V�;�;�C��H�I�Ir8c�v�tj|�sytj|�j	�S)z<Returns True if obj lacks text, or contains only whitespace.T)rrer
r��stripr�s r/�is_whitespace_or_emptyzAXText.is_whitespace_or_empty�s2���%�%�c�*���&�&�s�+�1�1�3�3�3r8c��tj|�}|sy|�d}|�|dz
}	tjj	|||tj
j||�}d|d|�d	|�d
�|�d|�d|��g}	tjtj|	d�|S#t$r4}d|��}tjtj|d�Yd}~yd}~wwxYw)
z.Attempts to scroll obj to the specified point.FNrrz0AXText: Exception in scroll_substring_to_point: T�AXText: Scrolled�substring (r�) tor�rd)r
rrr�scroll_substring_to_pointr�r�rrrrr%)
r&r4r5r#r$r(r*r+r)r.s
          r/r
z AXText.scroll_substring_to_point�s����+�+�C�0�������L����!��J�	��Z�Z�9�9��\�:�u���/E�/E�q�!�M�F�%�c�[���a�
�|�SW�+X��C�r�!��B�v�h�'�)��
���%�*�*�F�D�9��
���	�D�U�G�L�C����u�/�/��d�;���	�s�<B�	C�&*C�Cc�~�tj|�}|sy|�d}|�|dz
}	tjj	||||�}d|d|�d	|�d
�|d|��g}t
jtj|d�|S#t
$r4}d|��}t
jtj|d�Yd}~yd}~wwxYw)zLAttempts to scroll the substring to the specified Atspi.ScrollType location.FNrrz3AXText: Exception in scroll_substring_to_location: Trrrr	rd)
r
rrr�scroll_substring_torrrrr%)	r&�locationr#r$r(r*r+r)r.s	         r/�scroll_substring_to_locationz#AXText.scroll_substring_to_location�s����+�+�C�0�������L����!��J�	��Z�Z�3�3�C��z�S[�\�F�%�c�[���a�
�|�SW�+X��b���M�+��
���%�*�*�F�D�9��
���	�G��w�O�C����u�/�/��d�;���	�s�"A?�?	B<�*B7�7B<)N)r)rry)9�__name__�
__module__�__qualname__�__doc__�staticmethodr0r6r?rGrJrNrTrVrYr]r_rbrhrkrmrprrrrr}r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r2r�r�r�r�r�r�r�r�rrrr
rr�r8r/r
r
/s)��D��!F��!F�F�;��;��0��0�"�F��F�>�6��6��+��+�"�"F��"F�H�6��6��+��+�"�F��F�>�:��:��/��/�"�
��
��F��F�.�;��;��0��0�"�
��
�����"����"����"�/��/�
�M��M�
����"����2����"�����5��5�
�=��=��-��-�������������,�.��.�8�
��
��
��
�����(�]��]�(����8����"����(����"�A��A���������2�'��'�R�'��'�R�
��
��%��%�
�J��J�
�4��4�����2���r8r
)r�__id__�__version__�__date__�
__copyright__�__license__�gi�require_version�
gi.repositoryrr
r�	ax_objectr�ax_utilitiesrr
r�r8r/�<module>rsT��,�������;�
���	�����7�E�"����%�s�sr8

Zerion Mini Shell 1.0