+
    QiAI  c                  sR   R t ^ RIHt RtRtRtRtRt^ RIt^ RI	H
t
 ^ RIt]P                  ! R	R
4       ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RIHt ]
'       d    ]P                  ! RR4       ^ RIHt ^RIHt  ! R R4      t R# ):Script-customizable support for application spellcheckers.)annotationsz$Id$z
$Revision$z$Date$zCopyright (c) 2014 Igalia, S.L.ZLGPLN)TYPE_CHECKINGGtkz3.0)r   )braille)debug)focus_manager)	guilabels)messages)object_properties)settings_manager)AXObject)AXText)AXUtilitiesAtspiz2.0)r   )defaultc                  s   ] tR t^<tRtRBR R lltR R ltR R ltR R	 ltR
 R lt	R R lt
R R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltRCR  R! lltRCR" R# lltRCR$ R% lltRDR& R' lltR( R) ltR* R+ ltR, R- ltR. R/ ltR0 R1 ltR2 R3 ltR4 R5 ltR6 R7 ltR8 R9 lt R: R; lt!R< R= lt"R> R? lt#R@t$RA# )E
SpellCheckr    c               $    V ^8  d   QhRRRRRR/# )   scriptzdefault.Scripthas_change_to_entryboolreturnNone Zformat   "4/usr/lib/python3.14/site-packages/orca/spellcheck.py__annotate__SpellCheck.__annotate__?   s'     I I~ ID ITX I    c                	s    Wn         W n        R V n        R V n        R V n        R V n        RV n        RV n        R V n        R V n	        R V n
        R # )NF)N)_script_has_change_to_entry_window_error_widget_change_to_entry_suggestions_list
_activated_document_positionspell_error_check_buttonspell_suggestion_check_buttonpresent_context_check_button)selfr   r      &&&r   __init__ZSpellCheck.__init__?   sS    '-*=!046:9=:> %GO@D%EI*DH)r   c                    V ^8  d   QhRRRR/# r   windowAtspi.Accessibler   r   r   r   r   r   r   r   M   s     ! !/ !D !r   c                sD   RV.p\         P                  ! \         P                  VR4       V P                  V4      '       g.   RVR.p\         P                  ! \         P                  VR4       R# V P                  '       dO   V P                  V4      V n        V P                  f+   Rp\         P                  ! \         P                  VR4       R# V P                  V4      V n	        V P                  f+   Rp\         P                  ! \         P                  VR4       R# V P                  V4      V n        V P                  f+   Rp\         P                  ! \         P                  VR4       R# Wn        RV n        R	p\         P                  ! \         P                  VR4       R# )
zActivates spellcheck support.z&SPELL CHECK: Attempting activation forTSPELL CHECK:zis not spellcheck windowFz&SPELL CHECK: Change-to entry not foundz#SPELL CHECK: Error widget not foundz'SPELL CHECK: Suggestions list not foundz SPELL CHECK: Activation complete)r   print_tokens
LEVEL_INFOcan_be_spell_check_windowr!   _find_change_to_entryr$   print_message_find_error_widgetr#   _find_suggestions_listr%   r"   r&   )r+   r0   tokensmsg   &&  r   activateZSpellCheck.activateM   sT    ;FC5++VT:--f55$f.HIFu//>$$$$($>$>v$FD!$$,>##E$4$4c4@!44V<%7C 0 0#t<!%!<!<V!D!!);C 0 0#t<0E,,c48r   c                   V ^8  d   QhRR/# r   r   r   r   r   r   r   r   r   p   s      D r   c                s&    V P                  4        R# )zDeactivates spellcheck support.N)_clear_stater+      &r   
deactivateZSpellCheck.deactivatep   s     	r   c               r   )r   objr1   offsetZintr   r   r   r   r   r   r   r   u   s"     . .)9 .3 .4 .r   c                s    W3V n         R# )z5Sets the document position as an (obj, offset) tuple.N)r'   )r+   rD   rE   r,   r   set_document_positionZ SpellCheck.set_document_positionu   s     #&+r   c               r>   r   r   Atspi.Accessible | Noner   r   r   r   r   r   z   s     " ""9 "r   c                    V P                   # )z6Returns the widget which contains the misspelled word.)r#   rA   rB   r   get_error_widgetZSpellCheck.get_error_widgetz   s     !!!r   c               r>   r   r   Zstrr   r   r   r   r   r      s     ` `S `r   c                    V P                   '       g   R# \        P                  ! V P                   4      ;'       g!    \        P                  ! V P                   4      # )zReturns the misspelled word. r#   r   Zget_all_textr   get_namerA   rB   r   get_misspelled_wordZSpellCheck.get_misspelled_word   C     !!!""4#5#56__(:K:KDL^L^:__r   c               r>   rK   r   r   r   r   r   r      s     ` ` `r   c                rL   )zRReturns the string containing the app-provided message that the check is complete.rM   rN   rA   rB   r   get_completion_messageZ!SpellCheck.get_completion_message   rQ   r   c               r>   rG   r   r   r   r   r   r      s     % %%< %r   c                rI   )zRReturns the widget, usually an entry, that displays the suggested change-to value.)r$   rA   rB   r   get_change_to_entryZSpellCheck.get_change_to_entry   s     $$$r   c               r>   rG   r   r   r   r   r   r      s     & &&= &r   c                rI   )z6Returns the widget containing the list of suggestions.)r%   rA   rB   r   get_suggestions_listZSpellCheck.get_suggestions_list   s     %%%r   c               r>   r   r   r   r   r   r   r   r   r      s      4 r   c                rI   )z;Returns True if spellcheck support is currently being used.)r&   rA   rB   r   	is_activeZSpellCheck.is_active   s     r   c               r.   r/   r   r   r   r   r   r      s     % %,< % %r   c                sX    V'       d   WP                   8X  d   R# V P                  V4      # )zFReturns True if window is the window/dialog containing the spellcheck.T)r"   r=   r+   r0      &&r   is_spell_check_windowZ SpellCheck.is_spell_check_window   s"     f,}}V$$r   c               r>   rU   r   r   r   r   r   r      s      T r   c                st    V P                   '       d&   \        P                  ! V P                  4      '       * # R# )zAReturns True if we have reason to conclude the check is complete.F)r!   r   Zis_sensitiver$   rA   rB   r   is_completeZSpellCheck.is_complete   s-     $$$"//0E0EFFFr   c               r.   r   rD   r1   r   r   r   r   r   r   r   r      s     	 	'7 	D 	r   c                s    V P                   '       g   R# \        P                  ! WP                   4      pRVRV P                   RV 2.p\        P                  ! \        P
                  VR4       V# )z7Returns True if obj is an item in the suggestions list.Fr2   zis suggestion inz: T)r%   r   Zis_ancestorr   r3   r4   )r+   rD   resultr:   r<   r   is_suggestions_itemZSpellCheck.is_suggestions_item   sg     %%%%%c+A+AB #'94;Q;QUWX^W_S`a5++VT:r   c               r>   rU   r   r   r   r   r   r      s       r   c                s  a V P                  4       '       g   R# V P                  w  rV'       d   V^ 8  g   R# \        P                  ! W4      ^ ,          pV'       g}   \        P                  ! W4      ^ ,          p\
        P                  ! RV4      pV P                  4       oVP                  S4      ^8X  d#   \        \        V3R lV4      4      pV^ ,          pVP                  4       '       g   R# \        P                  V,          pV P                  P                  P!                  VR7      pV P                  P#                  WgR7       R# )z@Presents the context/surrounding content of the misspelled word.Fz(?:\.|\!|\?)c                s&   < V P                  S4      # )N)count)Zxwords   &r   Z<lambda>Z,SpellCheck.present_context.<locals>.<lambda>   s    aggdmr   stringvoiceT)rV   r'   r   Zget_sentence_at_offsetZget_line_at_offsetresplitrP   r^   ZlistZfilterstripr   ZMISSPELLED_WORD_CONTEXTr    speech_generatorrc   speak_message)	r+   rD   rE   ra   Z	sentencesZmatchr;   rc   r_   s	   &       @r   present_contextZSpellCheck.present_context   s     ~~--! ..s;A>..s;A>F&9I++-D||D!Q&V$;YGHq||~~..7--3333?""3"4r   c               r>   rU   r   r   r   r   r   r      s     
 
D 
r   c                sR   V P                  4       '       d   V P                  4       '       g   R# \        P                  ! 4        V P	                  4       pV P
                  P                  P                  VR7      pV P
                  P                  Y'       d
   V^ ,          MRR7       R# )z1Presents the message that spellcheck is complete.Fr`   Nrb   T)	rV   rZ   r   ZclearrR   r    rg   rc   Zpresent_message)r+   r;   rc      &  r   present_completion_messageZ%SpellCheck.present_completion_message   sx       T%5%5%7%7))+--3333?$$SEat$Lr   c                    V ^8  d   QhRRRR/# r   detailedr   r   r   r   r   r   r   r      s      d t r   c                s^   V P                  4       '       d+   Rp\        P                  ! \        P                  VR4       R# V P	                  V4      '       dV   V P                  V4       V'       g+   \        P                  ! 4       P                  R4      '       d   V P                  4        R# R# )z"Presents the details of the error.zASPELL CHECK: Not presenting error details: spellcheck is completeTFspellcheckPresentContext)
rZ   r   r7   r4   present_mistakepresent_suggestionr
   get_managerget_settingri   )r+   rn   r;   s   && r   present_error_detailsZ SpellCheck.present_error_details   s     UC 0 0#t<))##H-+779EEF`aa$$&r   c               rl   rm   r   r   r   r   r   r      s        r   c                sV   V P                  4       '       g+   Rp\        P                  ! \        P                  VR4       R# V P	                  4       pV'       g+   Rp\        P                  ! \        P                  VR4       R# \
        P                  V,          pV P                  P                  P                  VR7      pV P                  P                  W$R7       V'       g+   \        P                  ! 4       P                  R4      '       d   V P                  P                  V4       R# )zPresents the misspelled word.zESPELL CHECK: Not presenting mistake: spellcheck support is not activeTFz>SPELL CHECK: Not presenting mistake: misspelled word not foundr`   rb   spellcheckSpellError)rV   r   r7   r4   rP   r   ZMISSPELLED_WORDr    rg   rc   rh   r
   rr   rs   
spell_item)r+   rn   r;   r_   rc      &&   r   rp   ZSpellCheck.present_mistake   s     ~~YC 0 0#t<'')RC 0 0#t<&&---3333?""3"4'335AABXYYLL##D)r   c               rl   rm   r   r   r   r   r   r     s      4 D r   c                s   V P                   '       g   V P                  VRR7      # V P                  4       '       g+   Rp\        P                  ! \        P
                  VR4       R# V P                  pV'       g+   Rp\        P                  ! \        P
                  VR4       R# \        P                  ! V4      ;'       g    \        P                  ! V4      p\        P                  ! V^ R
4      pV RV 2pV P                  P                  P                  VR7      pV P                  P!                  W&R7       V'       g+   \"        P$                  ! 4       P'                  R	4      '       d   V P                  P)                  V4       R# )z"Presents the suggested correction.T)include_labelzHSPELL CHECK: Not presenting suggestion: spellcheck support is not activeFzASPELL CHECK: Not presenting suggestion: change-to entry not found r`   rb   spellcheckSpellSuggestionr   )r!   present_suggestion_list_itemrV   r   r7   r4   r$   r   get_displayed_labelr   rO   r   Zget_substringr    rg   rc   rh   r
   rr   rs   rv   )r+   rn   r;   Zentrylabelra   rc   s   &&     r   rq   ZSpellCheck.present_suggestion  s-    (((44XT4RR~~\C 0 0#t<%%UC 0 0#t<//6RR(:K:KE:R%%eQ3q!--3333?""3"4'335AAB]^^LL##F+r   c               s$    V ^8  d   QhRRRRRR/# )r   rn   r   rx   r   r   r   r   r   r   r   !  s$     & &&59&	&r   c                s   V P                  4       '       g+   Rp\        P                  ! \        P                  VR4       R# V P                  pV'       g+   Rp\        P                  ! \        P                  VR4       R# V P
                  P                  P                  V4      p\        V4      ^8X  g   R# V'       d6   \        P                  ! V4      ;'       g    \        P                  ! V4      pMRp\        P                  ! V^ ,          4      pV RV 2pV P
                  P                  P                  VR7      pV P
                  P                  VP!                  4       VR7       V'       g+   \"        P$                  ! 4       P'                  R	4      '       d   V P
                  P)                  V4       \"        P$                  ! 4       P'                  R
4      '       d   V^ ,          \*        P$                  ! 4       P-                  4       8X  dQ   V P/                  V^ ,          4      w  r\0        P2                  RV	RV
/,          pV P
                  P                  V4       R# )z4Presents the current item from the suggestions list.zLSPELL CHECK: Not presenting suggested item: spellcheck support is not activeTFzFSPELL CHECK: Not presenting suggested item: suggestions list not foundrM   ry   r`   rb   rz   ZenablePositionSpeakingindextotal)rV   r   r7   r4   r%   r    Z	utilitiesZselected_childrenlenr   r|   r   rO   rg   rc   rh   rf   r
   rr   rs   rv   r   Zget_locus_of_focus"_get_suggestion_index_and_positionr	   ZGROUP_INDEX_SPEECH)r+   rn   rx   r;   suggestionsZitemsr}   ra   rc   r~   r   s   &&&        r   r{   Z'SpellCheck.present_suggestion_list_item!  s   
 ~~`C 0 0#t<,,ZC 0 0#t<&&88E5zQ33K@bbHDUDUVaDbEE""58,q!--3333?""399;e"<'335AAB]^^LL##F+'')556NOOQx=446IIKKBB58LLE#66'5'SX9YYCLL&&s+r   c               r>   r?   r   r   r   r   r   r   I  s        d  r   c                	sL    R V n         R V n        R V n        R V n        RV n        R # )NF)r"   r#   r$   r%   r&   rA   rB   r   r@   ZSpellCheck._clear_stateI  s(    ! $!%r   c               r.   r/   r   r   r   r   r   r   P  s     8 80@ 8T 8r   c                s   \         P                  ! V4      pV'       g   RVR.pV P                  V4      # RVRV R2.p\        P                  ! \        P
                  VR4       VP                  4       P                  R4      # )z9Returns True if the window can be the spell check window.r2   z,lacks an accessible ID. Will use heuristics.z	has id: 'Z'TZspelling)r   get_accessible_id_is_candidate_windowr   r3   r4   lower
startswith)r+   r0   Z	window_idr:   r<   r   r5   Z$SpellCheck.can_be_spell_check_windowP  s|     ..v6	$f.\]F,,V44 !&Ii[*BC5++VT: ++J77r   c               r.   r/   r   r   r   r   r   r   ^  s     _ _+; _ _r   c                s    \        R4      h)zKReturns True if window could be the spellcheck window pending other checks.z9SPELL CHECK: subclasses must provide this implementation.)ZNotImplementedErrorrW   rX   r   r   ZSpellCheck._is_candidate_window^  s     ""]^^r   c               r.   r[   r   r   r   r   r   r   c  s     	5 	5'7 	5D 	5r   c                s   \         P                  ! V4      pVP                  4       P                  R4      '       d2   RVRV R2.p\        P
                  ! \        P                  VR4       R# \        P                  ! V4      # )z=Returns True if obj could be the spell check change-to entry.Zreplacementr2   
with id: 'z' is the change-to entryT)	r   r   r   r   r   r3   r4   r   Zis_single_line_entryr+   rD   obj_idr:   r<   r   _is_change_to_entryZSpellCheck._is_change_to_entryc  sm     ++C0<<>$$]33$cZx?W+XYFu//>//44r   c               r.   r   rootr1   r   rH   r   r   r   r   r   r   n  s      *: ?V r   c                	s    V P                   '       g   R # \        P                  ! WP                  4      pRVRV.p\        P
                  ! \        P                  VR4       V# )Nz!SPELL CHECK: Change-to entry for:is:T)r!   r   find_descendantr   r   r3   r4   r+   r   r\   r:   r<   r   r6   Z SpellCheck._find_change_to_entryn  sR    ((())$0H0HI5tUFK5++VT:r   c               r.   r[   r   r   r   r   r   r   w  s      $4  r   c                	s   \         P                  ! V4      pVP                  4       P                  R 4      '       d2   RVRV R2.p\        P
                  ! \        P                  VR4       R# \        P                  ! V4      '       g   R# \        P                  ! V4      '       g   R# \         P                  ! V4      pRV9   d   R# \        VP                  4       4      ^8w  d   R# R# )errorr2   r   z' is the error widgetTFZ:)r   r   r   r   r   r3   r4   r   Zis_labelZobject_is_unrelatedrO   r   re   )r+   rD   r   r:   Znamerw   r   _is_error_widgetZSpellCheck._is_error_widgetw  s    ++C0<<>$$W--$cZx?T+UVFu//>##C((..s33  %$;tzz|!r   c               r.   r   r   r   r   r   r   r     s      '7 <S r   c                	    \         P                  ! WP                  4      pR VRV.p\        P                  ! \        P
                  VR4       V# )zSPELL CHECK: Error widget for:r   T)r   r   r   r   r3   r4   r   r<   r   r8   ZSpellCheck._find_error_widget  sC    ))$0E0EF2D%H5++VT:r   c               r.   r[   r   r   r   r   r   r     s     	K 	K(8 	KT 	Kr   c                	s   \         P                  ! V4      pVP                  4       P                  R 4      '       d2   RVRV R2.p\        P
                  ! \        P                  VR4       R# \         P                  ! V4      '       g   R# \        P                  ! V4      ;'       gS    \        P                  ! V4      ;'       g5    \        P                  ! V4      ;'       g    \        P                  ! V4      # )r   r2   r   z' is the suggestions listTF)r   r   r   r   r   r3   r4   Zsupports_selectionr   Zis_listZis_list_boxZis_tableZis_tree_tabler   r<   r   _is_suggestions_listZSpellCheck._is_suggestions_list  s    ++C0<<>$$]33$cZx?X+YZFu//>**3//""3' K K;+B+B3+G K K##C(K K,7,E,Ec,J	Kr   c               r.   r   r   r   r   r   r   r     s      +; @W r   c                	r   )z"SPELL CHECK: Suggestions list for:r   T)r   r   r   r   r3   r4   r   r<   r   r9   Z!SpellCheck._find_suggestions_list  sC    ))$0I0IJ6eVL5++VT:r   c               r.   )r   
suggestionr1   r   ztuple[int, int]r   r   r   r   r   r     s      e e=M eRa er   c                	sh    \         P                  ! V4      ^,           \         P                  ! V4      3# )i   )r   Zget_position_in_setZget_set_size)r+   r   rX   r   r   Z-SpellCheck._get_suggestion_index_and_position  s)    ..z:Q>@X@XYc@dddr   c               r>   )r   r   z	Gtk.Framer   r   r   r   r   r     s     ! ! !r   c                s   \         P                  ! 4       p\         P                  ! R\        P                   R2R7      pVP                  R4       VP                  V4       \         P                  P                  RR^^4      pVP                  ^ ^ ^^ 4       VP                  V4       \         P                  ! 4       pVP                  V4       \        P                  p\        P                  ! 4       P                  R4      p\         P                   P#                  V4      V n        V P$                  P'                  V4       VP)                  V P$                  ^ ^ ^^4       \        P*                  p\        P                  ! 4       P                  R4      p\         P                   P#                  V4      V n        V P,                  P'                  V4       VP)                  V P,                  ^ ^^^4       \        P.                  p\        P                  ! 4       P                  R4      p\         P                   P#                  V4      V n        V P0                  P'                  V4       VP)                  V P0                  ^ ^^^4       V# )	z3Returns the preferences GUI for spellcheck support.z<b>z</b>)r}   Tg      ?ru   rz   ro   )r   ZFrameZLabelr   ZSPELL_CHECKZset_use_markupZset_label_widgetZ	AlignmentZnewZset_paddingZaddZGridZSPELL_CHECK_SPELL_ERRORr
   rr   rs   ZCheckButtonZnew_with_mnemonicr(   Z
set_activeZattachZSPELL_CHECK_SPELL_SUGGESTIONr)   ZSPELL_CHECK_PRESENT_CONTEXTr*   )r+   Zframer}   Z	alignmentZgridZvalues   &     r   get_app_preferences_guiZ"SpellCheck.get_app_preferences_gui  s    				#i&;&;%<D ABT"u%MM%%c315	aB*		)xxzd11 ,,.::;QR(+(I(I%(P%%%007D111aA>66 ,,.::;VW-0__-N-Nu-U***55e<D661aC55 ,,.::;UV,/OO,M,Me,T)))44U;D55q!QBr   c               r>   )r   r   Zdictr   r   r   r   r   r     s     
 
$ 
r   c                s.    RT P                  P                  4       RT P                  P                  4       RT P                  P                  4       /#   \          d8   pRT 2p\        P                  ! \        P                  TR4       / u Rp?# Rp?ii ; i)z7Returns a dictionary with the app-specific preferences.z.SPELL CHECK: Preferences GUI not initialized: TNru   rz   ro   )ZAssertionErrorr   r7   r4   r(   Z
get_activer)   r*   )r+   r   r;   rj   r   get_preferences_from_guiZ#SpellCheck.get_preferences_from_gui  s    	 #D$A$A$L$L$N')K)K)V)V)X&(I(I(T(T(V
 	
	  	B5'JC 0 0#t<I	s   B,B	BB)r&   r$   r'   r#   r!   r    r%   r"   r*   r(   r)   N)T)F)FF)%Z__name__Z
__module__Z__qualname__Z__firstlineno____doc__r-   r=   rC   rF   rJ   rP   rR   rS   rT   rV   rY   rZ   r]   ri   rk   rt   rp   rq   r{   r@   r5   r   r   r6   r   r8   r   r9   r   r   r   Z__static_attributes__r   r   r   r   r   <   s    DI!F
.
"
``%
&

%	8
 ,6&P 8_
	5,	Ke!F
 
r   r   )!r   Z
__future__r   Z__id__Z__version__Z__date__Z__copyright__Z__license__rd   Ztypingr   ZgiZrequire_versionZgi.repositoryr   Zorcar   r   r   r   r   r	   r
   Zorca.ax_objectr   Zorca.ax_textr   Zorca.ax_utilitiesr   r   Zscriptsr   r   r   r   r   <module>r      s   4 A #	1 	   	   5%         " ! #  )w&# ]
 ]
r   