+
    Qi c                   s	   R t RtRtRtRtRt^ RIt^ RIt^ RI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 ^RIHt ^RIHtHt ^RIHt Rs ^ RItRs Rt!Rs"^ s# ^ RI%t%]'       g   Rt%/ t&]!'       Ed   ]PN                  ]&]PP                  &   ]PN                  ]&]PR                  &   ]PN                  ]&]PT                  &   ]PV                  ]&]PX                  &   ]PV                  ]&]PZ                  &   ]PV                  ]&]P\                  &   ]P^                  ]&]P`                  &   ]Pb                  ]&]Pd                  &   ]Pf                  ]&]Ph                  &   ]Pj                  ]&]Pl                  &   ]Pn                  ]&]Pp                  &   ]Pr                  ]&]Pt                  &   ]Pv                  ]&]Px                  &   ]Pz                  ]&]P|                  &   ]P~                  ]&]P                  &   ]P                  ]&]P                  &   ^ tC]C^.sD. sERsFRisG^ ^ .sHRsIRsJRsK^ sL^ sMRsNRsO^ tP^2tQ^FtR]QsS/ R]P                  bR]P                  bR]P                  bR]P                  bR]P                  bR]P                  bR]P                  bR]P                  bR]P                  bR]P                  bR ]P                  bR!]P                  bR"]P                  bR#]P                  bR$]P                  bR%]P                  bR&]P                  bR']P                  R(]P                  R)]P                  R*]P                  R+]P                  R,]P                  R-]P                  R.]P                  R/]P                  R0]P                  R1]P                  R2]P                  R3]P                  R4]P                  R5]P                  /CttR6 tuR7 tvR8 tw]%'       d*   ]w! 4       txR9]x.ty]P                  ! ]P                  ]yR4        ! R: R;4      t| ! R< R=]|4      t} ! R> R?]}4      t~ ! R@ RA]|4      t ! RB RC]}4      t ! RD RE]|4      t ! RF RG4      tRH tRI tRJ tRK tRL tRM tRjRN ltRO tRP tRQ tRR tRS tRkRT ltRU tRlRV ltRW tRX tRmRY ltRnRZ ltR[ tR\ tRmR] ltRmR^ ltR_ tRoR` ltRa tRb tRc tRd tRe t]Q3Rf ltRoRg ltRh tR#   ]$ d	    Rt!Rs" ELri ; i  ]$ d    Rt% ELsi ; i)pz#Support for braille display output.z$Id$z
$Revision$z$Date$z-Copyright (c) 2005-2009 Sun Microsystems Inc.ZLGPLN)GLib)brlmon)brltablenames)cmdnames)debug)script_manager)settings)settings_manager)AXEventSynthesizer)AXHypertext)AXObject)AXTextAXTextAttribute)	tablesdirTFzCz-Cz-g1zEs-Es-g1zFr-Ca-g2zFr-Fr-g2zLv-Lv-g1zNl-Nl-g1zNo-No-g0zNo-No-g1zNo-No-g2zNo-No-g3zPl-Pl-g1zPt-Pt-g1zSe-Se-g1zar-ar-g1zcy-cy-g1zcy-cy-g2zde-de-g0zde-de-g1zde-de-g2zen-GB-g2zen-gb-g1zen-us-g1zen-us-g2zfr-ca-g1zfr-fr-g1zgr-gr-g1zhi-in-g1zhu-hu-comp8zhu-hu-g1zhu-hu-g2zit-it-g1znl-be-g1c                 s     \         P                  ! \        4       U u. uF  q RR R9   g   K  V NK  	  up # u up i   \         d    . u # i ; i)zBReturns a list of braille table filenames in the tables directory.Nz.utbz.ctb)oslistdirr   OSError)fname    1/usr/lib/python3.14/site-packages/orca/braille.pyget_table_filesr      sL    #%::i#8[#8%"#JJZ<Z#8[[[ 	s   < 77< < AAc                 s    / p \        4        FB  pVRR p\        P                  P                  \        V4      V \
        P                  W"4      &   KD  	  V # )z7Returns a list of available braille translation tables.Nr   )r   r   pathjoinr   TABLE_NAMESget)tablesr   Zaliass      r   list_tablesr      sM     F "cr
GGLLE* 	{u,- #
 M    c                 s  a	a
 \         P                  ! \         P                  4      ^ ,          p RV .p\        P                  ! \        P
                  VR4       V R9   dG   \         P                  ! 4       ^ ,          p RV .p\        P                  ! \        P
                  VR4       V R9   d,   Rp\        P                  ! \        P
                  VR4       Ro
M.RP                  V P                  R4      4      P                  4       o
 \        P                  ! \        4       Uu. uF  q3RR R9   g   K  VNK  	  ppRR.o	. ROpT	T
3R lp\        \!        Yd4      4      pR\#        T4      RRP                  T4      .p\        P                  ! \        P
                  TR4       T'       g   R
# T F:  pT F1  pYx9   g   K  \        P$                  P                  \        T4      u u # 	  K<  	  \        P$                  P                  \        T^ ,          4      # u upi   \         d3    R	\        .p\        P                  ! \        P
                  TR4        R
# i ; i)zEReturns the default braille translation table for the current locale.zBRAILLE: User locale isTNzBRAILLE: Default locale isz=BRAILLE: Locale cannot be determined. Falling back on 'en-us'zen-us-Z_z)BRAILLE: Exception calling os.listdir for Z	interlineZmathtextc                 s   <a  S P                  S4      ;'       d@    \        ;QJ d    V 3R  lS 4       F  '       g   K   RM	  RM! V 3R  lS 4       4      '       * # )c              3   s,   <"   T F	  qS9   x  K  	  R # 5iN )Z.0Zets   & r   Z	<genexpr>Z:get_default_table.<locals>.is_candidate.<locals>.<genexpr>  s     1J'Qq&'s   TF)Z
startswithZany)r"   excludelanguages   fr   is_candidateZ'get_default_table.<locals>.is_candidate  s8    ||H%JJcc1J'1Jccc1J'1J.J*JJr   zBRAILLE:z"candidate tables for locale found:, )NZCr   r   )Zg1Zg2Zcomp6Zcomp8)localeZ	getlocaleZLC_MESSAGESr   print_tokens
LEVEL_INFOZgetdefaultlocaleprint_messager   ZsplitZlowerr   r   r   r   listfilterlenr   )Zuser_localetokensmsgxr   Zpreferr%   ZpZtabler#   r$   s            @@r   get_default_tabler1      s    ""6#5#56q9K'5F	u''6k!--/2.<5++VT:k!ME,,c4888K--c2399;ZZ	2Q2f@P6P!!2Q J'G ,FK &./F#f+'KTYYW]M^_F	u''6Ezww||Iu55   77<<	6!9--A R =yI5++VT:s*   H "H2H8H H 9IIz&BRAILLE: Default contraction table is:c                   sl   a  ] tR tRt o RtRR ltR tR tRR ltR t	RR lt
R	 tR
 tR tR tRtV tR# )Regioni  z=Base class of content to be displayed on the braille display.c                sB   V'       g   R p\         P                  ;'       d	    \        RJV n        W0n        VP                  R4      V n        V P                  '       d   \         P                  ;'       g    \        V n	        VP                  4       '       d7   RVRV P                  .p\        P                  ! \        P                  VR4       V P                  V P                  W#4      w  V n        V n        V n        V n        R# VP                  4       '       do   \         P                  '       g.   RV R2p\        P$                  ! \        P                  VR4       M+RVR.p\        P                  ! \        P&                  VR4       V P                  V n        W n        R# )	r   NZ
zBRAILLE: Contracting 'z' with tableTzBRAILLE: Not contracting 'z,' because contracted braille is not enabled.z' due to problem with liblouis.)r   enableContractedBraillelouis
contractedexpand_on_cursorZstrip	_raw_linebrailleContractionTable_defaultContractionTable_contraction_tabler   r(   r)   _contract_linestringin_positionout_positioncursor_offsetr*   LEVEL_WARNING)selfr<   r?   r6   r.   r/   s   &&&&  r   __init__ZRegion.__init__  sL   F #::PPuD?P 0  d+???&.&F&F&b&bJbD#||~~2FNDLcLcd""5#3#3VTB ,,T^^+8L QDK)4+<d>P ||~~7774VH =E F  ''(8(8#tD:F?AF&&u':':FDI..DK!.r   c                :    R V P                    RV P                   2# )z	REGION: '', cursor offset:r<   r?   rA      &r   __str__ZRegion.__str__C  s!    4;;-'89K9K8LMMr   c                s\    RV 2p\         P                  ! \         P                  VR4       R# )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.z-BRAILLE REGION: Process routing key. Offset: TN)r   r*   r)   )rA   offsetr/      && r   process_routing_keyZRegion.process_routing_keyF  s(     >fXFE,,c48r   c                s:    R\        V P                  4      ,          # )SCreates a string which can be used as the attrOr field of brltty's write structure. )r-   r<   rA   Z_indicate_links   &&r   get_attribute_maskZRegion.get_attribute_maskO  s     DKK(((r   c                s    V P                   '       dM   V P                  V P                  V P                  V P                  4      w  V n        V n        V n        V n        R# R# )z1Reposition the cursor offset for contracted mode.Nr5   r;   r7   r?   r6   r<   r=   r>   rF   rG   r   reposition_cursorZRegion.reposition_cursorT  sR     ???**4>>)-););)-)>)>@ QDK)4+<d>P r   c                s@    W,          R8H  pV'       d	   V'       d   ^ pM\        P                  p\        P                  ! V P                  .VVVR7      w  rgrV\        V4      8  d   \        V4      p	M\        V	\        V4      4      p	WgW3#   \          d    Rp Li ; i)%Contracts and returns the given line. F)Z	cursorPosmode)
IndexErrorr4   ZcompbrlAtCursorZ	translater:   r-   min)
rA   liner?   r6   Zcursor_on_spacerV   r5   r=   r>   cursor_positions
   &&&&      r   r;   ZRegion._contract_line]  s    	$"1S8O  ?D((D OOT445 &3!%' 	?
 CI%!*oO!/3z?COEE/  	$#O	$s   B BBc                s     V P                   V,          pV#   \         d    \        T P                  4      p T# \         d    Tp T# i ; ir    )r=   rW   r-   r7   ZAttributeError)rA   display_offsetrJ   rK   r   _display_to_buffer_offsetZ Region._display_to_buffer_offset{  sX    	$%%n5F   	)(F
 	  	$#F		$s     A
A
A
	A
c                s    V'       d6   \         P                  ;'       g    \        V n        V P	                  4        R# V P                  4        R# )zAExpands or contracts the region based on the value of contracted.N)r   r8   r9   r:   contract_regionexpand_region)rA   r5   rP   r   set_contracted_brailleZRegion.set_contracted_braille  s6     &.&F&F&b&bJbD#  " r   c                s    V P                   '       d   R # V P                  V P                  V P                  V P                  4      w  V n        V n        V n        V n        RV n         R # )NTrR   rF   rG   r   r]   ZRegion.contract_region  sV    ???(('+'9'9'+'<'<> 	MT%t'8$:L r   c                s    V P                   '       g   R # V P                  V n         V P                  V P                  ,          V n        RV n         R #   \
         d    \        T P                  4      T n         L0i ; i)NF)r5   r7   r<   r=   r?   rW   r-   rF   rG   r   r^   ZRegion.expand_region  sb    nn	2!%!1!1$2D2D!ED    	2!$T[[!1D	2s   "A %A:9A:)r:   r7   r5   r?   r6   r=   r>   r<   N)    FT)__name__
__module____qualname____firstlineno____doc__rB   rH   rL   rQ   rS   r;   r\   r_   r]   r^   __static_attributes____classdictcell____classdict__   @r   r2   r2     sC     G"/HN9)
@F<
!   r   r2   c                   s@   a  ] tR tRt o RtR	R ltR tR tR tRt	V t
R# )
	Componenti  z:A subclass of Region associated with an accessible object.c                s    \         P                  WW54       V'       d9   V P                  '       d!   VR ,           V P                  ,           V n        MW@n        Wn        R# )rU   N)r2   rB   r<   
accessible)rA   rm   r<   r?   Z	indicatorr6   s   &&&&&&r   rB   ZComponent.__init__  s<     	mF{{{'#o;'$r   c                rC   )zCOMPONENT: 'rD   rE   rF   rG   r   rH   ZComponent.__str__  s!    dkk]*;D<N<N;OPPr   c                s    R# )zUReturns the caret position of the 0-based offset if the object has text with a caret.r!   )rA   Z_offsetrP   r   get_caret_offsetZComponent.get_caret_offset  s	     	r   c                s   RV 2p\         P                  ! \         P                  VR4       \        P                  ! 4       P                  4       pV'       dL   VP                  P                  V P                  4      '       d!   \        P                  ! V P                  4       \        P                  ! V P                  ^ 4      '       d   R#  \        P                  ! V P                  ^4      pV'       g+   Rp\         P                  ! \         P                  VR4       R# R#   \         d6   pRT.p\         P                  ! \         P                  TR4        Rp?R# Rp?ii ; i)rI   z0BRAILLE COMPONENT: Process routing key. Offset: TNz#INFO: Processing routing key failedz%ERROR: Could not process routing key:)r   r*   r)   r   get_managerget_active_script	utilitiesZgrab_focus_before_routingrm   r
   Z
grab_focusZ	do_actionr   Zclick_object	Exceptionr(   )rA   rJ   r/   scriptZresulterrorr.   s   &&     r   rL   ZComponent.process_routing_key  s    AIE,,c48++-??Af&&@@QQ0dooq11
	A'44T__aHF
 ;##E$4$4c4@ 	  	?=uEFu//>>	?s   !D! !E!,*EE!)rm   r<   N)r`   r   F)rb   rc   rd   re   rf   rB   rH   ro   rL   rg   rh   ri   rk   r   rl   rl     s$     D%"Q
A Ar   rl   c                   sJ   a a ] tR tRt oRtRV 3R lltR tRR ltRtVt	V ;t
# )	Linki  z.A Component whose accessible object is a link.c                s,   < \         SV `  WVR R4       R# )r   TN)superrB   )rA   rm   r<   r?   	__class__s   &&&&r   rB   ZLink.__init__  s    ]BEr   c                rC   )zLINK: 'rD   rE   rF   rG   r   rH   ZLink.__str__  s!    %6t7I7I6JKKr   c                sh    \        \        P                  4      \        V P                  4      ,          # )rM   )chrr   brailleLinkIndicatorr-   r<   rO   rP   r   rQ   ZLink.get_attribute_mask  s#     8001C4DDDr   r!   r`   ra   )rb   rc   rd   re   rf   rB   rH   rQ   rg   rh   __classcell__rx   rj      @@r   rv   rv     s      8FLE Er   rv   c                   s   a a ] tR tRt oRtRV 3R lltR tR tR tR t	RR lt
RV 3R	 lltV 3R
 ltV 3R ltRtVtV ;t# )Texti  z9A subclass of Region backed by an accessible Text object.c           
     s  < R VRV RV RV RV 2.p\         P                  ! \         P                  VR4       Wn        W0n        Rp^ V n        ^ V n        V P                  '       d   Ve   W`n        M%\        P                  ! V P                  4      V n        Ve   \        W@P
                  4      V n        \        P                  ! V P                  V P
                  4      R,          w  qn        VP                  R	R
4      p WPP                  ,
          V n         W@P                  ,
          V n        WP                  V P                   pV ;P
                  V P                  ,          un        \!        V P
                  V P                  ,
          \        V4      4      p	V P                  \        V4      ,           V n        V'       d   VR
,           V n        MRV n        V P$                  V,           pV	\        V P$                  4      ,          p	\&        S
V `Q  WR4       V P*                  '       g<   \,        P.                  '       g&   V ;P0                  V P                  ,          un        R# \,        P.                  '       d   V ;P0                  R
,          un        R# R#   \         d    \        T4      T n         ELi ; i  \         d    ^ T n         ELi ; i)z!BRAILLE: Creating text region forzlabel:'z', offsets: r   z	, caret: Tr   Nr`   i   Nu   ￼rU   )r   r(   r)   rm   _eolcaret_offsetline_offsetr   ro   maxget_line_at_offsetZreplace_end_offsetZ	TypeErrorr-   _start_offsetrX   _max_caret_offset_labelrw   rB   r5   r   ZdisableBrailleEOLr<   )rA   rm   ZlabelZeolstart_offset
end_offsetr   r.   r<   r?   rx   s   &&&&&&&   r   rB   ZText.__init__  s=    6zE7,|nAj\S_R`ac5++VT:$	???'$0!$*$;$;DOO$L!'$'6G6G$H!'-'@'@!2!2(447(9$F$^^Hc2F	+),<,<<D	#!-0@0@!@D **4+;+;<T///D--0@0@@#f+N!%!1!1CK!?#+DKDKv%T[[))5x'A'A'AKK499$K''' KK3K (1  	+"6{D	+
  	#!"D	#s$   J J; J87J8;KKc                sn    R V P                    RV P                   RV P                   RV P                   2# )zTEXT: 'rD   z start offset:z, line offset:)r<   r?   r   r   rF   rG   r   rH   ZText.__str__)  sE    dkk]"3D4F4F3G H ../~d>N>N=OQ	
r   c                s   \         '       g   R# \        P                  ! V P                  4      R,          w  r\        P                  ! V P                  4      p\        W2,
          \        V4      4      pW P                  8w  d   R# W0n        W n        V\        V P                  4      ,          pV P                  '       d2   V P                  V P                  VR4      w  V n        V n        V n        pW@n        R# )zFAttempts to reposition the cursor in response to a new caret position.Fr   T)_regionWithFocusr   r   rm   ro   rX   r-   r   r   r   r5   r;   r7   r<   r=   r>   r?   )rA   r<   r   r   r?      &    r   rS   ZText.reposition_cursor/  s      $77HM..t?L6FD***(&T[[))???**4>>=$O LDK)4+<m +r   c                s    V P                  V4      pV^ 8  d   R# \        V P                  V,           V P                  4      # )zNReturns the caret position of the given 0-based offset if the object has text.rn   )r\   rX   r   r   rA   rJ   rP   r   ro   ZText.get_caret_offsetI  s>     //7A:I4##f,d.D.DEEr   c                s"   RV 2p\         P                  ! \         P                  VR4       V P                  V4      pV^ 8  d   R# \        P
                  ! 4       P                  4       pVP                  P                  V P                  V4       R# )7Processes a cursor routing key press on this Component.z+BRAILLE TEXT: Process routing key. Offset: TN
r   r*   r)   ro   r   rp   rq   rr   Zset_caret_offsetrm   rA   rJ   r/   r   rt      &&   r   rL   ZText.process_routing_keyR  st     <F8DE,,c48,,V4!++-??A))$//<Hr   c                s
   \         P                  ! V P                  4      '       d   R# \        P                  ! 4       P                  4       pVf+   Rp\        P                  ! \        P                  VR4       R# \        V P                  4      \        V P                  4      ,
          pV P                  V,           p\        P                  .V,          p\        P                  p\        P                   p\        P"                  p	V'       d   V	\        P                  8w  d   \$        P&                  ! V P                  4      p
V
 F  p\$        P(                  ! V4      p\$        P*                  ! V4      p\-        WP                  ,
          ^ 4      p\/        WP                  ,
          V4      p\1        W4       F  pVV;;,          V	,          uu&   K  	  K  	  V'       Ed0   \        P2                  pV P                  pVV8  Ed   \         P4                  ! V P                  V4      w  prVV8:  d   M\        P                  pTpV FN  pVV9  d   K  \6        P8                  ! V4      pV'       g   K,  VP;                  VV,          4      '       d   KL  Tp M	  V\        P                  8w  g   K  \-        WP                  ,
          ^ 4      p\/        WP                  ,
          V4      p\1        W4       F  pVV;;,          V,          uu&   K  	  EK  V'       d   \         P<                  ! V P                  4      pV Fd  w  r\-        WP                  ,
          ^ 4      p\/        WP                  ,
          V4      p\1        W4       F  pVV;;,          V,          uu&   K  	  Kf  	  V P>                  '       d   ^ .\        V P                  4      ,          pV P@                  \        V P                  4      R pV P                  '       d3   V Uu. uF&  pV\        V P                  4      ,
          ^,
          NK(  	  pp\C        V4       F#  w  pp VVV,          ;;,          V,          uu&   K%  	  VR\        V PF                  4       pV^ .\        V PH                  4      ,          ,          pV P                  '       d%   ^ .\        V P                  4      ,          V,           pRPK                  \M        \N        V4      4      # u upi   \D         d     K  i ; i)rM   r   Nz9BRAILLE: Cannot get attribute mask without active script.T)(r   Zis_whitespace_or_emptyrm   r   rp   rq   r   r*   r)   r-   r7   r   r   r   ZBRAILLE_UNDERLINE_NONEZtextAttributesBrailleIndicatorZbrailleSelectorIndicatorrz   r	   Zget_all_linksZget_link_start_offsetZget_link_end_offsetr   rX   rangeZtextAttributesToBrailleZget_text_attributes_at_offsetr   Zfrom_stringZvalue_is_defaultZget_selected_rangesr5   r>   Z	enumeraterW   r<   r   r   Zmapry   )rA   indicate_linksrt   r/   Zstring_lengthZline_end_offsetZregion_maskZattr_indicatorZselection_indicatorZlink_indicatorZlinksZlinkr   r   Z
mask_startZmask_endiZenabledrJ   Z
attributesmaskZattribZax_text_attrZ
selectionsZcontracted_maskr>   Zms   &&                         r   rQ   ZText.get_attribute_mask_  s    ((99++-??A>MC 0 0#t<DNN+c$++.>>**]:667-G!@@&??!66n0O0OO--doo>E*@@F(<<TB
 0@0@!@!D
z,<,<<mLz4ANn4N 5  >66G%%F?*88&Q 5
L'66#(FW, #2#>#>v#FL#|L,I,I*U[J\,],]- ) 8:::!$\4D4D%Da!HJ":0@0@#@-PH":8#A.8 9 33DOODJ,6( 0@0@!@!D
z,<,<<mLz4AN&99N 5 -7 ??? cC$77O,,S-=->?L{{{LXYL&T[[)9 9A = =LY!+.1#LO494 /
 **;3t{{+;<K 	sS^++;;;#DKK 00;>Kwws3,--  Z " s   ,S7S<<T
Tc                sT   < \         SV `  WV4      w  rErgW@P                  ,           WVV3# )rT   )rw   r;   r   )	rA   rY   r?   r6   r5   r=   r>   rZ   rx   s	   &&&&    r   r;   ZText._contract_line  s6     BGAW!1B3>
II%{/QQr   c                s   < \         SV `  V4      pW P                  ,          pV\        V P                  4      ,          pV# r    )rw   r\   r   r-   r   )rA   r[   rJ   rx   s   && r   r\   ZText._display_to_buffer_offset  s8    2>B$$$#dkk""r   c                s   < \         SV `  V4       V'       g&   V ;P                  V P                  ,          un        R # R # r    )rw   r_   r<   r   )rA   r5   rx   s   &&r   r_   ZText.set_contracted_braille  s*    &z2KK499$K r   )r   r   r   r   r   rm   r   r?   r=   r   r>   r<   )r   r   NNNra   )r`   T)rb   rc   rd   re   rf   rB   rH   rS   ro   rL   rQ   r;   r\   r_   rg   rh   r|   r}   r~   r   r   r     s@     C:x
4FIN.`R% %r   r   c                   sB   a a ] tR tRt oRtV 3R ltR tR tRtVt	V ;t
# )ReviewComponenti  z@A subclass of Component that is to be used for flat review mode.c                s8   < \         SV `  WVR R7       W@n        R# T)r6   N)rw   rB   zone)rA   rm   r<   r?   r   rx      &&&&&r   rB   ZReviewComponent.__init__  s    ]TR	r   c                rC   )zReviewComponent: r&   r   r?   rF   rG   r   rH   ZReviewComponent.__str__  s     "499+R0B0B/CDDr   c                *   \        V\        4      ;'       d}    V P                  VP                  8H  ;'       d\    V P                  VP                  8H  ;'       d;    V P                  VP                  8H  ;'       d    V P
                  VP
                  8H  # r    )
isinstancer   rm   r   r<   r?   rA   ZotherrP   r   __eq__ZReviewComponent.__eq__  s    5/2 : :5#3#33: :		UZZ': : u||+: : ""e&9&99		;r   )r   )rb   rc   rd   re   rf   rB   rH   r   rg   rh   r|   r}   r~   r   r   r     s     JE; ;r   r   c                   sN   a a ] tR tRt oRtV 3R ltR tR tR tR t	Rt
VtV ;t# )	
ReviewTexti  zKA subclass of Region backed by a Text object and used for flat review mode.c                sN   < \         SV `  VR R7       Wn        W0n        W@n        R# r   )rw   rB   rm   r   r   )rA   rm   r<   r   r   rx   r   r   rB   ZReviewText.__init__  s%    $7$&	r   c                rC   )zReviewText: r&   r   rF   rG   r   rH   ZReviewText.__str__  s     dii[4+=+=*>??r   c                r   r    )r   r   rm   r   r   r<   r   rP   r   r   ZReviewText.__eq__  s    5*- , ,5#3#33, ,  E$5$55, , 		UZZ', , u||+		-r   c                s\    V P                  V4      pV^ 8  d   R# V P                  V,           # )zQReturns the caret position of 0-based offset if the object has text with a caret.rn   )r\   r   r   rP   r   ro   ZReviewText.get_caret_offset  s1     //7A:I&((r   c                s   RV 2p\         P                  ! \         P                  VR4       V P                  V4      p\        P
                  ! 4       P                  4       pVP                  P                  V P                  V4       R# )zProcesses 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.z2BRAILLE REVIEW TEXT: Process routing key. Offset: TNr   r   r   r   rL   ZReviewText.process_routing_key  sj     C6(KE,,c48,,V4++-??A))$//<Hr   )rm   r   r   )rb   rc   rd   re   rf   rB   rH   r   ro   rL   rg   rh   r|   r}   r~   r   r   r     s)     U@-)I Ir   r   c                   sV   a  ] tR tRt o RtRR ltR tR tRR ltR t	R	 t
R
 tRtV tR# )Linei  zIA horizontal line on the display composed of a sequential set of Regions.Nc                sX    . V n         R V n        V'       d   V P                  V4       R# R# )r   N)regionsr<   
add_regionrA   regionrP   r   rB   ZLine.__init__  s$    OOF# r   c                <    V P                   P                  V4       R# )zAdds region to this line.N)r   appendr   rP   r   r   ZLine.add_region  s     	F#r   c                r   )zAdds regions to this line.N)r   Zextend)rA   r   rP   r   add_regionsZLine.add_regions
  s     	G$r   c           	     s   RpRpRp. pV P                    FV  pV\        8X  d   \        V4      pVP                  '       d   W&P                  ,          pVP	                  V4      pWG,          pKX  	  \
        P                  ! RV4       Uu. uF  qP                  4       NK  	  p	p. p
V	 EF9  w  rV
'       d3   W^ ,          ,
          \        ^ ,          8  d   VP                  V
4       . p
V
'       g   W,
          pV\        ^ ,          8  d   V\        ^ ,          ,          pV'       d   \        V4       FM  pVP                  W\        ^ ,          ,          ,           W^,           \        ^ ,          ,          ,           .4       KO  	  V\        ^ ,          ,          '       d   W\        ^ ,          ,          ,           V.p
MEK  MW.p
MW^&   W8X  g   EK&  VP                  V
4       . p
EK<  	  V
'       d   VP                  V
4       W#WE.# u upi )zAReturns the computed [string, offsetIndex, attributeMask, ranges]r   z(^\s+|\S+\s*)rn   )r   r   r-   r<   rQ   reZfinditerspan_displaySizer   r   )rA   r   r<   focus_offsetattribute_maskrangesr   r   ZwordZwordsr   ZstartZendZword_lengthZdisplay_widthsr   s   &&              r   get_infoZLine.get_info  s    llF))"6{}}}--',,^<D"N # *,5Ev)NO)N)NOJE1gQ7d#!ka0%0LO%CN%!&~!6A"MM5|A3F+F,1qSLO4K,K+M N "7 'a88$)\!_,L$Lc#RD$ & "<DQ"d#/  0 MM$n==; Ps   Hc                s    RpRp^ pV P                    F4  pTpW5P                  ,           p\        V4      V8  d    M\        V4      pK6  	  V\        V4      8  d   RR.# W!V,
          .# )z:Finds the Region at the given 0-based offset in this line.Nr   rn   )r   r<   r-   )rA   rJ   focused_regionr<   Zposr      &&    r   getRegionAtOffsetZLine.getRegionAtOffsetD  so    
 llF#Nmm+F6{V#f+C # S[ ":--r   c                s    RV 2p\         P                  ! \         P                  VR4       V P                  V4      w  r4V'       d   VP	                  V4       R# R# )r   z+BRAILLE LINE: Process routing key. Offset: TN)r   r*   r)   r   rL   )rA   rJ   r/   r   region_offsetr   r   rL   ZLine.process_routing_keyW  sQ     <F8DE,,c48"&"8"8"@&&}5 r   c                sN    V P                    F  pVP                  V4       K  	  R # r    )r   r_   )rA   r5   r   rK   r   r_   ZLine.set_contracted_braillea  s    llF))*5 #r   )r   r<   r    ra   )rb   rc   rd   re   rf   rB   r   r   r   r   rL   r_   rg   rh   ri   rk   r   r   r     s1     S$$
%
3>j.&66 6r   r   c                s    \        \        4      ^ 8  dE   V ^,
          \        ^ ,          ,           p\        ^,          p\        V,          P                  V4      # RR.# )a.  Given 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.
Nrn   )r-   _linesviewportr   )cellrJ   line_number   &  r   getRegionAtCellr   e  sJ     6{Q(hqk)qkk"44V<<":r   c                s    V P                   R,          p\        V^,           4      w  r#V'       d=   \        V\        \        34      '       d!   VP
                  pVP                  V4      pWE.# RpRpWE.# )a6  Gets 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.
argumentNrn   )eventr   r   r   r   rm   ro   )r   rJ   r   r   rm   r      &     r   getCaretContextr   s  sr     [[$F-fqj9V*VdJ%788&&
..}=
 %% 
%%r   c                 s    . s Rs^ ^ .sR# )zYClears the logical structure, but keeps the Braille display as-is (until it's refreshed).N)r   r   r   r!   r   r   clearr     s     F1vHr   c                 s
    V s R # r    )r   )ZlinesrG   r   	set_linesr     s    Fr   c                s0    \         P                  V 4       R# )z;Adds a line to the end of the logical display for painting.N)r   r   )rY   rG   r   add_liner     s     MM$r   c                 sn    \        \        4      ^ 8  d   \        \        ^,          ,          # \        4       # )zEReturns the Line that is currently being painted on the display.
    )r-   r   r   r   r!   r   r   getShowingLiner     s%     6{Qhqk""vr   c                s   V s V'       d   \         '       g   R# ^ pRp\         FA  pVP                   F  pV\         8X  g   K  V\        ^&   Rp M	  V'       d    MV^,          pKC  	  \        \        ^,          ,          pVP	                  V4      w  rxr\         P
                  \        ^ ,          8  d1   V\         P
                  \        ^ ,          ,
          ^,           ,          p\        ^ V4      \        ^ &   R# )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
- indicate_links: 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).
NFT)r   r   r   r   r   r?   r   r   )r   Z
panToFocusr   r   ZdonerY   ZregZ_stringrJ   _attribute_mask_rangess   &&&        r   setFocusr     s    " ++ KD<<C&&)	  
 q  (1+D26--2O/Wo
 %%a8"00<?BQFFa.HQKr   c                 s   \         '       g    Rp \        P                  ! \        P                  V R4       \        P                  \        P                  ^ R\        4       Rs Rp \        P                  ! \        P                  V R4       \         # \         #   \         d1    Rp \        P                  ! \        P                  T R4        \         # i ; i)zUTry to hand off control to other screen readers without shutting down the connection.z$BRAILLE: Attempting to idle braille.TFz"BRAILLE: Idling braille succeeded.z=BRAILLE: Idling braille failled. This requires BrlAPI >= 0.8.)
idler   r*   r)   _brlAPIsetParameterbrlapiPARAM_CLIENT_PRIORITYBRLAPI_PRIORITY_IDLErs   r/   r   r   _idleBrailler     s    
 4
	=8C 0 0#t<  !=!=q%I]^D
 7C 0 0#t<K4K  	=QC 0 0#t<
 K	=s   AB 3CCc                 s"   \         '       g   \        \        4       \         '       d$    \        P	                  R^ 4       \        4        R# R#   \         d7    Rp \        P                  ! \        P                  T R4       \        4         R# i ; i)zKClear the display and then try to hand off control to other screen readers.r   *BRAILLE: BrlTTY seems to have disappeared.TN)_brlAPIRunninginit	_callbackr   Z	writeTextr   rs   r   r*   r@   shutdownr   r   r   _clearBrailler     sg     >Y~	b!$N   	>C 3 3S$?J	s    A =BBc                 s   R\         .p \        P                  ! \        P                  V R4       \         '       g8   Rp\        P                  ! \        P                  VR4       \        \        4       \         '       d   \        '       d   Rp\        P                  ! \        P                  VR4        Rp\        P                  ! \        P                  VR4       \        P                  \        P                  ^ R\        4       RsRp\        P                  ! \        P                  VR4       R	# R	# R	#   \         d-    Rp\        P                  ! \        P                  TR4        R	# i ; i)
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.FzBRAILLE: De-idle succeeded.z#BRAILLE: could not restore priorityN)r   r   r(   r)   r*   r   r   r   r   r   r   r   brlapi_priorityrs   r@   r.   r/        r   _enableBrailler     s    ;NKF	u''6>2E,,c48Y~44C 0 0#t<A?##E$4$4c4@$$V%A%A1e_]
 4##E$4$4c4@    D;##E$7$7dCDs   3AD5 53E,+E,c                 s   R\         .p \        P                  ! \        P                  V R4       \         '       d   \        '       g   Rp\        P
                  ! \        P                  VR4       \        4       '       ga   \        P                  ! 4       P                  R4      '       g5   Rp\        P
                  ! \        P                  VR4       \        4        R# R# R# R# R# )zWHand 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)r   r   r(   r)   r   r*   r   r   rp   get_settingr   r   r   r   disableBrailler     s     <^LF	u''6~dd5E,,c48~~&6&B&B&D&P&PQ`&a&aDC 0 0#t<J	 'b~	 #~r   c                 s    Rp \         P                  ! \         P                  V R4       \        P                  ! 4       P                  R4      '       g   \        4        R# R# )z5Disable Braille if it got disabled in the preferencesz"BRAILLE: Checking braille setting.Tr   N)r   r*   r)   r   rp   r   r   r   r   r   checkBrailleSettingr   ,  sG     /C	((#t4'')55oFF Gr   c           	     s|   RV  RV 2p\         P                  ! \         P                  VR4       V'       d   \        RR7       \        P
                  ! 4       P                  R4      '       gm   \        P
                  ! 4       P                  R4      '       gC   \        '       d3   Rp\         P                  ! \         P                  VR4       \        4        R,s	R	# \        \        4      ^ 8X  d   \        4        R,s	R	# \        w  rVrxR
VRV RV RV R2.p	\         P                  ! \         P                  V	R4       \        '       dL   \        \        \         4      '       d2   \        P"                  p
\        P$                  p\        P&                  pMR	p
^ p^ pT
;'       d    W8H  ;'       d    W8H  pRV
RV RV R2\)        V4      .p	\         P                  ! \         P                  V	R4       V^ 8  dG   \*        ^ ,          V,           ^,           pRV 2p\         P                  ! \         P                  VR4       V '       Eds   V^ 8X  Edk   V'       Edb   V^ 8X  d+   Rp\         P                  ! \         P                  VR4       EM0Wk8X  d,   TpRp\         P                  ! \         P                  VR4       MWk8  d   WV,
          ,           pV\*        ^ ,          8:  d/   RV 2p\         P                  ! \         P                  VR4       TpMRp\         P                  ! \         P                  VR4       \*        ^ ,          pMtWk8  do   WV,
          ,
          pV^8  d/   RV 2p\         P                  ! \         P                  VR4       TpM*Rp\         P                  ! \         P                  VR4       ^p\        \,        ^,          ,          pVP/                  V4      w  ppppR\,        ^,           RV RV RV 2p\         P                  ! \         P                  VR4       R-pV^ 8  dC   V\        P0                  ,           pRV 2p\         P                  ! \         P                  VR4       V '       Ed   V^ 8  Ed   \        V4      \*        ^ ,          8:  dL   V\*        ^ ,          8  d:   R\,        ^ ,           R2p\         P                  ! \         P                  VR4       EM+V'       d[   \3        ^ VV,
          ^,           4      \,        ^ &   R\,        ^ ,           R2p\         P                  ! \         P                  VR4       EMV\,        ^ ,          8  dM   \3        ^ V4      \,        ^ &   R\,        ^ ,           R 2p\         P                  ! \         P                  VR4       EMkV\,        ^ ,          \*        ^ ,          ,           8  de   \3        ^ V\*        ^ ,          ,
          ^,           4      \,        ^ &   R\,        ^ ,           R!2p\         P                  ! \         P                  VR4       M\5        V4      p\3        ^ V^ ,          4      \,        ^ &   R\,        ^ ,           R"2p\         P                  ! \         P                  VR4       V\,        ^ ,          \*        ^ ,          ,           8  dd   \3        ^ V\*        ^ ,          ,
          ^,           4      \,        ^ &   R#\,        ^ ,           R!2p\         P                  ! \         P                  VR4       \7        V4      w  ppV\,        ^ &   VV,
          s\8        ^ 8  g   \8        \*        ^ ,          8  d   ^ sM\8        ^,          sR$V R%2p\         P                  ! \         P                  VR4       R&VVV  R'\8         2p\         P                  ! \         P                  VR4       VVV pV'       d   VVV pMR(pVR)\        V4      \        V4      ,
          ,          ,          p\        P
                  ! 4       P                  R4      '       d   \;        4        \        P
                  ! 4       P                  R4      '       d   \        '       d   \<        P>                  ! 4       p^Vn         \        V4      Vn!        VPB                  \*        ^ ,          8  d6   VR,          pV'       d
   VR),          pV;PB                  ^,          un!        KQ  VVn"        \8        Vn#        V'       d   VVn$         \J        PM                  V4       \R        PT                  '       d{   \V        '       g7    \X        PZ                  ! \*        ^ ,          4      s+\V        P]                  4        V'       d   VVV pMR	p\V        '       d   \V        P_                  \8        VV4       M"\V        '       d   \V        Pa                  4        R	s+V^ 8H  s1V\        V4      8  s2\        '       dQ   \        \        \         4      '       d7   \        P"                  \        P$                  \        P&                  \8        3s	R	# R,s	R	#   \N         d7    R*p\         P                  ! \         PP                  TR4       \        4         ELei ; i  \N         d,    \         P                  ! \         PP                  R+4       R	s+ ELFi ; i).a  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.
- indicate_links: 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.
zBRAILLE: Refresh. Pan: z	 target: TF)restoreSavedr   enableBrailleMonitorz>BRAILLE: FIXME - Braille disabled, but not properly shut down.NzBRAILLE: Last text object:z(Caret: z, Line: z, Cell: )zBRAILLE: Current text object:z). On same line:z'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.zBRAILLE: Line z: 'z' focusOffset: rU   z*BRAILLE: Cursor offset in line string is: zBRAILLE: Not adjusting offset z . Cursor offset fits on display.zBRAILLE: Adjusting offset to z based on targetCursorCell.z (cursor on left)z (cursor beyond display end)z (unhandled condition)zBRAILLE: Readjusting offset to zBRAILLE LINE:  'Z'z     VISIBLE:  'z
', cursor=r   rN   r   zbrlmon failedNr`   r`   r`   rn   )3r   r*   r)   	killFlashr   rp   r   r   r   _lastTextInfor-   r   r   r(   r   r   r   rm   r   r   Zboolr   r   r   r?   r   _getRangeForOffset_adjustForWordWrap
cursorCellr   r   ZWriteStructZregionBeginZ
regionSizeZtextcursorZattrOrr   Zwriters   r@   r   r   _monitorr   ZBrlMonZshow_allZ
write_textdestroybeginningIsShowingendIsShowing)panToCursortargetCursorCellr   	stopFlashr/   Zlast_text_objZlast_caret_offsetZlast_line_offsetZlast_cursor_cellr.   Zcurrent_text_objZcurrent_caret_offsetZcurrent_line_offsetZon_same_lineZnew_locationrY   r<   r   r   r   r?   Zrange_for_offsetstart_positionend_positionZlog_lineZ	substringZsubmaskZwrite_structZsub_masks   &&&&                         r   refreshr   5  s   < $K=	:J9K
LC	((#t4u% '')55oFF++-99:PQQ>RC 0 0#t<J'
6{a'KXHM&6*M*+84D3EXN^M__`acF	u''6J'7>>+66/<<.:: # 4 4(8(I 4 43  ./?-.h7J6KK[\< "F 
u''6!'?-==A78H7IJE,,c48 {'1,q [C 0 0#t<6/\C 0 0#t<5+FW/WXL|A.KL>Z##E$4$4c4@#/ L##E$4$4c4@#/? 5+CW/WXLq KL>Z##E$4$4c4@#/ N##E$4$4c4@#$  (1+D59]]>5R2V\>68A;-s6(/,qQWPX
YC	((#t4Mq$'7'E'EE:=/JE,,c48 {*v;,q/)ml1o.M28A;-?_`C 0 0#t<a1A!AA!EFHQK1(1+>YZC 0 0#t<Xa[(a/HQK1(1+>OPC 0 0#t<x{\!_<=aa!@1!DEHQK1(1+>Z[C 0 0#t<1-@a!1!!45HQK1(1+>TUC 0 0#t<!|A!>?!!]\!_%Dq%HI7}D`a##E$4$4c4@#56F#G NL HQK
 /JQJ,q/9
a
!&+H	(((D9!&"E!FjQ[P\]H	(((D9~l3I =vY#g,677G##%11/BB##%11/BB~~))+#$ "%i.%%Q7I6!##q(#%(" ")L	MM,' $$$x !==a9!!# %n\BHH8
Ix@	'1,3v;.L J'7>>)44)66)55#%
 (E  	>C 3 3S$?J	   ##E$7$7I s$   i ?5j =jj2j;:j;c                  s    \         '       dC   \        w  sssp R p\
        P                  ! \
        P                  VR4       \        RRR7       ^ s R# )zBRAILLE: Flash message callbackTFr   r   )	_flashEventSourceId_savedr   r   r   r   r*   r)   r   )_flash_timer/   r   r   _flashCallbackr   3  sI     <B9!8[/E,,c48EU3r   c                 s   R p\         P                  ! \         P                  VRR4       \        '       dJ   \        ^ 8  d   \        P
                  ! \        4       V '       d   \        w  sss	p\        RRR7       ^ sR# R# )zBRAILLE: Kill flash messageTFr   N)r   r*   r)   r   r    source_remover   r   r   r   r   )r   r/   r   r   r   r   r   B  sg    
'C	((#tT: "23@F=V%x7 r   c                  s    \         ^ 8  dE   \        P                  ! \         4       \        ^,          p \        P                  ! V \
        4      s R# R# )r`   N)r   r    r   r   timeout_addr   )Z
flash_timer   r   resetFlashTimerr   R  s:    Q./AY
"..z>J r   c                sN   R\          2p\        P                  ! \        P                  VR4       \         '       d)   \         ^ 8  d   \        P
                  ! \         4       ^ s M\        \        \        V 3s	V ^ 8  d   \        P                  ! V \        4      s R# V ^ 8  d   Rs R# R# )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.
z(BRAILLE: Initializing flash: Source ID: TNif)r   r   r*   r)   r    r   r   r   r   r   r   r   )	flashTimer/      & r   
_initFlashr   Y  s     55H4I
JC	((#t4"23*Hi@1}"..y.I	Q" 
r   c                s    \        V4       V ^ ,          pV ^,          p\        4        \        4       pV F  pVP                  V4       K  	  \	        V4       \        V4       \        RR7       R# )a  Displays a list of regions on a single line, setting focus to the
   specified region.  The regionInfo parameter is something that is
   typically returned by a call to braille_generator.generate_braille.

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.
Fr   N)r   r   r   r   r   r   r   )Z
regionInfor   r   r   rY   Zitemr   r   displayRegionsr   w  sW      ymG]N	G6D TN^er   c                s    RV  RV R2p\         P                  ! \         P                  VR4       \        V4       \	        4        \        W4      p\        \        V4      4       \        V4       \        RRR7       R# )a.  Displays a single line, setting the cursor to the given position,
ensuring that the cursor is in view.

Arguments:
- message: the string to display
- cursor: the 0-based cursor position, where -1 (default) means no cursor
- flashTime:  if non-0, the number of milliseconds to display the
              regions before reverting back to what was there before.
              A 0 means to not do any flashing.  A negative number
              means display the message until some other message
              comes along or the user presses a cursor routing key.
zBRAILLE: Display message: 'z' (flashTime: r   TFr   N)
r   r*   r)   r   r   r2   r   r   r   r   )Zmessager   r   r/   r   s   &&&  r   displayMessager     se     (yyk
KC	((#t4y	GG$FT&\VDE"r   c                 s2  a a \         ^ ,          oS\        ^ ,          ,           pRS RV RS  2p\        P                  ! \        P                  VR4       \
        '       d   \        P                  '       g   SV3# \
        \         ^,          ,          pVP                  4       w  rErg\        \        VV 3R lV4      4      pV'       d   RV^ ,          ^ ,           RVR	,          ^,           R2p\        P                  ! \        P                  VR4       VR	,          ^,          V^ ,          ^ ,          ,
          \        ^ ,          8  d-   Rp\        P                  ! \        P                  VR4       SV3# V^ ,          ^ ,          VR	,          ^,          uopSV3# )
r`   zBRAILLE: Current range: (r&   z). Target cell: Tc                 sZ   < V ^ ,          SS,           u;8*  ;'       d    V ^,          8  # u # r{   r!   )r0   r   r   s   &r   Z<lambda>Z$_adjustForWordWrap.<locals>.<lambda>  s!    1Q4><L+L#S#SqQRt#Sr   zBRAILLE: Adjusted range: (r   z?BRAILLE: Not adjusting range which is greater than display sizern   )r   r   r   r*   r)   r   r   ZenableBrailleWordWrapr   r+   r,   )	r   r   r/   rY   Z_line_string_focus_offsetr   r   r   s	   f       @r   r   r     sM   a[N!LO3L%n%5R~EUVfUg
hC	((#t46777|++(1+D;?==?8L&SU[\]F*6!9Q<.6":a=/KE,,c48":a=6!9Q<',q/9SC 0 0#t< <'' ,2!9Q<A(NL<''r   c                 s    \         \        ^,          ,          P                  4       w  rr4V F(  pV^ ,          T u;8:  d   V^,          8  g   K"   Vu #  K*  	  V F  pW^,          8X  g   K  Vu # 	  ^ ^ .# )i   )r   r   r   )rJ   Z_linr_stringr   r   r   Zrr   r   r   r     sl    ;A(1+;N;W;W;Y8LQ46 AaD H !  qT>H  q6Mr   c                s   \         ^ ,          pV ^ 8X  dT   \        V4      w  r#\        V\        ^ ,          ,
          4      w  rE\        ^ \	        W$,
          \        ^ ,          4      4      p \        ^ \         ^ ,          V ,
          4      \         ^ &   RV  RV R\         ^ ,           R2p\
        P                  ! \
        P                  VR4       V\         ^ ,          8g  # )zPans the display to the left, limiting the pan to the beginning
of the line being displayed.

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

Returns True if a pan actually happened.
zBRAILLE: Panning left. Amount:  (from  to r   T)r   r   r   r   rX   r   r*   r)   )
pan_amountold_x	old_startZ_old_end	new_start_new_endr/   s   &      r   panLeftr    s     QKEQ07	0\!_1LM	C	 5|AGH
a!z12HQK+J<wugT(ST+VW
XC	((#t4HQKr   c                s   \         ^ ,          pV ^ 8X  dB   \        V4      w  r#\        V4      w  rE\        ^ \        WB,
          \        ^ ,          4      4      p \        \        4      ^ 8  dY   \         ^,          p\         ^ ,          V ,           p\        V,          P                  4       w  rrV\        V4      8  d
   V\         ^ &   RV  RV R\         ^ ,           R2p\        P                  ! \        P                  VR4       V\         ^ ,          8g  # )zPans the display to the right, limiting the pan to the length
of the line being displayed.

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

Returns True if a pan actually happened.
z BRAILLE: Panning right. Amount: r   r   r   T)r   r   r   rX   r   r-   r   r   r   r*   r)   )r   r  r  Zold_endr  r  r   Znew_xZline_stringr   r   r   r/   s   &            r   panRightr    s     QKEQ/6	09	C	 5|AGH

6{Qqkj(?Ek?R?[?[?]<O3{##HQK,ZLwd8TU;-WX
YC	((#t4HQKr   c                s2   RV  R\         ^ ,           2p\        P                  ! \        P                  VR4       V \         ^ ,          8  d   \	        4       '       d   K$   V \         ^ ,          \
        ^ ,          ,           8  d   \        4       '       d   K6  R# R# )zKAutomatically pan left or right to make sure the current offset is
showing.zBRAILLE: Panning to offset z. Current offset: TN)r   r   r*   r)   r  r   r  )rJ   r/   r   r   panToOffsetr    sm     (x/A(1+
OC	((#t4
8A;
yy
Xa[<?2
3zz 4r   c                s:    \        \        4       \        R4       R# )zPans 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   )Z_inputEventrG   r   returnToRegionWithFocusr    s     DMr   c                s    V P                   R,          \        P                  ,          ^ 8g  \        n        \
         F"  pVP                  \        P                  4       K$  	  \        4        R# )z?Turns contracted braille on or off based upon the BrailleEvent.ZflagsN)r   r   ZKEY_FLG_TOGGLE_ONr   r3   r   r_   r   )r   rY   r   r   r_   r_     sK    
 
W	 8 8	8Q> $##H$D$DE Ir   c                s\   R\          2p\        P                  ! \        P                  VR4       \         '       d   \	        4        R# V P
                  R,          p\        \        4      ^ 8  d>   V\        ^ ,          ,           p\        ^,          p\        V,          P                  V4       R# )z,Processes a cursor routing key BrailleEvent.z)BRAILLE: Process routing key. Source ID: Tr   )
r   r   r*   r)   r   r   r-   r   r   rL   )r   r/   r   r   r   r   r   rL   rL   &  s~     66I5J
KC	((#t4;;z"D
6{Q#qk{//7r   c                s   RV .p\         P                  ! \         P                  VR4       Rp\        '       d    \        V 4      pV# V#   \         d9   pRT 2p\         P
                  ! \         P                  TR4       Rp Rp?T# Rp?ii ; i)z<Processes a BrailleEvent, calling the callback if it exists.zBRAILLE: Processing eventTFz*WARNING: Could not process braille event: N)r   r(   r)   r   rs   r*   r@   )r   r.   Zconsumedru   r/   r   r   _processBrailleEventr	  9  s     *51F	u''6Hy	 'H O8O  	>ugFC 3 3S$?HO	s   A	 	B-BBc                s"    \         P                  R4      pT'       d   \        \         P                  T4      4       \        #   \         dA   pRT 2p\        P                  ! \        P
                  TR4       \        4         Rp?R# Rp?ii ; i)z.Method to read a key from the BrlAPI bindings.Fz$WARNING: Could not read BrlApi key: TN)
r   ZreadKeyrs   r   r*   r@   r   r	  ZexpandKeyCoder   )Z_sourceZ
_conditionkeyru   r/   r   r   _brlapi_key_readerr  I  sq    ooe$ W22378  4UG<E//d;
	s   A B5B		Bc                st   Rp\         P                  ! \         P                  VR4       \        '       g   \	        \
        4       \        '       g+   Rp\         P                  ! \         P                  VR4       R# Rp\         P                  ! \         P                  VR4       \        P                  \        P                  ^ .4       \        P                  \        P                  ,          .pRp\         P                  ! \         P                  VR4       V  F)  pVP                  \        P                  V,          4       K+  	  Rp\         P                  ! \         P                  VR4       \        P                  \        P                  V4       Rp\         P                  ! \         P                  VR4       R# )	zHacky 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.
zBRAILLE: Setting up key ranges.Tz7BRAILLE: Not setting up key ranges: BrlAPI not running.Nz!BRAILLE: Ignoring all key ranges.zBRAILLE: Enabling commands:z BRAILLE: Sending keys to BrlAPI.zBRAILLE: Key ranges set up.)r   r*   r)   r   r   r   r   Z
ignoreKeysr   ZrangeType_allZKEY_TYPE_CMDKEY_CMD_ROUTEr   Z
acceptKeysZrangeType_command)Zkeysr/   Zkey_setr
     &   r   setupKeyRangesr  W  s0    ,C	((#t4>Y>GE,,c48
-C	((#t4v++aS1""V%9%99:G
'C	((#t4v**S01  -C	((#t4v//9
'C	((#t4r   c                s|   \         '       d7   \        '       d+   \        P                  ! 4       P	                  R4      '       g   R# \
        '       d-   Rp\        P                  ! \        P                  VR4       V s	R#  RV .p\        P                  ! \        P                  VR4       \        P                  \        P                  ^ RV 4       Rp\        P                  ! \        P                  VR4       V s	R#   \         d7   pRT 2p\        P                  ! \        P                   TR4        Rp?R# Rp?ii ; i)	ziSet BRLAPI priority

Arguments:
-level: the priority level to apply, default to braille.PRIORITY_DEFAULT
r   Nz7BRAILLE: Braille is idle, don't change BRLAPI priority.TzBRAILLE: Setting priority to:FzBRAILLE: Priority set.zBRAILLE: Cannot set priority: )_brlAPIAvailabler   r   rp   r   r   r   r*   r)   r   r(   r   r   r   r   rs   r@   )Zlevelr/   r.   ru   r  r   setBrlapiPriorityr  }  s     >>**,88IItGE,,c48
 1595++VT:V991eUK
 'E,,c48  <.ug6E//d;;<s   >AC: :D;+D66D;c                s	   \         P                  '       g   R# RV .p\        P                  ! \        P                  VR4       \
        '       d+   Rp\        P                  ! \        P                  VR4       R# V sR\        P                  P                  R4      .p\        P                  ! \        P                  VR4       R\        P                  P                  R4      .p\        P                  ! \        P                  VR4        R	p\        P                  ! \        P                  VR4       \        P                  ! 4       sR
\        .p\        P                  ! \        P                  VR4       Rp\        P                  ! \        P                  VR4       \        P                  4        Rp\        P                  ! \        P                  VR4       Rs\        P                  w  r4RV RV R2p\        P                  ! \        P                  VR4       V^ 8X  d/   Rp\        P                  ! \        P                   VR4       \"        h\$        P&                  ! \        P(                  \$        P*                  \$        P,                  \.        4      sT^.s\:        '       d   \:        P=                  4        Rs\?        4        \A        R4       Rp\        P                  ! \        P                  TR4       R#   \2         d-    Rp\        P                  ! \        P                   TR4        R# \"         Ed   pRT 2p\        P                  ! \        P                   TR4       Rs\        '       g    Rp?R#  Rp\        P                  ! \        P                  TR4       \        P5                  4        Rp\        P                  ! \        P                  TR4       M9  \"         d,    Rp\        P                  ! \        P                  TR4        Mi ; i Rp\        P                  ! \        P                  TR4       \        P7                  4        Rp\        P                  ! \        P                  TR4       M9  \"         d,    Rp\        P                  ! \        P                  TR4        Mi ; iRs Rp?R# Rp?ii ; i)zInitializes 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.zBRAILLE: WINDOWPATH=Z
WINDOWPATHzBRAILLE: XDG_VTNR=ZXDG_VTNRz+BRAILLE: Attempting connection with BrlAPI.z,BRAILLE: Connection established with BrlAPI:z&BRAILLE: Attempting to enter TTY mode.zBRAILLE: TTY mode entered.zBRAILLE: Display size: (Z,r   z@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.zBRAILLE: TTY mode exited.$BRAILLE: Exception leaving TTY mode.(BRAILLE: Attempting to close connection.zBRAILLE: Connection closed.&BRAILLE: Exception closing connection.zBRAILLE: Initialized)!r   r   r   r(   r)   r   r*   r   r   Zenvironr   r   Z
Connectionr   ZenterTtyModeWithPathZdisplaySizer@   rs   r    Zio_add_watchZfileDescriptorZPRIORITY_DEFAULTZIO_INr  _brlAPISourceIdZ	NameErrorleaveTtyModecloseConnectionr   r   r   r   r   )Zcallbackr.   r/   r0   Zyru   r   r   r   r     s    !!! 1(;F	u''6~3E,,c48I$bjjnn\&BCF	u''6"BJJNN:$>?F	u''6A;E,,c48##%@'J5++VT:6E,,c48$$&*E,,c48$$(1QCq1E,,c486TC 3 3S$?O++G,B,B,0,A,A,0JJ,>@R q6L x	GDM
 C	((#t4a  FE//d; 8@E//d;w	=:C 0 0#t<  "-C 0 0#t< 	=8C 0 0#t<	=	=<C 0 0#t<##%/C 0 0#t< 	=:C 0 0#t<	= =so   
FK= =3S3	S=S>9S>A$O#"S#3PSPSA$RS3R85S7R88SSc                 st   Rp \         P                  ! \         P                  V R4       \        '       Ed>   RsRp \         P                  ! \         P                  V R4       \        P
                  ! \        4       ^ s Rp \         P                  ! \         P                  V R4       \        P                  4        Rp \         P                  ! \         P                  V R4        Rp \         P                  ! \         P                  V R4       \        P                  4        R	p \         P                  ! \         P                  V R4       Rs\        '       d   \        P                  4        Rs\        ^.sM*Rp \         P                  ! \         P                  V R4       R# Rp \         P                  ! \         P                  V R4       R#   \         d-    Rp \         P                  ! \         P                  T R4        ELi ; i  \         d,    R
p \         P                  ! \         P                  T R4        Li ; i)zQShuts down the braille module.   Returns True if the shutdown procedure
was run.
z%BRAILLE: Attempting braille shutdown.TFz#BRAILLE: Removing BrlAPI Source ID.r  z$BRAILLE: Leaving TTY mode succeeded.r  r  z&BRAILLE: Closing connection succeeded.r  Nz!BRAILLE: Braille was not running.z#BRAILLE: Braille shutdown complete.)r   r*   r)   r   r    r   r  r   r  rs   r@   r  r   r   DEFAULT_DISPLAY_SIZEr   r   r   r   r   r     s   
 2C	((#t4 ~3E,,c48?+		=:C 0 0#t<  "
 9C 0 0#t<		=<C 0 0#t<##%
 ;C 0 0#t<8H,a01E,,c48
/C	((#t4?  	@8C 3 3S$?	@  	@:C 3 3S$?	@s$   =<G "<H 3G>=G>3H76H7r   )TT)Tr`   TTra   r{   )rn   r`   r    )rf   Z__id__Z__version__Z__date__Z__copyright__Z__license__r'   r   r   Zgi.repositoryr    r   r   r   r   r   r   r   r   Zax_event_synthesizerr   Zax_hypertextr	   Z	ax_objectr
   Zax_textr   r   Zorca_platformr   r   r   r   r  r   r  rs   r4   Zcommand_nameZBRAILLE_LINE_LEFTZKEY_CMD_HWINLTZKEY_CMD_FWINLTZKEY_CMD_FWINLTSKIPZBRAILLE_LINE_RIGHTZKEY_CMD_HWINRTZKEY_CMD_FWINRTZKEY_CMD_FWINRTSKIPZBRAILLE_LINE_UPZKEY_CMD_LNUPZBRAILLE_LINE_DOWNZKEY_CMD_LNDNZBRAILLE_FREEZEZKEY_CMD_FREEZEZBRAILLE_TOP_LEFTZKEY_CMD_TOP_LEFTZBRAILLE_BOTTOM_LEFTZKEY_CMD_BOT_LEFTZBRAILLE_HOMEZKEY_CMD_HOMEZBRAILLE_SIX_DOTSZKEY_CMD_SIXDOTSZBRAILLE_ROUTE_CURSORr  ZBRAILLE_CUT_BEGINZKEY_CMD_CUTBEGINZBRAILLE_CUT_LINEZKEY_CMD_CUTLINEr  r   r   r   r   r   r   r   r   r   r   r   r   r   ZBRLAPI_PRIORITY_DEFAULTZBRLAPI_PRIORITY_HIGHr   ZCZ_CZ_G1ZES_ES_G1ZFR_CA_G2ZFR_FR_G2ZLV_LV_G1ZNL_NL_G1ZNO_NO_G0ZNO_NO_G1ZNO_NO_G2ZNO_NO_G3ZPL_PL_G1ZPT_PT_G1ZSE_SE_G1ZAR_AR_G1ZCY_CY_G1ZCY_CY_G2ZDE_DE_G0ZDE_DE_G1ZDE_DE_G2ZEN_GB_G2ZEN_GB_G1ZEN_US_G1ZEN_US_G2ZFR_CA_G1ZFR_FR_G1ZGR_GR_G1ZHI_IN_G1Z
HU_HU_8DOTZHU_HU_G1ZHU_HU_G2ZIT_IT_G1ZNL_BE_G1r   r   r   r1   r9   r.   r(   r)   r2   rl   rv   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r_   rL   r	  r  r  r  r   r   r!   r   r   <module>r     s  8 *?  	 	         4 %  , $GNO

  .6.H.HL&&'.6.H.HL&&'.6.H.HL**+.6.I.IL&&'.6.I.IL&&'.6.I.IL**+.6.F.FL$$%.6.H.HL$$%.6.E.EL&&'.6.G.GL(().6.J.JL(().6.C.CL$$%.6.G.GL''(.6.K.KL%%&.6.H.HL(().6.G.GL''(  $a(
 
     q6
 	
  
 
   
      *3z=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m66=11=11=11=11?3B	4.l 	0268PQF	u''6E  E N7A 7ArE9 EU%6 U%n;i ;"(I (ITg6 g6R&*	
2!h( A:&|(|  K#<8#0(.	 , 8& $5L 4  >rh:a6  N  Es$   ,S 9S. S+*S+.	S;:S;