+
   >Vc                   s   R 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
t
]
P                  R:8  d   ^ R
IHt M^ R
IHt ^ R	It^ R	It^ R	It^ R	It^ R	It^ R	It^ R	It^ R	It^ R	It^ R	It^ R	It^ R	It^ RIHtHt ^ RIHt ]! RR4       ^ RIH t  ]! RR4       ^ RIH!t! ]! RR4       ^ RIH"t" ^ R	I#t#^ R	I$t$^ R	I%t%^ R	I&t&^ R	I't'^ R	I(t(R	t) ^ R	I*t*R	t)Rt- ^ R	I.t.].P^                  ].n0        ].t1Rt-Rt2 ^ R	I3t3Rt2Rt6 ^ RI7H8t8 ^ RI9H:t; ^ RI9H<t= Rt6Rt> ^ R	I?t@Rt>]P                  ! R4      tBR;tCRtDR R ltER R ltFR tGR!tHR"tIR#tJ] P                  ] P                  ] P                  3tNR$ R% ltOR& R' ltP]"P                  tR]"P                  tTR( R) ltUR* R+ ltV]U]"nQ        ]V]"nS        ]! RR,7       ! R- R.4      4       tW ! R/ R04      tX ! R1 R2]P                  4      tZ ! R3 R44      t[ ! R5 R64      t\ ! R7 R84      t] ! R9 R] P                  4      t_R	#   ]+3 d   t,],t) R	t,A,ELJR	t,A,ii ; i  ]+ d    ^ R	I1t1Rt- ELFi ; i  ]+]4]53 d    Rt2 ELPi ; i  ]+3 d    Rt6 ELJi ; i  ]+3 d    Rt> ELRi ; i)<z>
This file implements the ibus engine for ibus-typing-booster
Any)Dict)List)Tuple)Union)Optional)Iterable)CallableN)Literal)	dataclassfield)require_versionIBusz1.0)r   Gioz2.0)r   GLib)r   FT)speech)enums)typeszibus-typing-boosterTypingBoosterEnginec                0    V ^8  d   QhR\         R\         /#    textreturnstrformat   "7/usr/share/ibus-typing-booster/engine/hunspell_table.py__annotate__r   y   s     . .C .C .    c                s8    \         P                  ! \        V 4      # )zGettext translation function.)gettextZdgettext
DOMAINNAMEr      &r   _r%   y   s    J--r    c                r   r   r   r   r   r   r   r   }   s      S S r    c                    V # )z{Mark string for translation without actually translating.

Used by gettext tools to extract strings that need translation.
 r#   r$   r   N_r(   }   s	    
 Kr    u   ☐u   ☑u   🙂u   🕵c                s    V ^8  d   QhR\         R\        3,          R\        \        R3,          R\        \        \        3,          RR/# )r   func.argskwargsr   N)r   r   r   r   r   r   r   r   r   r      sI     7 7sCx 7CHo7 S#X7 $(7r    c           	     s   \         P                  ! 4       w  r4pVf   Q hVf   Q h\        V\        4      '       d   \         P                  ! W4V4       R# \        V R\        V 4      4      p\        P                  RWaVW4V3R7       R# )z Log exceptions in GLib callbacksN__qualname__z;Unhandled exception in GLib callback %s(args=%r, kwargs=%r))exc_info)	sysr-   Z
issubclassZKeyboardInterruptZ__excepthook__getattrreprLOGGERerror)r)   r*   r+   Zexc_typeZ	exc_valueZexc_tracebackZ	func_name   &&&    r   log_glib_callback_exceptionr4      s    
 *-&H   (-..8>nd4j9I
LLE}5  7r    c                sd    V ^8  d   QhR\         R\        3,          R\         R\        3,          /# )r   r)   .r   r   r   r   r   r   r   r      s,     
 
hsCx0 
Xc3h5G 
r    c                s   a  R V 3R llpV# )zRWrap a GLib callback so that exceptions are logged via
log_glib_callback_exceptionc                s<    V ^8  d   QhR\         R\         R\         /# )r   r*   r+   r   r    r   r   r   r   Z)_wrap_glib_callback.<locals>.__annotate__   s!         r    c                  sR   <  S! V / VB #   \          d    \        SY4        R # i ; iF)	Exceptionr4   )r*   r+   r)   s   *,r   	safe_funcZ&_wrap_glib_callback.<locals>.safe_func   s4    	((( 	'd;	s    &&r'   )r)   r8   s   f r   _wrap_glib_callbackr9      s      r    c                sb    V ^8  d   QhR\         R\        3,          R\        R\        R\        /# )r   r)   .r*   r+   r   r5   r   r   r   r   r      s?     F FsCx FF F Fr    c                 s2    \        \        V 4      .VO5/ VB # N)_real_idle_addr9   )r)   r*   r+   s   &*,r   _idle_add_safer<      s     -d3EdEfEEr    c          
      sn    V ^8  d   QhR\         R\        R\        3,          R\        R\        R\        /# )r   intervalr)   .r*   r+   r   )intr   r   r   r   r   r   r      sJ     S SSsCx S S 	S 	Sr    c                 s4    \        V \        V4      .VO5/ VB # r:   )_real_timeout_addr9   )r=   r)   r*   r+   s   &&*,r   _timeout_add_safer@      s!    
 X':4'@R4R6RRr    )Zfrozenc                   st   a  ] tR t^t o RtRt^ t^ t]! ]	P                  R7      tV 3R lR ltV 3R ltRtV tR# )	SurroundingTexta5  
A dataclass containing the information about surrounding text

text: str = ''              The text
cursor_pos: int = 0         The cursor position
anchor_pos: int = 0         The anchor position. It should be different from
                            the cursor position if a selection is active.
event: threading.event = field(default_factory=threading.Event)
                            Used to check whether an update of this
                            surrounding text object happened since
                            the last trigger requesting an update
 )Zdefault_factoryc                   < V ^8  d   QhRR/# )r   r   rA   r'   r   __classdict__   "r   r   SurroundingText.__annotate__   s      ' r    c                s    \         P                  ! 4       pV P                  P                  4       '       d   VP	                  4        \        V P                  V P                  V P                  VR7      # )aP  Create a copy of a Surrounding text object

copy.deepcopy() fails on threading.Event because
a threading.Event contains a _thread.lock internally
and _thread.lock is not picklable.
And copy.deepcopy() relies on pickle under the hood to clone
objects with internal state. So Python raises:
TypeError: cannot pickle '_thread.lock' object
)r   
cursor_pos
anchor_posevent)		threadingEventrJ   is_setsetrA   r   rH   rI   )selfZ	new_event   & r   copyZSurroundingText.copy   sQ     OO%	::MMO	 	r    c                s^   < V ^8  d   Qh/ S[ ;R&   S[;R&   S[;R&   S[P                  ;R&   # )r   r   rH   rI   rJ   )r   r>   rK   rL   rD   rF   r   r   rG      s<      N     ! & ??C' r    r'   N)__name__
__module__r,   __firstlineno____doc__r   rH   rI   r   rK   rL   rJ   rQ   Z__annotate_func____static_attributes____classdictcell__rE      @r   rA   rA      s<      DJJ #9??CE +  r    rA   c                   s  a  ] tR t^t o RtRV 3R lR lltV 3R lR lt]V 3R lR l4       t]P                  V 3R lR	 l4       t]V 3R
 lR l4       t
]V 3R lR l4       t]V 3R lR l4       tV 3R lR ltV 3R lR ltRtV tR# )
ClientInfozCClass to make the parts of the client string more easily accessiblec                $   < V ^8  d   QhRS[ RR/# r   clientr   Nr   rD   rF   r   r   ClientInfo.__annotate__   s     ' '' 
'r    c                sR    R V n         R V n        R V n        V P                  V4       R# )rB   N)
_im_module_program_name_window_title_parse_client_strrO   r]      &&r   __init__ZClientInfo.__init__   s)      ""$"$v&r    c                r[   r\   r   rD   rF   r   r   r^      s     H H H Hr    c                st    VP                  R ^4      . RO,           R,          pVw  V n        V n        V n        R# )::N   NN)rB   rB   rB   )splitr_   r`   ra   )rO   r]   Zparts   && r   rb   ZClientInfo._parse_client_str   s0    c1%4b9BG?+T-?r    c                    < V ^8  d   QhRS[ /# r   r   r   rD   rF   r   r   r^      s     N N Nr    c                sR    V P                    RV P                   RV P                   2# )zreturn the full client stringrf   r_   r`   ra   rO   r$   r   r]   ClientInfo.client   s.     //"!D$6$6#7q9K9K8LMMr    c                r[   r\   r   rD   rF   r   r   r^     s     ' 'S 'T 'r    c                s(    V P                  V4       R# )zSet the clientN)rb   rc   rd   r   r]   rn     s     	v&r    c                rj   rk   r   rD   rF   r   r   r^     s      3 r    c                    V P                   # )zReturn only the input module)r_   rm   r$   r   	im_moduleZClientInfo.im_module  s     r    c                rj   rk   r   rD   rF   r   r   r^          " "c "r    c                ro   )zReturn only the program name)r`   rm   r$   r   program_nameZClientInfo.program_name       !!!r    c                rj   rk   r   rD   rF   r   r   r^     rq   r    c                ro   )zReturn only the window title)ra   rm   r$   r   window_titleZClientInfo.window_title  rs   r    c                rj   rk   r   rD   rF   r   r   r^     s       r    c                ro   r:   )r]   rm   r$   r   __str__ZClientInfo.__str__  s    {{r    c                rj   rk   r   rD   rF   r   r   r^     s     9 9# 9r    c                s\    R V P                   : RV P                  : RV P                  : R2# )zClientInfo(im_module=z, program_name=z, window_title=)rl   rm   r$   r   __repr__ZClientInfo.__repr__  s<    '': ;  $ 2 25 6  $ 2 25Q8 	9r    rl   NrB   )rR   rS   r,   rT   rU   re   rb   propertyr]   setterrp   rr   rt   ru   rw   rV   rW   rX   rY   r   rZ   rZ      s     M' 'H H N N ]]' '   " " " " 9 9r    rZ   c                   s   a  ] tR tRt o Rt]P                  ! 4       t]P                  ! 4       t]P                  ! 4       t	]P                  ! 4       t
]P                  ! 4       tV 3R lR ltRtV tR# )LookupTableStatei  z.Enum of states of the TypingBoosterLookupTablec                rj   rk   r   rD   rF   r   r   ZLookupTableState.__annotate__&  s     ! ! !r    c                6    V P                   P                  4       # r:   )namelowerrm   r$   r   ru   ZLookupTableState.__str__&  s    yy  r    r'   N)rR   rS   r,   rT   rU   enumZautoNORMALSELECTION_INFORELATED_CANDIDATESCOMPOSE_COMPLETIONSM17N_CANDIDATESru   rV   rW   rX   rY   r   r{   r{     sK     8YY[FYY[N))+iikO! !r    r{   c                   sT  a  ] tR tRt o Rt^	]P                  P                  3V 3R lR lltV 3R lR lt	V 3R lR lt
V 3R	 lR
 ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR  ltV 3R! lR" ltV 3R# lR$ ltV 3R% lR& ltV 3R' lR( ltV 3R) lR* lt]V 3R+ lR, l4       t]P<                  V 3R- lR. l4       t]V 3R/ lR0 l4       t]P<                  V 3R1 lR2 l4       t]V 3R3 lR4 l4       t ] P<                  V 3R5 lR6 l4       t ]V 3R7 lR8 l4       t!]!P<                  V 3R9 lR: l4       t!]V 3R; lR< l4       t"]"P<                  V 3R= lR> l4       t"]V 3R? lR@ l4       t#RAt$V t%RB# )CTypingBoosterLookupTablei)  u  Lookup table for Typing Booster

This extends IBus.LookupTable to make it easier to track
in which state the Typing Booster lookup table is.

Using composition instead of interiting from IBus.LookupTable!

When trying to use inheritance, the TypingBoosterLookupTable
instance, despite being created from the subclass, is effectively
an instance of the C-side IBus.LookupTable class — so the extra
Python methods of TypingBoosterLookupTable are lost.

The GObject system calls the C constructor first, which allocates
a GObject*.  PyGObject then wraps it in a Python object — but not
the subclass's object, unless the base class was designed to
allow Python subclassing.

IBus.LookupTable (and most IBus or GTK types) are not subclassable
in pure Python.
c                >   < V ^8  d   QhRS[ RS[P                  RR/# )r   	page_sizeorientationr   N)r>   r   OrientationrD   rF   r   r   %TypingBoosterLookupTable.__annotate__>  s/     9 99 ))9 
	9r    c                sd   \         P                  ! 4       V n        V P                  P                  4        V P                  P	                  V4       V P                  P                  V4       V P                  P                  R 4       V P                  P                  R 4       \        ^ ^	4       FN  p\        V^,           4      pV P                  P                  V\         P                  P                  V4      4       KP  	  \        P                  V n        R V n        RV n        R V n        R V n        R# FrB   N)r   LookupTable_ibus_lookup_tableclearset_page_sizeset_orientationset_cursor_visible	set_roundranger   	set_labelTextnew_from_stringr{   r   _state_hidden_related_candidates_phrase_enabled_by_tab_enabled_by_min_char_complete)rO   r   r   indexlabel   &&&  r   re   Z!TypingBoosterLookupTable.__init__>  s    
 #'"2"2"4%%'--i8//<2259
 	))%01a[E	NE##--tyy0079 ! )9(?(?"/1'%*38*r    c                rC   r   r   Nr'   rD   rF   r   r   r   f  s     ( (t (r    c                s:    V P                   P                  4        R# Delegate to IBus.LookupTableN)r   r   rm   r$   r   r   ZTypingBoosterLookupTable.clearf  s    %%'r    c                rj   rk   r>   rD   rF   r   r   r   j  s     B B# Br    c                r|   r   )r   get_number_of_candidatesrm   r$   r   r   Z1TypingBoosterLookupTable.get_number_of_candidatesj  s    &&??AAr    c                r[   r   visibler   NboolrD   rF   r   r   r   n  s     < <$ <4 <r    c                <    V P                   P                  V4       R# r   )r   r   rO   r   rd   r   r   Z+TypingBoosterLookupTable.set_cursor_visiblen  s    227;r    c                rj   rk   r   rD   rF   r   r   r   r  s     ; ;4 ;r    c                r|   r   )r   is_cursor_visiblerm   r$   r   r   Z*TypingBoosterLookupTable.is_cursor_visibler  s    &&88::r    c                r[   r   rH   r   Nr   rD   rF   r   r   r   v  s     ; ; ; ;r    c                r   r   )r   set_cursor_posrO   rH   rd   r   r   Z'TypingBoosterLookupTable.set_cursor_posv  s    ..z:r    c                rj   rk   r   rD   rF   r   r   r   z       8 8 8r    c                r|   r   )r   get_cursor_posrm   r$   r   r   Z'TypingBoosterLookupTable.get_cursor_posz  s    &&5577r    c                r[   )r   r   r   Nr   rD   rF   r   r   r   ~  s     9 9s 9t 9r    c                r   r   )r   r   )rO   r   rd   r   r   Z&TypingBoosterLookupTable.set_page_size~  s    --i8r    c                rj   rk   r   rD   rF   r   r   r     s     7 7s 7r    c                r|   r   )r   get_page_sizerm   r$   r   r   Z&TypingBoosterLookupTable.get_page_size  s    &&4466r    c                r[   )r   wrap_aroundr   Nr   rD   rF   r   r   r     s     7 7T 7d 7r    c                r   r   )r   r   )rO   r   rd   r   r   Z"TypingBoosterLookupTable.set_round  s    ))+6r    c                rj   rk   r   rD   rF   r   r   r          3 34 3r    c                r|   r   )r   	get_roundrm   r$   r   r   Z"TypingBoosterLookupTable.get_round      &&0022r    c                r[   )r   r   r   Nr   rD   rF   r   r   r     s     = =3 =4 =r    c                r   r   )r   r   )rO   r   rd   r   r   Z(TypingBoosterLookupTable.set_orientation  s    //<r    c                rj   rk   r   rD   rF   r   r   r     s     9 9 9r    c                r|   r   )r   get_orientationrm   r$   r   r   Z(TypingBoosterLookupTable.get_orientation  s    &&6688r    c                r   )r   r   r   r   Nr>   r   r   rD   rF   r   r   r     s&     7 7s 7$)) 7 7r    c                s<    V P                   P                  W4       R# r   )r   r   )rO   r   r      &&&r   r   Z"TypingBoosterLookupTable.set_label  s    ))%6r    c                s:   < V ^8  d   QhRS[ RS[P                  /# r   r   r   r   rD   rF   r   r   r     s     8 8s 8tyy 8r    c                s8    V P                   P                  V4      # r   )r   	get_labelrO   r   rd   r   r   Z"TypingBoosterLookupTable.get_label  s    &&0077r    c                rj   rk   r   rD   rF   r   r   r     s     1 1 1r    c                r|   r   )r   page_uprm   r$   r   r   Z TypingBoosterLookupTable.page_up  s    &&..00r    c                rj   rk   r   rD   rF   r   r   r     s     3 3$ 3r    c                r|   r   )r   	page_downrm   r$   r   r   Z"TypingBoosterLookupTable.page_down  r   r    c                rj   rk   r   rD   rF   r   r   r     r   r    c                r|   r   )r   	cursor_uprm   r$   r   r   Z"TypingBoosterLookupTable.cursor_up  r   r    c                rj   rk   r   rD   rF   r   r   r     s     5 5T 5r    c                r|   r   )r   cursor_downrm   r$   r   r   Z$TypingBoosterLookupTable.cursor_down  s    &&2244r    c                8   < V ^8  d   QhRS[ P                  RR/# )r   r   r   Nr   r   rD   rF   r   r   r     s     7 7TYY 74 7r    c                r   r   )r   append_candidate)rO   r   rd   r   r   Z)TypingBoosterLookupTable.append_candidate  s    006r    c                rj   rk   r{   rD   rF   r   r   r     s      ' r    c                ro   )The state of the lookup table)r   rm   r$   r   stateTypingBoosterLookupTable.state  s     {{r    c                r[   r   valuer   Nr   rD   rF   r   r   r     s     1 1+ 1 1r    c                sN    Wn         V\        P                  8w  d
   RV n        R# R# )r   rB   N)r   r{   r   r   rO   r   rd   r   r   r     s%     $777.0D+ 8r    c                rj   rk   r   rD   rF   r   r   r     s     $ $ $r    c                ro   )8Whether the lookup table has been enabled by typing Tab.r   rm   r$   r   enabled_by_tab'TypingBoosterLookupTable.enabled_by_tab  s     ###r    c                r[   r   r   rD   rF   r   r   r     s     % %D %T %r    c                    Wn         R# )r   Nr   r   rd   r   r   r     s
      %r    c                rj   rk   r   rD   rF   r   r   r     s     2 2d 2r    c                ro   )FWhether the lookup table has been enabled by typing enough characters.r   rm   r$   r   enabled_by_min_char_complete5TypingBoosterLookupTable.enabled_by_min_char_complete  s     111r    c                r[   r   r   rD   rF   r   r   r     s     3 3$ 34 3r    c                r   )r   Nr   r   rd   r   r   r     s
     .3*r    c                rj   rk   r   rD   rF   r   r   r     s     / /3 /r    c                ro   )3Phrase for which related candidates were looked up.r   rm   r$   r   related_candidates_phrase2TypingBoosterLookupTable.related_candidates_phrase       ...r    c                r[   r   phraser   Nr   rD   rF   r   r   r     s     1 1 1 1r    c                r   )r   Nr   rO   r   rd   r   r   r     s
     +1'r    c                rj   rk   r   rD   rF   r   r   r     s       r    c                ro   )z&Get whether the lookup table is hiddenr   rm   r$   r   hiddenTypingBoosterLookupTable.hidden  s     ||r    c                r[   )r   r   r   Nr   rD   rF   r   r   r     s      T d r    c                r   )z&Set whether the lookup table is hiddenNr   )rO   r   rd   r   r   r     s	     r    c                4   < V ^8  d   QhRS[ P                  /# rk   )r   r   rD   rF   r   r   r     s     ' '4#3#3 'r    c                ro   )z$Return the internal IBus.LookupTable)r   rm   r$   r   ibus_lookup_tableZ*TypingBoosterLookupTable.ibus_lookup_table       &&&r    )r   r   r   r   r   r   N)&rR   rS   r,   rT   rU   r   r   ZSYSTEMre   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   ry   r   rz   r   r   r   r   r   rV   rW   rX   rY   r   r   r   )  s    , ,0,<,<,C,C9 9P( (B B< <; ;; ;8 89 97 77 73 3= =9 97 78 81 13 33 35 57 7   \\1 1 $ $ % % 2 2 "((3 )3 / / %%1 &1   ]]  ' 'r    r   c                   s   a  ] tR tRt o RtV 3R lR lt]V 3R lR l4       t]P                  V 3R lR l4       t]V 3R	 lR
 l4       t	]	P                  V 3R lR l4       t	Rt
V tR# )TypingBoosterAuxiliaryTexti  zTracks the current contents and visibility of the auxiliary text.

This class encapsulates the state of the auxiliary text, ensuring that
the content and visibility are always synchronized with the displayed text.
c                rC   r   r'   rD   rF   r   r   'TypingBoosterAuxiliaryText.__annotate__  s     A A$ Ar    c                s\    R V n         \        P                  P                  R4      V n        R# r   )_visibler   r   r   _contentrm   r$   r   re   Z#TypingBoosterAuxiliaryText.__init__  s    ##'99#<#<R#@r    c                rj   rk   r   rD   rF   r   r   r            r    c                ro   )z)Get whether the auxiliary text is visibler   rm   r$   r   r   "TypingBoosterAuxiliaryText.visible       }}r    c                r[   r   r   rD   rF   r   r   r             t    r    c                r   )z(Set whether the auxiliary text is hiddenNr   r   rd   r   r   r     	      r    c                r   rk   r   rD   rF   r   r   r             r    c                ro   )z-Get the current content of the auxiliary textr   rm   r$   r   content"TypingBoosterAuxiliaryText.content  r   r    c                r   r   r   r   Nr   rD   rF   r   r   r             tyy  T  r    c                r   )z-Set the current content of the auxiliary textNr   rO   r   rd   r   r   r     r   r    )r   r   N)rR   rS   r,   rT   rU   re   ry   r   rz   r   rV   rW   rX   rY   r   r   r     sn     
A A   ^^      ^^   r    r   c                   s  a  ] tR tRt o RtV 3R lR lt]V 3R lR l4       t]P                  V 3R lR l4       t]V 3R	 lR
 l4       t	]	P                  V 3R lR l4       t	]V 3R lR l4       t
]
P                  V 3R lR l4       t
]V 3R lR l4       t]P                  V 3R lR l4       t]V 3R lR l4       tRtV tR# )TypingBoosterPreeditTexti	  zTracks the current contents and visibility of the preedit text.

This class encapsulates the state of the preedit text, ensuring that
the content and visibility are always synchronized with the displayed text.
c                rC   r   r'   rD   rF   r   r   %TypingBoosterPreeditText.__annotate__  s     < <$ <r    c                s    \         P                  P                  R 4      V n        ^ V n        RV n        \         P                  P                  V n        R# )rB   FN)	r   r   r   r   _cursor_posr   PreeditFocusModeCLEAR_focus_moderm   r$   r   re   Z!TypingBoosterPreeditText.__init__  s;    #'99#<#<R#@ !# $ 5 5 ; ;r    c                r   rk   r   rD   rF   r   r   r     r   r    c                ro   )z+Get the current content of the preedit textr   rm   r$   r   r    TypingBoosterPreeditText.content  r   r    c                r   r   r   rD   rF   r   r   r     r   r    c                r   )z+Set the current content of the preedit textNr   r   rd   r   r   r     r   r    c                rj   rk   r   rD   rF   r   r   r              C  r    c                ro   )zGet the preedit cursor positionr   rm   r$   r   rH   #TypingBoosterPreeditText.cursor_pos       r    c                r[   r   r   rD   rF   r   r   r   %       & &S &T &r    c                r   )zSet the preedit cursor positionNr   r   rd   r   rH   r   $  
     &r    c                rj   rk   r   rD   rF   r   r   r   *  r   r    c                ro   )z'Get whether the preedit text is visibler   rm   r$   r   r    TypingBoosterPreeditText.visible)  r   r    c                r[   r   r   rD   rF   r   r   r   /  r   r    c                r   )z&Set whether the preedit text is hiddenNr   r   rd   r   r   r   .  r   r    c                rj   rk   r   rD   rF   r   r   r   4  r   r    c                ro   )z.Get the current focus mode of the preedit textr   rm   r$   r   
focus_mode#TypingBoosterPreeditText.focus_mode3  r   r    c                r[   )r   r  r   Nr   rD   rF   r   r   r   9  r   r    c                r   )z.Set the current focus mode of the preedit textNr   )rO   r  rd   r   r  r  8  r   r    c                rj   rk   r   rD   rF   r   r   r   >  s     " "# "r    c                s.    V P                   P                  # )z/Get the content of the preedit text as a string)r   r   rm   r$   r   text_strZ!TypingBoosterPreeditText.text_str=  s     }}!!!r    )r   r   r   r   N)rR   rS   r,   rT   rU   re   ry   r   rz   rH   r   r  r  rV   rW   rX   rY   r   r   r   	  s     
< <   ^^        & &   ^^        & & " "r    r   c                   sn   a a ] tR tRt oRtERV3R lV 3R llltV3R lV 3R lltV3R lV 3R lltV3R	 lV 3R
 lltV3R lV 3R llt	V3R lV 3R llt
V3R lV 3R lltV3R lV 3R lltV3R lV 3R lltV3R lV 3R lltV3R lV 3R llt]V3R lR l4       t]V3R lR l4       tV3R lR ltV3R lR  ltV3R! lR" ltV3R# lR$ ltV3R% lR& ltV3R' lR( ltV3R) lR* ltV3R+ lR, ltV3R- lR. ltV3R/ lR0 ltV3R1 lR2 ltV3R3 lR4 ltERV3R5 lR6 lltERV3R7 lR8 llt V3R9 lR: lt!V3R; lR< lt"V3R= lR> lt#V3R? lR@ lt$V3RA lRB lt%V3RC lRD lt&V3RE lRF lt'V3RG lRH lt(V3RI lRJ lt)V3RK lRL lt*V3RM lRN lt+V3RO lRP lt,V3RQ lRR lt-V3RS lRT lt.V3RU lRV lt/V3RW lRX lt0V3RY lRZ lt1V3R[ lR\ lt2V3R] lR^ lt3ERV3R_ lR` llt4ERV3Ra lRb llt5V3Rc lRd lt6ERV3Re lRf llt7V3Rg lRh lt8ERV3Ri lRj llt9V3Rk lRl lt:V3Rm lRn lt;V3Ro lRp lt<ERV3Rq lRr llt=ERV3Rs lRt llt>ERV3Ru lRv llt?ERV3Rw lRx llt@ERV3Ry lRz lltAERV3R{ lR| lltBV3R} lR~ ltC]DP                  P                  3V3R lR lltGV3R lR ltHV3R lR ltIV3R lR ltJV3R lR ltKV3R lV 3R lltLV3R lR ltMV3R lR ltNV3R lR ltOV3R lR ltPV3R lR ltQV3R lR ltRV3R lR ltSV3R lR ltTV3R lR ltUV3R lR ltVV3R lR ltWV3R lR ltXV3R lR ltYERV3R lR lltZERV3R lR llt[V3R lR lt\V3R lR lt]ERV3R lV 3R lllt^ERV3R lV 3R lllt_V3R lR lt`V3R lR ltaV3R lR ltbERV3R lR lltcERV3R lR lltdV3R lR lteERV3R lR lltfV3R lR ltgERV3R lR llthV3R lR ltiERV3R lR lltjERV3R lR lltkV3R lR ltlERV3R lR lltmERV3R lR lltnV3R lR ltoERV3R lR lltpERV3R lR lltqV3R lR ltrERV3R lR lltsERV3R lR llttV3R lR ltuV3R lR ltvV3R lR ltwERV3R lR lltxERV3R lR lltyV3R lR ltzERV3R lR llt{V3R lR lt|ERV3R lR llt}V3R lR lt~ERV3R lR lltERV3R lR lltV3R lR ltERV3R lR lltERV3R lR lltV3R lR ltERV3R lR lltERV3R lR lltV3R lER  ltERV3ER lER lltERV3ER lER lltV3ER lER ltERV3ER lER lltV3ER	 lER
 ltERV3ER lER lltERV3ER lER lltV3ER lER ltERV3ER lER lltV3ER lER ltERV3ER lER lltV3ER lER ltERV3ER lER lltV3ER lER ltERV3ER lER lltV3ER lER  ltERV3ER! lER" lltV3ER# lER$ ltERV3ER% lER& lltV3ER' lER( ltERV3ER) lER* lltV3ER+ lER, ltERV3ER- lER. lltV3ER/ lER0 ltERV3ER1 lER2 lltV3ER3 lER4 ltERV3ER5 lER6 lltV3ER7 lER8 ltERV3ER9 lER: lltV3ER; lER< ltERV3ER= lER> lltV3ER? lER@ ltERV3ERA lERB lltV3ERC lERD ltERV3ERE lERF lltV3ERG lERH ltERV3ERI lERJ lltV3ERK lERL ltERV3ERM lERN lltV3ERO lERP ltERV3ERQ lERR lltV3ERS lERT ltERV3ERU lERV lltV3ERW lERX ltERV3ERY lERZ lltV3ER[ lER\ ltERV3ER] lER^ lltV3ER_ lER` ltERV3ERa lERb lltV3ERc lERd ltERV3ERe lERf lltV3ERg lERh ltERV3ERi lERj lltV3ERk lERl ltERV3ERm lERn lltV3ERo lERp ltERV3ERq lERr lltV3ERs lERt ltERV3ERu lERv lltV3ERw lERx ltERV3ERy lERz lltV3ER{ lER| ltERV3ER} lER~ lltV3ER lER ltERV3ER lER lltV3ER lER ltERV3ER lER lltV3ER lER ltERV3ER lER lltV3ER lER ltERV3ER lER lltV3ER lER ltERV3ER lER lltERV3ER lER lltV3ER lER ltERV3ER lER lltERV3ER lER lltV3ER lER ltERV3ER lER lltV3ER lER ltERV3ER lER lltV3ER lER ltERV3ER lER lltV3ER lER ltERV3ER lER lltV3ER lER ltERV3ER lER lltV3ER lER ltERV3ER lER lltV3ER lER ltERV3ER lER lltV3ER lER ltERV3ER lER lltV3ER lER ltERV3ER lER lltV3ER lER ltERV3ER lER llt]ERV3ER lER ll4       tERV3ER lER lltV3ER lER ltV3ER lER ltERV3ER lER lltV3ER lER ltERV3ER lER lltV3ER lER ltERV3ER lER lltV3ER lER ltERV3ER lER lltV3ER lER ltERV3ER lER lltV3ER lER ltERV3ER lER lltV3ER lER ltERV3ER lER lltV3ER lER ltV3ER lV 3ER lltV3ER lER ltV3ER lER ltV3ER lER ltV3ER lER lEt V3ER lER lEtV3ER lER lEtV3ER lER lEtV3ER lER lEtV3ER lER lEtV3ER lER lEtV3ER lER lEtV3ER lER  lEtV3ER lER lEt	V3ER lER lEt
V3ER lER lEtV3ER lER lEtV3ER	 lER
 lEtV3ER lER lEtV3ER lER lEtV3ER lER lEtV3ER lER lEtV3ER lER lEtV3ER lV 3ER llEtERV3ER lV 3ER lllEtV3ER lER lEtV3ER lV 3ER llEtV3ER lER lEtV3ER lER  lEtV3ER! lER" lEtV3ER# lER$ lEtV3ER% lER& lEtV3ER' lER( lEtV3ER) lER* lEtV3ER+ lER, lEtV3ER- lER. lEtV3ER/ lER0 lEt V3ER1 lER2 lEt!V3ER3 lER4 lEt"V3ER5 lER6 lEt#V3ER7 lER8 lEt$V3ER9 lER: lEt%V3ER; lER< lEt&V3ER= lER> lEt'V3ER? lV 3ER@ llEt(V3ERA lERB lEt)V3ERC lERD lEt*V3ERE lERF lEt+V3ERG lERH lEt,V3ERI lERJ lEt-V3ERK lERL lEt.V3ERM lERN lEt/V3ERO lERP lEt0V3ERQ lERR lEt1V3ERS lERT lEt2V3ERU lERV lEt3V3ERW lERX lEt4V3ERY lERZ lEt5V3ER[ lER\ lEt6V3ER] lER^ lEt7V3ER_ lER` lEt8V3ERa lERb lEt9V3ERc lERd lEt:V3ERe lERf lEt;V3ERg lERh lEt<V3ERi lERj lEt=V3ERk lERl lEt>V3ERm lERn lEt?V3ERo lERp lEt@V3ERq lERr lEtAV3ERs lERt lEtBV3ERu lERv lEtCV3ERw lERx lEtDV3ERy lERz lEtEV3ER{ lER| lEtFV3ER} lER~ lEtGV3ER lER lEtHV3ER lER lEtIV3ER lER lEtJERV3ER lER llEtKV3ER lER lEtLV3ER lV 3ER llEtMERV3ER lER llEtNV3ER lER lEtOV3ER lV 3ER llEtPERV3ER lV 3ER lllEtQV3ER lER lEtRV3ER lER lEtSV3ER lV 3ER llEtTV3ER lER lEtUV3ER lER lEtVV3ER lER lEtWERV3ER lER llEtXV3ER lER lEtYV3ER lER lEtZV3ER lER lEt[V3ER lER lEt\V3ER lER lEt]V3ER lER lEt^V3ER lER lEt_V3ER lER lEt`V3ER lER lEtaV3ER lER lEtbV3ER lER lEtcERV3ER lER llEtdERV3ER lER llEteV3ER lER lEtfV3ER lER lEtgEREthVEtiV ;Etj# (  r   iB  z'The IBus Engine for ibus-typing-boosterc                sP   < V ^8  d   QhRS[ P                  RS[RS[RS[RS[RR/# )r   busobj_pathdatabaseengine_name	unit_testr   N)r   ZBusr   r   r   rD   rF   r   r    TypingBoosterEngine.__annotate__E  sS     w( w(w( w( 	w(
 w( w( )-w(r    c                s:0  < \         P                  R WW4V4       \         P                  RRP                  \        \        \
        4      4      4       \        \        P                  P                  R4      '       d7   \        SV `-  VP                  4       VRR7       \         P                  R4       M4\        SV `-  VP                  4       VR7       \         P                  R4       W@n        R	V n        R	V n        R
pV P                  R8w  d    \         P"                  P%                  V P                  4      pV'       g   \'        R4      hVP)                  R4      V n        VP)                  R4      V n        RV P                   RV P                   R2p\0        P2                  ! RVR7      V n        \         P6                  ! 4       V n        \         P:                  ! 4       V n        WPn        ^ V n         ^ V n!        \E        4       V n#        \I        4       V n%        Wn&        W0n'        RV n(        RV n)        V PU                  4       V n+        / V n,        / V n-        \        P\                  ! 4       V n/        / V n0        / V n1        / V n2        / V n3        / V n4        / V n5        / V n6        / V n7        \        P\                  ! 4       V n8        / V n9        / V n:        \        P\                  ! 4       V n;        \y        4       V n=        . V n>        V PV                  R,          R,          V n?        V PV                  R,          R,          V n@        RV nA        RV nB        V PV                  R,          R,          V nC        V PV                  R,          R,          V nD        RV nE        . V nF        R	V nG        / V nH        R	V nI        RV nJ        RV nK        \        P                  ! 4       V nN        \        P                  ! ^PRRRRRR7      V nQ        ^ V nR        V PV                  R,          R,          V nS        \        V P                  ^ 4      V nS        \        V P                  \         P                  4      V nS        \         P                  RV P                  4       V PV                  R ,          R,          V nW        \         P                  R!V P                  4       V PV                  R",          R,          V nX        V P                  V P                  4      V nZ        V PV                  R#,          R,          V n[        V PV                  R$,          R,          V n\        RV n]        V PV                  R%,          R,          V n^        RV n_        V PV                  R&,          R,          V n`        R'V na        V PV                  R(,          R,          V nb        \        V P                  ^ 4      V nb        \        V P                  ^	4      V nb        V PV                  R),          R,          V nc        \        V P                  ^ 4      V nc        \         P                  R*V P                  4       V PV                  R+,          R,          V nd        \        V P                  ^4      V nd        \        V P                  ^	4      V nd        V PV                  R,,          R,          V ne        V PV                  R-,          R,          V nf        V PV                  R.,          R,          V ng        V PV                  R/,          R,          V nh        V PV                  R0,          R,          V ni        V PV                  R1,          R,          V nj        RV nk        V PV                  R2,          R,          V nl        V PV                  R3,          R,          V nm        V PV                  R4,          R,          V nn        V PV                  R5,          R,          V no        V PV                  R6,          R,          V np        V PV                  R7,          R,          V nq        RV nr        RV ns        V PV                  R8,          R,          V nt        V PV                  R9,          R,          V nu        V PV                  R:,          R,          V nv        V PV                  R;,          R,          V nw        V PV                  R<,          R,          V nx        V PV                  R=,          R,          V ny        V PV                  R>,          R,          V nz        V PV                  R?,          R,          V n{        V PV                  R@,          R,          V n|        V PV                  RA,          R,          V n}        V PV                  RB,          R,          V n~        V PV                  RC,          R,          V n        V PV                  RD,          R,          V n        \         EP                  ! V EP                   4      V n        V PV                  RE,          R,          V n        V PV                  RF,          R,          V n        \         EP                  ! V EP                  4      V n        V PV                  RG,          R,          V n        V PV                  RH,          R,          V n        \         EP                  ! V EP                  4      V n        V PV                  RI,          R,          V n        V PV                  RJ,          R,          V n        \         EP                  ! V EP                  4      V n        V PV                  RK,          R,          V n        V PV                  RL,          R,          V n        \         EP                  ! V EP                  4      V n        V PV                  RM,          R,          V n        V PV                  RN,          R,          V n        \         EP                  ! V EP                   4      V n        V PV                  RO,          R,          V n        V PV                  RP,          R,          V n        \         EP                  ! V EP&                  4      V n        V PV                  RQ,          R,          V n        V PV                  RR,          R,          V n        V PV                  RS,          R,          V n        V PV                  RT,          R,          V n        V PV                  RU,          R,          V n        R	V n        / V n        V EP9                  V PV                  RV,          R,          RRW7       V PV                  RX,          R,          V n        V PV                  RY,          R,          V n        V PV                  RZ,          R,          V n        RV n        R[V n        V PV                  R\,          R,          V n        / V n        RV n        RV n        RV n        V EPO                  V PV                  R],          R,          RRW7       . V n        V EPS                  V PV                  R^,          R,          RRW7       / V n        V PV                  R_,          R,          V n        V EPV                  '       d!   V PV                  R`,          R,          V ns        MV EPY                  RRRW7       V PV                  Ra,          R,          V n        RV n        R	V n        V PV                  Rb,          R,          V n        V EPc                  V PV                  Rc,          R,          RRW7       . V n        V PV                  Rd,          R,          p	\         EPf                  ! V	4      V n        ReP                  V EPd                  4      V	8w  dX   V P4                  EPi                  RdE\j        EPl                  EPo                  ReP                  V EPd                  4      4      4       V PN                  EPp                  EPs                  V EPd                  Rf,          4       \         EPt                  ! V EPd                  4      V n        V P                  '       d   V P                  ^8  d#   \         EPy                  RgV EPd                  4       E\z        EP|                  ! V EPd                  V P                  V P                  Rh7      V n(        V P                  ^8  d   \         EPy                  Ri4       MRV n(        V PV                  Rj,          R,          p
\         EP~                  ! V
4      V n>        ReP                  V P|                  4      V
8w  dW   V P4                  EPi                  RjE\j        EPl                  EPo                  ReP                  V P|                  4      4      4       RV n        RV n        ^ V n        E\        EP                  ! 4       V n        . V n        . V n        ^ V n        R	V n        R	V n        R	V n        RV n        / V n        / V n        R	V n        / V n        V EP                  4        . V n        . V n        RkV n        RkRlRmRnRoRpRq /RmRlRrRnRoRpRs /RtRlRrRnRmRpRu /RrRlRoRnRmRpE\        \        Rr4      /RoRlRmRnRrRpE\        \        Ro4      //V n        E\        V P                  V P                  Rv7      V n        \         EP                  ! 4       EP                  V P                  / 4      EP                  RwR	4      p\         P                  RxVV PV                  Ry,          R,          4       VV PV                  Ry,          R,          8w  d,   \         P                  Rz4       \         EP                  ! 4        R{R|^ RwV PV                  R},          R,          R~E\        R4      /RR|^RwV PV                  Ry,          R,          R~E\        R4      //V n5        RRR~E\        R4      RE\        R4      RE\        V EPF                  R,          4      RV Pj                  /V n4        RR|^ RwE\        E\        ,           R~E\        R4      /RR|^RwE\        E\        ,           R~E\        R4      //V n1        RRR~E\        R4      RE\        R4      RE\        V EPF                  R,          4      RV Pb                  /V n0        RR|^ RwE\        E\        ,           R~E\        R4      /RR|^RwE\        E\        ,           R~E\        R4      //V n3        RRR~E\        R4      RE\        R4      RE\        V EPF                  R,          4      RV Pf                  /V n2        V EP                  4        V EP                  4        V EP                  4        \        EP                  \        EP                  \        EP                  \        EP                  \        EP                  \        EP                  \        EP                  \        EP                  \        EP                  \        EP                  \        EP                  \        EP                  \        EP                  \        EP                  \        EP                  \        EP                  \        EP                  \        EP                  3pV\        EP                  \        EP                  \        EP                  \        EP                  \        EP                  \        EP                  \        EP                  \        EP                  3,           V n        E\        4       V En        E\        4       V En        V EP                  RV EP                  4       RV En        V P4                  EP                  RV EP                  4       V EP                  4        \         P                  RE\        EP                  ! 4       4       \        EP                  ! V PN                  EP                  R7      pVEP                  4        R#   \&         d2   p\         P+                  RYHP,                  P.                  T4       h Rp?ii ; i)z\TypingBoosterEngine.__init__(bus=%s, obj_path=%s, database=%s, engine_name=%s, unit_test=%s)zibus version = %s.has_focus_idT)
connectionobject_pathr  zThis ibus version has focus id.)r  r  z+This ibus version does *not* have focus id.rB   z,/org/freedesktop/ibus/engine/typing-booster/typing-boosterzInvalid engine name.Zlangr}   z /org/freedesktop/ibus/engine/tb//z&Failed to match engine_name %s: %s: %sN*org.freedesktop.ibus.engine.typing-booster)schemapathaichatenableuseraisystemmessageu   🦙ollamamodelollamamaxcontextauxF)ZwidthZexpand_tabsZreplace_whitespaceZdrop_whitespaceZbreak_long_wordsZbreak_on_hyphenscandidatesdelaymillisecondsz&self._candidates_delay_milliseconds=%sibuseventsleepsecondsz!self._ibus_event_sleep_seconds=%s
ibuskeymapuseibuskeymapwordpredictionsemojipredictionsunicodedataalli'  mincharcomplete
debuglevelzself._debug_level=%spagesizelookuptableorientationpreeditunderlinepreeditstyleonlywhenlookupshownumberofcandidatesshowstatusinfoinauxshowrawinputautoselectcandidate	tabenabledisableinterminalsasciidigitsshowfinalformofftherecordavoidforwardkeyeventprefercommitarrowkeysreopenpreeditemojitriggercharacters
emojistyleautocommitcharactersrememberlastusedpreeditimeaddspaceoncommitinlinecompletion
recordmodeautocapitalizecolorpreeditspellcheckcolorpreeditspellcheckstringcolorinlinecompletioncolorinlinecompletionstringcolorcomposepreviewcolorcomposepreviewstringcolorm17npreeditcolorm17npreeditstringcoloruserdbcoloruserdbstringcolorspellcheckcolorspellcheckstringcolordictionarycolordictionarystringlabeluserdblabeluserdbstringlabelspellchecklabelspellcheckstringlabeldictionarylabeldictionarystringupdate_gsettingsflagdictionary	labelbusylabelbusystringu   🎙️googleapplicationcredentialskeybindingsautosettingsrememberinputmode	inputmodesoundbackend
errorsounderrorsoundfile
dictionary,NNNz'Instantiate EmojiMatcher(languages = %sZ	languagesZunicode_data_allZvariation_selectorzEmojiMatcher() instantiated.inputmethodorignext
capitalizepreviousr~   functionc                 r&   r:   r'   xr$   r   <lambda>.TypingBoosterEngine.__init__.<locals>.<lambda>  s    ar    upperc                 sX    \        \        R 4      ! V R,          4      V R,          ,           # )rb  N   Nrk  NN)r/   r   re  r$   r   rg  rh    s&    g'''(u'.01"'6r    titlec                 sV    \        \        R 4      ! \        P                  ! V 4      4      # )rm  )r/   r   itb_util(normalize_nfc_and_composition_exclusionsre  r$   r   rg  rh    s#    g'""*"S"STU"V'Xr    )r   r   symbolz$Cached symbol: %r Current symbol: %rinputmodetruesymbolz3Cached symbol is outdated, call `ibus write-cache`.InputMode.Offnumberinputmodefalsesymbolr   ZOffInputMode.OnZOnkey	InputModez
Input modetooltipz2Here you can switch ibus-typing-booster on or off.shortcut_hinttoggle_input_mode_on_offsub_propertieszEmojiPredictionMode.OffzEmojiPredictionMode.OnEmojiPredictionModez%Unicode symbols and emoji predictionstoggle_emoji_predictionzOffTheRecordMode.OffzOffTheRecordMode.OnOffTheRecordModezOff the record modetoggle_off_the_recordzset-surrounding-textZchangedz<*** ibus-typing-booster %s initialized, ready for input: ***)target(  r1   infojoinZmapr   IBUS_VERSIONZhasattrr   EngineZpropssuperre   Zget_connection_engine_name_m17n_ime_lang_m17n_ime_namern  ZM17N_ENGINE_NAME_PATTERNsearch
ValueErrorgroup	exception	__class__rR   r   Settings
_gsettingsKeyvalsToKeycodes_keyvals_to_keycodesZComposeSequences_compose_sequences
_unit_test_input_purpose_input_hintsr   _current_auxiliary_textr   _current_preedit_text_busr  emoji_matcher_setup_process_init_settings_dict_settings_dict
_prop_dict_sub_props_dictPropListmain_prop_listemoji_prediction_mode_menu emoji_prediction_mode_propertiesoff_the_record_mode_menuoff_the_record_mode_propertiesinput_mode_menuinput_mode_propertiesdictionary_menudictionary_properties#dictionary_sub_properties_prop_listpreedit_ime_menupreedit_ime_properties$preedit_ime_sub_properties_prop_listrZ   _client_info_current_imes_ai_chat_enable_ai_system_message_ollama_client_ollama_server_label_ollama_model_ollama_max_context_ollama_response_style_ollama_messages_ollama_selection_text_ollama_prompt_ollama_response_ollama_chat_query_thread_ollama_chat_query_errorrK   rL   _ollama_stop_eventtextwrapZTextWrapper_ollama_aux_wrapper_timeout_source_id_candidates_delay_millisecondsmaxminZ
UINT32_MAX_ibus_event_sleep_seconds_ibus_keymapnew_ibus_keymap_ibus_keymap_object_use_ibus_keymap_word_predictions_temporary_word_predictions_emoji_predictions_temporary_emoji_predictions_unicode_data_all_emoji_match_limit_min_char_complete_debug_level
_page_size_lookup_table_orientation_preedit_underline_preedit_style_only_when_lookup_show_number_of_candidates#_show_status_info_in_auxiliary_text_show_raw_input_is_candidate_auto_selected_auto_select_candidate_tab_enable_disable_in_terminals_ascii_digits_show_final_form_off_the_record_hide_input_input_mode_avoid_forward_key_event_prefer_commit_arrow_keys_reopen_preedit_emoji_trigger_characters_emoji_style_auto_commit_characters_remember_last_used_preedit_ime_add_space_on_commit_inline_completion_record_mode_auto_capitalize_color_preedit_spellcheck _color_preedit_spellcheck_stringcolor_string_to_argb_color_preedit_spellcheck_argb_color_inline_completion_color_inline_completion_string_color_inline_completion_argb_color_compose_preview_color_compose_preview_string_color_compose_preview_argb_color_m17n_preedit_color_m17n_preedit_string_color_m17n_preedit_argb_color_userdb_color_userdb_string_color_userdb_argb_color_spellcheck_color_spellcheck_string_color_spellcheck_argb_color_dictionary_color_dictionary_string_color_dictionary_argb_label_userdb_label_userdb_string_label_spellcheck_label_spellcheck_string_label_dictionary_label_dictionary_string_label_dictionary_dictset_label_dictionary_string_flag_dictionary_label_busy_label_busy_string_label_speech_recognition _label_speech_recognition_string_google_application_credentials_keybindings_hotkeys"_normal_digits_used_in_keybindings"_keypad_digits_used_in_keybindingsset_keybindings_autosettingsset_autosettings_autosettings_revert_remember_input_modeset_input_mode_sound_backend_error_sound_object_error_sound_file_error_soundset_error_sound_file_dictionary_namesdictionaries_str_to_list	set_valuer   Variant
new_stringhunspell_objset_dictionary_names	get_flags_dictionary_flagsdebug	itb_emojiEmojiMatcherinput_methods_str_to_list_commit_happened_after_focus_in	_prev_key_translated_key_statem17n_translitTransliterationParts_m17n_trans_parts_typed_compose_sequence_typed_string_typed_string_cursor	_p_phrase
_pp_phrase_ppp_phrase_new_sentence_transliterated_strings&_transliterated_strings_before_compose$_transliterated_strings_compose_part_transliterators_init_transliterators_candidates_candidates_case_mode_orig_current_case_moder/   _case_modesr   _lookup_tableZibus_read_cachegetibus_write_cacher%   r0   MODE_OFF_SYMBOLEMOJI_PREDICTION_MODE_SYMBOLMODE_ON_SYMBOLOFF_THE_RECORD_MODE_SYMBOL_update_dictionary_menu_dicts_update_preedit_ime_menu_dicts_init_properties	KEY_RightKEY_KP_RightKEY_LeftKEY_KP_LeftZKEY_EndZ
KEY_KP_EndZKEY_HomeZKEY_KP_HomeZKEY_DownZKEY_KP_DownZKEY_UpZ	KEY_KP_UpZKEY_Page_DownZKEY_KP_Page_DownZKEY_KP_NextZKEY_Page_UpZKEY_KP_Page_UpZKEY_KP_Prior	KEY_spaceKEY_Tab
KEY_ReturnKEY_KP_Enter
KEY_DeleteKEY_KP_DeleteKEY_BackSpaceZ
KEY_Escape_commit_trigger_keysrA   _surrounding_text_surrounding_text_oldZconnect_on_set_surrounding_text!_is_context_from_surrounding_text_on_gsettings_value_changed_clear_input_and_update_uiitb_versionZget_versionThreadZcleanup_databasestart)rO   r  r  r  r  r  Zschema_pathmatchr2   r[  r_  Zcached_input_mode_true_symbolZkeys_which_select_with_shiftZcleanup_database_threadr  s   &&&&&&        r   re   ZTypingBoosterEngine.__init__E  sJ    	, 8)		=
 	'#c<2H)IJ4;;$$n55G--/$!  # KK9:G--/$  & KKEF'  D 00 99@@))+$%;<<&+kk&&9#&+kk&&9#A"&"5"5!6a8K8K7LA O ,,? %-$>$>$@!"*";";"=##$!"&( 	$ %& 	"	 ?C?C"668469;-1]]_:<'?A-8:%>@+/157"/157"BF--/00268#CG==?1(2(*%)%8%8&"&$'+':':(%('DH$*!"&"5"5#!##(,(;(;)  &)( AF#68&(#.0 "EI&(-%3<??3D9A9M9M# !!:#  ()373F3F)4++143+.1///4+.1//1D1D/F+<77	9 150C0C#1%%+1-&79W9WX!%!4!4\!B6!J  !2!23 	 &*&9&9'#'% (,':':(%('+0((,(;(;)  &)(,1)'+':':($(&"('+':':(%('"%d&=&=q"A"%d&=&=q"A!%!4!4\!B6!J 1 115*D,=,=>#22:>vFdooq1dooq1.2.A.A$/&&,/.& (,':':(  &(( 6:5H5H(6**062, 150C0C$1&&,1.' :>9L9L!:##):+0 %)$7$7%"%$ ,1(+/+>+>!,##),+# "&!4!4""! ,0+>+> ,""(,*" $(#6#6}#Ef#M&*&9&9/&J6&R%)%8%8&"&$ !.2.A.A"/$$*/,% %)$7$7%"%$ 150C0C$1&&,1.' /3.A.A$/&&,/.& "&!4!4" "" -1,?,?"-$$*-,$ 6:5H5H(6**062, +/*=*=+  &+(! (,':':(  &(( "&!4!4\!B6!J&*&9&9'$'& 04/B/B$0&&,0.& 6:5H5H*6,,264-.6.K.K11/3+ /3.A.A#/%%+/-% 594G4G)5++153,-5-J-J00.2* -1,?,?!-##)-+# 372E2E'3))/31*+3+H+H..,0( *.)<)<*  &*(  04/B/B$0&&,0.'(0(E(E++)-% $(#6#6}#Ef#M)-)<)<*!!'*)!"*"?"?%%#' (,':':(%(' .2-@-@#.%%+.-%&.&C&C))'+# (,':':(%(' .2-@-@#.%%+.-%&.&C&C))'+# $(#6#6}#Ef#M)-)<)<*!!'*)! (,':':(%(' .2-@-@#.%%+.-% (,':':(%(' .0%68#(( 78@" 	) 	$ '+&9&9'$'& "&!4!4[!A&!I'+':':(%(' 04&5>-484G4G*5,,254, 354827/27/.v6 	 	P :</7" 	 	$ 57!*.*=*=+!!'+)!$$$#22;?GDt<#'#6#6~#Fv#NDH !#"&"5"5l"CF"K!! 01&9" 	" 	$ -/((6v>
!)!B!B:!N88D**+z9 OO%%''1G1G(HIK 	""77""1%	'191C1C""2$ ###  1$F!335!*!7!700!%!7!7#'#4#4"6D   1$;<!%D ))-8@%??L88D&&';6 OO%%''1C1C(DEG 05,6:%&"..0 	24$(*$%!"79$FH3461IK""$?ANP'"( GK) G 67
 L  XY LGC13 GGC137
B 8Poo6688 )1(@(@(B(F(Fr)##&3x#4 	&:1''(=>vF	H *""#89&ABKKEG%%' !$--.DEfM5
 !$--.CDVL4&
"6 ;Q|_qMNT!!"<=?d88 
 &!/,HH5(
 %!.+GG4'1
- (Q>?56T!!";<>dCC+
' #!/,FF5%
 "!.+EE4$/
+ %Q,-q./T$"3"34K"LMdAA)
% 	**,++- NND--MM4++LL$//MM4++MM4++KK 5 5t7G7Gd1143D3D(F$ %ANNDLLOOT..OOT//	D1 %1!
 "1!2%4%6"+T-J-JK16.	4+K+KL'')J##%	' #,"2"2==11#3%%'a    <!9!95B 	s'   0A_ >AA_ _A`_),A``A`c                rC   r   r'   rD   rF   r   r   r	  ~  s     * *4 *r    c                F   < \         SV `  4        R V P                  n        R# FN)r  show_lookup_tablerA  r   rO   r     &r   rc  Z%TypingBoosterEngine.show_lookup_table~  s    !#$)!r    c                rC   r   r'   rD   rF   r   r   r	    s     ) )4 )r    c                ra  TN)r  hide_lookup_tablerA  r   rd  re  r   rg  Z%TypingBoosterEngine.hide_lookup_table  s    !#$(!r    c                sT   < V ^8  d   QhRS[ S[P                  S[3,          RS[RR/# )r   lookup_tabler   r   N)r   r   r   r   r   rD   rF   r   r   r	    s:     ? ? 0 02J JK? ? #?r    c                s   < \        V\        4      '       d)   \        SV `  VP                  V4       V'       * Vn        R # \        SV `  W4       R # r:   )
isinstancer   r  update_lookup_tabler   r   )rO   rh  r   r     &&&r   rj  Z'TypingBoosterEngine.update_lookup_table  s?     l$<==G'(F(FP&-+LG'>r    c                rC   r   r'   rD   rF   r   r   r	    s     4 4T 4r    c                ra  rf  )r  show_auxiliary_textr  r   rd  re  r   rl  Z'TypingBoosterEngine.show_auxiliary_text  s    #%/3$$,r    c                rC   r   r'   rD   rF   r   r   r	    s     5 5T 5r    c                ra  rb  )r  hide_auxiliary_textr  r   rd  re  r   rm  Z'TypingBoosterEngine.hide_auxiliary_text  s    #%/4$$,r    c                >   < V ^8  d   QhRS[ P                  RS[RR/# )r   r   r   r   N)r   r   r   rD   rF   r   r   r	    s)     7 7997/378<7r    c                sf   < \         SV `  W4       W P                  n        WP                  n        R # r:   )r  update_auxiliary_textr  r   r   )rO   r   r   r  rk  r   ro  Z)TypingBoosterEngine.update_auxiliary_text  s(    %g7/6$$,/6$$,r    c                rC   r   r'   rD   rF   r   r   r	    s     2 24 2r    c                ra  rf  )r  show_preedit_textr  r   rd  re  r   rp  Z%TypingBoosterEngine.show_preedit_text  s    !#-1""*r    c                rC   r   r'   rD   rF   r   r   r	    s     3 34 3r    c                ra  rb  )r  hide_preedit_textr  r   rd  re  r   rq  Z%TypingBoosterEngine.hide_preedit_text  s    !#-2""*r    c                sD   < V ^8  d   QhRS[ P                  RS[RS[RR/# )r   r   rH   r   r   Nr   r   r>   r   rD   rF   r   r   r	    s1     5 5995255@D5IM5r    c                s   < \         SV `  WV4       WP                  n        W P                  n        W0P                  n        R # r:   )r  update_preedit_textr  r   rH   r   )rO   r   rH   r   r  s   &&&&r   rs  Z'TypingBoosterEngine.update_preedit_text  s6    #GA-4""*0:""--4""*r    c          
      sJ   < V ^8  d   QhRS[ P                  RS[RS[RS[RR/# )r   r   rH   r   r  r   Nrr  rD   rF   r   r   r	    sA     ; ;YY; ; 	;
 ;
 !%;r    c                s   < \         SV `  WW44       WP                  n        W P                  n        W0P                  n        W@P                  n        R # r:   )r  update_preedit_text_with_moder  r   rH   r   r  )rO   r   rH   r   r  r  s   &&&&&r   rt  Z1TypingBoosterEngine.update_preedit_text_with_mode  sG     	-	6-4""*0:""--4""*0:""-r    c                rj   rk   r   rD   rF   r   r   r	    s     H H Hr    c                j    \        V P                  \        P                  P                  ,          4      # )z*Return True if OSK capability flag is set.)r   client_capabilitiesrn  
CapabiliteZOSKrm   r$   r   has_oskZTypingBoosterEngine.has_osk  s&     D,,x/B/B/F/FFGGr    c                rj   rk   r   rD   rF   r   r   r	    s     M Md Mr    c                ru  )z7Return True if SURROUNDING_TEXT capability flag is set.)r   rv  rn  rw  ZSURROUNDING_TEXTrm   r$   r   has_surrounding_textZ(TypingBoosterEngine.has_surrounding_text  s-     $$x':':'K'KKM 	Mr    c                rC   r   r'   rD   rF   r   r   r	    s     $ $$ $r    c                sn    V P                   P                  P                  4        V P                  4        R# )zTrigger surrounding text update by calling get_surrounding_text()

Also clears the event in the self._surrounding_text object
which indicates that an update happened since the last
trigger. But keeps the rest of the data.
N)rW  rJ   r   Zget_surrounding_textrm   r$   r    _trigger_surrounding_text_updateZ4TypingBoosterEngine._trigger_surrounding_text_update  s(     	$$**,!!#r    c                s6   < V ^8  d   QhRS[ S[S[3,          /# rk   )r   r   r   rD   rF   r   r   r	    s     q qT#s(^ qr    c                s   / p/ RRV P                   RV P                  /bRRV P                  RV P                  /bRRV P                  /bRRV P
                  /bRRV P                  RV P                  /bRRV P                  RV P                  /bR	RV P                  RV P                  /bR
RV P                  RV P                  /bRRV P                  RV P                  /bRRV P                   RV P"                  /bRRV P$                  RV P&                  /bRRV P(                  RV P*                  /bRRV P,                  RV P.                  /bRRV P0                  RV P2                  /bRRV P4                  RV P6                  /bRRV P8                  RV P:                  /bRRV P<                  RV P>                  /b/ RRV P@                  RV PB                  /bRRV PD                  RV PF                  /bRRV PH                  RV PJ                  /bRRV PL                  RV PN                  /bRRV PP                  RV PR                  /bRRV PT                  RV PV                  /bRRV PX                  RV PZ                  /bRRV P\                  RV P^                  /bRRV P`                  RV Pb                  /bRRV Pd                  RV Pf                  /bRRV Ph                  RV Pj                  /bRRV Pl                  RV Pn                  /bR RV Pp                  RV Pr                  /bR!RV Pt                  RV Pv                  /bR"RV Px                  RV Pz                  /bR#RV P|                  RV P~                  /bR$RV P                  RV P                  /bC/ R%RV P                  RV P                  /bR&RV P                  RV P                  /bR'RV P                  RV P                  /bR(RV P                  RV P                  /bR)RV P                  RV P                  /bR*RV P                  RV P                  /bR+RV P                  RV P                  /bR,RV P                  RV P                  /bR-RV P                  RV P                  /bR.RV P                  RV P                  /bR/RV P                  RV P                  /bR0RV P                  RV P                  /bR1RV P                  RV P                  /bR2RV P                  RV P                  /bR3RV P                  RV P                  /bR4RV P                  RV P                  /bR5RV P                  RV P                  /bC/ R6RV P                  RV P                  /bR7RV P                  RV P                  /bR8RV P                  RV P                  /bR9RV P                  RV P                  /bR:RV P                  RV P                  /bR;RV P                  RV P                  /bR<RV P                  RV P                  /bR=RV P                  RV P                  /bR>RV P                  RV P                  /bR?RV P                  RV P                  /bR@RV P                  RV P                  /bRARV P                  RV P                  /bRBRV P                  RV P                  /bRCRV P                  RV P                  /bRDRV EP                   RV EP                  /bRERV EP                  RV EP                  /bRFRV EP                  RV EP
                  /bCRGRV EP                  RV EP                  /RHRV EP                  RV EP                  /RIRV EP                  RV EP                  /RJRV EP                  RV EP                  /RKRV EP                  RV EP                  /RLRV EP                   RV EP"                  //CpE\$        EP&                  EP)                  4       pVEP+                  RMRN4      pRRORV EP,                   RPV EP.                   2RRQRRQRRRRRNR^ /pV EP0                  RS8w  d`   RRpE\2        EP4                   F2  w  rxE\6        EP8                  ! WpEP0                  4      '       g   K0  Tp M	  V'       d   WeRH&   RTV 2VRI&   MDE\2        EP:                  ! RU4      '       d'   E\2        EP<                  ! 4       R_8  d   RVVRH&   RWVRI&   VEP?                  4        EF  p	V	RJ8X  d   E\2        EP@                  ! V EPB                  EPE                  RJ4      4      p
V EP0                  RS8w  d   . V
RX&   . R`OV
RY&   E\F        EPH                  ! V
4      pE\2        EP@                  ! V EPB                  EPK                  V	4      4      pV'       g   / pE\2        EPL                  ! W4       ME\2        EP@                  ! V EPB                  EPE                  V	4      4      p
V EP0                  RS8w  g   V	Ra9   d   VEPO                  W4      p
E\2        EP@                  ! V EPB                  EPK                  V	4      4      pVf   T
pRZV
R[V/W&   W9   dS   RW),          9   d   W),          R,          VV	,          R\&   RW),          9   d   W),          R,          VV	,          R]&   EK  EK  E\P        EPS                  R^V	4       EK  	  V# )ba  Initialize a dictionary with the default and user settings for all
settings keys.

The default settings start with the defaults from the
gsettings schema. Some of these generic default values may be
overridden by more specific default settings for the specific engine.
After this possible modification for a specific engine we have the final default
settings for this specific typing booster input method.

The user settings start with a copy of these final default settings,
then they are possibly modified by user gsettings.

Keeping a copy of the default settings in the settings dictionary
makes it easy to revert some or all settings to the defaults.
r_  rN   rB  r[  ZdictionaryinstalltimestampZinputmethodchangetimestampr/  r0  r6  r7  r8  r9  r1  r  r  r  r.  r2  r3  r4  r*  r5  rV  rW  r+  r,  r-  r"  r#  r$  r%  r   r!  r  r  r  r  rY  rZ  rX  r&  r'  r(  r)  r:  r;  r<  r=  r>  r?  r@  rA  rB  rC  rD  rE  rF  rG  rH  rI  rJ  rK  rL  rM  rP  rQ  rR  r  r  r  r  rq  rt  rT  rU  rS  r  TZNone-FrB   r  u   •Zgnomeu   🚀︎u   🐌︎rz  commit_and_forward_keyZdefaultr  set_functionget_functionz#key %s missing in set_get_functions)i0   rg   )ZLeftzControl+Leftz	Mod1+Left)rq  rt  )set_current_imesget_current_imesr$  get_dictionary_names_reload_dictionaries_reload_input_methodsset_avoid_forward_key_eventget_avoid_forward_key_eventset_prefer_commitget_prefer_commitset_add_space_on_commitget_add_space_on_commitset_inline_completionget_inline_completionset_record_modeget_record_modeset_auto_capitalizeget_auto_capitalizeset_arrow_keys_reopen_preeditget_arrow_keys_reopen_preeditset_word_prediction_modeget_word_prediction_modeset_emoji_prediction_modeget_emoji_prediction_modeset_unicode_data_all_modeget_unicode_data_all_modeset_off_the_record_modeget_off_the_record_modeset_emoji_trigger_charactersget_emoji_trigger_charactersset_emoji_styleget_emoji_styleset_auto_commit_charactersget_auto_commit_charactersset_tab_enableget_tab_enable"set_remember_last_used_preedit_ime"get_remember_last_used_preedit_imeset_remember_input_modeget_remember_input_moder  get_input_modeset_disable_in_terminalsget_disable_in_terminalsset_ascii_digitsget_ascii_digitsset_show_final_formget_show_final_formr   r   set_lookup_table_orientationget_lookup_table_orientationset_preedit_underlineget_preedit_underline"set_preedit_style_only_when_lookup"get_preedit_style_only_when_lookupset_min_char_completeget_min_char_completeset_debug_levelget_debug_level!set_candidates_delay_milliseconds!get_candidates_delay_millisecondsset_ibus_event_sleep_secondsget_ibus_event_sleep_secondsset_use_ibus_keymapget_use_ibus_keymapset_ibus_keymapget_ibus_keymapset_error_soundget_error_soundr  get_error_sound_fileset_sound_backendget_sound_backendset_show_number_of_candidatesget_show_number_of_candidates&set_show_status_info_in_auxiliary_text&get_show_status_info_in_auxiliary_textset_show_raw_inputget_show_raw_inputset_auto_select_candidateget_auto_select_candidateset_color_preedit_spellcheckget_color_preedit_spellcheck#set_color_preedit_spellcheck_string#get_color_preedit_spellcheck_stringset_color_inline_completionget_color_inline_completion"set_color_inline_completion_string"get_color_inline_completion_stringset_color_compose_previewget_color_compose_preview set_color_compose_preview_string get_color_compose_preview_stringset_color_m17n_preeditget_color_m17n_preeditset_color_m17n_preedit_stringget_color_m17n_preedit_stringset_color_userdbget_color_userdbset_color_userdb_stringget_color_userdb_stringset_color_spellcheckget_color_spellcheckset_color_spellcheck_stringget_color_spellcheck_stringset_color_dictionaryget_color_dictionaryset_color_dictionary_stringget_color_dictionary_stringset_label_userdbget_label_userdbset_label_userdb_stringget_label_userdb_stringset_label_spellcheckget_label_spellcheckset_label_spellcheck_stringget_label_spellcheck_stringset_label_dictionaryget_label_dictionaryr  get_label_dictionary_stringset_flag_dictionaryget_flag_dictionaryset_label_busyget_label_busyset_label_busy_stringget_label_busy_stringset_ai_chat_enableget_ai_chat_enableset_ai_system_messageget_ai_system_messageset_ollama_modelget_ollama_modelset_ollama_max_contextget_ollama_max_contextset_input_mode_true_symbolget_input_mode_true_symbolset_input_mode_false_symbolget_input_mode_false_symbolr  get_keybindingsr  get_autosettings"set_google_application_credentials"get_google_application_credentialsr   ZSettingsSchemaSourceZget_defaultZlookupr  r  r  rn  ZM17N_IME_SYMBOLSreZ	fullmatchZ
is_desktopZget_gnome_shell_versionZ	list_keysvariant_to_valuer  get_default_valuerQ   deepcopyZget_user_valuedict_update_existing_keysrB  r1   warning)rO   Zsettings_dictZset_get_functionsZschema_sourcer  Zspecial_defaultsrp  patternZpattern_symbolrv  Zdefault_valueZ
user_valueZuser_gsettingss   &            r   r  Z'TypingBoosterEngine._init_settings_dict  s      )+]8
t,,t,,.]8
 t00t002	]8
 )t00+2]8
 )t11+3]8
 #t77t77%9]8
 t--t--/]8
" t33t33!5#]8
( t11t11!3)]8
. t++t++-/]8
4 t//t//15]8
: %t99t99';;]8
@ t44t44 6A]8
F t55t55!7G]8
L t55t557M]8
R t33t335S]8
X %t88t88':Y]8
^ t++t++-_]8
d #t66t66%8e]8
j t**t**,k]8
p )t>>t>>+@q]8
v  t33t33"5w]8
| t**t**,}]8
B !t44t44#6C]8
H t,,t,,.I]8
N t//t//1O]8
T t))t))+U]8
Z %t88t88':[]8
` t11t11!3a]8
f )t>>t>>+@g]8
l t11t11 3m]8
r t++t++-s]8
x *t==t==,?y]8
~ $t88t88&:]8
D t//t//1E]8
J t++t++-K]8
P t++t++-Q]8
V t00t002W]8
\ t--t--/]]8
b %t99t99';c]8
h "tBBtBB$Di]8
n t..t..0o]8
t "t55t55$7u]8
z %t88t88':{]8
@ +t??t??-AA]8
F $t77t77&9G]8
L *t>>t>>,@M]8
R "t55t55$7S]8
X (t<<t<<*>Y]8
^ t22t22!4_]8
d %t99t99';e]8
j t,,t,,.k]8
p  t33t33"5q]8
v t00t00 2w]8
| $t77t77&9}]8
B t00t00 2C]8
H $t77t77&9I]8
N t,,t,,.O]8
T  t33t33"5U]8
Z t00t00 2[]8
` $t77t77&9a]8
f t00t00 2g]8
l $t77t77&9m]8
r t//t//1s]8
x t**t**,y]8
~ t11t11 3]8
D t..t..0E]8
J t11t11 3K]8
P t,,t,,.Q]8
V t22t22!4 "t66t66$8 #t77t77%9 t++t++- t,,t,,. +t>>t>>-@u]8
~ $$002 	%2%9%98$&@ &d112!D4G4G3HIu$bD
  00F+3+D+D'<<):):;;+F ,E :@!67=@> !78!!'**224? 7C237C34##%Cm# ( 9 9OO55mD!F$$(88@BM"<=?=M":;
 "]]=9
!)!:!:OO2237"9%%'N22:N ( 9 9OO55c:!<%%)99MM$4$8$8$LM%66OO22379
%!.J"+]FJ!OM'-22/@/Ee/L "+--22/@/Ee/L "+- 3 DcJI &J r    c                rC   r   r'   rD   rF   r   r   r	    s     . .t .r    c                s   / V n         V P                   FP  p V P                  ^8  d   \        P	                  RRV/4       \
        P                  ! V4      V P                   V&   KR  	  V P                  4        R#   \         d>    \        P                  RY4       \
        P                  ! R4      T P                   T&    K  i ; i)z;Initialize the dictionary of m17n-db transliterator objectsz%instantiating Transliterator(%(ime)s)imezSError initializing Transliterator %s Maybe /usr/share/m17n/%s.mim is not installed?NoIMEN)
r;  r  r  r1   r'  r.  ZTransliteratorr  r  _update_transliterated_stringsrO   r  rP   r   r<  Z)TypingBoosterEngine._init_transliterators  s     "%%C$$q(LL?& .;-I-I#-N%%c* &  	++-    E
 .;-I-I.%%c*s   AA::ACCc                rj   rk   r   rD   rF   r   r   r	    s     / /T /r    c                s    \        V P                  ;'       gL    V P                  R8g  ;'       g5    V P                  ;'       g!    V P                  ;'       g    V P
                  4      # )u9  Checks whether prediction candidate lists are wanted

If neither emoji predictions are possible nor word predictions
are possible, calculations to produce the “normal” Typing Booster
lookup table can be skipped completely.

But m17n candidates lookup tables and Compose lookup tables
are still possible then.
rB   )r   r  r  r  r  r  rm   r$   r   _show_prediction_candidatesZ/TypingBoosterEngine._show_prediction_candidates  sn     D++ . .55;. .88. . 77. . --	/ 	/r    c                rj   rk   r   rD   rF   r   r   r	  '  s     U U4 Ur    c                s   \        V P                  4       '       * ;'       d    \        V P                  4      ^8H  ;'       d    V P                  '       * ;'       d    V P
                  '       * ;'       dl    V P                  '       * ;'       dS    V P                  '       * ;'       d:    V P                  '       * ;'       d!    V P                  ^ ,          V P                  9  4      # )zW
Whether it should be checked if parts of the
transliteration can be committed already
)r   is_emptylenr  r1  r  r  r  r  r2  r  rm   r$   r   _try_early_commitZ%TypingBoosterEngine._try_early_commit'  s    
 ' T TD../14T T 888T T !222T T !<<<	T T
 !333T T !===T T **1-T5S5SSU 	Ur    c                rj   rk   r   rD   rF   r   r   r	  5  s     , ,$ ,r    c                s2    \        V P                  4      ^ 8H  # )u[   Checks whether the preëdit is empty

Returns True if the preëdit is empty, False if not.
)r  r2  rm   r$   r   r  ZTypingBoosterEngine.is_empty5  s    
 4%%&!++r    c                rC   r   r'   rD   rF   r   r   r	  <  s     2 2d 2r    c                s   V P                   P                  4        V P                   P                  R4       RV n        . V n        RV n        . V n        \        P                  ! 4       V n	        RV n
        ^ V n        . V n        ^ V n        V P                   F  pRV P                  V&   K  	  ^ V n        V P#                  4        RV P                   n        RV P                   n        \(        P*                  V P                   n        RV n        RV n        V P3                  \4        P6                  P9                  R4      ^ R\4        P:                  P<                  4       V P?                  \4        P6                  P9                  R4      R4       R# )zClear all inputFr`  NrB   ) rA  r   r   r  r=  r?  r1  r.  r/  r0  r,  r-  r2  r3  r  r8  r  rg  r   r   r{   r   r   r  r  rt  r   r   r   r   COMMITro  r  rP   r   _clear_inputZ TypingBoosterEngine._clear_input<  sC     "--e4+0("(')$!.!C!C!E%&"$%!%%C02D((- &"# ,1):?7#3#:#: +0(,1)**II%%b)1e!!((	* 	""II%%b)5	2r    c                s4   < V ^8  d   QhRS[ S[,          RR/# )r   string_to_insertr   Nr   r   rD   rF   r   r   r	  X  s     . .c .t .r    c                s   V P                   ^8  dW   \        P                  RV4       \        P                  RV P                  4       \        P                  RV P                  4       V P                  RV P                   V,           V P                  V P                  R ,           V n        V ;P                  \        V4      ,          un        V P                  4        R# )z&Insert typed string at cursor positionzstring_to_insert=%sself._typed_string=%szself._typed_string_cursor=%sN)r  r1   r'  r2  r3  r  r  )rO   r  rd   r   _insert_string_at_cursorZ,TypingBoosterEngine._insert_string_at_cursorX  s    q LL.0@ALL0$2D2DELL7224!//0J1J1JK./"001J1J1KLM 	!!S)9%::!++-r    c                rC   r   r'   rD   rF   r   r   r	  e  s     2 2d 2r    c                s    V P                   ^ 8  d8   V P                  V P                   R V n        ^ V n         V P                  4        R# R# )z!Remove typed string before cursorNr3  r2  r  rm   r$   r   _remove_string_before_cursorZ0TypingBoosterEngine._remove_string_before_cursore  sE    $$q(!%!3!3D4M4M4N!OD()D%//1 )r    c                rC   r   r'   rD   rF   r   r   r	  l  s     2 2T 2r    c                s    V P                   \        V P                  4      8  d1   V P                  RV P                    V n        V P                  4        R# R# )z Remove typed string after cursorNr3  r  r2  r  rm   r$   r   _remove_string_after_cursorZ/TypingBoosterEngine._remove_string_after_cursorl  sH    $$s4+=+='>>!%!3!34NT5N5N!OD//1 ?r    c                rC   r   r'   rD   rF   r   r   r	  r  s     2 2 2r    c                s   V P                   ^ 8  do   V P                  RV P                   ^,
           V P                  V P                   R ,           V n        V ;P                   ^,          un         V P                  4        R# R# )z$Remove typed character before cursorNr  rm   r$   r   _remove_character_before_cursorZ3TypingBoosterEngine._remove_character_before_cursorr  su    $$q(""#?D$=$=a$?@##D$=$=$>?@  %%*%//1 )r    c                rC   r   r'   rD   rF   r   r   r	  {  s     2 2 2r    c                s    V P                   \        V P                  4      8  dV   V P                  RV P                    V P                  V P                   ^,           R ,           V n        V P                  4        R# R# )z#Remove typed character after cursorNr   rm   r$   r   _remove_character_after_cursorZ2TypingBoosterEngine._remove_character_after_cursor{  so    $$s4+=+='>>""#=D$=$=>##D$=$=a$?$@AB  //1	 ?r    c                &   < V ^8  d   QhRS[ RS[/# )r   extra_msymbolr   )r   r>   rD   rF   r   r   r	    s     A As AC Ar    c                s"   V P                   ^ ,          pV P                  RV P                   pV'       d   V P                  '       g
   W1.,          pV P                  V,          P                  W0P                  R7      pV'       d9   V P                  '       g'   VP                  V4      '       d   VR\        V4      )  p\        V4      pV P                  '       d6   V\        V P                  P                  V P                  4      4      ,          pV# )u  Get caret position in preëdit string

The preëdit contains the transliterated string, the caret
position can only be approximated from the cursor position in
the typed string.

For example, if the typed string is “gru"n” and the
transliteration method used is “Latin Postfix”, this
transliterates to “grün”. Now if the cursor position in the
typed string is “3”, then the cursor is between the “u”
and the “"”.  In the transliterated string, this would be in the
middle of the “ü”. But the caret cannot be shown there of course.

So the caret position is approximated by transliterating the
string up to the cursor, i.e. transliterating “gru” which
gives “gru” and return the length of that
transliteration as the caret position. Therefore, the caret
is displayed after the “ü” instead of in the middle of the “ü”.

This has the effect that when typing “arrow left” over a
preëdit string “grün” which has been typed as “gru"n”
using Latin Postfix translation, one needs to type “arrow
left” two times to get over the “ü”.

If the cursor is at position 3 in the input string “gru"n”,
and one types an “a” there, the input string becomes
“grua"n” and the transliterated string, i.e. the preëdit,
becomes “gruän”, which might be a bit surprising, but that
is at least consistent and better then nothing at the moment.

This problem is certainly worse in languages like Marathi where
these length differences between the input and the transliteration
are worse.

But until this change, the code to move around and edit in
the preëdit did not work at all. Now it works fine if
no transliteration is used and works better than nothing
even if transliteration is used.

https://github.com/mike-fabian/ibus-typing-booster/issues/519
A key which triggered a commit might have changed the
transliteration, see
https://bugzilla.redhat.com/show_bug.cgi?id=1353672 and it
might have even changed the length of the transliteration,
even increasing the length is possible.  So sometimes we need
to consider an extra msymbol coming from the commit key to
calculate the caret position in the preedit string.
NZascii_digits)r  r2  r3  r1  r;  transliterater  endswithr  r  preedit_representation)rO   r%  preedit_imetyped_stringZ"transliterated_string_up_to_cursorcaret   &&    r   	get_caretZTypingBoosterEngine.get_caret  s    b ((+))*D4+D+DE!=!=!=O+L!!+.<<+=+= = ? 	+ $">">">2;;MJJ23GS5G4GH /67'''S''>>0023 3E r    c                s<   < V ^8  d   QhRS[ RS[RS[ RS[RS[RR/# )r   r   	user_freqcommentfrom_user_dbspell_checkingr   N)r   floatr   rD   rF   r   r   r	    sM     Z5 Z5Z5Z5 Z5 	Z5
 !Z5
 .2Z5r    c                s   \         P                  ! V4      p. pV'       dy   \         P                  ! V4      '       d]   \        V4      ^8X  dA   VR8X  d:   R\	        V4      R R2\         P
                  ! V4      P                  4       ,           p\        V4      pMk\        V4      ^8  d\   V'       gT   V P                  P                  '       g8   V P                  '       g&   V P                  P                  P                  V4      p\         P                  ! V4      p\         P                  ! V^PR7      p\         P"                  ! 4       p\         P                  ! V^PR7      pV'       d%   VR\         P                  ! V4      ,           ,          pRpV P$                  P'                  4       p	V P(                  P'                  4       p
V P*                  P'                  4       pV'       dz   V P,                  '       d   V	'       d   VRV	,           ,          pV P.                  '       d=   VP1                  \         P2                  ! V P4                  ^ \        V4      4      4       RpMV'       dy   V P6                  '       d   V
'       d   VRV
,           ,          pV P8                  '       d=   VP1                  \         P2                  ! V P:                  ^ \        V4      4      4       RpV'       Ed/   V P<                  '       Ed   VP?                  R4      '       gH   V	'       d   VP?                  V	4      '       g)   V
'       d   VP?                  V
4      '       g
   VR,          pV P@                  '       d   V F  pWP@                  9   d   WP@                  V,          ,          pK.  \C        V P@                  RR7       F;  p\D        PF                  ! W4      '       g   K!  WP@                  V,          ,          p K  	  K  	  MV'       d	   W,          pV PH                  '       d   VP?                  R4      '       gg   V	'       d   VP?                  V	4      '       gH   V
'       d   VP?                  V
4      '       g)   V'       d   VP?                  V4      '       g
   VR,          pV F%  pWPJ                  PM                  VR4      ,          pK'  	  V PN                  '       dE   V'       g=   VP1                  \         P2                  ! V PP                  ^ \        V4      4      4       RpVPS                  R	R
4      PS                  RR4      PS                  R\        R4      4      PS                  R\        R4      4      pV PT                  ^8  d   V PV                  '       g|   VR\Y        V4       2,          pVP1                  \         P2                  ! \         PZ                  ! R4      \        V4      \        \Y        V4      4      ,
          \        V4      4      4       \         P\                  P_                  V4      pVPa                  V4       V Pb                  Pe                  V4       V Pb                  Pg                  R4       R# )z append candidate to lookup_tablerB   zU+04X Z
max_lengthFT)Zreverse
u   ␤u   ␍u    u    ZHotPinkN)4rn  ro  Zis_invisibler  ordZunicode_namer~   r0   r0  
candidatesr1  r  r#  Zspellcheck_match_listZ
bidi_embedelide_middler   AttrListr  stripr  r  r  r  appendattr_foreground_newr  r  r  r  r  r(  r  sortedfnmatchZfnmatchcaser	  r&  rB  r  r   replacer  rx  r   r  r   r   set_attributesrA  r   r   )rO   r   r/  r0  r1  r2  Zdictionary_matchesattrsZ
color_usedZlabel_spellcheck_stringZlabel_userdb_stringZlabel_dictionary_stringr[  rv  r   s   &&&&&&         r   !_append_candidate_to_lookup_tableZ5TypingBoosterEngine._append_candidate_to_lookup_table  s    BB6J(*h++F336{ab= !#3v;s"3158M8M9  %(G&\F&kQ**555000**@@H 6 $$V, &&v"=''B?cH//888F
"&"?"?"E"E"G"77==?"&"?"?"E"E"G%%%*A# 777%%%T55//CKA B!

 !!!&9# 333!!!T55++QF= >!
 %%%,,0#__-DEE,#__-@AAcMF...&8
%)D)DD"&A&A*&MMF'-d.I.I6:(<#*#6#6z#G#G$*.I.I#.N$NF$)	(<	 '9 -5F$$$,,0#__-DEE,#__-@AA0#__-DEEcMF"4J4488RHHF #5%%%jT55//CKA B!
  % e$Wd8n..5g $x./2 	
 q #i.)**FLL11--i8Fc#i.11F  yy((0E"++D1--e4r    c                rC   r   r'   rD   rF   r   r   r	  b  s     w wD wr    c                sH   V P                   ^8  d!   \        P                  RV P                  4       V P                  P                  4        V P                  P                  R4       V P                  4       '       d   R# . V n        / p. pRV P                  n	        V P                  '       g   V P                  '       Edx   V P                   EFP  pV P                  V,          '       g   K  . p^ pRp\        P                  ! V P                  V,          4      pVR9   d   \         P"                  ! RV4      pV'       d,   \%        V4      V P&                  8  d   RV P                  n	        V P                  P                  '       g/   V P                  P(                  '       g   V P*                  '       d~   \%        V P                  V,          4      \%        V4      ,
          pV'       d   V P                  V,          ^ V p V P,                  P/                  VV P0                  V P2                  R7      pV'       dJ   V'       dB   V U	u. uF5  p	\        P<                  ! WiP>                  ,           V	P@                  R	7      NK7  	  pp	. p
 V P,                  PC                  V P                  V,          4      p
WJ,            F`  pVP>                  V9   d5   \E        WP>                  ,          VP@                  4      WP>                  &   KH  VP@                  WP>                  &   Kb  	  EKS  	  \        PF                  ! V4      pV'       Ed)   \        PH                  ! V P                  V PK                  4       ^ ,          ,          4      p\        PH                  ! V^ ,          P>                  4      pW8X  d   / pV^ ,          P@                  p\%        V4      pV F  p\        PH                  ! VP>                  4      p\%        V4      V8  d9   VPM                  V4      '       d"   VP@                  V,           WP>                  &   Kk  VP@                  WP>                  &   K  	  \        PF                  ! V4      pV PN                  '       d   V P*                  '       dX   V PP                  '       gF   V P                  ^ ,          V PR                  9   g$   V P                  R,          V PR                  9   Ed!   V PT                  '       d*   V PT                  PW                  4       V PX                  8w  d=   \Z        P\                  ! V PX                  V P^                  V P`                  R7      V n*        / pRpV P                   EF3  pV P                  V,          '       g   K  \%        V P                  V,          4      V P&                  8  g'   V P*                  '       g   V Pb                  '       g   Kp  V PT                  Pe                  V P                  V,          V Pf                  V PR                  R7      pV Fz  p\E        VVP@                  4      pVP>                  V9  g,   VP@                  VVP>                  ,          ^ ,          8  g   KU  VP@                  VPh                  3VVP>                  &   K|  	  EK6  	  . pV EF  pRpVP>                  V9   d   VP>                  pMMVP>                  ^ ,          V PR                  9   d,   VP>                  R,          V9   d   VP>                  R,          pV'       d)   VVP@                  ,           VV,          ^,          3VV&   K  VPk                  \        P<                  ! VP>                  VP@                  V PT                  Pm                  VP>                  4      VP@                  ^ 8  VP@                  ^ 8  R7      4       EK  	  . p\o        VPq                  4       R R7      RV Pf                    F<  w  ppVPk                  \        P<                  ! VV^ ,          V^,          R7      4       K>  	  V P                  Ps                  4       pVRV^,
           pVV^,
          R pVRV pVVR pV Fi  pV P                  Pk                  \        P<                  ! VP>                  VP@                  VPh                  VPt                  VPv                  R7      4       Kk  	  V FU  pV P                  Pk                  \        P<                  ! VP>                  VP@                  VPh                  RRR7      4       KW  	  V Fi  pV P                  Pk                  \        P<                  ! VP>                  VP@                  VPh                  VPt                  VPv                  R7      4       Kk  	  V FU  pV P                  Pk                  \        P<                  ! VP>                  VP@                  VPh                  RRR7      4       KW  	  MkV Fe  pV P                  Pk                  \        P<                  ! VP>                  VP@                  RVP@                  ^ 8  VP@                  ^ 8  R7      4       Kg  	  V P                   FK  pV Py                  VP>                  VP@                  VPh                  VPt                  VPv                  R7       KM  	  V P                  P{                  4       V n>        V P~                  R8w  d   V P                  V P~                  R7       R#   \4         d7   p\        P7                  RTP8                  P:                  T4        Rp?E	L#Rp?ii ; iu up	i   \4         d7   p\        P7                  R
TP8                  P:                  T4        Rp?ELRp?ii ; i)zLUpdate the list of candidates and fill the lookup table with the
candidates
r  FNrB   ZNFKDTp_phrase	pp_phrasez+Exception when calling select_words: %s: %s)r   r/  z/Exception when calling select_shortcuts: %s: %sr^          )Zmatch_limitZtrigger_charactersrl  r   r/  r0  r1  r2  c                 sh    V ^,          ^ ,          ) \        V ^ ,          4      ) V ^,          ^,          3# )rk  r  re  r$   r   rg  Z8TypingBoosterEngine._update_candidates.<locals>.<lambda>  s,    A$q'	ad)!Q#r    rv  r   r/  r0  r`  mode)	ko-romajazko-han2)Ar  r1   r'  r2  rA  r   r   r  r=  r   r  r  r  r8  rn  lstrip_tokenunicodedataZ	normalizer  r  r   rx  r  select_wordsr4  r5  r7   r  r  rR   PredictionCandidater   r/  Zselect_shortcutsr  Zbest_candidatesro  r  
startswithr  r  r  r  get_languagesr  r(  r)  r  r  r  r:  r  r0  r>  r}   r@  itemsr   r1  r2  rE  rQ   r>  r?  _case_mode_change)rO   Zphrase_frequenciesphrase_candidatesr  r:  prefix_lengthZprefixZstripped_transliterated_stringr2   rf  Zshortcut_candidatescandr+  first_candidateZfirst_candidate_user_freqZfirst_candidate_lengthZcandidate_normalizedZemoji_scoresZemoji_max_scoreZemoji_matcher_candidatesZecandZphrase_candidates_emoji_nameemojiZemoji_candidatesrv  r   r   Zphrase_candidates_topZphrase_candidates_restZemoji_candidates_topZemoji_candidates_rests   &                              r   _update_candidatesZ&TypingBoosterEngine._update_candidatesb  s	    q LL0$2D2DE  "--e4==?? /1@B:?7!!!T%E%E%E))//44!#J$%MF --d.J.J3.OP 3660 :E9N9N"$B:D66 !?@ $ 7 78JN**G**GGG--<<<<<< < <S AB!"@AB & ) $ < <S A!M R #A)-)C)C >)-*.// *D *;J "f
 &0	&1 &0 %88'-hh*+++7 &0	 # &1
 DF'=.2mm.L.L 88=/?+ !+ @ @;;*<<>A 2;; ? $?0.{{; ?Cnn.{{; !AK *X !) 8 89K L #LL,,))+A.01L 'OO!!$++-O.%'",=a,@,J,J)),_)=&-D II KK) ) 014JJ0;;OLL NN-FF +;;7 ;?..*;;7 . %-$<$<&%(!$$$T\\\000!!!$(F(FF!!"%)G)GG
 &&&""002))*%.%;%;"44%)%;%;'+'8'8&:" :<L%(O))0055T99#>? 334 LLL ,,,/3/A/A/L/L44S9$($;$;+/+I+I 0M 0K, ":*-ou*O!LL<#(??\%,,5OPQ5R#R:?//5==9YL6	 ": * PR() ;;,. KKEkk!n(F(FFB<7 KKOE+:T^^+K+7+>q+A+CL' 177 44#';;&*nn$($6$6$;$;DKK$H)-!);+/>>A+=?@ ** DF & &&(! 0//!1e !''00"eAhaJK!1 **88:I$@)A+$N!%A)A+,%O"#3JY#? $4YZ$@!-  ''00#{{"&.. $%)%6%6'+':':<= . -  ''00#{{"&.. $%*',./ - /  ''00#{{"&.. $%)%6%6'+':':<= / .  ''00#{{"&.. $%*',./ . *  ''00#{{"&.. "%)^^a%7'+~~'9;< * $$D22{{..!..#22 3 4 % +/*:*:*?*?*A'""f,""(?(?"@a  ) A",, M % 8 8%A AA
&1 % =((M!OO44e= ==s6   >2l;m,m m"+mm n!++nn!c                rj   rk   r   rD   rF   r   r   r	  [  s      T r    c                s    V P                   P                  4       '       g   V P                   P                  R4       R# V P                   P                  4       '       d   R# R# )z:Process Arrow Down Key Event
Move Lookup Table cursor downTF)rA  r   r   r   rm   r$   r   _arrow_downZTypingBoosterEngine._arrow_down[  sK     !!335511$7))++r    c                rj   rk   r   rD   rF   r   r   r	  e  s      4 r    c                    V P                   P                  R4       V P                   P                  4       '       d   R# R# )z6Process Arrow Up Key Event
Move Lookup Table cursor upTF)rA  r   r   rm   r$   r   	_arrow_upZTypingBoosterEngine._arrow_upe  3     	--d3''))r    c                rj   rk   r   rD   rF   r   r   r	  m  s      D r    c                ra  )z7Process Page Down Key Event
Move Lookup Table page downTF)rA  r   r   rm   r$   r   
_page_downZTypingBoosterEngine._page_downm  rc  r    c                rj   rk   r   rD   rF   r   r   r	  u  s      $ r    c                ra  )z3Process Page Up Key Event
move Lookup Table page upTF)rA  r   r   rm   r$   r   _page_upZTypingBoosterEngine._page_upu  s3     	--d3%%''r    c                rj   rk   r   rD   rF   r   r   r	  }  s     	 	 	r    c                s    \        V P                  P                  4       V P                  P                  4       4      w  r\	        V4      # )zc
Returns the index of the currently visible page of the lookup table.

The first page has index 0.
)ZdivmodrA  r   r   r>   )rO   pageZdummy_pos_in_page   &  r   _get_lookup_table_current_pageZ2TypingBoosterEngine._get_lookup_table_current_page}  sA     #)--/,,.#0 4yr    c                r$  r   r>   r   rD   rF   r   r   r	    s      # $ r    c                s   V P                   P                  4       pV^ 8  g   W8  d   R# V P                  4       pW2,          V,           pW@P                   P                  4       8  d   R# V P                   P	                  V4       R# )u   Sets the cursor in the lookup table to index in the current page

Returns True if successful, False if not.

:param index: The index in the current page of the lookup table.
              The topmost candidate has the index 0 and the label “1”.
FT)rA  r   rh  r   r   )rO   r   r   rf  Znew_pos   &&   r   ,_set_lookup_table_cursor_pos_in_current_pageZ@TypingBoosterEngine._set_lookup_table_cursor_pos_in_current_page  sq     &&446	19*224"U*((AACC))'2r    c                rj   rk   r   rD   rF   r   r   r	    s     3 3 3r    c                s    V P                   '       g   R# V P                  P                  4       pV\        V P                   4      8  d   R# \	        V P                   V,          P
                  4      # )zG
Get the candidate at the current cursor position in the lookup
table.
rB   )r=  rA  r   r  r   r   r   rP   r   'get_string_from_lookup_table_cursor_posZ;TypingBoosterEngine.get_string_from_lookup_table_cursor_pos  sY    
 ""113C(())4##E*1122r    c                r$  r   )r>   r   rD   rF   r   r   r	    s     > >s >s >r    c                sT    V P                  V4      '       g   R# V P                  4       # )u   
Get the candidate at “index” in the currently visible
page of the lookup table. The topmost candidate
has the index 0 and has the label “1.”.
rB   )rk  rl  r   rd   r   )get_string_from_lookup_table_current_pageZ=TypingBoosterEngine.get_string_from_lookup_table_current_page  s'     @@GG;;==r    c                r$  r   ri  rD   rF   r   r   r	    s     N N N Nr    c                s   V P                   ^8  d   \        P                  RV4       V P                  V4      '       g   R# V P	                  4       pV'       g   R# V P
                  P                  4       p^ Tu;8:  d   \        V P                  4      8:  dd   M M`V P                  V,          P                  pV P                   ^8  d3   \        P                  RV4       V P                  P                  VR7       V P                  P                  4        F  w  rEVR,          ! V4      p\        P                  ! V4      pV'       dD   V P                   ^8  d   \        P                  RV4       V P                  P                  VR7       V P                   ^8  d   \        P                  RV4       V P                  P                  VR7       K  	  R# )u  Remove the candidate shown at index in the candidate list
from the user database.

Returns True if successful, False if not.

:param index: The index in the current page of the lookup table.
              The topmost candidate has the index 0 and the label “1”.
:return: True if successful, False if not.

The removal is done independent of the input phrase, all
rows in the user database for that phrase are deleted.

It does not matter either whether this is a user defined
phrase or a phrase which can be found in the hunspell
dictionaries.  In both cases, it is removed from the user
database.

In case of a system phrase, which can be found in the hunspell
dictionaries, this means that the phrase could still appear in
the suggestions after removing it from the user database
because it still can be suggested by the hunspell
dictionaries. But it becomes less likely because removing a
system phrase from the user database resets its user frequency
to 0 again.

So the user can always try to delete a phrase if he does not
want the phrase to be suggested wich such a high priority, no
matter whether it is a system phrase or a user defined phrase.
z3Removing candidate with index=%s from user databaseFu0   Removing phrase with original case mode “%s”r   rd  u   Removing “%s”T)r  r1   r'  rk  rl  rA  r   r  r>  r   r  Zremove_phraser@  rX  rn  rR  )rO   r   Zdisplayed_phraseZcase_mode_orig_phraser%   Zcase_mode_valuer   Zstripped_phrases   &&      r   #remove_candidate_from_user_databaseZ7TypingBoosterEngine.remove_candidate_from_user_database  sz   < q LLEuN@@GGGGI""113=T<<==$($C$C%v "  1$O24++0 , 2"&"2"2"8"8":A$Z01ABF '33F;O$$q(LL!4oF++?+C   1$0&9MM''v'6= #;> r    c                rj   rk   r   rD   rF   r   r   r	  	  r   r    c                sH    \        V P                  P                  4       4      # )z get lookup table cursor position)r>   rA  r   rm   r$   r   r   Z"TypingBoosterEngine.get_cursor_pos	  s    4%%44677r    c                rj   rk   )r   rD   rF   r   r   r	  	  s     " "": "r    c                ro   )zGet lookup table)rA  rm   r$   r   get_lookup_tableZ$TypingBoosterEngine.get_lookup_table	      !!!r    c                rj   rk   r   rD   rF   r   r   r	  
	  s      c r    c                ro   )zGet previous word)r4  rm   r$   r   get_p_phraseZ TypingBoosterEngine.get_p_phrase
	  s    ~~r    c                rj   rk   r   rD   rF   r   r   r	  	        s r    c                ro   )zGet word before previous word)r5  rm   r$   r   get_pp_phraseZ!TypingBoosterEngine.get_pp_phrase	      r    c                rj   rk   r   rD   rF   r   r   r	  	  s          r    c                ro   )z!Get 2nd word before previous word)r6  rm   r$   r   get_ppp_phraseZ"TypingBoosterEngine.get_ppp_phrase	      r    c                r[   r   r   rD   rF   r   r   r	  	  s        3  4  r    c                s    V P                   ^8  d8   \        P                  RV P                  V P                  V P
                  V4       RV n        V P                  V n        V P
                  V n        Wn        R# )zOPushes a word on the context stack which remembers the last three
words typed.
u0   context=“%s” “%s” “%s” push=“%s”FN)r  r1   r'  r6  r5  r4  rZ  r   rd   r   push_contextZ TypingBoosterEngine.push_context	  s_     q LLB  $//4>>6K 27.??..r    c                rC   r   r'   rD   rF   r   r   r	  #	  s     
# 
#t 
#r    c                s    V P                   ^8  d7   \        P                  RV P                  V P                  V P
                  4       RV n        RV n        RV n        RV n        R# )zJClears the context stack which remembers the last two words typed
        u"   context=“%s” “%s” “%s”rB   FN)r  r1   r'  r6  r5  r4  r7  rm   r$   r   clear_contextZ!TypingBoosterEngine.clear_context#	  sW     q LL4  $//4>>C "r    c                rC   r   r'   rD   rF   r   r   r	  /	  s     . . .r    c                s   / V n         V P                  '       d+   V P                  P                  V P                  4      V n        V P
                   EF*  pV P                  '       d   V P                  V,          P                  V P                  RV P                   V P                  R7      V P                  V&   V P                  V,          V P                  ,           V P                  V,          P                  V P                  V P                  R V P                  R7      ,           V P                   V&   K  V P                  V,          P                  V P                  V P                  R7      V P                   V&   EK-  	  V P                  ^8  dC   \        P                  RV P                  4       \        P                  RV P                   4       R# R# )zzTransliterates the current input (list of msymbols) for all current
input methods and stores the results in a dictionary.
Nr&  r  zself._transliterated_strings=%s)r8  r1  r  r)  r:  r  r;  r'  r2  r3  r  r9  r  r1   r'  r  rP   r   r  Z2TypingBoosterEngine._update_transliterated_strings/	  s    (*$'''''>>002 5 %%C+++))#.<<**+ED,E,EF%)%7%7 = 9 ;;C@
 ??D??@++C0>>**4+D+D+EF%)%7%7 ? 99 ,,S1 ))#.<<**%)%7%7 = 9 ,,S1 &" q LL0$2D2DELL1,,. !r    c                0   < V ^8  d   QhRS[ S[,          /# rk   r  rD   rF   r   r   r	  O	  s     % %$s) %r    c                (    V P                   R,          # )zGet current list of input methods

It is important to return a copy, we do not want to change
the private member variable directly.
r]  )r  rm   r$   r   r  Z$TypingBoosterEngine.get_current_imesO	  s     !!!$$r    c                T   < V ^8  d   QhRS[ S[S[S[,          S[3,          RS[RR/# )r   imesrO  r   Nr   r   r   r   r   rD   rF   r   r   r	  W	  s9     )9 )9T#Y+,)9 #)9 /3)9r    c                s   \         P                  RV\        V4      4       \        V\        4      '       d   \
        P                  ! V4      pWP                  8X  d   R# \        V4      \        V P                  4      8w  d   Wn        V P                  4        MWn        V P                  4        V P                  V P                  ^ R7       V P                  4       '       g   V P                  4        V'       dK   V P                  P!                  R\"        P$                  P'                  RP)                  V4      4      4       R# R# )ar  Set current list of input methods

:param imes: List of input methods
             If a single string is used, it should contain
             the names of the input methods separated by commas.
             If the string is empty, the default input
             methods for the current locale are set.
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
zimes=%s type(imes)=%sNcurrent_moder_  r\  )r1   r'  typeri  r   rn  r*  r  rN   r<  rI  )_init_or_update_property_menu_preedit_imer  r  
_update_uir  r   r   r!  r"  r  rO   r}  rO  r   r   r  Z$TypingBoosterEngine.set_current_imesW	  s    " 	,dDJ?dC  55d;D%%%t9D..// "&&&(!%++-66!! 	7 	3}}OOOO%%''79 r    c                r|  )r   dictionary_namesrO  r   Nr~  rD   rF   r   r   r	  	  s>     -E -E#CcC$78-E #-E /3-Er    c                s   \         P                  RV\        V4      4       \        V\        4      '       d   \
        P                  ! V4      pWP                  8X  d   R# Wn        V P                  P                  P                  V4       \
        P                  ! V P                  4      V n        V P                  4        V P                  V P                  ^ R7       V P                   '       dd   V P"                  '       d    V P"                  P%                  4       V8w  d3   \&        P(                  ! VV P*                  V P,                  R7      V n        V P/                  4       '       g   V P1                  4        V'       dK   V P2                  P5                  R\6        P8                  P;                  RP=                  V4      4      4       R# R# )a  Set current dictionary names

:param dictionary_names: List of names of dictionaries to use
                         If a single string is used, it should contain
                         the names of the dictionaries separated
                         by commas.
                         If the string is empty, the default
                         dictionaries for the current locale are set.
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
z-dictionary_names=%s type(dictionary_names)=%sNr  r^  r[  r\  )r1   r'  r  ri  r   rn  r  r  r  r#  r$  r%  r&  rH  (_init_or_update_property_menu_dictionaryr  r  r  rW  r(  r)  r  r  r  r  r  r   r   r!  r"  r  )rO   r  rO  r   r   r$  Z(TypingBoosterEngine.set_dictionary_names	  s\   $ 	D%t,<'=	?&,,'@@  "555!1""778HI!)!3!3D4J4J!K**,55  q 	6 	2"""&&&&&446'(%.%;%;.%)%;%;'+'8'8&:" }}OOOO%%''1A(BCE r    c                rz  rk   r  rD   rF   r   r   r	  	  s     ) )d3i )r    c                r{  )z$Get current list of dictionary namesr]  )r  rm   r$   r   r  Z(TypingBoosterEngine.get_dictionary_names	  s     %%a((r    c                sj   < V ^8  d   QhRS[ S[S[S[S[S[3,          ,          S[3,          RS[RR/# )r   rU  rO  r   N)r   r   r   r   r   r   rD   rF   r   r   r	  	  sC      U3S=%9 :C ?@ # /3r    c                s`   V P                   ^ 8  d   \        P                  RV4       \        V\        4      '       g   R# WP
                  8X  d   R# Wn        V'       d   \        P                  P                  \        P                  ! R4      V UUu. uFd  p\        P                  P                  \        P                  ! R4      V Uu. uF"  p\        P                  P                  V4      NK$  	  up4      NKf  	  upp4      pV P                  P                  RV4       R# R# u upi u uppi )a  Set the current automatic settings

:param autosettings: The automatic settings to use
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
zautosettings=%sNZassrU  )r  r1   r'  ri  listr  r   r!  	new_arrayVariantTyper"  r  r   )rO   rU  rO  Zautosettingrf  variant_array   &&&   r   r  Z$TypingBoosterEngine.set_autosettings	  s     q LL*L9,-----) LL2243C3CD3I (4L (4 LL**4+;+;C+@<GCI<Gq//2KCI J'3L M
 OO%% CILs   7D*
(D%2D*%D*c                sJ   < V ^8  d   QhRS[ S[S[S[S[3,          ,          /# rk   )r   r   r   rD   rF   r   r   r	  	  s$     ) )$uS#s]';"< )r    c                r|   )ztGet current autosettings

Returns the list of settings automatically applied when
regular expressions match windows
)r  rQ   rm   r$   r   r  Z$TypingBoosterEngine.get_autosettings	  s     !!&&((r    c                sf   < V ^8  d   QhRS[ S[S[S[S[,          3,          S[3,          RS[RR/# )r   rT  rO  r   N)r   r   r   r   r   r   rD   rF   r   r   r	  	  sE     J$ J$tCcN3S89J$ #J$ /3J$r    c           
     s   / p\         P                  ! V P                  P                  R4      4      p\         P                  ! W14       W0n        RV n        RV n        V F0  pW,           F!  pVR9   d   RV n        VR9   g   K  RV n        K#  	  K2  	  \         P                  ! V P
                  4      V n	        V P                  '       Ed   V P                  '       d*   \        V P
                  R,          4      V P                  R&   V P                  '       d*   \        V P
                  R,          4      V P                  R&   V P                  '       d*   \        V P
                  R,          4      V P                  R&   V P                  '       d   V P!                  4        V P"                  '       d   V P%                  4        V P'                  4        V'       d   \(        P*                  ! \(        P,                  ! R/ 4      4      p\/        V P
                  4       F  p\(        P,                  P1                  \(        P2                  ! R	4      V P
                  V,           Uu. uF"  p\(        P,                  P5                  V4      NK$  	  up4      pVP7                  WH4       K  	  V P                  P9                  RVP;                  4       4       R
# R
# u upi )a  Set current key bindings

:param keybindings: The key bindings to use
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
rT  FTrz  ry  r}  r  za{sv}r  N
Z0Z1Z2Z3Z4Z5Z6Z7Z8Z9)
KP_0KP_1KP_2KP_3KP_4KP_5KP_6KP_7KP_8KP_9)rn  r
  r  r  r  r  r  r  ZHotKeysr  r  r  r0   r  r  r  rH  r  rI  rJ  r   ZVariantDictr!  r@  r  r  r"  Zinsert_valuer   Zend)	rO   rT  rO  Znew_keybindingscommandZ
keybindingZvariant_dictrf  r  s	   &&&      r   r  Z#TypingBoosterEngine.set_keybindings	  sU    "33OO--m<> 	**?H+27/27/"G)22
11 ?CD;@@ ?CD; 3 # !(():):; ???###**+EFG $$_5...**+DEF //@,,,**+BCD --o>###224$$$335!!#++DLL",EFL!$"3"34 $ 6 6$$S)"//8:8 \\,,Q/8:!; ))'A 5 OO%%  "$ 
:s   (Kc                sF   < V ^8  d   QhRS[ S[S[S[,          3,          /# rk   )r   r   r   rD   rF   r   r   r	  +
  s!     ( (c49n!5 (r    c                r|   )zIGet current key bindings

Python dictionary of key bindings for commands
)r  rQ   rm   r$   r   r  Z#TypingBoosterEngine.get_keybindings+
  s       %%''r    c                rC   r   r'   rD   rF   r   r   r	  4
  s     : :t :r    c                s   / V n         V P                  4       p\        P                  p\	        ^ V4       F  pV\        V4      8  d   RVRW,          R,           \        P                  ! W,          4      ,           RW,          R,           \        P                  ! W,          4      ,           RR/V P                   R\        V4      ,           &   K  RVRRRRRR/V P                   R\        V4      ,           &   K  	  RR	R\        R
4      R\        R4      RR\        V P                  R,          4      ,           R,           \        V P                  R,          4      ,           RV P                   /V n        R# )zC
Update the Python dicts for the highest priority dictionary menu.
rs  rp  r5  r   rx  rB   zDictionary.rv  Z
DictionaryzHighest priority dictionaryz"Choose highest priority dictionaryry  Next: Znext_dictionary
Previous: Zprevious_dictionaryr{  N)r  r  rn  ZMAXIMUM_NUMBER_OF_DICTIONARIESr   r  get_flagr   r%   r0   r  r  )rO   Zcurrent_dictionariesZcurrent_dictionaries_maxi   &   r   rH  Z1TypingBoosterEngine._update_dictionary_menu_dicts4
  sl    &("#88:#+#J#J q23A3+,, q36 %../C/FG H25%../C/FGH **!CF* q(BYK **!#a&( 4  <Q45q=>tD--.?@AAt001FGHI d88 :r    c                rC   r   r'   rD   rF   r   r   r	  T
  s     ; ; ;r    c                s>   / V n         V P                  4       p\        P                  p\	        ^ V4       Fo  pV\        V4      8  d6   RVRW,          RW,          RR/V P                   R\        V4      ,           &   KH  RVRRRRRR/V P                   R\        V4      ,           &   Kq  	  RRR\        R	4      R\        R
4      RR\        V P                  R,          4      ,           R,           \        V P                  R,          4      ,           RV P                   /V n
        R# )u2   
Update the dictionary for the preëdit ime menu.
rs  rp  r   rx  rB   zPreeditIme.rv  Z
PreeditImezPreedit input methodzSwitch preedit input methodry  r  Znext_input_methodr  Zprevious_input_methodr{  N)r  r  rn  ZMAXIMUM_NUMBER_OF_INPUT_METHODSr   r  r   r%   r0   r  r  )rO   Zcurrent_imesZcurrent_imes_maxr  r  r   rI  Z2TypingBoosterEngine._update_preedit_ime_menu_dictsT
  s&    ')#,,.#CCq*+A3|$$ q|lo ++!CF* q(BYK ++!#a&( , <Q-.q67tD--.ABCCt001HIJK d99!;r    c                @   < V ^8  d   QhRS[ S[S[3,          RS[RR/# r   menur  r   Nr   r   r   r>   rD   rF   r   r   r	  r
  1     +7 +7sCx.+7 +7 '++7r    c                   VR,          pVR,          pRpRpRpV FU  pWH,          R,          \        V4      8X  g   K"  WH,          R,          pVR,           RV R2pVR	,           R
VR,           2pKW  	  \        V P                  4       4      ^8  p	V P                  WBR7       W0P                  9  d   \
        P                  ! V\
        P                  P                  \
        P                  P                  V4      R\
        P                  P                  V4      \
        P                  P                  V4      V	V	\
        P                  P                  V P                  R7
      V P                  V&   V P                  P                  V P                  V,          4       R# V P                  V,          P!                  \
        P                  P                  V4      4       V P                  V,          P#                  \
        P                  P                  V4      4       V P                  V,          P%                  \
        P                  P                  V4      4       V P                  V,          P'                  V	4       V P                  V,          P)                  V	4       V P+                  V P                  V,          4       R# )zR
Initialize or update the ibus property menu for
the highest priority dictionary.
rv  r{  rB   rs  rp  r    (rv   rx  r7  ry  r  
rv  	prop_typer   iconrp  rx  	sensitiver   r   	sub_propsN)r>   r  r  )_init_or_update_sub_properties_dictionaryr  r   PropertyPropTypeMENUr   r   	PropState	UNCHECKEDr  r  r>  r   
set_symbolset_tooltipset_sensitiveset_visibleupdate_property
rO   r  r  rv  r{  rp  r   rx  propr   
   &&&       r   r  Z<TypingBoosterEngine._init_or_update_property_menu_dictionaryr
  s    5k./"D#H-\1BB'-h7=/F815!)_-R_0E/FG	 #
 d//12Q666 	7 	7oo%#'==--,,ii//6yy008		11':!nn..BB
$DDOOC  &&ts';<OOC **		))%02OOC ++		))&13OOC ,,		))'24OOC ..w7OOC ,,W5  !56r    c                r  r  r  rD   rF   r   r   r	  
  r  r    c                r  )uL   
Initialize or update the ibus property menu for
the preëdit input method.
rv  r{  rB   rs  rp  r   r  rv   rx  r7  ry  r  r  N)r>   r  r  *_init_or_update_sub_properties_preedit_imer  r   r  r  r  r   r   r  r  r  r  r>  r   r  r  r  r  r  r  r  r   r  Z=TypingBoosterEngine._init_or_update_property_menu_preedit_ime
  s    5k./"D#H-\1BB'-h7=/F815!)_-R_0E/FG	 #
 d++-.277 	8 	7oo%#'==--,,ii//6yy008		11':!nn..CC
$EDOOC  &&ts';<OOC **		))%02OOC ++		))&13OOC ,,		))'24OOC ..w7OOC ,,W5  !56r    c                r  r   modesr  r   Nr  rD   rF   r   r   r	  
  1     -< -<S>-< -< '+-<r    c                F  a V P                   P                  ^ 4      f   Rp\        P                  ! 4       V n         MRp\	        V P                  4       4      p\        SV3R lR7       EF4  pSV,          R,          V8  pSV,          R,          \        V4      8X  d   \        P                  P                  pM\        P                  P                  pSV,          R,          pRSV,          9   d   SV,          R,          p	MR	p	V'       g   \        P                  ! V\        P                  P                  \        P                  P                  V4      R	\        P                  P                  V	4      VVVRR
7	      V P                   V&   V P                   P#                  V P                   V,          4       EKP  V P                   V,          P%                  \        P                  P                  V4      4       V P                   V,          P'                  \        P                  P                  V	4      4       V P                   V,          P)                  V4       V P                   V,          P+                  V4       V P-                  V P                   V,          4       EK7  	  R# )zc
Initialize or update the sub-properties of the property menu
for the highest priority dictionary.
NFTc                 6   < \        SV ,          R ,          4      # rs  r   rf  r  re  r   rg  ZOTypingBoosterEngine._init_or_update_sub_properties_dictionary.<locals>.<lambda>
      U1Xh5G1Hr    rL  rs  r   rx  rB   	rv  r  r   r  rx  r  r   r   r  )r  rB  r   r  r  r  r@  r>   r  CHECKEDr  r  r  RADIOr   r   r  r>  r   r  r  r  r  )
rO   r  r  updateZnumber_of_current_dictionariesrO  r   r   r   rx  
   &f&       r   r  Z=TypingBoosterEngine._init_or_update_sub_properties_dictionary
  s    3377:BF7;}}D4F),T-F-F-H)I&5&IJJDDk(+.LLGT{8$L(99..00$K(EE$K'+i0(,"mm11))33E: II55g>%#"	)$% 88??OOD)+ %//II--e46%11II--g68%33G<%11':$$T__T%:;? Kr    c                r  r  r  rD   rF   r   r   r	  
  r  r    c                r  )u]   
Initialize or update the sub-properties of the property menu
for the preëdit input method.
NFTc                 r  r  r   r  re  r   rg  ZPTypingBoosterEngine._init_or_update_sub_properties_preedit_ime.<locals>.<lambda>	  r  r    rL  rs  r   rx  rB   r  )r  rB  r   r  r  r  r@  r>   r  r  r  r  r  r  r   r   r  r>  r   r  r  r  r  )
rO   r  r  r  Znumber_of_current_imesrO  r   r   r   rx  r  r   r  Z>TypingBoosterEngine._init_or_update_sub_properties_preedit_ime
  s    4488;CF8<D5F!$T%:%:%<!=5&IJJDDk(+.DDGT{8$L(99..00$K(EE$K'+i0(,"mm11))33E: II55g>%#"	)$% 99@@OOD)+ %//II--e46%11II--g68%33G<%11':$$T__T%:;? Kr    c                r  r  r  rD   rF   r   r   r	  *  s1     7< 7<sCx.7< 7< '+7<r    c                s   VR,          pVR,          pRpRpRpV FO  pWH,          R,          \        V4      8X  g   K"  WH,          R,          pVR,          pVR,           RVR	,           2pKQ  	  R
p	VR8X  d   R
p	VR9   d   V P                  4       p	V P                  W4VR7       W0P                  9  d   \        P
                  ! V\        P                  P                  \        P                  P                  V4      R\        P                  P                  V4      \        P                  P                  V4      V	V	\        P                  P                  V P                  V,          R7
      V P                  V&   V P                  P                  V P                  V,          4       R# V P                  V,          P                  \        P                  P                  V4      4       V P                  V,          P!                  \        P                  P                  V4      4       V P                  V,          P#                  \        P                  P                  V4      4       V P                  V,          P%                  V	4       V P                  V,          P'                  V	4       V P)                  V P                  V,          4       R# )z+
Initialize or update a ibus property menu
rv  r{  rB   rs  rp  r   rx  r7  ry  Trw  r  r  Nr|  r~  )r>   r  _init_or_update_sub_propertiesr  r   r  r  r  r   r   r  r  r  r  r>  r   r  r  r  r  r  )
rO   r  r  menu_keyZsub_properties_dictrp  r   rx  r  r   r  r   _init_or_update_property_menuZ1TypingBoosterEngine._init_or_update_property_menu*  s(    ;"#34'D"(2c,6GG,28<W!)_-R_0E/FG	 (
 {" GBB668G++ 	, 	F??*(,--,,ii//6yy008		11':!nn....x8
):DOOH% &&tx'@AOOH%//		))%02OOH%00		))&13OOH%11		))'24OOH%33G<OOH%11':  !:;r    c                sF   < V ^8  d   QhRS[ RS[S[ S[3,          RS[RR/# )r   r  r  r  r   N)r   r   r   r>   rD   rF   r   r   r	  c  s;     :< :<:< S>:< 	:< '+	:<r    c                sz  a WP                   9  d&   Rp\        P                  ! 4       V P                   V&   MRpRpVR8X  d   RpVR9   d   V P                  4       p\	        SV3R lR7       EFJ  pSV,          R,          \        V4      8X  d   \        P                  P                  pM\        P                  P                  pSV,          R,          pRSV,          9   d   SV,          R,          p	MR	p	V'       g   \        P                  ! V\        P                  P                  \        P                  P                  V4      R	\        P                  P                  V	4      VVVR
R7	      V P                  V&   V P                   V,          P                  V P                  V,          4       EKD  V P                  V,          P!                  \        P                  P                  V4      4       V P                  V,          P#                  \        P                  P                  V	4      4       V P                  V,          P%                  V4       V P                  V,          P'                  V4       V P                  V,          P)                  V4       V P+                  V P                  V,          4       EKM  	  R
# )zC
Initialize or update the sub-properties of a property menu entry.
FTrw  c                 r  r  r   r  re  r   rg  ZDTypingBoosterEngine._init_or_update_sub_properties.<locals>.<lambda>~  r  r    rL  rs  r   rx  rB   Nr  r  )r  r   r  r  r@  r>   r  r  r  r  r  r  r   r   r  r>  r   r  r  r  Z	set_stater  )
rO   r  r  r  r  r   rO  r   r   rx  s
   &&f&      r   r  Z2TypingBoosterEngine._init_or_update_sub_propertiesc  s    ///F-1]]_D  *F{" GBB668G5&IJJDT{8$L(99..00$K(EE$K'+i0(,"mm11))33E: II55g>%#"	)$% $$X.55OOD)+ %//II--e46%11II--g68%33G<%11':%//6$$T__T%:;? Kr    c                rC   r   r'   rD   rF   r   r   r	    s     F6 F6$ F6r    c           
     s$   / V n         / V n        \        P                  ! 4       V n        \        P                  ! 4       V n        \        P                  ! 4       V n        V P                  R8w  d   \        P                  ! 4       p\        P                  ! R\        P                  P                  V P                  4      VP                  V P                   RV P                   24      \        P                  P                  V P                  4      RRR7      pV P                  P!                  V4       V P#                  V P$                  V P&                  4       V P)                  4       '       dM   V P#                  V P*                  V P,                  4       V P#                  V P.                  V P0                  4       V P3                  V P4                  ^ R7       V P7                  V P8                  ^ R7       \        P                  ! R\        P                  P                  \;        R	4      4      R
\        P                  P                  \;        R4      4      RRR7      pV P                  P!                  V4       V P=                  V P                  4       R# )z$
Initialize the ibus property menus
r  Z	m17n_iconr{  TF)rv  r   r  rx  r  r   r  setupZSetupzgtk-preferencesz#Preferences for ibus-typing-boosterN)r  r  r   r  r  r  r  r  rn  Z
M17nDbInfor  r   r   Zget_iconr  r  r>  r  r  r  r  r  r  r  r  r  r  r  r  r%   register_properties)rO   Zm17n_db_infoZm17n_icon_propertyZsetup_propertyr  r   rJ  Z$TypingBoosterEngine._init_properties  s    !48MMO137==?0"mmo 00#..0L!%ii//0A0AB"++**+1T-@-@,ABD		11$2C2CD
  !"$ &&'9: 	**  	 ++-- ..//'') ..--$$& 	55  q 	6 	2 	66!! 	7 	3 ))++AgJ7"II--78: 	"">2  !4!45r    c                r   )r   ibus_property
prop_stater   N)r   r   r  rD   rF   r   r   r	    s/     7 77 7 GK7r    c                s   V P                   ^8  d   \        P                  RW4       VR8X  d   V P                  4        R# V\        P
                  P                  8w  d   R# VP                  V P                  R,          R,           4      '       dh   V P                  V,          R,          pV^ 8w  dE   V P                  4       pV P                  WC,          .WC^,           R ,           VRV ,           RR7       R# VP                  V P                  R,          R,           4      '       dr   V P                  V,          R,          pV^ 8w  dO   V P                  4       pV P                  WS,          .WS^,           R ,           VRV ,           V P                   R7       R# VP                  V P"                  R,          R,           4      '       d3   V P%                  \'        V P(                  V,          R,          4      4       VP                  V P*                  R,          R,           4      '       d5   V P-                  \'        V P.                  V,          R,          4      4       R# VP                  V P0                  R,          R,           4      '       d5   V P3                  \'        V P4                  V,          R,          4      4       R# R# )	z
Handle clicks on properties
zibus_property=%s prop_state=%sr  Nrv  r
  rs  TrN  )r  r1   r'  _start_setupr   r  r  rV  r  r  r  r$  r  r  r  r  r  r  r  r   r  r  r  r  r  r  r  )rO   r  r  rs  namesr}  r  r   do_property_activateZ(TypingBoosterEngine.do_property_activate  su    q LL0-MG#/// ##D$8$8$?$CDD//>xHF{ 113))]Oe1HI&66wG%) * + ##D$9$9%$@$DEE00?IF{ ,,.%%\NT()_4tGV}D%)%I%I & K ##$$U+c13 3T//#%%-/ 01 ##//6<> >**T::#%%-/ 01 ##--e4s:< <((T88#%%-/ 01 <r    c                rC   r   r'   rD   rF   r   r   r	     s     ' 'd 'r    c                sN   V P                  4       '       d&   \        P                  R4       V P                  4        \        P
                  ! R4      '       dF   \        P                  P                  \        P
                  ! RR4      R4      pVRV P                  .pM|\        P                  P                  \        P                  P                  \        P                  P                  \        4      4      R4      p\        P                  VRV P                  .p\        P                  RRP                  V4      4        \        P                  ! V4      V n        R
#   \"         d>   p\        P%                  R	TP&                  P(                  T4       R
T n         R
p?R
# R
p?ii ; i)z-Start the setup tool if it is not running yetz7Another setup tool is still running, terminating it ...Z IBUS_TYPING_BOOSTER_LIB_LOCATIONrB   zibus-setup-typing-boosterz--engine-namez../setup/main.pyzStarting setup tool: "%s"r5  z+Exception when starting setup tools: %s: %sN)_is_setup_runningr1   r  _stop_setuposgetenvr  r  r  dirnameZabspath__file__r.   
executable
subprocessPopenr  r7   r  r  rR   )rO   Z	setup_cmdZcmdZsetup_python_scriptr2      &    r   r  Z TypingBoosterEngine._start_setup   s/   !!##KKQR99788		<bA+-I ot/@/@AC"$'',, 9:"#$ >>#6IZIZ[C/#?	'","2"2#D 	'=((%1 #'D		's   ?E F$'2FF$c                rj   rk   r   rD   rF   r   r   r	  :  s     2 24 2r    c                sZ    V P                   f   R# V P                   P                  4       RJ # )z,Check if the setup process is still running.NF)r  Zpollrm   r$   r   r  Z%TypingBoosterEngine._is_setup_running:  s+    &""'')T11r    c                rC   r   r'   rD   rF   r   r   r	  @  s     / /T /r    c                s    V P                  4       '       dF   V P                  '       d2   V P                  P                  4        \        P	                  R4       R# R# R# )z'Terminate the setup process if running.zStopped setup tool.N)r  r  Z	terminater1   r  rm   r$   r   r  ZTypingBoosterEngine._stop_setup@  sC    !!##(;(;(;))+KK-. )<#r    c                rC   r   r'   rD   rF   r   r   r	  G  s     & &D &r    c                sF    V P                  4        V P                  4        R# )u6   Clear the preëdit and close the lookup table
        N)r  _update_ui_empty_inputrm   r$   r   r\  Z.TypingBoosterEngine._clear_input_and_update_uiG  s     	##%r    c                rC   r   r'   rD   rF   r   r   r	  M  s      D r    c                s   < V P                   ^ 8  d   \        P                  R4       V P                  4        V P	                  4        \
        SV `  4        R# )z3Called when this input engine is destroyed
        entering functionN)r  r1   r'  r\  do_focus_outr  Zdestroyrd  re  r   
do_destroyZTypingBoosterEngine.do_destroyM  sB     q LL,-'')r    c                rj   rk   r   rD   rF   r   r   r	  V  s      3 r    c                sb   V P                   '       g   R# RP                  V P                   RV P                   4       RRP                  V P                   V P                  R 4       2pV P                  ^ ,          R8X  d0   VP	                  RP                  \
        P                  4      R4      # V# )u  Return a representation of the raw input as a string

The cursor position within the raw input is indicated with
'│' U+2502 BOX DRAWINGS LIGHT VERTICAL.

Compared to '|' U+007C VERTICAL BAR, U+2502 has the advantages:

- less likely in regular input
- wider spacing in a horizontal box and thicker line
  (makes it less likely to be confused with a normal character)

`te│st`      ← Obvious separation, clear gap, cursor stands out
`I│love`     ← No confusion with capital I
`l│ist`      ← No confusion with lowercase L

'┃' U+2503 BOX DRAWINGS HEAVY VERTICAL might be an alternative
but this renders ugly and narrow on Gnome Wayland on a default
Fedora 43 install.
rB   Nu   │ja-anthy)r2  r  r3  r  rB  rn  ANTHY_HENKAN_WIDE)rO   Zraw_input_reprrP   r   _raw_input_representationZ-TypingBoosterEngine._raw_input_representationV  s    ( !!!wwt))*D4+D+DEFGswwt))$*C*C*DEFGI 	 a J. "))"''(2L2L*MrRRr    c                s@   < V ^8  d   QhRS[ P                  RS[RS[/# )r   rD  r   r   )r   r<  r   r   rD   rF   r   r   r	  u  s)      .16:r    c           
     s   V P                   '       gR   V P                  P                  '       g6   V P                  4       ^ ,          R,          R9   g   V P                  '       g   R# \
        P                  ! V4      pVP                  V4      p\        V4      ^8  do   V P                  P                  P                  V4      '       gD   VP                  \        P                  ! V P                  VV\        V4      ,           4      4       R# R# )zMay color the preedit if spellchecking fails

:param attrs: The attribute list of the preedit
:param text: The current text in the preedit which
             may need color added
Nr   NFT)zhja)r1  r0  r:  r  r  rn  strip_tokenfindr  r  r#  
spellcheckr>  r   r?  r  )rO   rD  r   Zstripped_textr[  r   r   "_add_color_to_attrs_for_spellcheckZ6TypingBoosterEngine._add_color_to_attrs_for_spellchecku  s     (((%%000$$&q)"-=111 ,,T2		-0!#MM&&11-@@LL1133M 224 5 r    c                :   < V ^8  d   QhRS[ P                  RS[/# r   rD  r   r   r<  r   rD   rF   r   r   r	    s      T]] t r    c                sP   V P                   '       d   V P                  '       g   R# V P                  4       ^ ,          p\        V P                  V,          4      p\        V P
                  4      pVP                  \        P                  ! V P                  VW4,           4      4       R# )z[May color the compose part of the preedit

:param attrs: The attribute list of the preedit
FT)
r1  r  r  r  r9  r:  r>  r   r?  r  )rO   rD  r  Zlength_before_composeZlength_composerj  r   _add_color_to_attrs_for_composeZ3TypingBoosterEngine._add_color_to_attrs_for_compose  s    
 ,,,...##%a( #77<!>557T--,,!!24 	5 r    c                r  r  r  rD   rF   r   r   r	    s!     # ##+/#r    c                s   V P                   '       g   V P                  '       g   R# V P                  P                  '       dA   \	        V P                  P
                  4      p\	        V P                  P                  4      pEMV P                  4       ^ ,          pV P                  V,          pVP                  V P                  V P                  R7      pVP
                  p\	        V4      pVP                  p\	        V4      pV P                  '       dw   VP                  V P                  R.,           V P                  R7      p	V	P                  R4      '       d1   V	P                  V4      '       d   V	\	        V4      R p\	        V4      pV'       g   R# VP!                  \"        P$                  ! V P&                  VW#,           4      4       R# )zMay color the m17n candidate part of the preedit

:param attrs: The attribute list of the preedit

Uses the same color as for compose preedits.
Fr&  r5  TrQ  )r1  r  r0  r:  r  	committedpreeditr  r;  transliterate_partsr2  r  r  r'  r(  rV  r>  r   r?  r  )
rO   rD  Zlength_beforeZlength_inner_preeditr  transtransliterated_partsbeforeinner_preedit	finalized
   &&        r   $_add_color_to_attrs_for_m17n_preeditZ8TypingBoosterEngine._add_color_to_attrs_for_m17n_preedit  s    (((+++!!,,, 6 6 @ @AM#&t'='='E'E#F '')!,C))#.E#(#<#<""1C1C $= $E )33FKM088M#&}#5 $$$!//&&#.T=O=O 0 Q	%%c**y/C/CF/K/K$-c&k"$=M+.}+=(#T--))02 	3 r    c                rj   rk   r   rD   rF   r   r   r	    s      .  .C  .r    c                s   V P                  4       ^ ,          pV P                  V,          pV P                  V,          pV P                  '       d@   V P                  V,          pV P
                  pV\        V4      \        V4      ,           R pEM%V P                  P                  '       dL   V P                  P                  pV P                  P                  pV\        V4      \        V4      ,           R pMVP                  V P                  V P                  R7      pVP                  pVP                  pRpV P                  '       dl   VP                  V P                  R.,           V P                  R7      pVP!                  R4      '       d&   VP#                  V4      '       d   V\        V4      R pV P$                  V P&                  ,          R,          p	\)        V	! V4      4      p\)        V	! V4      4      pWE,           V,           # )u   Apply the current case mode and normalization only to the
parts of the preedit which do not belong to an “inner” preedit.

An “inner” preedit might come from a compose sequence, an m17n
candidate list, or an unfinished m17n transliteration.
Nr&  rB   r5  rd  rQ  )r  r;  r8  r1  r9  r:  r  r0  r:  r  r  r  r2  r  r  r'  r(  rV  r@  r?  r   )
rO   r  r  r   r  r  Zafterr  r  Zcm_func
   &         r   *_get_preedit_string_with_case_mode_appliedZ>TypingBoosterEngine._get_preedit_string_with_case_mode_applied  s    ##%a(%%c*++C0'''@@EF EEMVs='99:;E##...++55F 22::MVs='99:;E#(#<#<""1C1C $= $E )33F088ME$$$!//&&#.T=O=O 0 Q	%%c**y/C/CF/K/K$-c&k"$=M""4#:#:;JGWV_%GEN#%--r    c                rC   r   r'   rD   rF   r   r   r	    s     6= 6= 6=r    c           	     s(   V P                   ^8  d   \        P                  R4       V P                  ^8  d   V P                  '       d   V P
                  P                  '       g!   V P
                  P                  4       '       g_   V P                  \        P                  P                  V P                  4        4      R4       V P                  V P                  4       R4       V P                  4       pV P                   ^8  d   \        P                  RV4       V P                   '       d   R\#        V4      ,          pVR8X  d   V P$                  P&                  R8X  d)   V P                   ^8  d   \        P                  R4       R# V P)                  \        P                  P                  R4      ^ R\        P*                  P,                  4       R# \        P.                  ! 4       pV P0                  '       d9   V P
                  P2                  '       g   V P
                  P4                  '       d   VP7                  \        P8                  ! V P:                  ^ \#        V4      4      4       V P=                  V4      pRpV'       g   V P?                  V4      pV'       g   V'       g   V PA                  W!4       MHVP7                  \        P8                  ! \        PB                  PD                  ^ \#        V4      4      4       \        P                  P                  V4      pVPG                  V4       V PI                  4       pV PJ                  '       d   V PI                  R	R
7      pV P)                  WVR\        P*                  P,                  4       R# )zUpdate Preedit String in UIr  TFu   _str=“%s”*rB   %Avoid clearing already empty preedit.Nr5  r%  )&r  r1   r'  r  r2  rA  r   r   ro  r   r   r   r  rj  rp  r  r  r  r  r  rt  r   r  r<  r  r   r   r>  attr_underline_newr  r  r  r  AttrUnderlineNONErC  r.  r  )rO   Z_strrD  Zcompose_coloredm17n_coloredr   r,  s   &      r   _update_preeditZ#TypingBoosterEngine._update_preedit  s   q LL,-  A%"""##*****CCEE&&		))T-K-K-M,NP $$T%:%:%<eD>>@q LL$/T?D2:))22b8$$q(LL!HI..		))"-q%%%,,. 444!!000!!>>>LL00''CI7 8"BB5IO L"#HHO#|77D LL00""''CI7 8yy((.E"    NNN5E**t44;;	=r    c                rC   r   r'   rD   rF   r   r   r	     s     S2 S2T S2r    c           	     sN   RpV P                   P                  \        P                  8X  dz   VRP	                  V P
                  V P                  P                  V P                   4      P                  RP	                  \        P                  4      R4      ,          pVR,          pV P                  ^8  dC   V P                   P                  \        P                  8X  d   WP                  4        R2,          pV P                  '       dH   VRV P                   P!                  4       ^,            RV P                   P#                  4        R2,          pV P$                  '       Ed   V P                   P                  \        P&                  8X  d   VR,          pEMV P                   P                  \        P(                  8X  d   VR,          pEMoV P                   P                  \        P*                  8X  d   VR,          pEM;V P                   P                  \        P                  8X  d#   VR	V P                  P,                   R2,          pMV P.                  '       d   V\0         \2         R
2,          pMV\4         \2         R
2,          pV P6                  '       d   V\0         \8         R
2,          pMV\4         \8         R
2,          pV P;                  4       pV'       d0   W^ ,           R\        P<                  ! V^ ,          4       2,          pV P?                  4       ^ ,          pVR8w  d   VRV R2,          p\@        PB                  ! 4       pVPE                  \@        PF                  ! \        PH                  ! R4      ^ \K        V4      4      4       V PL                  ^ 8  d   V PN                  '       g   RV PP                  PR                   2pW,          pVPE                  \@        PF                  ! \        PH                  ! R4      \K        V4      \K        V4      ,
          \K        V4      4      4       V PL                  ^8  d   RpV PT                  '       d   Rp\K        V4      pW V PW                  4        R
V PY                  4        R
V P[                  4        2,          pVPE                  \@        PF                  ! \        PH                  ! R4      V\K        V4      4      4       \@        P\                  P_                  V4      pVPa                  V4       Rp	V P                   P#                  4       ^ 8X  g[   V Pb                  '       gI   V Pd                  '       d/   V Pf                  '       g   V P                   Ph                  '       d	   V'       g   Rp	V Pk                  W4       R# )zUpdate auxiliary textrB       Z(z / z) u   ⎄ u   🔗 u   🔬 u   🦜 r5  r  Z	SlateGrayu   🪟ZPurpleu   🔴u   🟢ZDeepPinkTFN)6rA  r   r{   r   r  r2  r0  committed_indexr3  rB  rn  r  r  r   r  r  r   r   r  r   r   r   Zstatusr  rF  rE  rD  r  rG  r  r  r  r   r<  r>  r?  r  r  r  r  r  r]   rZ  rv  rt  rr  r   r   rC  r  r  rx  r   ro  )
rO   Z
aux_stringr  r*  rD  r]   Zcontext_indicatorZlen_aux_string_origr   r   r  r   _update_auxZTypingBoosterEngine._update_aux   s   
##'7'G'GG"''""**::..01 29#%778+E+E#F2LLJ
 %J  A%""((,<,C,CC;;=>cBBJ***D&&557!;<C%%>>@AEFJ 333!!''+;+O+OOh&
##))-=-P-PPi'
##))-=-L-LLi'
##))-=-M-MM(>(>(E(E'FcJJ
 ***)*+G*HJLJ *+,H+IKMJ''')*+E*FaHJJ *+,F+GqIKJ1131XJc(2C2CE!H2M1N"OOJ"335a8')C}C"88J T--))+6
O 	 q D--4456F JLL11--h7JF+J! " q  &555$*!"%j/0"1134A"00231"//124 5J LL11--j9#J! " yy((4E"779Q>   **999G""41r    c                rC   r   r'   rD   rF   r   r   r	  u  s     _ _d _r    c           
     sV   V P                  4       '       do   V P                  '       g]   V P                  ^ 8w  dL   V P                  P                  \
        P                  \
        P                  39  d   V P                  '       dr   V P                  '       g`   V P                  P                  4       ^ 8X  gA   V P                  '       dQ   V P                  '       g?   V P                  P                  '       g#   V P                  4        V P                  4        R# V P                  '       d   V P                  '       gz   V P                  '       gh   V P                  P                  \
        P                   \
        P                  \
        P                  39   g    V P                  P#                  4       ^ 8w  d3   V P%                  V P'                  4       R4       V P                  4        R# \(        P*                  ! V P,                  V P/                  4       ^ ,          ,          4      p\(        P*                  ! V P0                  ^ ,          P2                  4      pVP5                  V4      '       d   W!8X  d   V P                  ^8  g!   V P                  P7                  4       '       d"   V P%                  V P'                  4       R4       MAV P                  4        \8        P:                  P=                  R4      pV P?                  VR4       V P                  4        R# V\A        V4      R pV P                  4        \8        P:                  P=                  R4      pV P?                  VR4       \8        P:                  P=                  W,           4      p\8        PB                  ! 4       pVPE                  \8        PF                  ! V PH                  ^ \A        V4      4      4       V P                  P7                  4       '       dK   VPE                  \8        PF                  ! V PH                  \A        V4      \A        W,           4      4      4       MV PK                  V4      pV'       g   V PM                  WQ4       V PN                  '       dJ   VPE                  \8        PP                  ! V PR                  \A        V4      \A        W,           4      4      4       VPE                  \8        PF                  ! \8        PT                  PV                  \A        V4      \A        W,           4      4      4       VPY                  V4       V P                  P7                  4       '       d   V PZ                  '       g   \A        V4      pMV P]                  4       pV P_                  W7R\8        P`                  Pb                  4       R# )zYUpdate the lookup table

Show it if it is not empty and not disabled, otherwise hide it.
NTrB   F)2r  rx  r  rA  r   r{   r   r   r1  r  r   r  r   rg  r   r  r   r   rj  rp  rn  ro  r8  r  r=  r   rV  r   r   r   r   ro  r  r<  r>  r  r  r  r  r  r?  r  r  r  rC  r  r.  rt  r   r  )rO   r+  r]  r   Z
completionrD  r  r,     &       r   _update_lookup_tableZ(TypingBoosterEngine._update_lookup_tableu  s1    ]]__\\\((A-##))!44!0022 2 111!!::<A   **999""$  "'''|||+++!!'' 00 33 //,1 1 !!002a7$$T%:%:%<dC  "  HH((%%'*,- #KKQ&&(**<88. ''!+%%7799(()>)>)@$G &&(yy004**47  " %S%6%78
 yy((,""4/yy(()BCT,,##QL(9; 	<//11LL00''L!3|'@#AC D  DDUKL77L,,,T5566%s<+D'EG H LL00""''L!3|'@#AC D 	E"0022444(ENN$E**t44;;	=r    c                rC   r   r'   rD   rF   r   r   r	    s     '$ '$d '$r    c                s   V P                  4        RV n        V P                  P                  4       '       Ed   V P                  P	                  4       '       Egl   V P
                  ^8X  d%   V P                  P                  R4       RV n        EM6V P
                  ^8X  Ed%   RpRpRpV P                  '       d;   V P                  ^ ,          P                  pV P                  ^ ,          P                  p\        P                  ! V P                  V P                  4       ^ ,          ,          4      pV P                  P                  P!                  V P"                  V P$                  V34      pV'       dS   V'       dK   W18w  dE   \        P&                  ! V4      V8X  d*   VR8  d#   V P                  P                  R4       RV n        V P)                  4        ^ V n        R# )zUpdate the lookup table and the auxiliary text

:return: None, always, which is falsy and should work
         the same as `return False` to remove the source
         added by Glib.timeout_add() (GLib.SOURCE_REMOVE is False)
FTrB   rI  g?N)r  r  rA  r   r   r  r   r=  r   r/  rn  ro  r8  r  r  r#  spellcheck_single_dictionaryr4  r5  Zremove_accentsr  r  )rO   r]  r/  r+  r  r  r   _update_lookup_table_and_auxZ0TypingBoosterEngine._update_lookup_table_and_aux  s}    	 ,1(7799&&88::**a/""55d;370,,1"$	!###&*&6&6q&9&@&@O $ 0 0 3 = =I'PP001F1F1H1KL N MM..KK/JL - 1$$7 //@#$!C&&99$?7;D4!!#"#r    c                rC   r   r'   rD   rF   r   r   r	    s     J JT Jr    c                s&   V P                   '       di   V P                  P                  4       '       dI   V P                  \        P
                  P                  V P                  P                  4       4      R4       M/V P                  \        P
                  P                  R4      R4       V P                  4        V P                  4        V P                  ^8  d   R# V P                  '       g   R# \        P                  RV P                  4       R# )zUpdate the candidates, the lookup table and the auxiliary text

:return: None, always, which is falsy and should work
         the same as `return False` to remove the source
         added by Glib.timeout_add() (GLib.SOURCE_REMOVE is False)
TrB   FNself._surrounding_text=%r)r
  r  r=  ro  r   r   r   r_  r  r  ry  r1   r'  rW  rm   r$   r   +_update_candidates_and_lookup_table_and_auxZ?TypingBoosterEngine._update_candidates_and_lookup_table_and_aux  s      7 7 = = ? ? &&		))++11356:< &&		))"-u6!))+q (((0$2H2HIr    c                rC   r   r'   rD   rF   r   r   r	    s     2 2 2r    c                s   V P                   ^8  d   \        P                  R4       V P                  4        V P                  P                  4        V P                  P                  R4       V P                  4        RV P                  n        \        P                  V P                  n        V P                  \        P                  P                  R4      R4       R# )a  Update the UI when the input is empty.

Even when the input is empty, it is possible that a preedit
and a lookup table are shown because it is possible that
self._min_char_complete == 0 and then sometimes a completion
is tried even when the input is empty.

r  FrB   N)r  r1   r'  r   rA  r   r   rg  r   r{   r   r   ro  r   r   r   rm   r$   r   r  Z*TypingBoosterEngine._update_ui_empty_input  s     q LL,-  "--e4 ,1)#3#:#: ""II%%b)5	2r    c                rC   r   r'   rD   rF   r   r   r	  ,  s     N6 N6t N6r    c                s.	   V P                   ^8  d   \        P                  R4       V P                  4       '       g   V P	                  4        R# V P                  4        V P                  '       gu   V P                  P                  P                  4       '       d   V P                  '       g9   V P                   ^8  d   \        P                  R4       V P                  4        R# V P                  ^ 8w  d   V P                  '       de   V P                  '       gS   V P                  '       dA   V P                   '       dA   V P                  '       g/   V P"                  P$                  '       g   V P                  4        R# RV P"                  n        \&        P(                  V P"                  n        V P,                  P/                  RV P1                  4       V P3                  4       R7      pV P                   ^8  d   \        P                  RV4       V'       g   V P                  4        R# V P"                  P5                  4        V P"                  P7                  R4       V P9                  4        V P:                  '       di   V P<                  P?                  4       '       dI   V PA                  \B        PD                  PG                  V P<                  P?                  4       4      R4       M/V PA                  \B        PD                  PG                  R4      R4       V Uu. uF2  p\H        PJ                  ! VPL                  VPN                  RRRR	7      NK4  	  upV n(        V PP                   FK  pV PS                  VPL                  VPN                  VPT                  VPV                  VPX                  R	7       KM  	  V PP                  P[                  4       V n.        V P^                  R
8w  d   V Pa                  V P^                  R7       V P	                  4        V Pb                  '       d(   \d        Pf                  ! V Pb                  4       ^ V n1        V Ph                  pV P                  '       d   ^ p\d        Pj                  ! W0Pl                  4      V n1        R# u upi )z;Update the UI when the input is empty and try a completion.r  NzSFailed to get context from surrounding text. Do not try to complete on empty input.FrB   rF  zphrase_candidates=%sTrJ  r`  rN  )7r  r1   r'  r  r   get_contextr  rW  rJ   rM   rZ  r  r  rx  r  r  r  rA  r   r{   r   r   r  rT  rr  rt  r   r   rg  r
  r  r=  ro  r   r   r   rn  rU  r   r/  r=  rE  r0  r1  r2  rQ   r>  r?  rY  r  r   source_remover  timeout_addr  )rO   rZ  r\  delayr  r   %_update_ui_empty_input_try_completionZ9TypingBoosterEngine._update_ui_empty_input_try_completion,  s|   q LL,-}}  "''--4466:::  1$=> '')$$)$,,,)))   **999
 ''),1)#3#:#:  MM66**,8J8J8L 7 Nq LL/1BC '')  "--e4  7 7 = = ? ? &&		))++11356:< &&		))"-u6 *+ * (({{..!$& *+ $$D22{{..!..#22 3 4 % +/*:*:*?*?*A'""f,""(?(?"@"""t667&'D#33<<<E"&"2"244#63+s   8Rc                rC   r   r'   rD   rF   r   r   r	  |  s     -E -ED -Er    c                s   V P                   ^8  d   \        P                  R4       V P                  4       '       d   RV P                  n        V P                  4       '       gi   V P                  '       gW   V P                  4       '       dA   V P                  '       d   V P                  '       g   V P                  P
                  '       g   V P                  P                  4        V P                  P                  R4       V P                  4        V P                  \        P                  P!                  R4      R4       V P#                  4        R# \$        P&                  V P                  n        V P#                  4        V P                  P                  4        V P                  P                  R4       V P                  4        V P                  \        P                  P!                  R4      R4       V P*                  '       d(   \,        P.                  ! V P*                  4       ^ V n        V P0                  pV P                  '       d   ^ p\,        P2                  ! WP4                  4      V n        R# )zUpdate User Interfacer  FrB   N)r  r1   r'  r  rA  r   r  r  r  rx  r   r   rg  ro  r   r   r   r   r{   r   r   r  r   r  r  r  r	  )rO   r  rP   r   r  ZTypingBoosterEngine._update_ui|  s   q LL,-==?? 16D-MMOO3355   **999
 $$&11%8""$&&		))"-u6  "#3#:#:  	  "--e4 ""II%%b)5	2"""t667&'D#33<<<E"&"2"2CC#Er    c                r$  )r   r   r   r   r   rD   rF   r   r   r	    s     | | |T |r    c                s   V P                   P                  \        P                  \        P                  39   d)   V P
                  ^8  d   \        P                  R4       R# V P                  '       d@   V P                  '       g.   V P                   P                  '       g   RV P                   n
        VR8X  dz   V P                   P                  4       '       d2   V P                   P                  4       '       d   V P                  4       pM(V P                  V P                  4       ^ ,          ,          pV'       g   R# V P                   P"                  pV P                   P$                  pV P                   P                  4       '       d   V P'                  4        V P(                  '       di   V P*                  P-                  4       '       dI   V P/                  \0        P2                  P5                  V P*                  P-                  4       4      R4       M/V P/                  \0        P2                  P5                  R4      R4       . pV P6                  '       d*   V P6                  P9                  4       V P:                  8w  d=   \<        P>                  ! V P:                  V P@                  V PB                  R7      V n        V P
                  ^ 8  d   V P6                  PE                  V4      pMV P6                  PE                  VRR7      p\F        '       g   \        PI                  R4       M\        PI                  RV4        \J        PL                  ! VRR	7       F+  pVPO                  \P        PR                  ! V^ R
R7      4       K-  	  \J        PT                  ! VRR	7       F+  pVPO                  \P        PR                  ! V^ RR7      4       K-  	  \J        PV                  ! VRR	7       F+  pVPO                  \P        PR                  ! V^ RR7      4       K-  	  V P
                  ^8  d   \        P                  RW4       V'       gU   V P/                  VV4       V P                   P                  4       '       d!   V Pa                  V Pc                  4       R4       R# . V n2        V P                   Pg                  4        V P                   Pi                  R4       V F  p	V Pd                  PO                  \P        PR                  ! V	Pj                  V	Pl                  V	Pn                  RRR7      4       V Pq                  V	Pj                  V	Pl                  V	Pn                  R7       K  	  \        Pr                  V P                   n        WP                   n:        V Pw                  4        R#   \X        3 d7   p\        P[                  RTP\                  P^                  T4        Rp?ELRp?ii ; i)zLookup related (similar) emoji or related words (synonyms,
hyponyms, hypernyms).

:return: True if related candidates could be found, False if not.
zSCompose completions or m17n candidates are shown, not looking up related candidatesFTrB   r^  )Zshow_keywordsznltk is not availableu-   Getting related words from nltk for: “%s”)Zkeep_originalz	[synonym]rM  z
[hypernym]z	[hyponym]z)Exception when trying to use nltk: %s: %sNu$   related_candidates of “%s” = %s
rJ  )<rA  r   r{   r   r   r  r1   r'  r  rx  r   r   r   rl  r8  r  r  r   r   rg  r
  r  r=  ro  r   r   r   r  rW  r  r(  r)  r  r  ZsimilarIMPORT_ITB_NLTK_SUCCESSFULr  itb_nltkZsynonymsr>  rn  rU  Z	hypernymsZhyponymsLookupErrorr  r  rR   rj  rp  r=  r   r   r   r/  r0  rE  r   r   r  )
rO   r   Zoriginal_auxiliary_text_contentZoriginal_auxiliary_text_visibleZrelated_candidatesZsynonymZhypernymZhyponymr2   r\  r  r   _lookup_related_candidatesZ.TypingBoosterEngine._lookup_related_candidates  s    $$ 44 00)2 2   1$89  LLL&&55504D-R<"";;==''99;;EEG55))+A.0 +/*F*F*N*N'*.*F*F*N*N'6688""$ 7 7 = = ? ? &&		))++11356:< &&		))"-u6 """,,.%%&!*!7!700!%!7!7#'#4#4"6D q !%!3!3!;!;" "&!3!3!;!;e "< "-))KK/0KKGP6'00uMG&--h.J.J&![/J K  N !) 2 26 OH&--h.J.J'1l/L M !P  (00uMG&--h.J.J&![/J K  N q LL7, " &&//1 !!::<<(()>)>)@$G  "--e4&D##,,;;"nn LL!&#(*+ 22{{dnndll 3 T ' $4#F#F 7=4))+C  > 6  ?__--u6 66s   >CV   W",+WW"c                r$  )r   rO  r   r  rD   rF   r   r   r	  )  s     = ==#'=r    c                sf   V P                   ^8  d   \        P                  R4       VR9  d   R# V P                  4       '       d   R# VR9   d+   V P                  V P
                  ,          V,          V n        MWn        V P                  '       d!   V P                  P                  4       '       g   R# . pV P                   F  pVP                  \        P                  ! V P                  V P
                  ,          R,          ! VP                  4      VP                  VP                  VP                   VP"                  R7      4       K  	  W n        V P                  P%                  4       pV P                  P'                  4       pV P                  P)                  4        V P                   FK  pV P+                  VP                  VP                  VP                  VP                   VP"                  R7       KM  	  V P                  P-                  V4       V P                  P/                  V4       R# )a  Change the case of the current candidates and the preedit

Change the case of all the candidates in the current list of
candidates. Then create a new lookup table and fill it
with the changed candidates to make the changes visible. But
keep the cursor position and cursor visibility status of the
old lookup table.

Available modes:

    'next', 'previous', 'capitalize', 'title', 'upper', 'lower'

:return: True if something was done, False if not.
u   ⎆FTrd  rJ  )ra  rc  r`  rb  rm  ri  r~   )ra  rc  )r  r1   r'  r  r@  r?  r=  rA  r   r>  r>  rn  rU  r   r/  r0  r1  r2  r   r   r   rE  r   r   )rO   rO  Znew_candidatesr\  Zcursor_visiblerH   r-  r   rY  Z%TypingBoosterEngine._case_mode_change)  s   " q LL   ==??''&*&6&6'''))-'/D# '+#   %%>>@@33D!!,,++//11;==A[[J"nn LL!%!2!2#'#6#689 4 *++==?''668
  "$$D22{{..!..#22 3 4 % 	))*5--n=r    c                s6   < V ^8  d   QhRS[ S[,          RS[/# )r   msymbol_listr   )r   r   r   rD   rF   r   r   r	  h  s      c t r    c                sB   V P                  4        Fc  pV P                  V,          P                  V4      RP                  V4      8w  g   K;  V P                  ^8  d   \
        P                  RV4        R# 	  V P                  ^8  d   \
        P                  RV4       R# )zCheck whether the current input (list of msymbols) has a
(non-trivial, i.e. not transliterating to itself)
transliteration in any of the current input methods.
rB   z!_has_transliteration(%s) == True
Tz"_has_transliteration(%s) == False
F)r  r;  r'  r  r  r1   r'  )rO   r  r  ri   r   _has_transliterationZ(TypingBoosterEngine._has_transliterationh  s    
 ((*C$$S)77 "%'WW\%:;$$q(LL<lL + q LL5|Er    c                r$  r   ri  rD   rF   r   r   r	  y  s      s t r    c                sh   V P                   P                  4       '       g   R# V P                  4       V P                  ,          V,           pVV P                   P                  4       8  d   ^ Tu;8:  d   V P                  8  g    R#  R# V P	                  V4      '       d   V P                  4        R# R# )u   
Removes the candidate at “index” in the lookup table from the
user database.

:return: True if a candidate could be removed, False if not
:param index: The index of the candidate to remove in the lookup table
FT)rA  r   rh  r  ro  r  )rO   r   candidate_numberri   r   _remove_candidateZ%TypingBoosterEngine._remove_candidatey  s     !!::<<//1DOOCeK 	   99;<U,T__, -33E::OOr    c                s,   < V ^8  d   QhRS[ RS[RS[/# )r   r   
extra_textr   )r>   r   r   rD   rF   r   r   r	    s.     i ii i &*ir    c                s  <a V P                   '       d   \        P                  RV4       R# V P                  P	                  4       '       d   V P                  P
                  '       d   R# V P                  4       V P                  ,          V,           pVV P                  P	                  4       8  d   ^ Tu;8:  d   V P                  8  g    R#  R# V P                  V4      pV'       g   R# V P                  P                  \        P                  8X  Ed
   \        P                  V P                  n	        . V n        V P                  P                  4        V P                  P                  R4       V P!                  4        . V n        V P%                  4        V P'                  4        V P)                  4       '       d-   V P+                  \-        V4      4       V P/                  4        R# \0        SV `e  \4        P6                  P9                  V4      4       RV n        R# V P                  P                  \        P<                  8X  Ed   V P>                  ^8  d   \        PA                  RV4       \        P                  V P                  n	        . V n        V P                  P                  4        V P                  P                  R4       V P!                  4        \C        V4      oTp\D        ;QJ d3    V3R lV PF                  PH                   4       F  '       d   K   RM(	  RM$! V3R lV PF                  PH                   4       4      '       dt   V PF                  PJ                  RV PF                  PL                   R\C        V4      )  V,           V PF                  PJ                  V PF                  PL                  R ,           pV P>                  ^8  dV   \        PA                  RV\O        V PF                  4      4       \        PA                  RV PP                  V PR                  4       V PP                  RV PF                  PT                   \-        V4      ,           V PP                  V PR                  R ,           V n(        V PF                  PT                  \C        \-        V4      4      ,           V n)        V P>                  ^8  d,   \        PA                  R	V PP                  V PR                  4       V P%                  4        \V        PX                  ! 4       V n#        V P/                  4        R# V P[                  4       '       d   V P]                  WB,           VR
7       MV P]                  WB,           4       V P_                  4        VR8X  d4   V Pa                  4        \b        Pd                  ! ^V Pf                  4       R# V Pi                  4        R# )u  
Commits the candidate at “index” in the lookup table

:return: True if a candidate could be committed, False if not.
:param index: The index of the candidate to commit in the lookup table
:param extra_text: Additional text append to the commit,
                   usually a space
z3OSK is visible: do not commit candidate by index %sFTu   Commit m17n candidate “%s”c              3   @   <"   T F  p\        V4      S8H  x  K  	  R # 5ir:   rK  .0	candidateselected_candidate_length   & r   	<genexpr>Z8TypingBoosterEngine._commit_candidate.<locals>.<genexpr>  #      G$Ey 	N&??$E   N0   m17n_preedit_replacement=“%s” trans_parts=%s8OLD: self._typed_string=%s, self._typed_string_cursor=%sz8NEW: self._typed_string=%s, self._typed_string_cursor=%sinput_phraser5  )5rx  r1   r  rA  r   r   rh  r  rm  r   r{   r   r   r=  r   r   r  r1  r  r   r  r  r  r  r  commit_textr   r   r   r+  r   r  r'  r  allr0  r:  r  rH   r0   r2  r3  r  r.  r/  r  _commit_stringr  rz  r   r  r  r  )rO   r   r  r  selected_candidatem17n_preedit_replacementr  r  s   &&&   @r   _commit_candidateZ%TypingBoosterEngine._commit_candidate  s    <<<KKEuN"";;==!!(((//1DOOCeK 	   99;<U,T__, -::5A 	!##'7'K'KK'7'>'>D$!D$$&11%8--/+-D(//1  """$$--d3E.FG!G		))*<=?37D0##'7'G'GG  1$=?QR'7'>'>D$!D$$&11%8--/(+,>(?%'9$ G$($:$:$E$EG G$($:$:$E$EG G G **22://::<5c"4557 )) ,,44..99:<	< )   1$F,d43I3I.JL N&&(A(AC ""#JD$:$:$J$JK/01$$T%>%>%?@A 
 &&66d3456 %   1$N&&(A(AC //1%2%G%G%ID"OO==?? 2 ?-?   A  2 ?@113 Q J JK  '')r    c          
      s6   < V ^8  d   QhRS[ RS[ RS[RS[RR/# )r   commit_phraser%  rx  fix_sentence_endr   Nr  rD   rF   r   r   r	    sD     H6 H6H6 H6 	H6
 #H6
 /3H6r    c                s  < V P                   ^8  d*   \        P                  R\        V4      \        V4      4       V'       g   R# RV P                  n        RV P                  n        V'       g)   V P                  V P                  4       ^ ,          ,          pV'       g   TpVP                  4       '       gO   RV n
        V P                  4       pV'       d
   V^ ,          MRp\        P                  ! WR7      '       d   RV n
        V'       d   V P                  V4      V,           pVP                  R4      pV P                   ^ 8  d*   \        P                  R\        V4      \        V4      4       RpR	p	\!        V4      ^8  d   V P                   ^ 8  d+   \        P                  RV P"                  P$                  4       V F`  w  r\&        P(                  ! WP"                  P$                  4      '       g   K7  V P                   ^ 8  d   \        P                  RW4       Tp	 M	  V	R
8X  d   V P*                  '       d   Rp	V P                   ^ 8  d   \        P                  RV	4       V	P-                  R4      '       Ed   \/        V4       EF  w  rV\!        V4      ^,
          8  d   V'       dM   \0        SV `e  \4        P6                  P9                  V4      4       \:        P<                  ! V P>                  4       V	R
8X  db   V PA                  \4        PB                  V PD                  PG                  \4        PB                  4      \4        PH                  PJ                  4       M\0        SV `e  \4        P6                  P9                  R4      4       M\V P                   ^ 8  d    \        P                  R\        V4      4       \0        SV `e  \4        P6                  P9                  V4      4       \:        P<                  ! V P>                  4       EK  	  M,\0        SV `e  \4        P6                  P9                  V4      4       RV n&        V PN                  '       gU   V PP                  ^8X  gD   V PR                  '       g2   V PT                  \        PV                  PX                  ,          '       d)   V P                   ^8  d   \        P                  R4       R# \        PZ                  ! V4      pV P                   ^8  d   \        P                  RW!V P]                  4       V P_                  4       V Pa                  4       V PP                  V Pb                  Pd                  Pg                  V4      V Pb                  Pi                  V4      4	       V PP                  ^8X  d   V Pb                  Pi                  V4      '       g`   V Pb                  Pd                  Pg                  V4      '       g5   V P                   ^8  d"   \        P                  RV PP                  V4       R# V PP                  ^8X  d`   V Pb                  Pd                  Pg                  V4      '       g5   V P                   ^8  d"   \        P                  RV PP                  V4       R# V P                   ^8  d   \        P                  R4       V Pb                  Pk                  VVV P]                  4       V P_                  4       R7       V'       Ed_   V P]                  4       '       EdH   V P_                  4       '       Ed1   V Pa                  4       '       Ed   V PP                  ^8X  d   V Pb                  Pi                  V P]                  4       4      '       g   V Pb                  Pd                  Pg                  V P]                  4       4      '       gQ   V P                   ^8  d>   \        P                  RV PP                  V P]                  4       R,           V,           4       R# V PP                  ^8X  d   V Pb                  Pd                  Pg                  V P]                  4       4      '       gQ   V P                   ^8  d>   \        P                  RV PP                  V P]                  4       R,           V,           4       R# V P                   ^8  d3   \        P                  RV P]                  4       R,           V,           4       V Pb                  Pk                  V P]                  4       R,           V,           V P]                  4       R,           V,           V P_                  4       V Pa                  4       R7       V'       d   V Pm                  V4       R# R# )uF  Commits a string

:param commit_phrase: The string to commit
:param input_phrase: What the use typed to get this string committed
                     (Might be shorter than commit_phrase if a
                     completion was selected)
:param push_context: Whether to push commit_phrase on the context
                     stack. Doesn’t matter if surrounding text works
                     well and the context is always fetched from
                     surrounding text. But if the fallback of
                     remembering the context is used, this matters.
                     The context should only be pushed if the
                     cursor will end up to the right of commit_phrase.
:param fix_sentence_end: Whether to try fixing whitespace before
                         sentence end characters like “.!?”.
                         Better set this to False when calling
                         this function several times before
                         there was a chance that surrounding text
                         was updated (surrounding text is usually
                         only updated when a new key event is
                         processed).

May also update the context and the user database of learned
input.

May remove whitespace before the committed string if
the committed string ended a sentence.
u,   commit_phrase=“%s” input_phrase=“%s”NFrB   )ZlanguageTr7  z commit_phrase=%s commit_lines=%ssinglemulti-forward-shift-returnu!   self._client_info.client=“%s”z-commit_mode_pattern match: pattern=%s mode=%szmulti-commit-returnzcommit_mode=%sZmultir8  z	commit %s+Privacy: NOT recording and pushing context.z{input_phrase=%r commit_phrase=%r p_phrase=%r pp_phrase=%r ppp_phrase=%r record_mode=%d spellcheck=%r previously recorded=%d'self._record_mode=%d: Not recording: %rrecording and pushing context.r%  r   rG  rH  z-self._record_mode=%d: Not recording multi: %rr5  zRecording multi: %r)	)z^gnome-shell:r.  )z	^gtk4-im:r.  )z^(Qt|QIBusInputContext):r.  )z^xim:r.  )z	^gtk3-im:r/  )z(?i)^:.*firefox.*:r/  )z(?i)^:.*google-chrome.*:r/  )z(?i)^:.*thunderbird.*:r/  )z^:r.  )7r  r1   r'  r0   rA  r   r   r8  r  Zisspacer7  r  rn  Ztext_ends_a_sentence_commit_string_fix_sentence_endrh   r  r  r]   r	  r  r  rV  	enumerater  r&  r   r   r   timesleepr  forward_key_eventrQ  r  ibus_keycodeModifierType
SHIFT_MASKr+  r  r  r  r  
InputHintsPRIVATEr  rr  rt  rv  r  r#  r  phrase_exists!check_phrase_and_update_frequencyrx  )rO   r,  r%  rx  r-  r  r}   Zcommit_linesZcommit_mode_patternsZcommit_moder  rO  r   Zcommit_linestripped_commit_phraser  s   &&&&&          r   r(  Z"TypingBoosterEngine._commit_string  s>   D q LLGm,d<.@B -2)
 ;@777%%'*,L(L$$&& "'D--/E$58"D,,]JJ%)"44]C  \ %**40q LL;m,d<.@B 
* |!  1$79J9J9Q9QS!599W&7&7&>&>??((1,K#+ #'K "6 77---/Kq LL);7!!'**&/&="3|,q00"+ II55kBD 

4#A#AB"&BB.. OO 55BB $1 --88	: + II55d;= ((1,[${2CDG'		11+>@

499:1 '>4 G		))-8:/3,     A%  8#6#6#>#>>>  1$JK!)!5!5m!Dq LL @ &**,d.@.@.B,,.0A0A33>>}M44]CE "MM//>>MM..99-HH  1$F!..?"MM..99-HH  1$F!..?q LL9:77% &&(((*	 	8 	,
 #"!!##""$$##%% !!Q&33D4E4E4GHH**55d6G6G6IJJ$$q(LLG))))+c14JJL !!Q&**55d6G6G6IJJ$$q(LLG))))+c14JJL   1$)%%'#-0FFH MM;;!!#c),BB((*S03II++---/ < 1 45 r    c                s&   < V ^8  d   QhRS[ RS[ /# )r   r,  r   r   rD   rF   r   r   r	  C  s     T TS TS Tr    c                s   V P                   '       d5   V P                  \        P                  P                  P
                  39   d   R# Rp0 RmP                  V P                  4      pV'       d   V P                  ^ ,          V9   d   V P                  ^ ,          pMoVP                  V P                  P                  P                  V P                  V P                  V P                  34      4      pV'       d   \        V4      ^ ,          pV P                  ^8  d   \         P#                  RV4       \        P$                  P'                  V\        P$                  R,          4      pVP)                  4        EF  w  rg\*        P,                  ! R\*        P.                  ! V4      ,           R,           4      pVP1                  V4      '       g   KW  V P2                  P4                  p	V P2                  P6                  p
V P                  ^8  d!   \         P#                  RWP2                  4       \*        P,                  ! R4      pV P8                  P:                  R8X  dl   V P8                  P<                  R9   dQ   R	\*        P.                  ! V4      ,           R
,           p\         P#                  RV4       \*        P,                  ! V4      pVP1                  V	RV
 4      pV'       g   EKo  \?        VPA                  R4      4      pV PC                  V) V4       V P                  ^8  dO   V P2                  P4                  p	V P2                  P6                  p
\         P#                  RVV P2                  V4       Vu # 	  R# )u  Remove trailing white space before sentence end characters

:param commit_phrase: The text which is going to be committed.
                      (Not committed yet!)

If a single character ending a sentence is committed (possibly
followed by whitespace) remove trailing white space before the
committed string. For example if commit_phrase is “!”, and the
context before is “word ”, make the result “word!”.  And if
the commit_phrase is “! ” and the context before is “word ”
make the result “word! ”.

rB   r  zlanguage_code=%rz^[z]+[\s]*$zJChecking for whitespace before commit_phrase %r: self._surrounding_text=%rz(?P<white_space>[\s]+)$QIBusInputContextz(?P<white_space>[\s]+)Z$z/Special hack for kate and kwrite, use regexp=%rNZwhite_spacezURemoved whitespace before commit_phrase %r: self._surrounding_text=%r Replace with %r>   Zfr_BEZfr_CAZfr_CHZfr_FRZfr_LUZfr_MC)ZkateZkwrite)"ry  r  rn  InputPurposeTERMINALr   Zintersectionr  r  r#  r  r4  r5  r6  r  r  r1   r'  ZFIX_WHITESPACE_CHARACTERSrB  rX  r	  compileZescaper  rW  r   rH   r  rp   rr   r  r  delete_surrounding_text)rO   r,  language_codeZ used_french_spacing_dictionariesZ#matched_french_spacing_dictionariesZ
chars_dictZcharsZnew_whitespaceZpattern_sentence_endr   rH   r  regexpr`  Zncharss   &&             r   r4  Z3TypingBoosterEngine._commit_string_fix_sentence_endC  s    )))H$9$9$B$B$H$H#II,

,t--
. 	) ,%%a(,LL!%!7!7!: 5AA22OO$:J:JKMN 4 7$()L$Ma$PMq LL+];77;;8==cBD
%/%5%5%7!E#%::		%((;6$8 #**=99--22!33>>
$$q(LL4%'='=? **%?@%%//3FF))66:LL 8 "		- 89 $%F LLI  !jj0GtKZ'895 ]!;<F00&&A((1,#55::%)%;%;%F%F
. * 22ND *)_ &8` r    c                r  r   rv  r   rn  KeyEventr   rD   rF   r   r   r	    s'     Q Q((Q-1Qr    c                s   V P                   ^8  d7   \        P                  RV4       \        P                  RV P                  4       V P                  '       g)   V P                   ^8  d   \        P                  R4       R# V P	                  4       '       g)   V P                   ^8  d   \        P                  R4       R# V P
                  eN   V P
                  P                  VP                  8w  d)   V P                   ^8  d   \        P                  R4       R# VP                  \        P                  \        P                  \        P                  \        P                  \        P                  \        P                  \        P                  39  d)   V P                   ^8  d   \        P                  R4       R# VP                  '       g   VP                   '       g   VP"                  '       g   VP$                  '       g   VP&                  '       g   VP(                  '       g   VP*                  '       g   VP,                  '       gm   VP.                  '       g[   VP0                  '       gI   VP2                  '       g7   VP4                  '       g%   VP6                  '       g   VP8                  '       d)   V P                   ^8  d   \        P                  R	4       R# V P:                  '       d5   V P<                  \>        P@                  PB                  PD                  39   d)   V P                   ^8  d   \        P                  R
4       R# V P                   ^8  d!   \        P                  RV PF                  4       V PF                  PH                  pV PF                  PJ                  pV PF                  PL                  pV'       g   \        P                  R4       R# W48w  d.   \        P                  RW44       \        P                  R4       R# V PN                  PP                  PS                  RR7       V PN                  PP                  PU                  4       '       g   \        P                  R4       R# V P                   ^8  d!   \        P                  RV PN                  4       V PN                  PH                  pV PN                  PJ                  pV PN                  PL                  pVR8X  d   \        P                  R4       R# Wg8w  d.   \        P                  RWg4       \        P                  R4       R# VP                  \        P                  \        P                  \        P                  39   EdG   Wc^,
          8w  d   \        P                  R4       R# \V        PX                  ! R4      pVP[                  WVR 4      p	V	'       g)   V P                   ^8  d   \        P                  R4       R# \V        PX                  ! R4      pVP[                  VRV 4      p	V	'       g)   V P                   ^8  d   \        P                  R4       R# V	P]                  R4      p
V P_                  \a        V
4      ) \a        V
4      4       V Pc                  \        Pd                  Pg                  R4      ^ R\        Ph                  Pj                  4       V Pl                  Pn                  Pq                  R4      '       Ed   \a        V
4      V8X  Edx   \        P                  R4       \r        Pt                  ! V Pv                  4       V Py                  \        Pz                  \        P|                  P~                  R7       V Py                  \        Pz                  \        P|                  P~                  \        P|                  P                  ,          R7       V Py                  \        P                  \        P|                  P~                  R7       V Py                  \        P                  \        P|                  P~                  \        P|                  P                  ,          R7       \r        Pt                  ! V Pv                  4       V P                  4        V P                  \        V
4      4       V P                  4        R# VP                  \        P                  \        P                  \        P                  \        P                  39   Ed   VP                  \        P                  \        P                  39   d   Wc8:  d   \        P                  R 4       R# VP                  \        P                  \        P                  39   d   Wc8w  d   \        P                  R!4       \V        PX                  ! R"4      pVP[                  VRV 4      p	V	'       g)   V P                   ^8  d   \        P                  R#4       R# \V        PX                  ! R$4      pVP[                  WVR 4      p	V	'       g)   V P                   ^8  d   \        P                  R%4       R# V	P]                  R4      p
V P_                  ^ \a        V
4      4       V Pc                  \        Pd                  Pg                  R4      ^ R\        Ph                  Pj                  4       V Pl                  Pn                  Pq                  R4      '       Ed   VRV P                  4       '       Egx   \        P                  R4       \r        Pt                  ! V Pv                  4       V Py                  \        Pz                  \        P|                  P~                  R7       V Py                  \        Pz                  \        P|                  P~                  \        P|                  P                  ,          R7       V Py                  \        P                  \        P|                  P~                  R7       V Py                  \        P                  \        P|                  P~                  \        P|                  P                  ,          R7       \r        Pt                  ! V Pv                  4       V P                  4        V P                  \        V
4      4       ^ V nG        V P                  4        R# R# )&u'  BackSpace, Delete or arrow left or right has been typed.

If the end of a word has been reached again and if it is
possible to get that word back into preëdit, do that and
return True.

If no end of a word has been reached or it is impossible to
get the word back into preëdit, return False.

KeyEvent object: %sz"self._arrow_keys_reopen_preedit=%sz?self._arrow_keys_reopen_preedit not set. Do not reopen preedit.Fz*There is input already, no need to reopen.NzdPrevious key not set or not equal to the just released key. Better do not try to reopen the preedit.zbRelease key was not in list of keys allowed to reopen a preedit. Do not try to reopen the preedit.z4Not reopening the preedit because a modifier is set.z=Surrounding text is not supported. No way to repopen preedit.zself._surrounding_text_old=%rz5Old surrounding text is empty. Cannot reopen preedit.z+cursor_pos_old=%s anchor_pos_old=%s differ.zCannot reopen preedit.皙?)Ztimeoutz}Surrounding text has not been set since last key event. Something is wrong with the timing. Do not try to reopen the preedit.r  rB   z5New surrounding text is empty. Cannot reopen preedit.z#cursor_pos=%s anchor_pos=%s differ.z<Cursor has not moved one column left, cannot reopen preedit.z^($|[\s]+.*)z>No whitespace or end of line or buffer to the right of cursor.z(^|.*[\s]+)(?P<token>[\S]+)$z%Could not match token left of cursor.tokenTWhatsAppKApply WhatsApp workaround for reopening preedit at the beginning of a line.keystatez2Cursor has not moved right, cannot reopen preedit.z@Unexpected cursor movement on Delete key, cannot reopen preedit.z(^|.*[\s]+)$zCNo whitespace or beginning of line or buffer to the left of cursor.z^(?P<token>[\S]+)($|[\s]+.*)z&Could not match token right of cursor.)Hr  r1   r'  r  r  r,  valr   rM  rN  rK  rL  rU  rS  rT  shiftcontrolmod1Zmod3mod4mod5Zbutton1Zbutton2Zbutton3Zbutton4Zbutton5r  hypermetary  r  rn  rB  rC  r   rX  r   rH   rI   rW  rJ   ZwaitrM   r	  rD  r`  r  rE  r  rt  r   r   r   r  r  rt   rV  r6  r7  r  _forward_generated_key_eventKEY_cr:  CONTROL_MASKRELEASE_MASKKEY_vr
  r  r  r  r=  r3  )rO   rv  Ztext_oldZcursor_pos_oldZanchor_pos_oldr   rH   rI   r  r`  rM  s   &&         r   _maybe_reopen_preeditZ)TypingBoosterEngine._maybe_reopen_preedit  s%	    q LL.4LL=88:...  1$ 6 7}}  1$IJ>>%$..*<*<*G  1$DE GGDMM4+;+; NND,=,= .. OOT-?-?A A   1$JK III{{{xxxxxxxxxxxx{{{{{{{{{{{{{{{yyyyyyxxx,   1$JL)))""x'<'<'E'E'K'K&LL  1$ : ;q LL/1K1KM--2233>>33>>LLGI+LLF'9LL12$$))#)6%%++2244LL  q LL4d6L6LM%%**++66
++66
2:LLGI#LL>#1LL1277t))4==$:J:JKKa// 6 7jj1GMM${"34E$$q(LL23 jj!@AGMM${
"34E$$q(LL!HIKK(E((#e*c%jA ..		))"-q$%%,,. !!..99*EEJ*,& 23 

499:11JJ):):)G)G 2 I11JJ%%2243D3D3Q3QQ 2 S 11JJ):):)G)G 2 I11JJ%%2243D3D3Q3QQ 2 S 

499:))$u+6OO77t(:(:~~t'8'8: :ww4>>4+<+<==/ LLLN ww4??D,>,>??/LL ": ;jj1GMM${
"34E$$q(LL12 jj!@AGMM${"34E$$q(LL!IJKK(E((CJ7 ..		))"-q$%%,,. !!..99*EE[j)//11$ 23 

499:11JJ):):)G)G 2 I11JJ%%2243D3D3Q3QQ 2 S 11JJ):):)G)G 2 I11JJ%%2243D3D3Q3QQ 2 S 

499:))$u+6()D%OOr    c                rC   r   r'   rD   rF   r   r   r	    s     06 06T 06r    c                s\   RV n         V P                  '       d5   V P                  \        P                  P
                  P                  39   d)   V P                  ^8  d   \        P                  R4       R# V P                  P                  pV P                  P                  pV P                  ^8  d!   \        P                  RV P                  4       VR8X  d)   V P                  ^8  d   \        P                  R4       R# \        P                  ! VRV 4       Uu. uF  p\        P                  ! V4      NK  	  upR
R pV P                  ^8  d    \        P                  R\        V4      4       RV n        RV n        RV n        V'       d   VR,          V n        \'        V4      ^8  d   VR,          V n        \'        V4      ^8  d   VR
,          V n        V P                  ^8  d7   \        P                  RV P$                  V P"                  V P                   4       R	V n         R# u upi )u  Try to get the context from the application using the “surrounding
text” feature, if possible. If this works, it is much better
than just using the last two words which were
committed. Because the cursor position could have changed
since the last two words were committed, one might have moved
the cursor with the mouse or the arrow keys.  Unfortunately
surrounding text is not supported by many applications.
Basically it only seems to work reasonably well in Gnome
applications.

FzSurrounding text not supported.Nr  rB   z.Surrounding text is empty, cannot get context.z&Found from surrounding text: tokens=%su@   Updated context from surrounding text=“%s” “%s” “%s”TirQ  i)rZ  ry  r  rn  rB  rC  r   r  r1   r'  rW  r   rH   Ztokenizer  r0   r4  r5  r6  r  )rO   r   rH   rM  Ztokensr  r   r
  ZTypingBoosterEngine.get_context  s    27.)))""x'<'<'E'E'K'K&LL   1$>?%%**++66
q LL4d6L6LM2:  1$MN "**4+<=?=   '=?@BE q LL8$v,H#BZDNv;?$RjDOv;?%bzDq LLR  $//4>>C 26.'?s   H)c                @   < V ^8  d   QhRS[ S[S[3,          RS[RR/# r   rO  rO  r   Nr   r   r   rD   rF   r   r   r	    2     0 0c	"0 #0 /30r    c                
   V P                   ^8  d   \        P                  RW4       WP                  8X  d   R# Wn        V'       d<   V P                  P                  R\        P                  P                  V4      4       R# R# )a  Sets whether a space is added when a candidate is committed by 1-9
or F1-F9 or by mouse click.

:param mode: Whether to add a space when committing by label
             or mouse click.
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
(%s, update_gsettings = %s)Nr6  )	r  r1   r'  r  r  r   r   r!  new_booleanrO   rO  rO  r   r   r  Z+TypingBoosterEngine.set_add_space_on_commit  sh     q LL-tG,,,$(!OO%%"((.0 r    c                r[   r   rO  r   Nr   rD   rF   r   r   r	    s     = =$(=48=r    c                H    V P                  V P                  '       * V4       R# )a  Toggles whether a space is added when a candidate is committed by
1-9 or F1-F9 or by mouse click.

:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
N)r  r  rO   rO  rd   r   toggle_add_space_on_commitZ.TypingBoosterEngine.toggle_add_space_on_commit  s!     	$$)))+;	=r    c                rj   rk   r   rD   rF   r   r   r	    s     ) ) )r    c                ro   )z~Returns the current value of the flag whether to add a space when a
candidate is committed by 1-9 or F1-F9 or by mouse click.
)r  rm   r$   r   r  Z+TypingBoosterEngine.get_add_space_on_commit  s     (((r    c                r  ra  r   r>   r   r   rD   rF   r   r   r	    s1     . .S/. #. /3.r    c                rd  )u  Sets whether the best completion is first shown inline in the
preëdit instead of using a combobox to show a candidate list.

:param mode: Whether to show completions inline
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  Nr7  )	r  r1   r'  r  r  r   r   r!  	new_int32rg  r   r   r  Z)TypingBoosterEngine.set_inline_completion  sh     q LL-tG***"&OO%%"&&t,. r    c                rj   rk   r   rD   rF   r   r   r	  %  s     ' 's 'r    c                ro   )u   Returns the current value of the flag whether to show a completion
first inline in the preëdit instead of using a combobox to show a
candidate list.
)r  rm   r$   r   r  Z)TypingBoosterEngine.get_inline_completion%  s    
 &&&r    c                r  ra  rl  rD   rF   r   r   r	  ,  1     . .S/. #. /3.r    c                rd  )a/  Sets whether the value of record mode

:param mode: Specifies how much to record
             0: Everything
             1: Correctly spelled or previously recorded words
             2: Correctly spelled words
             3: Nothing
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  Nr8  )	r  r1   r'  r  r  r   r   r!  rm  rg  r   r   r  Z#TypingBoosterEngine.set_record_mode,  sh    " q LL-tG$$$ OO%%&&t,. r    c                rj   rk   r   rD   rF   r   r   r	  H       ! ! !r    c                ro   )z,Returns the current value of the record mode)r  rm   r$   r   r  Z#TypingBoosterEngine.get_record_modeH         r    c                r`  ra  rb  rD   rF   r   r   r	  L  2     0 0c	"0 #0 /30r    c                rd  )a  Sets whether to capitalize automatically after punctuation

:param mode: Whether to automatically capitalize after punctuation.
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  Nr9  )	r  r1   r'  r  r  r   r   r!  rf  rg  r   r   r  Z'TypingBoosterEngine.set_auto_capitalizeL  sh     q LL-tG((( $OO%% ((.0 r    c                r[   rh  r   rD   rF   r   r   r	  d       
9 
9t 
9t 
9r    c                ri  )a  Toggles whether to capitalize automatically after punctuation

:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
N)r  r  rj  rd   r   toggle_auto_capitalizeZ*TypingBoosterEngine.toggle_auto_capitalized  !     	  %%%'7	9r    c                rj   rk   r   rD   rF   r   r   r	  p  s     % %T %r    c                ro   )z\Returns the current value of the flag whether to automatically
capitalize after punctuation
)r  rm   r$   r   r  Z'TypingBoosterEngine.get_auto_capitalizep  s     $$$r    c                r`  ra  rb  rD   rF   r   r   r	  v  rq  r    c                rd  )a  Sets whether to avoid forward_key_event() or not

:param mode: Whether to avoid forward_key_event() or not
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  Nr/  )	r  r1   r'  r  r  r   r   r!  rf  rg  r   r   r  Z/TypingBoosterEngine.set_avoid_forward_key_eventv  sh     q LL-tG000(,%OO%%&((.0 r    c                r[   rh  r   rD   rF   r   r   r	    s!     A A$(A48Ar    c                ri  )ay  Toggles whether to avoid forward_key_event() or not

:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
N)r  r  rj  rd   r   toggle_avoid_forward_key_eventZ2TypingBoosterEngine.toggle_avoid_forward_key_event  s"     	((---/?	Ar    c                rj   rk   r   rD   rF   r   r   r	         - -T -r    c                ro   )z5Returns whether forward_key_event() is avoided or not)r  rm   r$   r   r  Z/TypingBoosterEngine.get_avoid_forward_key_event      ,,,r    c                r`  ra  rb  rD   rF   r   r   r	    rq  r    c                rd  )a  Sets whether to prefer commits over passing key events through

:param mode: Whether to prefer commits over passing key events through
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  Nr0  )	r  r1   r'  r  r  r   r   r!  rf  rg  r   r   r  Z%TypingBoosterEngine.set_prefer_commit  sh     q LL-tG&&&"OO%%((.0 r    c                r[   rh  r   rD   rF   r   r   r	    s     7 7$(7487r    c                ri  )a  Toggles whether to prefer commits over passing key events through

:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
N)r  r  rj  rd   r   toggle_prefer_commitZ(TypingBoosterEngine.toggle_prefer_commit  s!     	###%5	7r    c                rj   rk   r   rD   rF   r   r   r	    s     # #4 #r    c                ro   )zG
Returns whether commits are preferred over passing key events through
)r  rm   r$   r   r  Z%TypingBoosterEngine.get_prefer_commit       """r    c                r`  ra  rb  rD   rF   r   r   r	    rq  r    c                rd  )u  Sets whether the arrow keys are allowed to reopen a preëdit

:param mode: Whether arrow keys can reopen a preëdit
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  Nr1  )	r  r1   r'  r  r  r   r   r!  rf  rg  r   r   r  Z1TypingBoosterEngine.set_arrow_keys_reopen_preedit  sh     q LL-tG222*.'OO%%(((.0 r    c                r[   rh  r   rD   rF   r   r   r	    s!     C C$(C48Cr    c                ri  )u  Toggles whether arrow keys are allowed to reopen a preëdit

:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
N)r  r  rj  rd   r    toggle_arrow_keys_reopen_preeditZ4TypingBoosterEngine.toggle_arrow_keys_reopen_preedit  s"     	**///1A	Cr    c                rj   rk   r   rD   rF   r   r   r	    s     / /t /r    c                ro   )uY   Returns the current value of the flag whether to
allow arrow keys to reopen the preëdit
)r  rm   r$   r   r  Z1TypingBoosterEngine.get_arrow_keys_reopen_preedit  s     ...r    c                rC   r   r'   rD   rF   r   r   r	    s     * *4 *r    c                s    RP                  V P                  4      pV P                  '       d   RP                  V P                  RV P                   4      V P                  P                  V P                  4      ,           RP                  V P                  V P                  R 4      ,           pV P                  WR7       V P                  V P                  R  F"  pV P                  \        P                  4       K$  	  V P                  4        R# )zCommits the raw inputrB   Nr$  )r  r2  r1  r3  r  r)  r(  rZ  r   rM  r\  )rO   commit_stringr%   rg  r   _commit_raw_inputZ%TypingBoosterEngine._commit_raw_input  s     2 23'''**+ED,E,EFG))@@0022 ''$,,T-F-F-GHIJ 
 	MF##D$=$=$>?A--dmm< @'')r    c                rC   r   r'   rD   rF   r   r   r	    s     ;A ;At ;Ar    c                s   V P                   '       d   V P                  P                  \        P                  8X  d   V P                  P                  4       '       d   \        P                  V P                  n        V P                  4       p. V n        V P                  P                  4        V P                  P                  R4       V P                  4        . V n         V P                  \        V4      4       V P                  4        V P                  ^ ,          pV P                   V,          pVP#                  V P$                  R.,           V P&                  R7      pVP)                  R4      '       d   VRR
 pV P*                  V P,                  ,          R,          ! V4      pV P                  P/                  4       '       d2   V P                  P                  4       '       d   V P                  4       pMTpV'       g)   V P0                  ^ 8  d   \2        P5                  R4       R# RpV P                  P                  4       '       d   Rp\6        P8                  ! WPP;                  RR7      4      pV P=                  WTR	7       V P?                  4        V'       g5   \A        ^ V4       F"  pV PC                  \D        PF                  4       K$  	  R# R# )a?  Commits the current state:

- If nothing is selected in the lookup table, commit the preedit
- If something is manually selected in the compose lookup table,
  insert it in the preedit, update the preedit and then commit it.
- If something is selected in the regular (not compose) lookup
  table, commit the selection.
Fr5  r&  Nrd  !commit string unexpectedly empty.Tr  r$  rQ  )$r1  rA  r   r{   r   r   r   rl  r=  r   r   r  r  r  r  r  r;  r'  r2  r  r(  r@  r?  r   r  r1   r2   rn  estimate_left_stepsr.  r(  r\  r   rZ  r   rM  )	rO   compose_resultr*  r  r%  r{  candidate_was_selected
left_stepsr%   	   &        r   _commit_current_inputZ)TypingBoosterEngine._commit_current_input  sD    (((""((,<,P,PP""4466'7'>'>D$!IIKN!D$$&11%8--/+-D())$~*>?//1((+%%k2**#&T5G5G + I  %%',L''##%%/11=?7799""4466 !HHJM )M   1$@A "'//11%)"11>>><>
ME'')%1j)11$--@ * &r    c                *   < V ^8  d   QhRS[ RS[ RR/# ra  r   rD   rF   r   r   r	  @  s%     % %%04%AE%r    c                s,   V P                   ^8  d   \        P                  RV4       WP                  8X  d   R# Wn        V P                  '       g   RV n        V P
                  '       d/   V P                  '       d   V P                  V P                  V4       V'       d:   V P                  P                  R\        P                  P                  V4      4       V P                  4       '       d   V P                  '       g   R# V P                  4        R# )zRSets the input mode

:param mode: Whether to switch ibus-typing-booster on or off
(%s)NFrW  )r  r1   r'  r  r  r  r  r  r  r   r   r!  rf  r  r1  r  rg  r   r   r  Z"TypingBoosterEngine.set_input_mode@  s     q LL&###$D???t333..$$d,OO%%((.0 ==??4#?#?#? 	""$r    c                r[   rh  r   rD   rF   r   r   r	  [  s     D D$ D$ Dr    c                ri  )z9Toggles whether ibus-typing-booster is on or off
        N)r  r  rj  rd   r   toggle_input_modeZ%TypingBoosterEngine.toggle_input_mode[  s     	 0 002BCr    c                rj   rk   r   rD   rF   r   r   r	  `            r    c                ro   )z+Returns the current value of the input mode)r  rm   r$   r   r  Z"TypingBoosterEngine.get_input_mode`  rw  r    c                *   < V ^8  d   QhRS[ RS[RR/# r   rp  rO  r   Nr  rD   rF   r   r   r	  d  s%     2 22152BF2r    c                s   V P                   ^8  d   \        P                  RV4       WP                  4       8X  d   R# WP                  R,          R&   V P
                  '       d/   V P                  '       d   V P                  V P                  ^4       \        P                  ! 4        V'       d<   V P                  P                  R\        P                  P                  V4      4       R# R# )zbSets the symbol used for input mode true

:param symbol: Which symbol to  use for input mode true
r  Nru  rp  rq  )r  r1   r'  r  r  r  r  r  rn  rC  r  r   r   r!  rf  rO   rp  rO  r   r   r  Z.TypingBoosterEngine.set_input_mode_true_symbold  s     q LL(4466?E"">28<???t333..$$a)!!#OO%%%((02 r    c                rj   rk   r   rD   rF   r   r   r	  x  s     I IC Ir    c                H    \        V P                  R,          R,          4      # )z@Returns the current value of the symbol used for input mode trueru  rp  r   r  rm   r$   r   r  Z.TypingBoosterEngine.get_input_mode_true_symbolx  s    4--n=hGHHr    c                r  r  r  rD   rF   r   r   r	  |  s%     2 22152BF2r    c                s   V P                   ^8  d   \        P                  RV4       WP                  4       8X  d   R# WP                  R,          R&   V P
                  '       d/   V P                  '       d   V P                  V P                  ^ 4       V'       d<   V P                  P                  R\        P                  P                  V4      4       R# R# )zdSets the symbol used for input mode false

:param symbol: Which symbol to  use for input mode false
r  Nrr  rp  rt  )r  r1   r'  r  r  r  r  r  r  r   r   r!  rf  r  r   r   r  Z/TypingBoosterEngine.set_input_mode_false_symbol|  s     q LL(5577@F""?3H=???t333..$$a)OO%%&((02 r    c                rj   rk   r   rD   rF   r   r   r	    s     J JS Jr    c                r  )zAReturns the current value of the symbol used for input mode falserr  rp  r  rm   r$   r   r  Z/TypingBoosterEngine.get_input_mode_false_symbol  s    4--o>xHIIr    c                r  ra  r   rD   rF   r   r   r	    s%     0 00040@D0r    c                *   V P                   ^8  d   \        P                  RW4       WP                  8X  d   R# Wn        V P	                  4        V'       d<   V P
                  P                  R\        P                  P                  V4      4       R# R# )a  Sets the word prediction mode

:param mode: Whether to switch word prediction on or off
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  Nr  )
r  r1   r'  r  r  r  r   r   r!  rf  rg  r   r   r  Z,TypingBoosterEngine.set_word_prediction_mode  sr     q LL-tG)))!%OO%%!((.0 r    c                r[   rh  r   rD   rF   r   r   r	    s     : :$(:48:r    c                ri  )aw  Toggles whether word predictions are shown or not

:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
N)r  r  rj  rd   r   toggle_word_prediction_modeZ/TypingBoosterEngine.toggle_word_prediction_mode  s!     	%%&&&(8	:r    c                rj   rk   r   rD   rF   r   r   r	    s     & &$ &r    c                ro   )z5Returns the current value of the word prediction mode)r  rm   r$   r   r  Z,TypingBoosterEngine.get_word_prediction_mode      %%%r    c                r  ra  r   rD   rF   r   r   r	    s%      0  0 004 0@D 0r    c                st   V P                   ^8  d   \        P                  RW4       WP                  8X  d   R# Wn        V P	                  V P
                  V4       V P                  '       dx   V P                  '       d*   V P                  P                  4       V P                  8w  d=   \        P                  ! V P                  V P                  V P                  R7      V n        V P                  4        V'       d<   V P                  P                  R\         P"                  P%                  V4      4       R# R# )a  Sets the emoji prediction mode

:param mode: Whether to switch emoji prediction on or off
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  Nr^  r  )r  r1   r'  r  r  r  r  rW  r  r(  r)  r  r  r  r  r   r   r!  rf  rg  r   r   r  Z-TypingBoosterEngine.set_emoji_prediction_mode  s     q LL-tG***"&**++T	3###'''##113**+!*!7!700!%!7!7#'#4#4"6D 	OO%%"((.0 r    c                r[   rh  r   rD   rF   r   r   r	    s     ; ;$(;48;r    c                ri  )ax  Toggles whether emoji predictions are shown or not

:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
N)r  r  rj  rd   r   toggle_emoji_prediction_modeZ0TypingBoosterEngine.toggle_emoji_prediction_mode  s!     	&&''')9	;r    c                rj   rk   r   rD   rF   r   r   r	    s     ' '4 'r    c                ro   )z6Returns the current value of the emoji prediction mode)r  rm   r$   r   r  Z-TypingBoosterEngine.get_emoji_prediction_mode      &&&r    c                r  ra  r   rD   rF   r   r   r	    s%     0 00040@D0r    c                s   V P                   ^8  d   \        P                  RW4       WP                  8X  d   R# Wn        V P                  '       dc   V P                   ^8  d   \        P                  R4       \
        P                  ! V P                  V P                  V P                  R7      V n        V P                  4        V'       d<   V P                  P                  R\        P                  P                  V4      4       R# R# )a  Sets the mode whether to load all Unicode characters for
Unicode symbol and emoji prediction

:param mode: Whether to load all Unicode characters
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.

re  NUpdating EmojiMatcherr^  r  )r  r1   r'  r  r  r(  r)  r  r  r  r  r   r   r!  rf  rg  r   r   r  Z-TypingBoosterEngine.set_unicode_data_all_mode  s     q LL-tG)))!%  1$45!*!7!700!%!7!7#'#4#4"6D 	OO%% ((.0 r    c                r[   rh  r   rD   rF   r   r   r	    s     : :$(:48:r    c                ri  )a  Toggles whether all Unicode characters are loaded for
Unicode symbol and emoji prediction.

:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
N)r  r  rj  rd   r   toggle_unicode_data_all_modeZ0TypingBoosterEngine.toggle_unicode_data_all_mode  s!     	&&&&&(8	:r    c                rj   rk   r   rD   rF   r   r   r	    s     & &4 &r    c                ro   )zuReturns the current value of the mode whether to load all
Unicode characters for Unicode symbol and emoji prediction
)r  rm   r$   r   r  Z-TypingBoosterEngine.get_unicode_data_all_mode       %%%r    c                r`  ra  rb  rD   rF   r   r   r	  "  s2     0 0c	"0 #0 /30r    c                sb   V P                   ^8  d   \        P                  RW4       WP                  8X  d   R# Wn        V P	                  V P
                  V4       V P                  4        V'       d<   V P                  P                  R\        P                  P                  V4      4       R# R# )u  Sets the “Off the record” mode

:param mode: Whether to prevent saving input to the
             user database or not
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  Nr.  )r  r1   r'  r  r  r  r  r  r   r   r!  rf  rg  r   r   r  Z+TypingBoosterEngine.set_off_the_record_mode"  s     q LL-tG'''#**))4	1OO%%((.0 r    c                r[   rh  r   rD   rF   r   r   r	  >  s     8 8$(8488r    c                ri  )a  Toggles whether input is saved to the user database or not

:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
N)r  r  rj  rd   r   toggle_off_the_record_modeZ.TypingBoosterEngine.toggle_off_the_record_mode>  s!     	$$$$$&6	8r    c                rj   rk   r   rD   rF   r   r   r	  K  s     $ $ $r    c                ro   )u:   Returns the current value of the “off the record” mode)r  rm   r$   r   r  Z+TypingBoosterEngine.get_off_the_record_modeK      ###r    c                r  )r   emoji_trigger_charactersrO  r   Nr   r   r   r   rD   rF   r   r   r	  O  s6     C C&+CHoC #C /3Cr    c                rd  )a  Sets the emoji trigger characters

:param emoji_trigger_characters: The characters which trigger an
                                 emoji and Unicode symbol lookup
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  Nr2  )	r  r1   r'  r  r  r   r   r!  r"  )rO   r  rO  r   r   r  Z0TypingBoosterEngine.set_emoji_trigger_charactersO  sl     q LL-(< $'E'EE)A&OO%%(''(@AC r    c                rj   rk   r   rD   rF   r   r   r	  i       . .c .r    c                ro   )z,Returns the current emoji trigger characters)r  rm   r$   r   r  Z0TypingBoosterEngine.get_emoji_trigger_charactersi      ---r    c                r  )r   stylerO  r   Nr  rD   rF   r   r   r	  m  s1     )0 )0c?)0 #)0 /3)0r    c                s   V P                   ^8  d   \        P                  RW4       WP                  8X  d   R# Wn        V P                  '       dL   V P                   ^8  d   \        P                  R4       V P                  P                  V P                  4       V P                  P                  \        P                  8X  d'   V P                  V P                  P                  4       M9V P                  P                  \        P                  8X  d   V P                  4        V'       d<   V P                  P                  R\         P"                  P%                  V4      4       R# R# )a  Sets the emoji style

:param style: 'emoji' uses colorful emoji (emoji style).
              'text' uses monochrome emoji (text style).
              Any other value uses unqualified emoji sequences.
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.

z(%r, update_gsettings = %s)Nr  r3  )r  r1   r'  r  r  Zset_variation_selectorrA  r   r{   r   r  r   r   r  r  r   r   r!  r"  )rO   r  rO  r   r   r  Z#TypingBoosterEngine.set_emoji_stylem  s     q LL-) %%%!  1$4555!!###'7'J'JJ ++""<<>%%)9)@)@@ OOOO%%''.0 r    c                r[   rh  r   rD   rF   r   r   r	    s      $(48r    c                sj    RRRR/pV P                  VP                  V P                  R4      V4       R# )a  Toggles through the values of the emoji style

Does not toggle through all 3 styles on purpose, toggles only
between 'emoji' and 'text'. If any other style is set, it toggles to 'emoji'.

It is possible to set 'No style' in the setup tool to get
unqualified emoji sequences, but that is useful only in very
rare circumstances. If that is desired, use the setup tool.
This command toggles only between 'emoji' and 'text', I found
that toggling through the 3rd state as well was more confusing
then helpful.
r^  r   N)r  rB  r  )rO   rO  Z
next_styleri   r   toggle_emoji_styleZ&TypingBoosterEngine.toggle_emoji_style  s7     vvw7
NN4,,g6	r    c                rj   rk   r   rD   rF   r   r   r	    ro  r    c                ro   )zReturns the current emoji style)r  rm   r$   r   r  Z#TypingBoosterEngine.get_emoji_style  rp  r    c                r  )r   auto_commit_charactersrO  r   Nr  rD   rF   r   r   r	    s6     A A$)#s(OA #A /3Ar    c                rd  )a  Sets the auto commit characters

:param auto_commit_characters: The characters which trigger a commit
                               with an extra space
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  Nr4  )	r  r1   r'  r  r  r   r   r!  r"  )rO   r  rO  r   r   r  Z.TypingBoosterEngine.set_auto_commit_characters  sl     q LL-&: "%A%AA'=$OO%%&''(>?A r    c                rj   rk   r   rD   rF   r   r   r	    s     , ,C ,r    c                ro   )z*Returns the current auto commit characters)r  rm   r$   r   r  Z.TypingBoosterEngine.get_auto_commit_characters  s    +++r    c                r`  ra  rb  rD   rF   r   r   r	    rq  r    c                rd  )a  Sets whether spellchecking is done on the contents of the preedit

:param mode: Whether to do spellchecking on the contents of the preedit
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  Nr:  )	r  r1   r'  r  r  r   r   r!  rf  rg  r   r   r  Z0TypingBoosterEngine.set_color_preedit_spellcheck  sh     q LL-tG111)-&OO%%(((.0 r    c                rj   rk   r   rD   rF   r   r   r	    s     . .d .r    c                ro   )uD   Returns the current value of the “color preedit_spellcheck” mode)r  rm   r$   r   r  Z0TypingBoosterEngine.get_color_preedit_spellcheck  r  r    c                r  r   color_stringrO  r   Nr  rD   rF   r   r   r	    1     7 7S/7 #7 /37r    c                T   V P                   ^8  d   \        P                  RW4       WP                  8X  d   R# Wn        \        P
                  ! V P                  4      V n        V'       d<   V P                  P                  R\        P                  P                  V4      4       R# R# )u  Sets the color for for preedit spellchecking

:param color_string: The color for preedit spellchecking
                    It is a string in one of the following formats:
                    - Standard name from the X11 rgb.txt
                    - Hex value: “#rgb”, “#rrggbb”, “#rrrgggbbb”
                                 or ”#rrrrggggbbbb”
                    - RGB color: “rgb(r,g,b)”
                    - RGBA color: “rgba(r,g,b,a)”
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  Nr;  )r  r1   r'  r  rn  r  r  r  r   r   r!  r"  rO   r  rO  r   r   r  Z7TypingBoosterEngine.set_color_preedit_spellcheck_string  s    & q LL-|O@@@0<-.6.K.K11/3+OO%%.''57 r    c                rj   rk   r   rD   rF   r   r   r	  	  s     5 5S 5r    c                ro   )uO   Returns the current value of the “color preedit spellcheck” string
        )r  rm   r$   r   r  Z7TypingBoosterEngine.get_color_preedit_spellcheck_string	  s     444r    c                r`  ra  rb  rD   rF   r   r   r	    rq  r    c                rd  )a  Sets whether to use color for inline completion

:param mode: Whether to use color for inline completion
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  Nr<  )	r  r1   r'  r  r  r   r   r!  rf  rg  r   r   r  Z/TypingBoosterEngine.set_color_inline_completion  sh     q LL-tG000(,%OO%%'((.0 r    c                rj   rk   r   rD   rF   r   r   r	  &  rv  r    c                ro   )uC   Returns the current value of the “color inline completion” mode)r  rm   r$   r   r  Z/TypingBoosterEngine.get_color_inline_completion&  rw  r    c                r  r  r  rD   rF   r   r   r	  *  r  r    c                r  )u	  Sets the color for inline completion

:param color_string: The color for inline completion
                    It is a string in one of the following formats:
                    - Standard name from the X11 rgb.txt
                    - Hex value: “#rgb”, “#rrggbb”, “#rrrgggbbb”
                                 or ”#rrrrggggbbbb”
                    - RGB color: “rgb(r,g,b)”
                    - RGBA color: “rgba(r,g,b,a)”
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  Nr=  )r  r1   r'  r  rn  r  r  r  r   r   r!  r"  r  r   r   r  Z6TypingBoosterEngine.set_color_inline_completion_string*  s    & q LL-|O???/;,-5-J-J00.2*OO%%-''57 r    c                rj   rk   r   rD   rF   r   r   r	  J  s     4 4C 4r    c                ro   )uE   Returns the current value of the “color inline completion” string)r  rm   r$   r   r  Z6TypingBoosterEngine.get_color_inline_completion_stringJ      333r    c                r`  ra  rb  rD   rF   r   r   r	  N  rq  r    c                rd  )a  Sets whether to use color for the compose preview

:param mode: Whether to use color for the compose preview
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  Nr>  )	r  r1   r'  r  r  r   r   r!  rf  rg  r   r   r  Z-TypingBoosterEngine.set_color_compose_previewN  sh     q LL-tG...&*#OO%%%((.0 r    c                rj   rk   r   rD   rF   r   r   r	  f  s     + +4 +r    c                ro   )uA   Returns the current value of the “color compose preview” mode)r  rm   r$   r   r  Z-TypingBoosterEngine.get_color_compose_previewf  s    ***r    c                r  r  r  rD   rF   r   r   r	  j  r  r    c                r  )u  Sets the color for the compose preview

:param color_string: The color for the compose preview
                    It is a string in one of the following formats:
                    - Standard name from the X11 rgb.txt
                    - Hex value: “#rgb”, “#rrggbb”, “#rrrgggbbb”
                                 or ”#rrrrggggbbbb”
                    - RGB color: “rgb(r,g,b)”
                    - RGBA color: “rgba(r,g,b,a)”
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  Nr?  )r  r1   r'  r  rn  r  r  r  r   r   r!  r"  r  r   r   r  Z4TypingBoosterEngine.set_color_compose_preview_stringj  s    & q LL-|O===-9*+3+H+H..,0(OO%%+''57 r    c                rj   rk   r   rD   rF   r   r   r	    s     2 2# 2r    c                ro   )uC   Returns the current value of the “color compose preview” string)r  rm   r$   r   r  Z4TypingBoosterEngine.get_color_compose_preview_string  s    111r    c                r`  ra  rb  rD   rF   r   r   r	    rq  r    c                rd  )a  Sets whether to use color for the m17n preedit

:param mode: Whether to use color for the m17n preedit
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  Nr@  )	r  r1   r'  r  r  r   r   r!  rf  rg  r   r   r  Z*TypingBoosterEngine.set_color_m17n_preedit  sh     q LL-tG+++#' OO%%"((.0 r    c                rj   rk   r   rD   rF   r   r   r	    s     ( ( (r    c                ro   )u>   Returns the current value of the “color m17n preedit” mode)r  rm   r$   r   r  Z*TypingBoosterEngine.get_color_m17n_preedit      '''r    c                r  r  r  rD   rF   r   r   r	    r  r    c                r  )u  Sets the color for the m17n preedit

:param color_string: The color for the m17n preedit
                     It is a string in one of the following formats:
                     - Standard name from the X11 rgb.txt
                     - Hex value: “#rgb”, “#rrggbb”, “#rrrgggbbb”
                                  or ”#rrrrggggbbbb”
                     - RGB color: “rgb(r,g,b)”
                     - RGBA color: “rgba(r,g,b,a)”
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  NrA  )r  r1   r'  r  rn  r  r  r  r   r   r!  r"  r  r   r   r  Z1TypingBoosterEngine.set_color_m17n_preedit_string  s    & q LL-|O:::*6'(0(E(E++)-%OO%%(''57 r    c                rj   rk   r   rD   rF   r   r   r	    s     / /s /r    c                ro   )u@   Returns the current value of the “color m17n preedit” string)r  rm   r$   r   r  Z1TypingBoosterEngine.get_color_m17n_preedit_string  s    ...r    c                r`  ra  rb  rD   rF   r   r   r	    rq  r    c                rd  )a  Sets whether to use color for user database suggestions

:param mode: Whether to use color for user database suggestions
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  NrB  )	r  r1   r'  r  r  r   r   r!  rf  rg  r   r   r  Z$TypingBoosterEngine.set_color_userdb  h     q LL-tG%%%!OO%%((.0 r    c                rj   rk   r   rD   rF   r   r   r	         " "$ "r    c                ro   )u8   Returns the current value of the “color userdb” mode)r  rm   r$   r   r  Z$TypingBoosterEngine.get_color_userdb  rq  r    c                r  r  r  rD   rF   r   r   r	    r  r    c                r  )u  Sets the color for user database suggestions

:param color_string: The color for user database suggestions
                    It is a string in one of the following formats:
                    - Standard name from the X11 rgb.txt
                    - Hex value: “#rgb”, “#rrggbb”, “#rrrgggbbb”
                                 or ”#rrrrggggbbbb”
                    - RGB color: “rgb(r,g,b)”
                    - RGBA color: “rgba(r,g,b,a)”
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  NrC  )r  r1   r'  r  rn  r  r  r  r   r   r!  r"  r  r   r   r  Z+TypingBoosterEngine.set_color_userdb_string  s    & q LL-|O444$0!"*"?"?%%#'OO%%#''57 r    c                rj   rk   r   rD   rF   r   r   r	  
       ) ) )r    c                ro   )u:   Returns the current value of the “color userdb” string)r  rm   r$   r   r  Z+TypingBoosterEngine.get_color_userdb_string
      (((r    c                r`  ra  rb  rD   rF   r   r   r	    rq  r    c                rd  )a  Sets whether to use color for spellchecking suggestions

:param mode: Whether to use color for spellchecking suggestions
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  NrD  )	r  r1   r'  r  r  r   r   r!  rf  rg  r   r   r  Z(TypingBoosterEngine.set_color_spellcheck  h     q LL-tG)))!%OO%%!((.0 r    c                rj   rk   r   rD   rF   r   r   r	  &       & &d &r    c                ro   )u<   Returns the current value of the “color spellcheck” mode)r  rm   r$   r   r  Z(TypingBoosterEngine.get_color_spellcheck&  r  r    c                r  r  r  rD   rF   r   r   r	  *  r  r    c                r  )u  Sets the color for spellchecking suggestions

:param color_string: The color for spellchecking suggestions
                    It is a string in one of the following formats:
                    - Standard name from the X11 rgb.txt
                    - Hex value: “#rgb”, “#rrggbb”, “#rrrgggbbb”
                                 or ”#rrrrggggbbbb”
                    - RGB color: “rgb(r,g,b)”
                    - RGBA color: “rgba(r,g,b,a)”
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  NrE  )r  r1   r'  r  rn  r  r  r  r   r   r!  r"  r  r   r   r  Z/TypingBoosterEngine.set_color_spellcheck_string*      & q LL-|O888(4%&.&C&C))'+#OO%%'''57 r    c                rj   rk   r   rD   rF   r   r   r	  J       - -S -r    c                ro   )u>   Returns the current value of the “color spellcheck” string)r  rm   r$   r   r  Z/TypingBoosterEngine.get_color_spellcheck_stringJ  rw  r    c                r`  ra  rb  rD   rF   r   r   r	  N  rq  r    c                rd  )a  Sets whether to use color for dictionary suggestions

:param mode: Whether to use color for dictionary suggestions
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  NrF  )	r  r1   r'  r  r  r   r   r!  rf  rg  r   r   r  Z(TypingBoosterEngine.set_color_dictionaryN  r  r    c                rj   rk   r   rD   rF   r   r   r	  f  r  r    c                ro   )u<   Returns the current value of the “color dictionary” mode)r  rm   r$   r   r  Z(TypingBoosterEngine.get_color_dictionaryf  r  r    c                r  r  r  rD   rF   r   r   r	  j  r  r    c                r  )u  Sets the color for dictionary suggestions

:param color_string: The color for dictionary suggestions
                    It is a string in one of the following formats:
                    - Standard name from the X11 rgb.txt
                    - Hex value: “#rgb”, “#rrggbb”, “#rrrgggbbb”
                                 or ”#rrrrggggbbbb”
                    - RGB color: “rgb(r,g,b)”
                    - RGBA color: “rgba(r,g,b,a)”
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  NrG  )r  r1   r'  r  rn  r  r   r  r   r   r!  r"  r  r   r   r  Z/TypingBoosterEngine.set_color_dictionary_stringj  r  r    c                rj   rk   r   rD   rF   r   r   r	    r  r    c                ro   )u>   Returns the current value of the “color dictionary” string)r  rm   r$   r   r  Z/TypingBoosterEngine.get_color_dictionary_string  rw  r    c                r`  ra  rb  rD   rF   r   r   r	    rq  r    c                rd  )a  Sets whether to use a label for user database

:param mode: Whether to use a label for user database suggestions
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  NrH  )	r  r1   r'  r  r  r   r   r!  rf  rg  r   r   r  Z$TypingBoosterEngine.set_label_userdb  r  r    c                rj   rk   r   rD   rF   r   r   r	    r  r    c                ro   )u8   Returns the current value of the “label userdb” mode)r  rm   r$   r   r  Z$TypingBoosterEngine.get_label_userdb  rq  r    c                r  r   label_stringrO  r   Nr  rD   rF   r   r   r	    1     7 7S/7 #7 /37r    c                rd  )a  Sets the label for user database suggestions

:param label_string: The label for user database suggestions
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  NrI  )	r  r1   r'  r  r  r   r   r!  r"  rO   r  rO  r   r   r  Z+TypingBoosterEngine.set_label_userdb_string  sh     q LL-|O444$0!OO%%#''57 r    c                rj   rk   r   rD   rF   r   r   r	    r  r    c                ro   )u:   Returns the current value of the “label userdb” string)r  rm   r$   r   r  Z+TypingBoosterEngine.get_label_userdb_string  r  r    c                r`  ra  rb  rD   rF   r   r   r	    rq  r    c                rd  )a  Sets whether to use a label for spellchecking suggestions

:param mode: Whether to use a label for spellchecking suggestions
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  NrJ  )	r  r1   r'  r  r  r   r   r!  rf  rg  r   r   r  Z(TypingBoosterEngine.set_label_spellcheck  r  r    c                rj   rk   r   rD   rF   r   r   r	    r  r    c                ro   )u<   Returns the current value of the “label spellcheck” mode)r  rm   r$   r   r  Z(TypingBoosterEngine.get_label_spellcheck  r  r    c                r  r  r  rD   rF   r   r   r	    r  r    c                rd  )a  Sets the label for spellchecking suggestions

:param label_string: The label for spellchecking suggestions
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  NrK  )	r  r1   r'  r  r  r   r   r!  r"  r  r   r   r  Z/TypingBoosterEngine.set_label_spellcheck_string  sh     q LL-|O888(4%OO%%'''57 r    c                rj   rk   r   rD   rF   r   r   r	    r  r    c                ro   )u>   Returns the current value of the “label spellcheck” string)r  rm   r$   r   r  Z/TypingBoosterEngine.get_label_spellcheck_string  rw  r    c                r`  ra  rb  rD   rF   r   r   r	    rq  r    c                rd  )a  Sets whether to use a label for dictionary suggestions

:param mode: Whether to use a label for dictionary suggestions
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  NrL  )	r  r1   r'  r  r  r   r   r!  rf  rg  r   r   r  Z(TypingBoosterEngine.set_label_dictionary  r  r    c                rj   rk   r   rD   rF   r   r   r	    r  r    c                ro   )u<   Returns the current value of the “label dictionary” mode)r  rm   r$   r   r  Z(TypingBoosterEngine.get_label_dictionary  r  r    c                r  r  r  rD   rF   r   r   r	    s1     #7 #7S/#7 ##7 /3#7r    c                s   V P                   ^8  d   \        P                  RW4       WP                  8X  d   R# Wn        / V n        VP                  R4      '       dD    \        P                  ! V4      V n        \        V P                  \        4      '       g   / V n        V P                   ^8  d*   \        P                  R\        V P                  4      4       V'       d<   V P                   P#                  R\$        P&                  P)                  V4      4       R# R#   \        \        3 d6   p\        P                  RTP                  P                  T4        Rp?LRp?ii ; i)a  Sets the label for dictionary suggestions

:param label_string: The label for dictionary suggestions
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  NZ{z)Cannot parse label_string as dict: %s: %szself._label_dictionary_dict=%srM  )r  r1   r'  r  r  rV  astZliteral_evalri  dictZSyntaxErrorr  r  r  rR   r0   r  r   r   r!  r"  )rO   r  rO  r2      &&& r   r  Z/TypingBoosterEngine.set_label_dictionary_string  s    q LL-|O888(4%&(#""3''5.1.>.>|.L+!$"="=tDD24D/
 q LL9d99:<OO%%'''57   , 5  ?OO,,e5 55s   AD   E&1+E!!E&c                rj   rk   r   rD   rF   r   r   r	  ?  r  r    c                ro   )u>   Returns the current value of the “label dictionary” string)r  rm   r$   r   r  Z/TypingBoosterEngine.get_label_dictionary_string?  rw  r    c                r`  ra  rb  rD   rF   r   r   r	  C  2     0 0c	"0 #0 /30r    c                rd  )a  Sets whether to add flags to dictionary matches

:param mode: Whether to add flags to suggestions matching
             in dictionaries
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  NrP  )	r  r1   r'  r	  r  r   r   r!  rf  rg  r   r   r  Z'TypingBoosterEngine.set_flag_dictionaryC  sh     q LL-tG((( $OO%% ((.0 r    c                rj   rk   r   rD   rF   r   r   r	  \       % %T %r    c                ro   )u;   Returns the current value of the “flag dictionary” mode)r	  rm   r$   r   r  Z'TypingBoosterEngine.get_flag_dictionary\      $$$r    c                r`  ra  rb  rD   rF   r   r   r	  `  rq  r    c                rd  )a  Sets whether to use a label to indicate busy state

:param mode: Whether to use a label to indicate busy state
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  NrQ  )	r  r1   r'  r
  r  r   r   r!  rf  rg  r   r   r  Z"TypingBoosterEngine.set_label_busy`  h     q LL-tG###OO%%((.0 r    c                rj   rk   r   rD   rF   r   r   r	  x  r  r    c                ro   )u6   Returns the current value of the “label busy” mode)r
  rm   r$   r   r  Z"TypingBoosterEngine.get_label_busyx  rw  r    c                r  r  r  rD   rF   r   r   r	  |  r  r    c                rd  )a  Sets the label used to indicate busy state

:param label_string: The label to indicate busy state
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  NrR  )	r  r1   r'  r  r  r   r   r!  r"  r  r   r   r  Z)TypingBoosterEngine.set_label_busy_string|  sh     q LL-|O222".OO%%!''57 r    c                rj   rk   r   rD   rF   r   r   r	         ' 's 'r    c                ro   )u8   Returns the current value of the “label busy” string)r  rm   r$   r   r  Z)TypingBoosterEngine.get_label_busy_string  r  r    c                r`  ra  rb  rD   rF   r   r   r	    rq  r    c                rd  )a  Sets whether to enable AI chat or not

:param mode: Whether to enable AI chat or not
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  Nr  )	r  r1   r'  r  r  r   r   r!  rf  rg  r   r   r  Z&TypingBoosterEngine.set_ai_chat_enable  sh     q LL-tG'''#OO%%((.0 r    c                rj   rk   r   rD   rF   r   r   r	    s     $ $D $r    c                ro   )zGReturns the current value of the flag whether
to enable AI chat or not
)r  rm   r$   r   r  Z&TypingBoosterEngine.get_ai_chat_enable  s     ###r    c                r  )r   ai_system_messagerO  r   Nr  rD   rF   r   r   r	    s1     < <$S#X< #< /3<r    c                rd  )a  Sets the system message to start AI chats with

:param ai_system_message: The system message to start AI chats with
:param update_gsettings:  Whether to write the change to Gsettings.
                          Set this to False if this method is
                          called because the Gsettings key changed
                          to avoid endless loops when the Gsettings
                          key is changed twice in a short time.
re  Nr  )	r  r1   r'  r  r  r   r   r!  r"  )rO   r  rO  r   r   r  Z)TypingBoosterEngine.set_ai_system_message  sj     q LL-/@T 7 77"3OO%%!''(9:< r    c                rj   rk   r   rD   rF   r   r   r	    r  r    c                ro   )z9Returns the current system message to start AI chats with)r  rm   r$   r   r  Z)TypingBoosterEngine.get_ai_system_message  r  r    c                r  )r   ollama_modelrO  r   Nr  rD   rF   r   r   r	    r  r    c                rd  )a  Sets the model to use for ollama

:param ollama_model:     The model to use for ollama
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  Nr  )	r  r1   r'  r  r  r   r   r!  r"  )rO   r  rO  r   r   r  Z$TypingBoosterEngine.set_ollama_model  sh     q LL-|O---)OO%%''57 r    c                rj   rk   r   rD   rF   r   r   r	    s     " "# "r    c                ro   )z-Returns the current value of the ollama model)r  rm   r$   r   r  Z$TypingBoosterEngine.get_ollama_model  rq  r    c                r  )r   max_contextrO  r   Nrl  rD   rF   r   r   r	    s1     6 6sCx6 #6 /36r    c                s    \         P                  RW4       WP                  8X  d   R# Wn        V'       d<   V P                  P	                  R\
        P                  P                  V4      4       R# R# )a  Sets the maximum number of ollama messages to keep as context
when continuing a chat

:param max_context:      Maximum number of messages to keep as context.
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  Nr  )r1   r'  r  r  r   r   r!  
new_uint32)rO   r  rO  r   r   r  Z*TypingBoosterEngine.set_ollama_max_context  sZ     	);	J222#. OO%%"''46 r    c                rj   rk   r   rD   rF   r   r   r	    s     ( ( (r    c                ro   )z@Returns the maximum number of ollama messages to keep as context)r  rm   r$   r   r   Z*TypingBoosterEngine.get_ollama_max_context  r  r    c                r  r   r  rO  r   Nr  rD   rF   r   r   r	  
  s1     / /S// #/ /3/r    c                s   V P                   ^8  d   \        P                  RW4       V P                  V8X  d   R# Wn        V'       d<   V P                  P                  R\        P                  P                  V4      4       R# R# )a  Sets the label used to indicate busy state

:param path: Full path of the Google application
             credentials .json file.
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  NrS  )	r  r1   r'  r  r  r   r   r!  r"  rO   r  rO  r   r   r  Z6TypingBoosterEngine.set_google_application_credentials
  sj     q LL-tG//47/3,OO%%.''-/ r    c                rj   rk   r   rD   rF   r   r   r	  #  s     4 4C 4r    c                ro   )z]Returns the current value of the full path to the
Google application credentials .json file.
)r  rm   r$   r   r  Z6TypingBoosterEngine.get_google_application_credentials#       333r    c                r`  ra  rb  rD   rF   r   r   r	  )  rq  r    c                rd  )u  Sets the “Tab enable” mode

:param mode: Whether to show a candidate list only when typing Tab
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  Nr*  )	r  r1   r'  r  r  r   r   r!  rf  rg  r   r   r  Z"TypingBoosterEngine.set_tab_enable)  r  r    c                rj   rk   r   rD   rF   r   r   r	  A  r  r    c                ro   u6   Returns the current value of the “Tab enable” mode)r  rm   r$   r   r  Z"TypingBoosterEngine.get_tab_enableA  rw  r    c                r`  ra  rb  rD   rF   r   r   r	  E  rq  r    c                rd  )u  Sets the “Disable in terminals” mode

:param mode: Whether to disable Typing Booster in terminals
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  Nr+  )	r  r1   r'  r  r  r   r   r!  rf  rg  r   r   r  Z,TypingBoosterEngine.set_disable_in_terminalsE  sh     q LL-tG---%)"OO%%$((.0 r    c                rj   rk   r   rD   rF   r   r   r	  ]  s     * *$ *r    c                ro   )u@   Returns the current value of the “Disable in terminals” mode)r  rm   r$   r   r  Z,TypingBoosterEngine.get_disable_in_terminals]  s    )))r    c                r`  ra  rb  rD   rF   r   r   r	  a  r  r    c                rd  )a  Sets whether the to convert language specific digits to ASCII digits

:param mode: Whether to convert language specific digits
             to ASCII digits
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  Nr,  )	r  r1   r'  r  r  r   r   r!  rf  rg  r   r   r  Z$TypingBoosterEngine.set_ascii_digitsa  sh     q LL-tG%%%!OO%%((.0 r    c                rj   rk   r   rD   rF   r   r   r	  z  r  r    c                ro   )u8   Returns the current value of the “ASCII digits” mode)r  rm   r$   r   r  Z$TypingBoosterEngine.get_ascii_digitsz  rq  r    c                r[   rh  r   rD   rF   r   r   r	  ~  s     
6 
6D 
6D 
6r    c                ri  )a  Toggles whether to convert languages specific digits to ASCII digits

:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
N)r  r  rj  rd   r   toggle_ascii_digitsZ'TypingBoosterEngine.toggle_ascii_digits~  s!     	"""$4	6r    c                r`  ra  rb  rD   rF   r   r   r	    rq  r    c                rd  )a  Sets whether the show the final form while typing

:param mode: Whether to show the final form while typing
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  Nr-  )	r  r1   r'  r  r  r   r   r!  rf  rg  r   r   r  Z'TypingBoosterEngine.set_show_final_form  sh     q LL-tG((( $OO%%((.0 r    c                rj   rk   r   rD   rF   r   r   r	    r  r    c                ro   )uH   Returns the current value of the “Show final form while typing” mode)r  rm   r$   r   r  Z'TypingBoosterEngine.get_show_final_form  r  r    c                r[   rh  r   rD   rF   r   r   r	    rr  r    c                ri  )ay  Toggles whether to show the final form while typing

:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
N)r  r  rj  rd   r   toggle_show_final_formZ*TypingBoosterEngine.toggle_show_final_form  rt  r    c                r`  ra  rb  rD   rF   r   r   r	    r  r    c                rd  )u  Sets the “Remember last used preëdit ime” mode

:param mode: Whether to remember the input method used last for
             the preëdit
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  Nr5  )	r  r1   r'  r  r  r   r   r!  rf  rg  r   r   r  Z6TypingBoosterEngine.set_remember_last_used_preedit_ime  sh     q LL-tG777/3,OO%%,((.0 r    c                rj   rk   r   rD   rF   r   r   r	    s     4 4D 4r    c                ro   )uL   Returns the current value of the
“Remember last used preëdit ime” mode
)r  rm   r$   r   r  Z6TypingBoosterEngine.get_remember_last_used_preedit_ime  r  r    c                r`  ra  rb  rD   rF   r   r   r	    rq  r    c                rd  )u  Sets the “Remember input mode” mode

:param mode: Whether to remember the input mode (on/off)
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  NrV  )	r  r1   r'  r  r  r   r   r!  rf  rg  r   r   r  Z+TypingBoosterEngine.set_remember_input_mode  sh     q LL-tG,,,$(!OO%%#((.0 r    c                rj   rk   r   rD   rF   r   r   r	    s     ) ) )r    c                ro   )u>   Returns the current value of the ”Remember input mode" mode.)r  rm   r$   r   r  Z+TypingBoosterEngine.get_remember_input_mode  r  r    c                r  )r   r   rO  r   Nrl  rD   rF   r   r   r	    s1     7 7S#X7 #7 /37r    c                s   V P                   ^8  d   \        P                  RW4       WP                  8X  d   R# ^Tu;8:  d   ^	8:  d   M R# Wn        V P                  P                  V P                  4       V P                  4        V'       d<   V P                  P                  R\        P                  P                  V4      4       R# R# R# )a  Sets the page size of the lookup table

:param page_size: The page size of the lookup table
                  1 <= size <= 9
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  Nr"  )r  r1   r'  r  rA  r   r\  r  r   r   r!  rm  )rO   r   rO  r   r   r   Z!TypingBoosterEngine.set_page_size  s     q LL-yL'	Q'O,,T__=++-))LL**957  	 r    c                rj   rk   r   rD   rF   r   r   r	  	  rs  r    c                ro   )z1Returns the current page size of the lookup table)r  rm   r$   r   r   Z!TypingBoosterEngine.get_page_size	  ru  r    c                r  )r   r   rO  r   Nrl  rD   rF   r   r   r	    s1     9 9sCx9 #9 /39r    c                s   V P                   ^8  d   \        P                  RW4       WP                  8X  d   R# ^ Tu;8:  d   ^8:  d   M R# Wn        V P                  P                  V P                  4       V P                  4        V'       d<   V P                  P                  R\        P                  P                  V4      4       R# R# R# )ao  Sets the orientation of the lookup table

:param orientation: The orientation of the lookup table
                    0 <= orientation <= 2
                    IBUS_ORIENTATION_HORIZONTAL = 0,
                    IBUS_ORIENTATION_VERTICAL   = 1,
                    IBUS_ORIENTATION_SYSTEM     = 2.
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  Nr#  )r  r1   r'  r  rA  r   r\  r  r   r   r!  rm  )rO   r   rO  r   r   r  Z0TypingBoosterEngine.set_lookup_table_orientation  s    " q LL-{N888 q  -8*..t/M/MN++-)),LL**;79  	 !r    c                rj   rk   r   rD   rF   r   r   r	  ,  r  r    c                ro   )z3Returns the current orientation of the lookup table)r  rm   r$   r   r  Z0TypingBoosterEngine.get_lookup_table_orientation,  r  r    c                r  )r   underline_moderO  r   Nrl  rD   rF   r   r   r	  0  s1     < <!#s(O< #< /3<r    c                s   V P                   ^8  d   \        P                  RW4       WP                  8X  d   R# ^ Tu;8:  d    \        P
                  P                  8  d`   M R# Wn        V P                  4        V'       d<   V P                  P                  R\        P                  P                  V4      4       R# R# R# )a  Sets the underline style for the preedit

:param underline_mode: The underline mode to be used for the preedit
                      0 <= underline_mode <= 3
                      IBus.AttrUnderline.NONE    = 0,
                      IBus.AttrUnderline.SINGLE  = 1,
                      IBus.AttrUnderline.DOUBLE  = 2,
                      IBus.AttrUnderline.LOW     = 3,
                      IBus.AttrUnderline.ERROR   = 4,
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  Nr$  )r  r1   r'  r  r   r  ZERRORr  r  r   r   r!  rm  )rO   r  rO  r   r   r  Z)TypingBoosterEngine.set_preedit_underline0  s    & q LL-2 4449!3!3!9!999&4#OO))&LL**>:<   :r    c                rj   rk   r   rD   rF   r   r   r	  Q  r  r    c                ro   )z2Returns the current underline style of the preedit)r  rm   r$   r   r  Z)TypingBoosterEngine.get_preedit_underlineQ  r  r    c                r`  ra  rb  rD   rF   r   r   r	  U  r  r    c                rd  )u  Sets the “Use preedit styling only when lookup is enabled” mode

:param mode: Whether preedit styling like underlining should
             be enabled only when lookup is enabled.
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
z(%s, update_gsettings=%s)Nr%  )	r  r1   r'  r  r  r   r   r!  rf  rg  r   r   r  Z6TypingBoosterEngine.set_preedit_style_only_when_lookupU  sh     q LL+TE777/3,OO%%,((.0 r    c                rj   rk   r   rD   rF   r   r   r	  n  s     4 4D 4r    c                ro   r  )r  rm   r$   r   r  Z6TypingBoosterEngine.get_preedit_style_only_when_lookupn  r  r    c                r  )r   min_char_completerO  r   Nrl  rD   rF   r   r   r	  r  s1     ? ?$S#X? #? /3?r    c                sT   V P                   ^8  d   \        P                  RW4       WP                  8X  d   R# ^ Tu;8:  d   ^	8:  d`   M R# Wn        V P	                  4        V'       d<   V P
                  P                  R\        P                  P                  V4      4       R# R# R# )a,  Sets the minimum number of characters to try completion

:param min_char_complete: The minimum number of characters
                          to type before completion is tried.
                          0 <= min_char_complete <= 9
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  Nr   )
r  r1   r'  r  r\  r  r   r   r!  rm  )rO   r  rO  r   r   r  Z)TypingBoosterEngine.set_min_char_completer  s     q LL-!5  7 77!&Q&&&7#++-))%LL**+<=?   'r    c                rj   rk   r   rD   rF   r   r   r	    s     ' 's 'r    c                ro   )zKReturns the current minimum number of characters to try completion
        )r  rm   r$   r   r  Z)TypingBoosterEngine.get_min_char_complete  r   r    c                r  )r   debug_levelrO  r   Nrl  rD   rF   r   r   r	    s1     9 9sCx9 #9 /39r    c                sT   V P                   ^8  d   \        P                  RW4       WP                   8X  d   R# ^ Tu;8:  d   ^8:  d`   M R# Wn         V P                  4        V'       d<   V P                  P                  R\        P                  P                  V4      4       R# R# R# )a  Sets the debug level

:param debug_level: The debug level
                    0 <= debug_level <= 255
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  Nr!  )	r  r1   r'  r\  r  r   r   r!  rm  )rO   r  rO  r   r   r  Z#TypingBoosterEngine.set_debug_level  s     q LL-{N+++"s"" +++-)) LL**;79   #r    c                rj   rk   r   rD   rF   r   r   r	    ro  r    c                ro   )zReturns the current debug level)r  rm   r$   r   r  Z#TypingBoosterEngine.get_debug_level  rp  r    c                r  )r   millisecondsrO  r   Nrl  rD   rF   r   r   r	    s6     N NS/N #N /3Nr    c                    \         P                  RW4       WP                  8X  d   R# Wn        V'       dF   V P                  P	                  R\
        P                  P                  V P                  4      4       R# R# )a  Sets the delay of the candidates in milliseconds

:param milliseconds:     delay of the candidates in milliseconds
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  Nr  )r1   r'  r  r  r   r   r!  r  )rO   r  rO  r   r   r  Z5TypingBoosterEngine.set_candidates_delay_milliseconds  sa     	)<	K>>>.:+OO%%-''(K(KLN r    c                rj   rk   r   rD   rF   r   r   r	    s     3 33 3r    c                ro   )zAReturns the current value of the candidates delay in milliseconds)r  rm   r$   r   r  Z5TypingBoosterEngine.get_candidates_delay_milliseconds  s    222r    c                r  )r   secondsrO  r   N)r   r3  r   r   rD   rF   r   r   r	    s7     I I5#:&I #I /3Ir    c                r  )a  Sets the ibus event sleep seconds

:param seconds:          ibus event sleep seconds
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  Nr  )r1   r'  r  r  r   r   r!  Z
new_double)rO   r  rO  r   r   r  Z0TypingBoosterEngine.set_ibus_event_sleep_seconds  sa     	)7	F444)0&OO%%'''(F(FGI r    c                rj   rk   )r3  rD   rF   r   r   r	    s     . .e .r    c                ro   )z3Returns the current value ibus event sleep seconds )r  rm   r$   r   r  Z0TypingBoosterEngine.get_ibus_event_sleep_seconds  r  r    c                r  ra  r   rD   rF   r   r   r	    s%     0 00040@D0r    c                rd  )a  Sets whether the use of an IBus keymap is forced

:param mode: True if the use of an IBus keymap is forced, False if not
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  Nr  )	r  r1   r'  r  r  r   r   r!  rf  rg  r   r   r  Z'TypingBoosterEngine.set_use_ibus_keymap  sh     q LL-tG((( $OO%%((.0 r    c                sJ   < V ^8  d   QhRS[ RS[S[P                  ,          /# )r   keymapr   )r   r   r   KeymaprD   rF   r   r   r	     s$       x/D r    c                s>   V \         P                  9  d/   \        P                  RV \	        \         P                  4      4        \
        P                  ! V 4      #   \         d7   p\        P                  RYP                  P                  T4        Rp?R# Rp?ii ; i)zLConstruct a new IBus.Keymap object and store it in
self._ibus_keymap_object
z3keymap %s not in itb_util.AVAILABLE_IBUS_KEYMAPS=%sz7Exception in IBus.Keymap("%s"): %s: %s. Returning None.N)rn  ZAVAILABLE_IBUS_KEYMAPSr1   r  r0   r   r  r7   r2   r  rR   )r  r2   rP   r   r  Z#TypingBoosterEngine.new_ibus_keymap  sx    
 888NNEX<<=?	;;v&& 	LLI00%9 		s   A B&+BBc                r  )r   r  rO  r   Nr  rD   rF   r   r   r	    s1     1 1#s(O1 #1 /31r    c                sJ   V P                   ^8  d   \        P                  RW4       WP                  8X  d   R# Wn        V P                  P                  V4      V n        V'       d<   V P                  P                  R\        P                  P                  V4      4       R# R# )a  Sets the  IBus keymap to use if the use of an IBus keymap is forced

:param keymap: The IBus keymap to use
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  Nr  )r  r1   r'  r  r  r  r  r  r   r   r!  r"  )rO   r  rO  r   r   r  Z#TypingBoosterEngine.set_ibus_keymap  s     q LL-vI&&&"#'>>#A#A&#I OO%%''/1 r    c                rj   rk   r   rD   rF   r   r   r	  )  r  r    c                ro   )z3Returns whether the use of an IBus keymap is forced)r  rm   r$   r   r  Z'TypingBoosterEngine.get_use_ibus_keymap)  r  r    c                rj   rk   r   rD   rF   r   r   r	  -  s     ! ! !r    c                ro   )zRReturns the name of the IBus keymap to use if the use of an
IBus keymap is forced
)r  rm   r$   r   r  Z#TypingBoosterEngine.get_ibus_keymap-  s        r    c                r  )r   error_soundrO  r   Nr   rD   rF   r   r   r	  3  s%     7 7#77;7GK7r    c                rd  )a  Sets whether a sound is played on error or not

:param error_sound: True if a sound is played on error, False if not
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  NrY  )	r  r1   r'  r  r  r   r   r!  rf  )rO   r  rO  r   r   r  Z#TypingBoosterEngine.set_error_sound3  sh     q LL-{N+++'OO%%((57 r    c                rj   rk   r   rD   rF   r   r   r	  I  s     ! ! !r    c                ro   )z1Returns whether a sound is played on error or not)r  rm   r$   r   r  Z#TypingBoosterEngine.get_error_soundI  rp  r    c                r  r  r  rD   rF   r   r   r	  M  s1     / /S// #/ /3/r    c                s   V P                   ^8  d   \        P                  RW4       \        V\        4      '       g   R# WP
                  8X  d   R# Wn        V'       d:   V P                  P                  R\        P                  P                  V4      4       \        P                  ! \        P                  P                  V4      V P                   R7      V n        R# )a  Sets the path of the .wav file containing the sound
to play on error.

:param path: The path of the .wav file containing the error sound
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the dconf key changed
                         to avoid endless loops when the dconf
                         key is changed twice in a short time.
re  NrZ  Zaudio_backend)r  r1   r'  ri  r   r  r  r   r   r!  r"  	itb_soundSoundObjectr  r  
expanduserr  r  r  r   r   r  Z(TypingBoosterEngine.set_error_sound_fileM  s     q LL-tG$$$)))!%OO%% ''-/ $-#8#8GGt$--$/ r    c                rj   rk   r   rD   rF   r   r   r	  k  s     & &c &r    c                ro   )z>
Return the path of the .wav file containing the error sound.
)r  rm   r$   r   r  Z(TypingBoosterEngine.get_error_sound_filek  r  r    c                r  )r   sound_backendrO  r   Nr  rD   rF   r   r   r	  q  s1     / / c?/ #/ /3/r    c                s   V P                   ^8  d   \        P                  RW4       \        V\        4      '       g   R# WP
                  8X  d   R# Wn        V'       d:   V P                  P                  R\        P                  P                  V4      4       \        P                  ! \        P                  P                  V P                   4      V P
                  R7      V n        R# )a  Sets the sound backend to use

:param sound_backend: The name of sound backend to use
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the dconf key changed
                         to avoid endless loops when the dconf
                         key is changed twice in a short time.
re  NrX  r  )r  r1   r'  ri  r   r  r  r   r   r!  r"  r  r  r  r  r  r  r  )rO   r  rO  r   r   r  Z%TypingBoosterEngine.set_sound_backendq  s     q LL-}P---///+OO%%''68 $-#8#8GGt556--$/ r    c                rj   rk   r   rD   rF   r   r   r	    s     # #3 #r    c                ro   )z5
Return the name of the currently used sound backend
)r  rm   r$   r   r  Z%TypingBoosterEngine.get_sound_backend  ry  r    c                r`  ra  rb  rD   rF   r   r   r	    rc  r    c                r  )u  Sets the “Show number of candidates” mode

:param mode: Whether to show the number of candidates
             in the auxiliary text
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  Nr&  )
r  r1   r'  r  r\  r  r   r   r!  rf  rg  r   r   r  Z1TypingBoosterEngine.set_show_number_of_candidates  st     q LL-tG222*.''')OO%%(((.0 r    c                rj   rk   r   rD   rF   r   r   r	    s     / /t /r    c                ro   )uN   Returns the current value of the “Show number of candidates” mode
        )r  rm   r$   r   r  Z1TypingBoosterEngine.get_show_number_of_candidates  r   r    c                r`  ra  rb  rD   rF   r   r   r	    s2     0 0c	"0 #0 /30r    c                r  )u  Sets the “Show status info in auxiliary text” mode

:param mode: Whether to show status information in the
             auxiliary text.
             Currently the status information which can be
             displayed there is whether emoji mode and
             off-the-record mode are on or off
             and which input method is currently used for
             the preëdit text.
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  Nr'  )
r  r1   r'  r  r\  r  r   r   r!  rf  rg  r   r   r  Z:TypingBoosterEngine.set_show_status_info_in_auxiliary_text  st    & q LL-tG;;;370'')OO%%%((.0 r    c                rj   rk   r   rD   rF   r   r   r	    s     8 8 8r    c                ro   )uJ   Returns the current value of the
“Show status in auxiliary text” mode
)r  rm   r$   r   r  Z:TypingBoosterEngine.get_show_status_info_in_auxiliary_text  s     777r    c                r  ra  rl  rD   rF   r   r   r	    rn  r    c                r  )u  Sets the “Show raw input” mode

:param mode: Whether to show the raw input in the auxiliary text.
             0: Never
             1: When there are candidates
             2: Always
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
re  Nr(  )
r  r1   r'  r  r\  r  r   r   r!  rm  rg  r   r   r  Z&TypingBoosterEngine.set_show_raw_input  st      q LL-tG'''#'')OO%%&&t,. r    c                rj   rk   r   rD   rF   r   r   r	    s     $ $C $r    c                ro   )u:   Returns the current value of the “Show raw input” mode)r  rm   r$   r   r  Z&TypingBoosterEngine.get_show_raw_input  r  r    c                r  ra  rl  rD   rF   r   r   r	    s1     . .S/. #. /3.r    c                r  )u  Sets the “Automatically select the best candidate” mode

:param mode: Whether to automatically select the best candidate
:param update_gsettings: Whether to write the change to Gsettings.
                         Set this to False if this method is
                         called because the Gsettings key changed
                         to avoid endless loops when the Gsettings
                         key is changed twice in a short time.
z4set_auto_select_candidate(%s, update_gsettings = %s)Nr)  )
r  r1   r'  r  r\  r  r   r   r!  rm  rg  r   r   r  Z-TypingBoosterEngine.set_auto_select_candidate  sv     q LLF( ...&*#'')OO%%%&&t,. r    c                rj   rk   r   rD   rF   r   r   r	    s     + +3 +r    c                ro   )uT   Returns the current value of the
“Automatically select the best candidate” mode
)r  rm   r$   r   r  Z-TypingBoosterEngine.get_auto_select_candidate  s     ***r    c                s0   < V ^8  d   QhRS[ RS[ RS[ RR/# )r   r   buttonr   r   Nr   rD   rF   r   r   r	    s3     A AA&)A25A:>Ar    c                s  < V P                   ^8  d   \        P                  RWV4       V P                  V4      '       g   R# V P                  P                  R4       V P                  P                  \        P                  8X  Ed*   V^8X  Ed    V P                  4       p\        P                  V P                  n        . V n        V P                  P                  4        V P                  P                  R4       V P                  4        . V n        V P                  4        V'       d   V P!                  4       '       d-   V P#                  \%        V4      4       V P'                  4        R# V P)                  4        \*        SV `Y  \.        P0                  P3                  V4      4       RV n        R# V^8X  dK   V\.        P6                  P8                  ,          '       d$   V P;                  V4       V P'                  4        R# V^8X  d   V P                  4       pV'       d   V P<                  '       d
   VR,          pV P?                  V4       V P<                  '       g   V P@                  '       dD   V PC                  4        V PE                  4        \F        PH                  ! ^V PJ                  4       R# V PM                  4        R# V^8X  da   V\.        P6                  PN                  ,          '       d:   V\.        P6                  P8                  ,          '       d   V PQ                  4        R# V^8X  d:   V\.        P6                  P8                  ,          '       d   V PS                  4        R# V^8X  d:   V\.        P6                  PN                  ,          '       d   V PU                  4        R# V^8X  d   V PW                  4        R# R# )zFCalled when a candidate in the lookup table
is clicked with the mouse
z"index = %s button = %s state = %s
NTFr5  ),r  r1   r'  rk  rA  r   r   r{   r   rl  r   r=  r   r  r1  r  r  r  r  r  r   r  r&  r   r   r   r+  r:  r\  ro  r  r(  rx  r  rz  r   r  r  r\  	MOD1_MASKr  r  r  r  )rO   r   r  r   r   r  s   &&&& r   do_candidate_clickedZ(TypingBoosterEngine.do_candidate_clicked  s   
 q LL5ueM@@GG--d3##'7'K'KK{EEG+;+B+B""(#% ""((*""55e<113/1,335**,,55d6lC)((*G'		11&9;;?D8Q;ED$5$5$B$BBB44U;OOQ;AACF,,,cMF##F+,,,%%'99; $$Q(R(RS  335aK**4444**7777Q;ED$5$5$B$BBB--/Q;ED$5$5$?$???++-Q;++- r    c                r[   )r   error_messager   Nr   rD   rF   r   r   r	  [  s      s t r    c                sh   RpV P                   '       d;   V P                  P                  4       '       d   V P                  P                  4       pV P                  \        P
                  P                  VR,           V,           4      R4       \        P                  ! ^4       V P                  4        R# )zShow an error message in the auxiliary text when
something goes wrong with speech recognition.

:param error_message: The text to display as error message
rB   u   ⚠️TN)
r  r  r=  ro  r   r   r   r6  r7  r  )rO   r  auxiliary_text_labelri   r   _speech_recognition_errorZ-TypingBoosterEngine._speech_recognition_error[  s      "***55;;== 55;;= !""II%%$x/-?ABF	H 	

1r    c                rC   r   r'   rD   rF   r   r   r	  n  s     m mT mr    c           	     st   V P                   '       d   \        P                  R4       V P                  4        \        '       g   V P                  \        R4      4       R# \        P                  '       g   V P                  \        R4      4       R# \        P                  '       g   V P                  \        R4      4       R# V P                  ^ ,          pV'       g   V P                  \        R4      4       R# \        P                  P                  V P                  4      '       g.   V P                  \        R4      V P                  ,          4       R# V P                  \        P                  R&    \         P"                  ! 4       p\,        P.                  ! \0        P.                  P2                  P4                  \        P6                  TR7      p\,        P8                  ! TRR7      pRpT P:                  '       d;   T P<                  P?                  4       '       d   T P<                  P?                  4       pYa,          p\        P@                  ! TPC                  RR4      4      pT'       d   TRT,           ,          pTPC                  RR4      \        PD                  9  d
   TR,          pTR,          pT PG                  \H        PJ                  PM                  T4      R4       Rp\        PN                  ! \        P6                  \        PP                  4      ;_uu_ 4       p	T	PS                  4       p
R T
 4       pTPU                  Y[4      p T EF  pTPV                  '       g   K  TPV                  ^ ,          pTPX                  '       g   K?  TPX                  ^ ,          PZ                  pT P                   ^8  d]   \        P                  R\]        TPX                  4      4       TPX                   F#  p\        P                  RTPZ                  4       K%  	  T PG                  \H        PJ                  PM                  Yh,           4      R4       TP^                  '       g   EK   M	   RRR4       T'       Ed.   T P`                  '       d5   T Pb                  \        Pd                  Pf                  Ph                  39   d'   T^ ,          Pk                  4       TR,          ,           pMT Pl                  Pn                  pT Pl                  Pp                  pTRT P?                  4       pT P                   ^8  d7   \        P                  RT Pl                  4       \        P                  RT4       T'       d   TR,          R9   d&   T^ ,          Pk                  4       TR,          ,           pT Ps                  \u        T4      4       T Pw                  4        T Py                  4        R#   \$         dQ   p\        P'                  R	TP(                  P*                  T4       T P                  \        R
4      4        Rp?R# Rp?ii ; i  \$         dY   p\        P'                  RTP(                  P*                  T4       T P                  \        R4      4        Rp?RRR4       R# Rp?ii ; i  + '       g   i     ELG; i)z^
Listen to microphone, convert to text using Google speech-to-text
and insert converted text.
zspeech_recognition()
z'Failed to import Google speech-to-text.NzFailed to import pyaudio.zFailed to import queue.z-No supported language for speech recognition.u=   “Google application credentials” file “%s” not found.ZGOOGLE_APPLICATION_CREDENTIALSz8Exception when intializing Google speech-to-text: %s: %sz4Failed to init Google speech-to-text. See debug.log.)ZencodingZsample_rate_hertzrF  T)configZinterim_resultsrB   r{  r%   r  u   ❌z: c              3   sP   "   T F  p\         P                  ! VR 7      x  K  	  R# 5i))Zaudio_contentN)speech_typesZStreamingRecognizeRequest)r  r   rP   r   r  Z:TypingBoosterEngine._speech_recognition.<locals>.<genexpr>  s%      8'6G %>>WUU'6s   $&z&-------------------  %s alternative(s)z%sz#Google speech-to-text error: %s: %sz+Google speech-to-text error. See debug.log.rl  r  ztext_left = %rz.;:?!rQ  )=r  r1   r'  r\  'IMPORT_GOOGLE_SPEECH_TO_TEXT_SUCCESSFULr  r%   rn  ZIMPORT_PYAUDIO_SUCCESSFULZIMPORT_QUEUE_SUCCESSFULr  r  r  Zisfiler  Zenvironr   ZSpeechClientr7   r  r  rR   r  ZRecognitionConfigspeech_enumsZAudioEncodingZLINEAR16Z
AUDIO_RATEZStreamingRecognitionConfigr  r  r=  r  rB  ZGOOGLE_SPEECH_TO_TEXT_LANGUAGESro  r   r   r   ZMicrophoneStreamZAUDIO_CHUNKZ	generatorZstreaming_recognizeZresultsZalternatives
transcriptr  Zis_finalry  r  rB  rC  r   ri  rW  r   rH   r  r  r  r  )rO   rF  r]   r2   r  Zstreaming_configr  Zflagr  streamZaudio_generatorZrequestsZ	responsesZresponseresultZalternativer   rH   Z	text_lefts   &                  r   _speech_recognitionZ'TypingBoosterEngine._speech_recognitionn  s_   
 LL12'')66**;<>111**1-H+IJ///**1-F+GH..q1**ABDww~~dBBCC**QR6678  00 	

34	((*F //!33AAJJ&11') (BB "  "***55;;== 55;;= !-  !6!6sC!@A EDL0 !!#s+;;<H !E) $""II%%&:;T	C 
&&##X%9%9; ;>D$..0O8'68H223CNI' )H#+++ 
 &--a0F!... !'!4!4Q!7!B!BJ((1,D 3 346 ,2+>+>K"LL{/E/EF ,? ..		110=? A !*;^ : ---##(=(=(F(F(L(L'MM']002Z^C
--22!33>>
 *-335	$$q(LL3T5K5KMLL!19= IbMW$<!+A!4!4!6B!GJ%%d:&67++-Y  	J((%1 **HIK	Z    !F!&!9!95B..CDF[; ;PQ; ; ;si   5W" "+Z&>Y CY #Y $Z&%Y 'Z&"X=-AX88X= Z#AZZ&Z##Z&&Z7	c                rj   rk   r   rD   rF   r   r   r	          4 r    c                &    V P                  4        R# )u}   Handle hotkey for the command “toggle_input_mode_on_off”

:return: True if the key was completely handled, False if not.
T)r  rm   r$   r   !_command_toggle_input_mode_on_offZ5TypingBoosterEngine._command_toggle_input_mode_on_off  s    
 	 r    c                rj   rk   r   rD   rF   r   r   r	  %        T r    c                r  )uw   Handle hotkey for the command “speech_recognition”

:return: True if the key was completely handled, False if not.
T)r  rm   r$   r   _command_speech_recognitionZ/TypingBoosterEngine._command_speech_recognition%      
 	  "r    c                rj   rk   r   rD   rF   r   r   r	  -  s       r    c                    V P                   P                  \        P                  \        P                  \        P
                  \        P                  39   d   R# V P                  RR7       V P                  4        R# )s   Handle hotkey for the command “next_case_mode”

:return: True if the key was completely handled, False if not.
Fra  rN  T	rA  r   r{   r   r   r   r   rY  r  rm   r$   r   _command_next_case_modeZ+TypingBoosterEngine._command_next_case_mode-  sf    
 $$ 00 44 // 33	)5 5
 F+))+r    c                rj   rk   r   rD   rF   r   r   r	  <  s      T r    c                r  )r  Frc  rN  Tr  rm   r$   r   _command_previous_case_modeZ/TypingBoosterEngine._command_previous_case_mode<  sf    
 $$ 00 44 // 33	)5 5
 J/))+r    c                rj   rk   r   rD   rF   r   r   r	  K  s     C C Cr    c                sR   V P                   '       d   V P                  RR7       R# V P                  4       '       d   V P                  '       g   V P                  P
                  \        P                  8w  dY   V P                  P                  4       '       g%   V P                  '       g   V P                  '       d   V P                  4        R# R# V P                  '       Ed   V P                  P
                  \        P                  8X  d   V P                  P                  4       '       dI   V P                  P                  R4       V P                  P                  ^ 4       V P!                  4        R# \        P"                  V P                  n        V P                  P%                  4        V P                  P                  R4       V P!                  4        V P'                  4        . V n        R# V P*                  ^8  d   \,        P/                  R4       . V n        V P1                  4        V P3                  4       '       d   V P5                  4        R# V P'                  4        R# V P6                  P8                  '       Ed   V P                  P
                  \        P:                  8X  Ed   V P                  P                  4       '       dI   V P                  P                  R4       V P                  P                  ^ 4       V P!                  4        R# V P*                  ^8  d   \,        P/                  R4       \        P"                  V P                  n        V P<                  '       g   V P>                  ^8  d.   V P                  P@                  '       d   RV P                  n         V PB                  ^ ,          R8X  d   V PD                  RV PF                   pV\I        \J        PL                  4      ) R \J        PL                  8X  dy   V P*                  ^8  d   \,        P/                  R4       VR\I        \J        PL                  4      )  pVV PD                  V PF                  R ,           V n"        \I        V4      V n#        V PO                  4        MqV PD                  RV P6                  PP                   V PD                  V PF                  R ,           V n"        V P6                  PP                  V n#        V P1                  4        \R        PT                  ! 4       V n        V P5                  4        R# V P                  P                  4       '       d{   V P                  P                  R4       V P                  P                  ^ 4       V PW                  V PY                  4       R4       V PZ                  '       g   V P!                  4        R# V P                  P
                  \        P\                  8X  g   V P^                  R	8w  d   R	V n/        V P5                  4        R# V P<                  '       g   V P>                  ^8  d   V P`                  '       g   V P                  P@                  '       d   V P                  P                  4       '       dw   RV P                  n         V P                  P%                  4        V P                  P                  R4       V P!                  4        V P'                  4        . V n        R	V n/        R# V P                  4        V P5                  4        R# )
uk   Handle hotkey for the command “cancel”

:return: True if the key was completely handled, False if not.
Tcommit_selectionFzCompose sequence cancelled.z#Cancel m17n candidates lookup tabler  N-ja-anthy: removing itb_util.ANTHY_HENKAN_WIDEr`  )1r  _ollama_chat_query_cancelr  r1  rA  r   r{   r   r   r  r  r\  r   r   r   r   r  r   r   r   r=  r  r1   r'  r  r  r  r0  r:  r   r  r  r   r  r2  r3  r  rn  r  r"  r  r.  r/  rj  rp  r  r   r?  rx  )rO   typed_string_up_to_cursorrP   r   _command_cancelZ#TypingBoosterEngine._command_cancelK  s   
 )))**D*AMMOO000""((,<,K,KK"";;==333444 //1'''!!''+;+O+OO%%7799 &&99%@&&55a8557+;+B+B""(""((*""55e<113$$&#%   1$:;+-D(//1""$$!  $$&""---""((,<,L,LL!!3355 ""55e<""11!4113  1$BC'7'>'>D$!!!T%<%<q%@&&55549""1!!!$
2 &&'A(A(AB *-X77889;112 ((1,KM0I9#h88991;- 2,,T-F-F-GHI & 144M0ND-446 &&?//??A(()B)B)CDE "
 **:: )335%2%G%G%ID"OO//11 11%8--a0$$T%:%:%<dC333113$$(8(K(KK&&&0&,D#OO!8!81!<LLL""111"";;== 16D-$$&11%8--/  "!D&,D#'')r    c                rj   rk   r   rD   rF   r   r   r	    s     c c cr    c                s
   V P                   '       d   \        P                  R4       R# V P                  '       Ed   V P                  P
                  \        P                  8X  d   R# V P                  P                  V P                  V P                  P                  4       4      p. V n        V P                  P                  4        V P                  P                  R4       V EF  pV P                  P                  V P                  V,           4      pV'       g   K:  V P                  P!                  \"        P$                  ! V^ RRRR7      4       V P                  P'                  V4      pV P                  P)                  4       \*        P,                  P.                  8X  d   VRV,           ,          pMVRV,           ,          pV P                  P)                  4       \*        P,                  P.                  8X  d{   \1        V4      ^8  d)   VR,          pV F  pVR\3        V4      R	 2,          pK  	  \1        V4      ^8X  d3   VR\4        P6                  ! V4      P9                  4       ,           ,          pV P;                  VR
7       EK  	  RV P                  n        \        P                  V P                  n        V P?                  4        R# V P@                  PB                  '       Ed   V P@                  PD                  '       g   V PF                  ^ ,          R8X  EdV   V P                  P
                  \        PH                  8X  d   V PF                  ^ ,          R8w  d   R# V PJ                  ^8  d   \        PM                  R4       V PN                  '       d(   \P        PR                  ! V PN                  4       ^ V n'        RV P                  n        \        PH                  V P                  n        V P?                  4        V P                  P                  R4       RV n*        V PF                  ^ ,          R8X  d   V PW                  4        RV n*        V PY                  V P[                  4       R4       R# V P\                  '       g.   V P^                  ^8  dr   V P                  P`                  '       gV   V P                  P<                  '       g:   V Pc                  4       '       g$   RV P                  n        V Pe                  4        R# R# )ur   Handle hotkey for the command “enable_lookup”

:return: True if the key was completely handled, False if not.
z2enable_lookup command ignored because OSK is used.FrB   rJ  z   	r5  z  	 U+r4  rn  Tr  zEnabling m17n lookup table)3rx  r1   r  r1  rA  r   r{   r   r  Zfind_compose_completionsr  keyvalsr=  r   r   composer>  rn  rU  Zlookup_representationr   r   r   ZVERTICALr  r9  rS  r}   r~   rE  r   r  r0  r:  candidate_showr  r   r  r'  r  r   r  r  _command_select_next_candidaterj  rp  r  r  r   r  r  )rO   Zcompose_completionsZcompose_completionr  Ztext_for_lookup_tablechar   &     r   _command_enable_lookupZ*TypingBoosterEngine._command_enable_lookup  s   
 <<<KKLM'''!!''+;+O+OO''@@00--5579    "D$$&11%8&9"!%!8!8!@!@003EE"G!>$$++ 44#1&'$&).+023 //EE.0 * **::<++445->1II--~1EE-**::<++445~.21V;1(6 53s4yo9N N 5 )7~.!31S;;K;K .<00568 81::4 ; 69 ':< 15D-'7'K'KD$--/""---''666&&q)Z7""((,<,L,LL&&q)Z7   1$9:&&&
 ""4#:#:;*+'04D-'7'G'GD$--/ 11$7/3D,!!!$
2335380$$T%:%:%<dC((1,''DDD&&555MMOO04D- OOr    c                rj   rk   r   rD   rF   r   r   r	  5  s     	 	t 	r    c                F    \         P                  ! V P                  4       R# )a  Put the selection into preedit

The return value should always be True. Even if putting the
selection into preedit failed, the key which executed the
command has been fully handled.  Makes no sense to use it as
input just because getting the selection failed.
T)r   idle_add#_selection_to_preedit_get_selectionrm   r$   r   _command_selection_to_preeditZ1TypingBoosterEngine._command_selection_to_preedit5  s     	d>>?r    c                rj   rk   r   rD   rF   r   r   r	  @  s     W WT Wr    c                s  a a RoS P                   '       d   S P                  P                  P                  4       '       g'   S P                  ^8  d   \
        P                  R4       S P                  ^8  d!   \
        P                  RS P                  4       S P                  P                  pS P                  P                  pS P                  P                  p\        W#4      p\        W#4      pWV o\
        P                  RS4       SR8w  Edb   XX8  d'   S P                  \        S4      ) \        S4      4       MS P                  ^ \        S4      4       S P                  \         P"                  P%                  R4      ^ R\         P&                  P(                  4       S P*                  P,                  P/                  R4      '       Ed   XRV P1                  4       '       Egx   \
        P                  R4       \2        P4                  ! S P6                  4       S P9                  \         P:                  \         P<                  P>                  R	7       S P9                  \         P:                  \         P<                  P>                  \         P<                  P@                  ,          R	7       S P9                  \         PB                  \         P<                  P>                  R	7       S P9                  \         PB                  \         P<                  P>                  \         P<                  P@                  ,          R	7       \2        P4                  ! S P6                  4       S PE                  S4       R
# S P                  ^8  d   \
        P                  R4       \F        PH                  ! 4       o\
        P                  RS4       SR8w  d   \J        PL                  ! VV 3R l4       R
# )Get the primary selection

If possible use surrounding text, if that is not supported
or fails, get it using the clipboard.

:return: *Must* always return False to avoid that this callback
         called by GLib.idle_add() runs again.
rB   ,Surrounding text not set since last trigger.r  zselection_text=%rTrN  NrO  rP  FHSurrounding text not supported or failed. Fallback to primary selection.c                  s&   < SP                  S 4      # r:   )"_selection_to_preedit_open_preeditselection_textrO      r   rg  ZITypingBoosterEngine._selection_to_preedit_get_selection.<locals>.<lambda>  s    77Gr    )'ry  rW  rJ   rM   r  r1   r  r'  r   rH   rI   r  r  rE  r  rt  r   r   r   r   r  r  rt   rV  r=  r6  r7  r  rZ  r[  r:  r\  r]  r^  r  rn  get_primary_selection_textr   r  )rO   r   rH   rI   selection_startselection_endr  s   f     @r   r  Z7TypingBoosterEngine._selection_to_preedit_get_selection@  s    $$$))//6688$$q(NNFH  1$8!335))..D//::J//::J!*9O
7M!-@NLL,n=RJ&,,((#n*=? ,,QN0CD ..		))"-q$%%,,. !!..99*EE[j)//11$ 23 

499:11JJ):):)G)G 2 I11JJ%%2243D3D3Q3QQ 2 S 11JJ):):)G)G 2 I11JJ%%2243D3D3Q3QQ 2 S 

499:33NCq LL : ;!<<>(.9 RMM H Ir    c                r$  )r   r  r   r  rD   rF   r   r   r	    s     	 	 	 	r    c                sz    V P                  4        V P                  \        V4      4       V P                  4        R# )zPut selection text into preedit

:return: *Must* always return False to avoid that this callback
         called by GLib.idle_add() runs again.
F)r
  r  r  r  )rO   r  rd   r   r  Z6TypingBoosterEngine._selection_to_preedit_open_preedit  s0     	%%d>&:;r    c                rj   rk   r   rD   rF   r   r   r	    s     	 	d 	r    c                r  )a  Show info about the currently selected text

The return value should always be True. Even if showing the
selection failed, the key which executed the command has been
fully handled.  Makes no sense to use it as input just because
getting the selection failed.
T)r   r  "_show_selection_info_get_selectionrm   r$   r   _command_show_selection_infoZ0TypingBoosterEngine._command_show_selection_info  s     	d==>r    c                rj   rk   r   rD   rF   r   r   r	    s     = =D =r    c                s  a aa RoRoS P                   '       Ed   S P                  P                  P                  4       '       g'   S P                  ^8  d   \
        P                  R4       S P                  ^8  d!   \
        P                  RS P                  4       S P                  P                  pS P                  P                  pS P                  P                  p\        W#4      p\        W#4      pWV oVRV oS P                  ^8  d   \
        P                  RSS4       SR8w  d   \        P                  ! VV 3R l4       R# S P                  ^8  d   \
        P                  R4       \        P                   ! 4       o^pSR8w  d   \        P"                  ! VVV 3R	 l4       R# SR8w  d   \        P"                  ! VV V3R
 l4       R# )r  rB   r  r  Nz(selection_text=%r text_left_of_cursor=%rc                  (   < SP                  S S 4      # r:   $_show_selection_info_show_candidatesr   r  r   rg  HTypingBoosterEngine._show_selection_info_get_selection.<locals>.<lambda>      990r    Fr  c                  r  r:   r	  r   r  r   rg  r    r  r    c                  s(   < S P                  R S4      # rx   r	  )rO   text_left_of_cursorr  r   rg  r    s    99')r    )ry  rW  rJ   rM   r  r1   r  r'  r   rH   rI   r  r  r   r  rn  r  r  )	rO   r   rH   rI   r  r  r  r  r  	   f      @@r   r  Z6TypingBoosterEngine._show_selection_info_get_selection  s     $$$))//6688$$q(NNFH  1$8!335))..D//::J//::J!*9O
7M!-@N #'{
"3  1$G+-@BRMM 0 1 q LL : ;!<<> RU01 "$U)* r    c                ,   < V ^8  d   QhRS[ RS[ RS[/# )r   r  text_to_analyzer   r  rD   rF   r   r   r	    s*     P P"%P8;P@DPr    c           
     s   V P                   ^8  d   \        P                  RW4       VR8X  d   R# \        V4      p\        '       d   \
        P                  ! RV4      pVR8X  d   VRR pV P                  '       d*   V P                  P                  4       V P                  8w  d=   \        P                  ! V P                  V P                  V P                  R7      V n        . pRpRpV EF  pV P                  P                  V4      p\        V4      ^8X  de   RV R\!        V4      R	 R
V 2p	T	p
VP#                  \$        P&                  ! W,           V
R7      4       Wi,          pVR\!        V4      R	 2,          pK  RV 2p	V'       d   V	R
V 2,          p	T	p
VP#                  \$        P&                  ! W,           V
R7      4       \)        V4       F  w  rV P                  P                  V4      pRV R\!        V4      R	 2p	V'       d   V	R
V 2,          p	V\        V4      ^,
          8  d   RV	 2p
MRV	 2p
VP#                  \$        P&                  ! W,           V
R7      4       Wi,          pVR\!        V4      R	 2,          pK  	  EK  	  V'       g)   V P                   ^8  d   \        P                  R4       R# VP#                  \$        P&                  ! W,           \$        P*                  ! V^(R7      R7      4       VP#                  \$        P&                  ! W,           \$        P*                  ! V^(R7      R7      4       W@n        V P.                  P1                  4        V P.                  P3                  R4       V P,                   F   pV P5                  RVP6                  R7       K"  	  \8        P:                  V P.                  n        V P?                  4        R# )zShow info about grapheme clusters in text_to_analyze

:return: *Must* always return False to avoid that this callback
         called by GLib.idle_add() runs again.
z$selection_text=%r text_to_analyze=%rrB   Fz\XNr^  t    r  r4  r5  r   r0  u    ├─u    └─zNo candidates found.r6  rQ  ) r  r1   r'  r  USING_REGEXr	  Zfindallr  rW  r  r(  r)  r  r  r}   r  r9  r>  rn  rU  r5  r;  r=  rA  r   r   rE  r0  r{   r   r   r  )rO   r  r  Zgrapheme_clustersr:  Zcode_point_list_phraseZfull_breakdown_phraseZclusterr}   r   r0  r   r  r  s   &&&           r   r
  Z8TypingBoosterEngine._show_selection_info_show_candidates  s    q LL?':b  1; "

5/ B R 1"# 6 """!!//1T5K5KK!*!7!700!%!7!7#'#4#4"6D 
!# "(G%%**73D7|q !'#c'l3-?qG !!(">">)2G#E F%/%&CGS/A*BB&gY'FAdV*$Gh::%.A B(1))..t4!$s3t9S/:$j(F3w<!++ 'x0G 'x0G!!(">">)2G#E F%/%&CD	#*??&  2! ):   1$34(66!:))&278 	9 	(66!9))%"67 	8 &  "--e4))I229#4#4 3 6 * $4#B#B ))+r    c                rj   rk   r   rD   rF   r   r   r	  @  s      D r    c                s\    V P                   '       g   R# . V n        V P                  4        R# )a  Start a new chat with an AI chat bot forgetting
previous interactions adding the current selection as
the initial input.

The return value should always be True. Even something fails
the key which executed the command has been fully handled and
it makes no sense to use it as input.
FT)r  r  _ai_chatrm   r$   r   _command_ai_chat_start_newZ.TypingBoosterEngine._command_ai_chat_start_new@  s'     ### "r    c                rj   rk   r   rD   rF   r   r   r	  O  s      4 r    c                sN    V P                   '       g   R# V P                  4        R# )zContinue a chat with an AI chat bot adding the
current selection as additional input.

The return value should always be True. Even something fails
the key which executed the command has been fully handled and
it makes no sense to use it as input.
FT)r  r  rm   r$   r   _command_ai_chat_continueZ-TypingBoosterEngine._command_ai_chat_continueO  s     ###r    c                rC   r   r'   rD   rF   r   r   r	  \  s     (0 (0$ (0r    c           
     sV   \         '       d   \        P                  R\         4       R# V P                  R8X  d   \        P                  R4       R# \        P
                  ! 4       V n        V P                  P                  4       R9  d   RV n        \        P                  R4       R# V P                  P                  4       R8X  d   RV n        V P                  P                  4       R8X  d   R	V n        V P                  P                  V P                  4      '       g   \        P                  \        P                  P                  \        P                  P                  \         4      R
4      RV P                   .p \#        \        P$                  R4      ;_uu_ 4       p\&        P(                  ! VVVVRR7      pRRR4       R# \.        P0                  ! V P2                  4       R#   + '       g   i     R# ; i  \*         d"   p\        P-                  RY4        Rp?R# Rp?ii ; i)zContinue or start a chat with an AI chat bot using
the current selection, as additional input. If nothing
is selected but surrounding text works, use the current
line up to the cursor as additional input.
u"   “import itb_ollama” failed: %rNrB   zollama model is not set.ollamaramalamaz#Failed to connect to ollama server.u   🦙🔵u   🦙🔴zollama_pull.pyz--modelZwbT)ZstdoutZstderrZstdinZstart_new_sessionzException when calling %r: %s)r  r  )IMPORT_ITB_OLLAMA_ERRORr1   r2   r  
itb_ollamaZItbOllamaClientr  Z
get_serverr  Zis_availabler.   r  r  r  r  r  r  Zopendevnullr  r  r7   r  r   r  _ai_chat_get_prompt)rO   r  r  r%   r2   r  r   r  ZTypingBoosterEngine._ai_chat\  s    #"LL46MO#LL34(88:))+3II"&DLL>?))+x7(2D%))+z9(2D%""//0B0BCC~~ww||77??846FH T%7%7$8;GE"**d++w"((&&%*.0A , d../ ,+   E  3WE EEs6   >"G<  G(<G< (G9	3G< 9G< <H(H##H(c                rj   rk   r   rD   rF   r   r   r	    s     P PT Pr    c                s~  a aa RoS P                   '       d   S P                  ^8  d!   \        P                  RS P                  4       S P                  P
                  pS P                  P                  pS P                  P                  p\        W#4      p\        W#4      pWV oSR8w  d>   S P                  4        S P                  4        \        P                  ! VV 3R l4       R# S P                  ^8  d   \        P                  R4       \        P                  ! 4       o^pSR8w  d?   S P                  4        S P                  4        \        P                   ! VVV 3R l4       R# S P                  ^8  d   \        P                  R4       S P                   '       g   \        P#                  R4       R# S P                  ^8  d!   \        P                  RS P                  4       S P                  P
                  R	S P                  P                   P%                  R
4      R,          oS P&                  P(                  R8w  dY   SP+                  S P&                  P(                  4      '       g   SS P&                  P(                  ,          oS P-                  4        \        P                   ! VVV 3R l4       R# )aw  Get the prompt from the primary selection or surrounding text

Try these methods to get a prompt and use the first which works:

- use surrounding text to get the selection
- get the primary selection
- get the current line up to the cursor from surrounding text

:return: *Must* always return False to avoid that this callback
         called by GLib.idle_add() runs again.
rB   r  c                  r  r:   _ai_chat_queryr   r  r   rg  9TypingBoosterEngine._ai_chat_get_prompt.<locals>.<lambda>  s    --,n>r    Fz[Surrounding text not supported or failed to get a selection. Fallback to primary selection.c                  r  r:   r  r   r  r   rg  r    s    !00!/Ar    z(Could not get a selection by any method.z:Surrounding text not supported, giving up to get a prompt.Nr7  c                  s(   < SP                  R S 4      # rx   r  )promptrO   r  r   rg  r    s    (;(;B(Gr    rQ  )ry  r  r1   r'  rW  r   rH   rI   r  r  r  rg  r   r  rn  r  r  r2   rh   r  r  r(  r  )	rO   r   rH   rI   r  r  r  r  r  r  r   r  Z'TypingBoosterEngine._ai_chat_get_prompt  s3    $$$  1$8!335))..D//::J//::J!*9O
7M!-@NR ""$MM > ? q LL12 "<<>R ""$ UAB q LLCD(((LLLNq LL4d6L6LM'',,.T##..005dB@%%.."4??4#=#=#F#FGG$44===&&( GHr    c                r  )r   r  r  r   r  rD   rF   r   r   r	    s"     + +S +# +$ +r    c                s   V P                   ^8  d   \        P                  RW4       V P                  '       d   V P                  P                  4       '       d   RP                  V P                  P                  V4      .4      pV P                  \        P                  P                  V P                  P                  4        V P                   R\        V P                  4       RV P                    RV 24      R4       M/V P                  \        P                  P                  R4      R4       VR8X  dH   \"        P$                  ! ^4       V P                  \        P                  P                  R4      R4       R# V P&                  ^ 8X  d   . M V P                  V P&                  ) ^,          R V n        Wn        R	R
RV/V n        V P,                  '       d   V P,                  P/                  4        \0        P2                  ! RV P4                  R	RRV P6                  /.\8        P:                  ! V P                  4      ,           V P*                  .,           V P,                  3R7      V n        V P<                  P?                  4        R# )zDo something with AI on the selected text

:return: *Must* always return False to avoid that this callback
         called by GLib.idle_add() runs again.
zselection_text=%r prompt=%rr7  [] TrB   FNroler  r   Zsystem)Zdaemonr  r*   ) r  r1   r'  r
  r  r=  r  r  fillro  r   r   r   r  r  r  r  r6  r7  r  r  r  r  r   rK   r^  "_ollama_chat_query_thread_functionr  rQ   r  r  r_  )rO   r  r  Zwrapped_promptr  r   r  Z"TypingBoosterEngine._ai_chat_query  s#    q LL6O 7 7 = = ? ?!YY(@(@(E(Ef(M'NON &&		))..4467001D11232d6H6H5I%&() +/0 &&		))"-u6R< JJqM&&tyy'@'@'DeL**a/B&&(@(@'@1'D'FG 	 '5#%vy&A"""##))+)2)9)9::Hi1H1HIJMM$"7"789(()* ))+*,& 	&&,,.r    c                sd   < V ^8  d   QhRS[ S[S[S[3,          ,          RS[P                  RR/# )r   messages
stop_eventr   N)r   r   r   rK   rL   rD   rF   r   r   r	     s?     #L #L4S>*#L "#L -1#Lr    c                s   V P                   ^8  d   \        P                  RV4       V P                  f   \        P	                  R4       R# RV n         V P                  P                  V P                  VRR7      p\        P                  R4       V EF  pVP                  4       '       d   \        P                  R4        M\        V\        4      '       d   R	V9   d   VP                  R	4      p\        V\        4      '       d   \        V4      ^ 8  dz   V^ ,          p\        V\        4      '       d[   R
V9   dT   VR
,          p\        V\        4      '       d5   RV9   d.   VR,          pVe!   V ;P
                  VR,          ,          un        \        P                   ! V P"                  4       EK!  	  V P
                  P%                  4       V n        \        P                   ! V P"                  4       \        P                   ! V P&                  4       R#   \(         dL   p	\        P	                  RT	4       \        P                   ! T P*                  \-        T	4      4        Rp	?	R# Rp	?	ii ; i)z(Thread to stream an ollama chat responsezStarting ollama chat stream %rNzOllama client not connected.rB   T)r%  r  zOllama chat stream started.z$Ollama chat stream stopped by event.choicesdeltar   zError in ollama chat stream: %s)r  r1   r'  r  r2   r  Zchatr  r  rM   ri  r  rB  r  r  r   r  "_ollama_chat_query_update_responser=   _ollama_chat_query_finalize_chatr7   _ollama_chat_query_handle_errorr   )
rO   r%  r&  r  Zchunkr'  Zchoice0r(  r   r2   r  r   r$  Z6TypingBoosterEngine._ollama_chat_query_thread_function   s   
 q LL98D&LL78 "	L((--""Xd . DFKK56$$&&KK FGeT**yE/A#ii	2G!'400S\A5E")!*%gt44G9K$+G$4E)%669;M*/	*:#*#6$($9$9U9=M$M$9dEEF   %)$9$9$?$?$AD!MM$AABMM$??@ 	LLL:EBMM$>>E
KK	Ls   GH I.#A I))I.c                rj   rk   r   rD   rF   r   r   r	  *   s     $ $D $r    c           	     s   V P                   R8X  d   \        P                  ! 4       pVP                  \        P                  ! V P
                  ^ \        V P                  4      4      4       \        P                  P                  V P                  4      pVP                  V4       V P                  V\        V P                  4      R\        P                  P                  4       R# V P                   R8X  EdH   RpV P                  '       dm   V P                  P!                  4       '       dM   V P                  P!                  4        V P"                   R\        V P$                  4       RV P&                   R2pRP)                  V P                  P+                  4        Uu. uF  pV P,                  P/                  V4      NK   	  up4      p^
pVP+                  4       p\        V4      V8  d   RP)                  R	.Wv) R
 ,           4      pV P1                  \        P                  P                  W5,           4      R4       R# \2        P5                  RV P                   4       R# u upi )zUpdate ollama preedit text from main thread

:return: *Must* always return False to avoid that this callback
         called by GLib.idle_add() runs again.
r  TFr  rB   r   r!  r7  u   […]N(Invalid self._ollama_response_style = %r)r  r   r<  r>  r  r  r  r  r   r   rC  rt  r   r   r
  r  r=  r  r  r  r  
splitlinesr  r#  ro  r1   r2   )rO   rD  Z	ibus_textZ
aux_prefixlineZ	aux_linesZmax_aux_lines_streamZaux_lines_splitr  r   r)  Z6TypingBoosterEngine._ollama_chat_query_update_response*   s    &&)3MMOELL00''C0E0E,FH I		11$2G2GHI$$U+..3t445t%%++- &&%/JD$;$;$A$A$C$C..4467001D11232d6H6H5IM  		!22==?#A?T $(#;#;#@#@#F?#A BI#% '224O?#&:: III0E0F GGI	&&		))**@A ?00	2#As   $I!c                rj   rk   r   rD   rF   r   r   r	  P   s      $ r    c                s&   V P                   ^8  d!   \        P                  RV P                  4       V P                  R8X  d2   V P                  \        P                  P                  R4      R4       R# V P                  R8X  d   V P                  P                  R4      '       dF   \        P                  ! RRV P                  \        P                  R7      P                  4       V n        T P                  \        P                  P                  R	P                  V P                  P!                  4        Uu. uF  pV P"                  P%                  V4      NK   	  up4      4      R
4       R# \        P'                  RV P                  4       R# u upi )zFinalize the chat from main thread

:return: *Must* always return False to avoid that this callback
         called by GLib.idle_add() runs again.
zself._ollama_response=%rr  rB   Fr  Zdeepseekz<think>.*?</think>)Zflagsr7  Tr,  )r  r1   r'  r  r  ro  r   r   r   r  rV  r	  ZsubZDOTALLr=  r  r-  r  r#  r2   )rO   r.  rP   r   r*  Z4TypingBoosterEngine._ollama_chat_query_finalize_chatP   sC    q LL3T5J5JK&&)3&&tyy'@'@'DeL&&%/!!,,Z88(*)2)))<<AEG % &&		))II%)%:%:%E%E%GI%GT 1166t<%GIJK  ?00	2Is   6$Fc                r$  )r   r  r   r  rD   rF   r   r   r	  k   s      S T r    c                s  < \         P                  RV4       RV n        \        SV `  \
        P                  P                  V P                   4      4       V P                  \
        P                  P                  R4      ^ R\
        P                  P                  4       V P                  \
        P                  P                  R4      R4       R# )zHandle chat errors from main thread

:return: *Must* always return False to avoid that this callback
         called by GLib.idle_add() runs again.
zOllama chat error: %sTrB   F)r1   r2   r  r  r&  r   r   r   r  rt  r   r  ro  )rO   r  r     &&r   r+  Z3TypingBoosterEngine._ollama_chat_query_handle_errork   s     	,m<(,%DII55**+. 	/**II%%b)1d!!((	* 	""499#<#<R#@%Hr    c                r[   )r   r  r   Nr   rD   rF   r   r   r	  {   s     > >$(>48>r    c                s*  < \         P                  R4       V P                  '       g   R# V P                  '       g   R# V P                  P	                  4       '       dO   V P                  P                  4        V P                  P                  4        V P                  P                  4        RV n        V'       d8   \        SV `%  \        P                  P                  V P                   4      4       \        P                  ! V P                   4       R# )zICancel an ollama chat query, if it already finished,
discard the result.
zOllama chat cancel.N)r1   r  r  r  is_aliverN   r  r   r  r&  r   r   r   r  r   r  !_ollama_chat_query_cancel_hide_ui)rO   r  r  r/  r   r  Z-TypingBoosterEngine._ollama_chat_query_cancel{   s    
 	)*---&&&))2244##'')**//1##))+)-&G		 9 9../!2 3d<<=r    c                rj   rk   r   rD   rF   r   r   r	     s     
 
4 
r    c                s    V P                  \        P                  P                  R4      ^ R\        P                  P
                  4       V P                  \        P                  P                  R4      R4       R# )zHide the preedit text and the auxiliary text

:return: *Must* always return False to avoid that this callback
         called by GLib.idle_add() runs again.
rB   TF)rt  r   r   r   r   r  ro  rm   r$   r   r1  Z5TypingBoosterEngine._ollama_chat_query_cancel_hide_ui   s[     	**II%%b)1d!!((	* 	""499#<#<R#@%Hr    c                r  rH  rI  rD   rF   r   r   r	     s!     2 2(2C2C 2 2r    c                s  < V P                   '       g   R# V P                  VR.R7      w  r#V'       d   V# V P                   P                  4       '       d   R# VP                  \        P
                  \        P                  \        P                  \        P                  \        P                  \        P                  \        P                  \        P                  \        P                  \        P                  \        P                  39   d   R# RV n         V P                   '       d
   RV n        R# V P"                  P%                  V P&                  4       V P"                  P%                  RRRV P(                  /4       VP*                  '       d9   \,        SV `]  \        P0                  P3                  V P(                   4      4       MVP4                  '       d9   \,        SV `]  \        P0                  P3                  V P6                   4      4       ME\,        SV `]  \        P0                  P3                  V P6                   R	V P(                   24      4       V P9                  \        P0                  P3                  R
4      ^ R\        P:                  P<                  4       V P?                  \        P0                  P3                  R
4      R4       R# )a   Process a key event while an ollama chat query is ongoing

:return: True if the key event has been completely handled by
         ibus-typing-booster and should not be passed through anymore.
         False if the key event has not been handled completely
         and is passed through.
FcancelcommandsTNr"  Z	assistantr   r7  rB   ) r  _handle_hotkeysr0  rR  r   KEY_Shift_RKEY_Shift_LKEY_ISO_Level3_ShiftKEY_Control_LKEY_Control_R	KEY_Alt_L	KEY_Alt_R
KEY_Meta_L
KEY_Meta_RKEY_Super_LKEY_Super_Rr  r  r>  r  r  rT  r  r&  r   r   rU  r  rt  r   r  ro  )rO   rv  r`  return_valuer  s   &&  r   _ollama_chat_query_process_keyZ2TypingBoosterEngine._ollama_chat_query_process_key   s    --- $ 4 4SH: 4 N))2244 GG((((11****((((
* 
* )-&(((,1D)$$T%8%89$$[)T-B-BC	E;;;G		 9 9(()!, -XXXG		 9 9../!2 3 G		 9 9../r$2G2G1HI!K L**II%%b)1d!!((	* 	""499#<#<R#@%Hr    c                rj   rk   r   rD   rF   r   r   r	     s      D r    c                s   V P                  4       p\        V4      ^8  d   V P                  pRV P                  9   d   RpV P	                  VR,          VR,          ,           VR7       V P                  4       '       df   V P                  \        P                  P                  V P                  4       ^ ,           4      R4       V P                  V P                  4       R4       R# R# )uv   Handle hotkey for the command “next_input_method”

:return: True if the key was completely handled, False if not.
r_  Frl  rj  rN  Tr  r  r  r  r  r  ro  r   r   r   rj  rp  r  rg  r   _command_next_input_methodZ.TypingBoosterEngine._command_next_input_method   s    
 $$&t9q=!AA 9 99#( !!R48#!1 " 3 }}**II--1F1F1H1K0LN (()>)>)@%Hr    c                rj   rk   r   rD   rF   r   r   r	     s       r    c                s   V P                  4       p\        V4      ^8  d   V P                  pRV P                  9   d   RpV P	                  VRR VRR ,           VR7       V P                  4       '       df   V P                  \        P                  P                  V P                  4       ^ ,           4      R4       V P                  V P                  4       R4       R# R# )uz   Handle hotkey for the command “previous_input_method”

:return: True if the key was completely handled, False if not.
r_  FNrN  TrQ  rC  r  rg  r   _command_previous_input_methodZ2TypingBoosterEngine._command_previous_input_method   s    
 $$&t9q=!AA 9 99#( !!RS	D"I%!1 " 3 }}**II--1F1F1H1K0LN (()>)>)@%Hr    c                rj   rk   r   rD   rF   r   r   r	  !  s      $ r    c                s    V P                  4       p\        V4      ^8  d@   RpRV P                  9   d   RpV P                  VR,          VR,          ,           VR7       R# R# )ut   Handle hotkey for the command “next_dictionary”

:return: True if the key was completely handled, False if not.
Tr[  Frl  rj  rN  r  r  r  r$  rO   r  rO  rg  r   _command_next_dictionaryZ,TypingBoosterEngine._command_next_dictionary!  sg    
 ))+u:>  $t888#( %%b	E"I%!1 & 3 r    c                rj   rk   r   rD   rF   r   r   r	  !  s      d r    c                s    V P                  4       p\        V4      ^8  d8   RpRV P                  9   d   RpV P                  VRR VRR ,           VR7       R# R# )ux   Handle hotkey for the command “previous_dictionary”

:return: True if the key was completely handled, False if not.
Tr[  FNrN  rQ  rF  rG  rg  r   _command_previous_dictionaryZ0TypingBoosterEngine._command_previous_dictionary!  si    
 ))+u:>#t888#( %%bc
U3BZ'!1 & 3 r    c                rj   rk   r   rD   rF   r   r   r	  $!  s       r    c                *   V P                   P                  '       d5   V P                   P                  '       g   V P                  ^ ,          R8w  g!   V P                  P                  4       '       g   R# V P                  4       pV P                  4        R# )uz   Handle hotkey for the command “select_next_candidate”

:return: True if the key was completely handled, False if not.
r  FT)r0  r:  r  r  rA  r   r`  r  rO   Z_dummyrP   r   r  Z2TypingBoosterEngine._command_select_next_candidate$!  sp    
 ##...''666##A&*4&&??AA!!#))+r    c                rj   rk   r   rD   rF   r   r   r	  2!  s      D r    c                rJ  )u~   Handle hotkey for the command “select_previous_candidate”

:return: True if the key was completely handled, False if not.
r  FT)r0  r:  r  r  rA  r   rb  r  rK  rP   r   "_command_select_previous_candidateZ6TypingBoosterEngine._command_select_previous_candidate2!  sn    
 ##...''666##A&*4%%>>@@!))+r    c                rj   rk   r   rD   rF   r   r   r	  @!  s       r    c                rJ  )u{   Handle hotkey for the command “lookup_table_page_down”

:return: True if the key was completely handled, False if not.
r  FT)r0  r:  r  r  rA  r   rd  r  rK  rP   r   _command_lookup_table_page_downZ3TypingBoosterEngine._command_lookup_table_page_down@!  sn    
 ##...''666##A&*4%%>>@@"))+r    c                rj   rk   r   rD   rF   r   r   r	  N!  s      t r    c                rJ  )uy   Handle hotkey for the command “lookup_table_page_up”

:return: True if the key was completely handled, False if not.
r  FT)r0  r:  r  r  rA  r   re  r  rK  rP   r   _command_lookup_table_page_upZ1TypingBoosterEngine._command_lookup_table_page_upN!  sm    
 ##...''666##A&*4%%>>@@))+r    c                rj   rk   r   rD   rF   r   r   r	  \!  s      $ r    c                r  )u|   Handle hotkey for the command “toggle_emoji_prediction”

:return: True if the key was completely handled, False if not.
T)r  rm   r$   r    _command_toggle_emoji_predictionZ4TypingBoosterEngine._command_toggle_emoji_prediction\!  s    
 	))+r    c                rj   rk   r   rD   rF   r   r   r	  d!  r  r    c                r  )uw   Handle hotkey for the command “toggle_emoji_style”

:return: True if the key was completely handled, False if not.
T)r  rm   r$   r   _command_toggle_emoji_styleZ/TypingBoosterEngine._command_toggle_emoji_styled!  s    
 	!r    c                rj   rk   r   rD   rF   r   r   r	  l!  s      D r    c                    RV n         R# )u~   Handle hotkey for the command “trigger_emoji_predictions”

:return: True if the key was completely handled, False if not.
T)r  rm   r$   r   "_command_trigger_emoji_predictionsZ6TypingBoosterEngine._command_trigger_emoji_predictionsl!  s    
 -1)r    c                rj   rk   r   rD   rF   r   r   r	  t!  r  r    c                rQ  )u}   Handle hotkey for the command “trigger_word_predictions”

:return: True if the key was completely handled, False if not.
T)r  rm   r$   r   !_command_trigger_word_predictionsZ5TypingBoosterEngine._command_trigger_word_predictionst!  s    
 ,0(r    c                rj   rk   r   rD   rF   r   r   r	  |!  s       r    c                r  )uz   Handle hotkey for the command “toggle_off_the_record”

:return: True if the key was completely handled, False if not.
T)r  rm   r$   r   _command_toggle_off_the_recordZ2TypingBoosterEngine._command_toggle_off_the_record|!  s    
 	'')r    c                rj   rk   r   rD   rF   r   r   r	  !  s      d r    c                r  )ux   Handle hotkey for the command “toggle_ascii_digits”

:return: True if the key was completely handled, False if not.
T)r  rm   r$   r   _command_toggle_ascii_digitsZ0TypingBoosterEngine._command_toggle_ascii_digits!  r  r    c                rj   rk   r   rD   rF   r   r   r	  !  s       r    c                sR    V P                  4       '       g   V P                  4       # R# )us   Handle hotkey for the command “lookup_related”

:return: True if the key was completely handled, False if not.
F)r  r  rm   r$   r   _command_lookup_relatedZ+TypingBoosterEngine._command_lookup_related!  s!    
 }}2244r    c                rj   rk   r   rD   rF   r   r   r	  !  s      D r    c                sR    V P                   '       * V n         V P                  4        R# )uv   Handle hotkey for the command “toggle_hide_input”

:return: True if the key was completely handled, False if not.
T)r  r  rm   r$   r   _command_toggle_hide_inputZ.TypingBoosterEngine._command_toggle_hide_input!  s"    
  $///r    c                rj   rk   r   rD   rF   r   r   r	  !  s       r    c                r  )uj   Handle hotkey for the command “setup”

:return: True if the key was completely handled, False if not.
T)r  rm   r$   r   _command_setupZ"TypingBoosterEngine._command_setup!  s    
 	r    c                r[   )r   	directionr   Nr   rD   rF   r   r   r	  !  s     { { { {r    c           	     sn  < \         P                  RWP                  P                  4       V P                  '       d5   V P
                  \        P                  P                  P                  39   d   \         P                  R4       R# V P                  P                  R.9   g,   V P                  P                  P                  R4      '       d   \         P                  R4       R# V P                  4       '       d   V P                  '       d=   \         P                  R4       V P                  4        \         P                  R4       R# \         P                  RV P                  V P                   4       V P                   P"                  R	8X  d)   V P$                  ^8  d   \         P                  R
4       R# V P                   P"                  pV P                   P&                  pV P                   P(                  pV P$                  ^8  d+   \         P                  RV P                   \+        V4      4       W48w  d   \         P                  R4       R# TpR	pVP-                  RR7       F)  p\/        V4      V8  d   V\/        V4      ,          pK'  Tp M	  VP1                  R4      '       d   VRR/ p\         P                  RV\/        V4      V4       VP3                  4       '       g   \         P                  R4       R# VR8X  d!   Rp\        P4                  ! V4      '       d   Rp\         P                  RV4       RRRRRRR/RRRRRRR//pW,          R,          \        P4                  ! V4      8X  d   \         P                  RV4       R# V P7                  V) \/        V4      4       WeR p	. R0Op
R	pV
 F  pW9  g   K  Tp M	  V'       g   \         P                  R4       R# \         P                  RV4       VRV  V WeR  2pW,          R,          p\9        W,          R,          4      p\9        W,          R,          4      pVP                  V4      '       d)   \         P                  RV4       VR ,          pVR ,          pV\        P4                  ! V4      8w  dU   \         P                  R!V4       V V 2pV V 2pV\        P4                  ! V4      8w  d   \         P;                  R"4       R# \<        SV `}  \@        PB                  PE                  V4      4       RV n        \F        PH                  ! V PJ                  4       V P                  PL                  R#8X  d   \         P                  R$4       \@        PN                  pVR8X  d   \@        PP                  pV	 F\  p\         P                  R%V\R        PT                  ! V4      4       \R        PT                  ! V4      R19  g   KK  V PW                  V4       K^  	  R# V P                  PL                  R29   Ed   V P                  PL                  p\         P                  R(V4       VR&8X  d   \         P                  R)4       R# VR'8X  d   \         P                  R*4       R# \X        '       g   \         P                  R+4       R# \Z        P\                  P_                  V4      pVPa                  V4      pV^ 8  d   \         P                  R,4       R# \@        PN                  pVV\/        V4      ,           R pVR8X  d   \@        PP                  pVRV p\         P                  R-VVVV4       V F\  p\         P                  R%V\R        PT                  ! V4      4       \R        PT                  ! V4      R19  g   KK  V PW                  V4       K^  	  R# )3zChange the direction of the current line

:param direction: The desired direction of the current line:
                  'ltr', 'rtl', 'toggle'
z@Trying to change line direction to %rself._client_info.client=%sz=Surrounding text not supported, cannot change line direction.Nlibreofficea  firefox, libreoffice, or google-chrome detected. Cannot change line direction in these programs. These programs already have their own support to change direction between RTL and LTR for the whole buffer, use this instead of changing the direction of single lines with typing booster.z"Committing pending input first ...zTo make the committed text appear in the surrounding text, another key event is needed. Therefore, a return is unfortunately necessary here and to really change the line direction, one has to press the keybinding again.zAself._commit_happened_after_focus_in=%r self._surrounding_text=%rrB   z5Surrounding text empty. Cannot change line direction.z'self._surrounding_text=%r list(text)=%rz%cursor_pos != anchor_pos, do nothing.T)Zkeependsr7  zCcurrent_line=%r len(current_line)=%d cursor_pos_in_current_line=%d z2Current line empty or whitespace only, do nothing.togglertlltrz-Current line needs to change direction to %r.addmarku   ‎
removemarku   ‏is_right_to_leftFz:Current_line already has desired direction %r, do nothing.z%Could not find suitable cursor markerzUsing cmarker=%rz)Wrong direction mark %r found, remove it.rl  zAdd direction mark %rz0Line direction still wrong, should never happen.rA  z.QIBusInputContext detected, correcting cursor.z%cursor correction char=%r category=%rgtk4-imgnome-shellz&%r detected, trying to correct cursor.uV   forward_key_event() does not work in “gtk4-im”, cursor correction cannot not work.zgnome-shell, i.e. wayland input in gnome wayland detected. Probably typing into some Gtk program. But correcting the cursor does not seem to work with gnome wayland input. uj   "import bidi.algorithm" didn’t work, no cursor correction possible. Try `pip install --user python-bidi`zHFailed to find cursor marker in new line. No cursor correction possible.zicurrent_line_with_cmarker=%r, new_line_with_cmarker=%r, cmarker_pos=%d cursor_correction_chars_display=%r)Zfirefoxzgoogle-chromesofficerQ  )u   _�_u   _￼_u   _☺_☺_☺_)ZMn)gtk3-imra  rb  )1r1   r'  r  r]   ry  r  rn  rB  rC  r   rr   rV  r  r1  r  r+  rW  r   r  rH   rI   r  r-  r  r(  r=  r`  rE  r   r2   r  r&  r   r   r   r6  r7  r  rp   rM  rK  rS  categoryrZ   IMPORT_BIDI_ALGORITHM_SUCCESSFULbidiZ	algorithmZget_displayr  )rO   rY  r   rH   rI   Zcursor_pos_in_current_lineZcurrent_liner.  Z
directionsZcursor_correction_chars_logicalZmarkersZcmarkerZmarkerZcurrent_line_with_cmarkerr`  r_  r^  Zarrow_key_valuer  rp   Znew_line_with_cmarkerZcmarker_posZcursor_correction_chars_displayr  s   &&                     r   _change_line_directionZ*TypingBoosterEngine._change_line_direction!  s    	 3 1 1 8 8	: )))H$9$9$B$B$H$H#IILLOQ** /7 7  --88GGLL @ A }}$">">">LL=>&&(LLMN
  199++	- !!&&",  1$KM%%**++66
++66
q LLB//d=#LL@A%/"OOTO2D4y55*c$i7*L 3   &&',L-#l+&		(
 !!##LLMN I((66!	D	  Ix (&/ Ix (&.	

 !"45((67LLL $$''\):	<*67R*S'
 F)   LL@A'17789i789; 	" &01CD.|<=
j+I67"":..LLD#%'+L(A"(E%x88FFLL0':%Y|n5L+2)4M3N(O%8#<#<\#JJOPII%%l3	5/3,

4112&&)<<LLIJ"mmOE!"&..7D!;#7#7#=?''-W<55oF	 8h 	_ ((,QQ))33ILLA9MI% B CM) 5 6
 33;< $(NN$>$>)%+!/44W=KQ > ?"mmO.CCL()/++E!"&..2G [3"/LL > 3.$8: 8D!;#7#7#=?''-W<55oF	 8
 	r    c                rj   rk   r   rD   rF   r   r   r	  c"        d r    c                (    V P                  R4       R# )z4Make the direction of the current line left-to-rightr]  Trh  rm   r$   r   ,_command_change_line_direction_left_to_rightZ@TypingBoosterEngine._command_change_line_direction_left_to_rightc"      ##E*r    c                rj   rk   r   rD   rF   r   r   r	  h"  ri  r    c                rj  )z4Make the direction of the current line right-to-leftr\  Trk  rm   r$   r   ,_command_change_line_direction_right_to_leftZ@TypingBoosterEngine._command_change_line_direction_right_to_lefth"  rm  r    c                rj   rk   r   rD   rF   r   r   r	  m"  s      t r    c                rj  )zQToggle the direction of the current line between
left-to-right and right-to-left
r[  Trk  rm   r$   r   %_command_change_line_direction_toggleZ9TypingBoosterEngine._command_change_line_direction_togglem"  s     	##H-r    c                rj   rk   r   rD   rF   r   r   r	  t"  s      4 r    c                z    V P                  4       '       d   V P                  '       g   R# V P                  4        R# )uu   Handle hotkey for the command “commit_raw_input”

:return: True if the key was completely handled, False if not.
FTr  r1  r|  rm   r$   r   _command_commit_raw_inputZ-TypingBoosterEngine._command_commit_raw_inputt"  ,    
 ==??4#?#?#? r    c                rj   rk   r   rD   rF   r   r   r	  ~"  s      4 r    c                rp  )u   Handle hotkey for the command “commit_raw_input_and_forward_key”

:return: True if the key was completely handled, False if not.
FTrq  rm   r$   r   )_command_commit_raw_input_and_forward_keyZ=TypingBoosterEngine._command_commit_raw_input_and_forward_key~"  rs  r    c                rj   rk   r   rD   rF   r   r   r	  "  s       r    c                rp  )uk   Handle hotkey for the command “commit”

:return: True if the key was completely handled, False if not.
FTr  r1  r  rm   r$   r   _command_commitZ#TypingBoosterEngine._command_commit"  ,    
 ==??4#?#?#?""$r    c                rj   rk   r   rD   rF   r   r   r	  "  s       r    c                rp  )u{   Handle hotkey for the command “commit_and_forward_key”

:return: True if the key was completely handled, False if not.
FTru  rm   r$   r   _command_commit_and_forward_keyZ3TypingBoosterEngine._command_commit_and_forward_key"  rw  r    c                rj   rk   r   rD   rF   r   r   r	  "       8 8T 8r    c                (    V P                  ^ RR7      # )uw   Handle hotkey for the command “commit_candidate_1”

:return: True if the key was completely handled, False if not.
rB   r  r+  rm   r$   r   _command_commit_candidate_1Z/TypingBoosterEngine._command_commit_candidate_1"      
 %%aB%77r    c                rj   rk   r   rD   rF   r   r   r	  "       9 9 9r    c                rz  )u   Handle hotkey for the command “commit_candidate_1_plus_space”

:return: True if the key was completely handled, False if not.
r5  r{  r|  rm   r$   r   &_command_commit_candidate_1_plus_spaceZ:TypingBoosterEngine._command_commit_candidate_1_plus_space"      
 %%aC%88r    c                rj   rk   r   rD   rF   r   r   r	  "       ) )T )r    c                s$    V P                  ^ 4      # )uw   Handle hotkey for the command “remove_candidate_1”

:return: True if the key was completely handled, False if not.
r  rm   r$   r   _command_remove_candidate_1Z/TypingBoosterEngine._command_remove_candidate_1"      
 %%a((r    c                rj   rk   r   rD   rF   r   r   r	  "  ry  r    c                (    V P                  ^RR7      # )uw   Handle hotkey for the command “commit_candidate_2”

:return: True if the key was completely handled, False if not.
rB   r{  r|  rm   r$   r   _command_commit_candidate_2Z/TypingBoosterEngine._command_commit_candidate_2"  r~  r    c                rj   rk   r   rD   rF   r   r   r	  "  r  r    c                r  )u   Handle hotkey for the command “commit_candidate_2_plus_space”

:return: True if the key was completely handled, False if not.
r5  r{  r|  rm   r$   r   &_command_commit_candidate_2_plus_spaceZ:TypingBoosterEngine._command_commit_candidate_2_plus_space"  r  r    c                rj   rk   r   rD   rF   r   r   r	  "  r  r    c                s$    V P                  ^4      # )uw   Handle hotkey for the command “remove_candidate_2”

:return: True if the key was completely handled, False if not.
r  rm   r$   r   _command_remove_candidate_2Z/TypingBoosterEngine._command_remove_candidate_2"  r  r    c                rj   rk   r   rD   rF   r   r   r	  "  ry  r    c                (    V P                  ^RR7      # )uw   Handle hotkey for the command “commit_candidate_3”

:return: True if the key was completely handled, False if not.
rB   r{  r|  rm   r$   r   _command_commit_candidate_3Z/TypingBoosterEngine._command_commit_candidate_3"  r~  r    c                rj   rk   r   rD   rF   r   r   r	  "  r  r    c                r  )u   Handle hotkey for the command “commit_candidate_3_plus_space”

:return: True if the key was completely handled, False if not.
r5  r{  r|  rm   r$   r   &_command_commit_candidate_3_plus_spaceZ:TypingBoosterEngine._command_commit_candidate_3_plus_space"  r  r    c                rj   rk   r   rD   rF   r   r   r	  "  r  r    c                s$    V P                  ^4      # )uw   Handle hotkey for the command “remove_candidate_3”

:return: True if the key was completely handled, False if not.
r  rm   r$   r   _command_remove_candidate_3Z/TypingBoosterEngine._command_remove_candidate_3"  r  r    c                rj   rk   r   rD   rF   r   r   r	  "  ry  r    c                (    V P                  ^RR7      # )uw   Handle hotkey for the command “commit_candidate_4”

:return: True if the key was completely handled, False if not.
rB   r{  r|  rm   r$   r   _command_commit_candidate_4Z/TypingBoosterEngine._command_commit_candidate_4"  r~  r    c                rj   rk   r   rD   rF   r   r   r	  "  r  r    c                r  )u   Handle hotkey for the command “commit_candidate_4_plus_space”

:return: True if the key was completely handled, False if not.
r5  r{  r|  rm   r$   r   &_command_commit_candidate_4_plus_spaceZ:TypingBoosterEngine._command_commit_candidate_4_plus_space"  r  r    c                rj   rk   r   rD   rF   r   r   r	  "  r  r    c                s$    V P                  ^4      # )uw   Handle hotkey for the command “remove_candidate_4”

:return: True if the key was completely handled, False if not.
r  rm   r$   r   _command_remove_candidate_4Z/TypingBoosterEngine._command_remove_candidate_4"  r  r    c                rj   rk   r   rD   rF   r   r   r	  "  ry  r    c                (    V P                  ^RR7      # )uw   Handle hotkey for the command “commit_candidate_5”

:return: True if the key was completely handled, False if not.
rB   r{  r|  rm   r$   r   _command_commit_candidate_5Z/TypingBoosterEngine._command_commit_candidate_5"  r~  r    c                rj   rk   r   rD   rF   r   r   r	  "  r  r    c                r  )u   Handle hotkey for the command “commit_candidate_5_plus_space”

:return: True if the key was completely handled, False if not.
r5  r{  r|  rm   r$   r   &_command_commit_candidate_5_plus_spaceZ:TypingBoosterEngine._command_commit_candidate_5_plus_space"  r  r    c                rj   rk   r   rD   rF   r   r   r	  "  r  r    c                s$    V P                  ^4      # )uw   Handle hotkey for the command “remove_candidate_5”

:return: True if the key was completely handled, False if not.
r  rm   r$   r   _command_remove_candidate_5Z/TypingBoosterEngine._command_remove_candidate_5"  r  r    c                rj   rk   r   rD   rF   r   r   r	  #  ry  r    c                (    V P                  ^RR7      # )uw   Handle hotkey for the command “commit_candidate_6”

:return: True if the key was completely handled, False if not.
rB   r{  r|  rm   r$   r   _command_commit_candidate_6Z/TypingBoosterEngine._command_commit_candidate_6#  r~  r    c                rj   rk   r   rD   rF   r   r   r	  #  r  r    c                r  )u   Handle hotkey for the command “commit_candidate_6_plus_space”

:return: True if the key was completely handled, False if not.
r5  r{  r|  rm   r$   r   &_command_commit_candidate_6_plus_spaceZ:TypingBoosterEngine._command_commit_candidate_6_plus_space#  r  r    c                rj   rk   r   rD   rF   r   r   r	  #  r  r    c                s$    V P                  ^4      # )uw   Handle hotkey for the command “remove_candidate_6”

:return: True if the key was completely handled, False if not.
r  rm   r$   r   _command_remove_candidate_6Z/TypingBoosterEngine._command_remove_candidate_6#  r  r    c                rj   rk   r   rD   rF   r   r   r	  #  ry  r    c                (    V P                  ^RR7      # )uw   Handle hotkey for the command “commit_candidate_7”

:return: True if the key was completely handled, False if not.
rB   r{  r|  rm   r$   r   _command_commit_candidate_7Z/TypingBoosterEngine._command_commit_candidate_7#  r~  r    c                rj   rk   r   rD   rF   r   r   r	  !#  r  r    c                r  )u   Handle hotkey for the command “commit_candidate_7_plus_space”

:return: True if the key was completely handled, False if not.
r5  r{  r|  rm   r$   r   &_command_commit_candidate_7_plus_spaceZ:TypingBoosterEngine._command_commit_candidate_7_plus_space!#  r  r    c                rj   rk   r   rD   rF   r   r   r	  (#  r  r    c                s$    V P                  ^4      # )uw   Handle hotkey for the command “remove_candidate_7”

:return: True if the key was completely handled, False if not.
r  rm   r$   r   _command_remove_candidate_7Z/TypingBoosterEngine._command_remove_candidate_7(#  r  r    c                rj   rk   r   rD   rF   r   r   r	  /#  ry  r    c                (    V P                  ^RR7      # )uw   Handle hotkey for the command “commit_candidate_8”

:return: True if the key was completely handled, False if not.
rB   r{  r|  rm   r$   r   _command_commit_candidate_8Z/TypingBoosterEngine._command_commit_candidate_8/#  r~  r    c                rj   rk   r   rD   rF   r   r   r	  6#  r  r    c                r  )u   Handle hotkey for the command “commit_candidate_8_plus_space”

:return: True if the key was completely handled, False if not.
r5  r{  r|  rm   r$   r   &_command_commit_candidate_8_plus_spaceZ:TypingBoosterEngine._command_commit_candidate_8_plus_space6#  r  r    c                rj   rk   r   rD   rF   r   r   r	  =#  r  r    c                s$    V P                  ^4      # )uw   Handle hotkey for the command “remove_candidate_8”

:return: True if the key was completely handled, False if not.
r  rm   r$   r   _command_remove_candidate_8Z/TypingBoosterEngine._command_remove_candidate_8=#  r  r    c                rj   rk   r   rD   rF   r   r   r	  D#  ry  r    c                (    V P                  ^RR7      # )uw   Handle hotkey for the command “commit_candidate_9”

:return: True if the key was completely handled, False if not.
rB   r{  r|  rm   r$   r   _command_commit_candidate_9Z/TypingBoosterEngine._command_commit_candidate_9D#  r~  r    c                rj   rk   r   rD   rF   r   r   r	  K#  r  r    c                r  )u   Handle hotkey for the command “commit_candidate_9_plus_space”

:return: True if the key was completely handled, False if not.
r5  r{  r|  rm   r$   r   &_command_commit_candidate_9_plus_spaceZ:TypingBoosterEngine._command_commit_candidate_9_plus_spaceK#  r  r    c                rj   rk   r   rD   rF   r   r   r	  R#  r  r    c                s$    V P                  ^4      # )uw   Handle hotkey for the command “remove_candidate_9”

:return: True if the key was completely handled, False if not.
r  rm   r$   r   _command_remove_candidate_9Z/TypingBoosterEngine._command_remove_candidate_9R#  r  r    c                sf   < V ^8  d   QhRS[ P                  RS[S[,          RS[S[S[3,          /# )r   rv  r4  r   )rn  rJ  r   r   r   r   rD   rF   r   r   r	  Y#  sA     K K""K smK .34:->Kr    c                s^   V P                   ^8  d   \        P                  RV4       V P                   ^8  d*   \        P                  R\        V P                  4      4       V'       g$   \        V P                  P                  4       4      pRpV EF  pV P                  W3V P                  9   g   K#  V P                   ^8  d   \        P                  RV4       V P                  '       du   V'       gm   V P                  P                  V P                  4      pVR8w  d   R	u # V P                  P                  4        V P                  4        V P                  4        RpRV 2p \        W4      pT! 4       '       g   K  TP(                  R
9   d   Ru # TR9   d   Ru # Ru # 	  V'       d&   V P                  P%                  VP&                  4       R	#   \         3 dK    \        P#                  RT4       T'       d&   T P                  P%                  TP&                  4       R	u u # i ; i)u  Handle hotkey commands

:return: A tuple of too boolean values (match, return_value)
         “match” is true if the hotkey matched, false if not
         “return_value” is the value which should be returned
         from do_process_key_event().
:param key: The typed key. If this is a hotkey,
            execute the command for this hotkey.
:param commands: A list of commands to check whether
                 the key matches the keybinding for one of
                 these commands.
                 If the list of commands is empty, check
                 *all* commands in the self._keybindings
                 dictionary.
zKeyEvent object: %s
zself._hotkeys=%s
Fzmatched command=%srB   TZ	_command_zThere is no function %s)FF)Shift_LShift_R	Control_L	Control_RAlt_LAlt_RZMeta_LZMeta_RSuper_LSuper_RISO_Level3_Shift)TF)r|   commit_raw_input_and_forward_key)TT)r  r1   r'  r   r  r@  r  Zkeysr,  r1  r  r  popr  r   r/   ZAttributeErrorr  r>  rR  r}   )rO   rv  r4  Z$hotkey_removed_from_compose_sequencer  r  Zcommand_function_nameZcommand_function   &&&     r   r5  Z#TypingBoosterEngine._handle_hotkeysY#  s   & q LL0#6q LL-s4==/AB d//4467H/4,G->$$q(LL!5w?000@%)%<%<%D%D44&6N%+  .-00446779((*;?8*3G9(=%*'.t'K$ $%%xx $8 8  -,@@  -,''Q  R 0((//8+ '( *$$%>%:<;44;;CGGD))*s   'G)H, 'H,+H,c                r  rH  rI  rD   rF   r   r   r	  #  s!       1 1 d r    c                s(   V P                   ^ 8  d   \        P                  RV4       Wn        \        P                  ! 4       V P                  n        RV P                  n        V P                  P                  4       V n        V P                  4        R# )u   A replacement for “return True” in do_process_key_event()

do_process_key_event() should return “True” if a key event has
been handled completely. It should return “False” if the key
event should be passed to the application.
key=%sT)
r  r1   r  r,  r6  handledrW  rQ   rX  rz  )rO   rv  rd   r   _return_trueZ TypingBoosterEngine._return_true#  si     q KK#&"iik!%%)%;%;%@%@%B"--/r    c                r  rH  rI  rD   rF   r   r   r	  #  s%     n n!2!2 nt nr    c                s
  < V P                   ^ 8  d   \        P                  RV4       Wn        \        P                  ! 4       V P                  n        RV P                  n        V P                  P                  4       V n        V P                  4        VP                  '       g   \        P                  R4       V P                  '       Edd   VP                  '       EdQ   \        P                  ! VP                  4      R9  Ed+   VP                   \"        P$                  \"        P&                  \"        P(                  \"        P*                  \"        P,                  39  d   VP.                  \"        P0                  P2                  ,          '       g   VP.                  \4        P6                  ,          '       gw   V P                   ^ 8  d   \        P                  R4       \8        SV `u  \"        P<                  P?                  VP                  4      4       RV n         RV P                  n        R# V PB                  '       d4   V PE                  VP                   VP                  VP.                  4       R# V PF                  '       gh   V PH                  PJ                  R8X  gM   V PH                  PJ                  R8X  g2   V PL                  \4        PN                  PP                  ,          '       d)   V P                   ^ 8  d   \        P                  R4       R# V PH                  PJ                  R	8X  d   \R        PT                  ! R
4      R8X  d   VPV                  '       d   VPX                  R9   gm   VPZ                  '       g[   VP8                  '       gI   VP\                  '       g7   VP^                  '       g%   VP`                  '       g   VPb                  '       d   \        P                  R4       R# VP                  '       g   \        P                  RVP                  4       V Pd                  Pg                  VP                   4      Vn
        VP                  '       d"   \        P                  RVP                  4       M\        P                  R4       \        P                  R4       V PE                  VP                   VP                  VP.                  4       R# V P                   ^ 8  d   \        P                  R4       R# )u  A replacement for “return False” in do_process_key_event()

do_process_key_event() should return “True” if a key event has
been handled completely. It should return “False” if the key
event should be passed to the application.

But just doing “return False” has many problems.

1) It doesn’t work well when trying to do the unit
tests. The MockEngine class in the unit tests cannot get that
return value. Therefore, it cannot do the necessary updates to
the self._mock_committed_text etc. which prevents proper
testing of the effects of such keys passed to the application.

2) It does *not* work when using XIM, i.e. *not* when using Qt
with the XIM module and *not* in X11 applications like xterm.
When “return False” is used with XIM, the key event which
triggered the commit here arrives *before* the committed
string. I.e. when typing “word ” the space which triggered the
commit gets to application first and the applications receives
“ word”. No amount of sleep before the “return False” can fix
this. See: https://bugzilla.redhat.com/show_bug.cgi?id=1291238
This has been fixed though at least when triggering a commit
with space by inserting the space into the application by
committing it as well instead of sending it to the application.
I.e. when a space triggers a commit, neither `return False`
nor `forward_key_event()` is used.

3) “return False” fails to work correctly when the key.code is
incorrect. The on-screen-keyboard (OSK) often seems to pass
key events which have key.code == 0, instead of a correct
key.code. “return False” then does not work, the application
receives nothing at all.

To work around the problems with “return False”, one can
sometimes use self.forward_key_event(key.val, key.code,
key.state) instead to pass the key to the application.  This
works fine with the unit tests because a forward_key_event()
function is implemented in MockEngine as well which then gets
the key and can test its effects. As far as the unit tests are
concerned, it does not matter whether the key.code is correct
or incorrectly key.code == 0.

But when forward_key_event() is used “for real”, i.e. when not
doing unit testing, it has the same problem as “return False”
that it does nothing at all when key.code is 0, which is often
the case when the on-screen-keyboard OSK is
used. ibus-typing-booster can fix that in many or even most
cases by getting a correct key.code for key.val from the
current keyboard layout, but there are circumstances when this
is also not possible.

On top of that, “forward_key_event()” does not work at all in
some environments even if OSK is not involved:

- Qt4 when using the input module and not XIM
- older versions of Qt5
- older versions of Wayland
- Gtk4

So using “forward_key_event()” instead of “return False”
in “do_process_key_event()” helps in some cases, but there
are cases when this fails as well.

A third possibility to pass a key to the application can
sometimes be to commit something instead of using
forward_key_event() or “return False”. When committing is
possible, it seems to be the most reliable option, no problems
with the order of things as in the “return False” with XIM
case and no problems when the key.code is incorrectly 0.

But committing is also not always possible, for example
key.unicode needs to be a non-empty string in order to make
committing something possible. And even then it does not
always make sense, for example when key.val is
IBus.KEY_Return, key.unicode is '' but committing that does
not have the desired effect of breaking a line. And key
release events as well as events where modifiers like Control,
Alt, ... are set should not be committed but really passed
through to the application.

To work around these problems as good as possible we use this
helper function which

- prefers a commit if possible
- if committing is not possible, but forward_key_event()
  is possible, use forward_key_event() and try to fix
  key.code in case it is incorrectly set to 0 by OSK (unless
  unit testing, then the key.code does not matter)
- if committing is not possible and forward_key_event()
  is is not possible either, fall back to the worst option
  “return False”.
r  Fz:key.code=0 is not a valid keycode. Probably caused by OSK.u6   Committing instead of forwarding or “return False”Tra  ZSDL2_ApplicationzReturning Falserb  ZXDG_SESSION_TYPEZwaylandztReturning False: gnome-shell client in wayland session and possibly a Gnome keyboard shortcut involving a modifier. z9key.code= %s, probably coming from OSK, try to fix it ...zFixed key.code = %sz+Could not fix key.code, still key.code == 0zForwarding key event)ZCc)ZF1ZF2ZF3ZF4ZF5ZF6ZF7ZF8ZF9ZF10ZF11ZF12)4r  r1   r  r,  r6  r  rW  rQ   rX  rz  coder  r  unicoderS  re  rR  r   rQ  rR  KEY_ISO_EnterrU  rS  r   r:  r]  rn  KEYBINDING_STATE_MASKr  r&  r   r   r+  r  r8  r  r  rp   rv  rw  ZSYNC_PROCESS_KEYr  r  rS  r}   rT  rX  rY  rU  rV  r  r9  )rO   rv  r  r/  r   _return_falseZ!TypingBoosterEngine._return_false#  sN   | q KK#&"iik!&%)%;%;%@%@%B"--/xxxNNLN $$S[[1@!2!2D4F4F""DOO!5 5 II 1 1 > >>>II > >>>  1$TUG		))#++6837D0%)DNN" ???""377CHHcii@
 )))  **i7  **.@@%%(;(;(L(LLL  1$-.''=8		,-:))):!: KKKIIIIIIHHHHHHHHH KKCD xxxKKK 00==cggFCHxxx1388<IJKK./""377CHHcii@q KK)*r    c                r  )r   keyvalrQ  r   Nr   rD   rF   r   r   r	  f$  s"     ? ?3 ?# ?d ?r    c                s   V P                   '       g<   V P                  '       d*   V P                  ^ 8  d   \        P	                  RV4       R# V P
                  P                  V4      pV P
                  P                  V4      pV P                  ^ 8  d   \        P	                  RWWB4       V P                  WV4       R# )z<Forward a generated key event for keyval to the application.zVreturn without doing anything because self._avoid_forward_key_event is True. keyval=%sNz0keyval=%s keycode=%s ibus_keycode=%s keystate=%s)	r  r  r  r1   r'  r  keycoder9  r8  )rO   r  rQ  r  r9  r   r   rZ  Z0TypingBoosterEngine._forward_generated_key_eventf$  s     4#@#@#@  1$ !') ++33F;00==fEq LLK,BvX>r    c                rC   r   r'   rD   rF   r   r   r	  $  s     B B4 Br    c                s   V P                   '       d2   V P                  '       d    V P                  P                  4        R# R# R#   \         d7   p\        P                  RTP                  P                  T4        Rp?R# Rp?ii ; i)z+Play an error sound if enabled and possiblez"Playing error sound failed: %s: %sN)r  r  Zplayr7   r1   r  r  rR   )rO   r2   rP   r   _play_error_soundZ%TypingBoosterEngine._play_error_sound$  st    !9!9!9B((--/ ":  B  !E!&!9!95B BBs   A B+BBc                r  rH  rI  rD   rF   r   r   r	  $  s%     g g8+<+< g gr    c                s6  <a V P                   ^8  d   \        P                  RV4       V P                  '       d)   V P                   ^8  d   \        P                  R4       R# VP                  \
        P                  P                  ,          '       d)   V P                   ^8  d   \        P                  R4       R# V P                  P                  '       g{   V P                  '       gi   V P                  P                  4       '       dI   V P                  P                  4       '       d)   V P                   ^8  d   \        P                  R4       R# V P                  P                  '       g;   VP                  '       g)   V P                   ^8  d   \        P                  R4       R# V P                  P                  '       g   VP                  V P                   9   dq   V P"                  ^ ,          R<9  dY   VP                  \
        P$                  8X  d:   VP                  R8X  d)   V P                   ^8  d   \        P                  R	4       R# V P                  P                  '       d   VP                  \
        P&                  \
        P(                  \
        P*                  \
        P,                  \
        P.                  \
        P0                  \
        P2                  \
        P4                  \
        P6                  \
        P8                  \
        P:                  39   dH   V P                   ^8  d5   \        P                  R
\
        P<                  ! VP                  4      4       R# V P                  P                  '       dI   V P?                  V. R=OR7      w  r#V'       d*   V P                   ^8  d   \        P                  RW#4       V# V P                  P                  \@        PB                  8X  Ed   V P                  P                  4       '       Ed   V P                  '       Eg   VP                  \
        PD                  39  Ed   V P                   ^8  d   \        P                  R4       V P"                  ^ ,          R8X  di   VP                  \
        P$                  8X  dJ   VP                  R8X  d9   V P                   ^8  d   \        P                  R4       V PG                  4        R# V P                   ^8  d   \        P                  R4       V PI                  4       p. V n%        V P                  PM                  4        V P                  PO                  R4       V PQ                  4        \@        PR                  V P                  n        \U        V4      oTp\V        ;QJ d3    V3R lV P                  P                   4       F  '       d   K   RM(	  RM$! V3R lV P                  P                   4       4      '       dt   V P                  PX                  RV P                  PZ                   R\U        V4      )  V,           V P                  PX                  V P                  PZ                  R ,           pV P                   ^8  dV   \        P                  RV\]        V P                  4      4       \        P                  RV P^                  V P`                  4       V Pc                  4       '       d   V P                   ^8  d2   \        P                  RV P                  Pd                  V,           4       V P^                  V P`                  R V n/        ^ V n0        \f        SV `  \
        Pj                  Pm                  V P                  Pd                  V,           4      4       \n        Pp                  ! V Pr                  4       MV P^                  RV P                  Pt                   \w        V4      ,           V P^                  V P`                  R ,           V n/        V P                  Pt                  \U        \w        V4      4      ,           V n0        V P                   ^8  d,   \        P                  RV P^                  V P`                  4       V Py                  4        \z        P|                  ! 4       V n        V P"                  ^ ,          P                  R4      '       di   VP                  \
        P$                  8X  dJ   VP                  R8X  d9   V P                   ^8  d   \        P                  R4       V P                  4        R# V P"                  ^ ,          R8X  dw   VP                  \
        P                  \
        P                  \
        P                  39   d9   V P                   ^8  d   \        P                  R4       V P                  4        R# V P                   ^8  d   \        P                  R4       V P                  V4      # V P                  P                  '       Ed   VP                  V P                   9   Ed   V P"                  ^ ,          R>9   d$   V P^                  RV P`                   R?R R.8X  Eg   VP                  \
        PD                  39  Edz   V P                   ^8  d   \        P                  R4       V P"                  ^ ,          R8X  di   VP                  \
        P$                  8X  dJ   VP                  R8X  d9   V P                   ^8  d   \        P                  R4       V P                  4        R# V P                  PX                  p. V n%        V P                  PM                  4        V P                  PO                  R4       V PQ                  4        \@        PR                  V P                  n        V P                   ^8  dV   \        P                  RV\]        V P                  4      4       \        P                  RV P^                  V P`                  4       V Pc                  4       '       d   V P                   ^8  d2   \        P                  RV P                  Pd                  V,           4       V P^                  V P`                  R V n/        ^ V n0        \f        SV `  \
        Pj                  Pm                  V P                  Pd                  V,           4      4       \n        Pp                  ! V Pr                  4       MV P^                  RV P                  Pt                   \w        V4      ,           V P^                  V P`                  R ,           V n/        V P                  Pt                  \U        V4      ,           V n0        V P                   ^8  d,   \        P                  RV P^                  V P`                  4       V Py                  4        \z        P|                  ! 4       V n        V P"                  ^ ,          P                  R4      '       di   VP                  \
        P$                  8X  dJ   VP                  R8X  d9   V P                   ^8  d   \        P                  R4       V P                  4        R# V P"                  ^ ,          R8X  dw   VP                  \
        P                  \
        P                  \
        P                  39   d9   V P                   ^8  d   \        P                  R 4       V P                  4        R# R# V P^                  RV P`                   pV P                   ^8  d    \        P                  R!\]        V4      4       V P"                  ^ ,          R8X  Ed   V\U        \        P                  4      ) R \        P                  8X  Ed   V P                   ^8  d   \        P                  R"4       VR\U        \        P                  4      )  pVV P^                  V P`                  R ,           V n/        \U        V4      V n0        VP                  \
        P$                  8X  dQ   VP                  R8X  d@   V P                   ^8  d   \        P                  R#4       V\        P                  ,          pEMVP                  \
        PD                  39   d9   V P                   ^8  d   \        P                  R$4       VP                  4        EMV P                   ^8  d   \        P                  R%4       VP                  VP                  4       EMVP                  \
        P$                  8X  dY   VP                  R8X  dH   V P                   ^8  d   \        P                  R&4       VR.\        P                  ,           ,          pEM	VP                  \
        PD                  39   d8   V P                   ^8  d   \        P                  R'4       VP                  4        MV P                   ^8  d   \        P                  R(4       VP                  VP                  4       MpV'       g   VP                  VP                  4       MLVP                  \
        PD                  39   d   VP                  4        MVP                  VP                  4       V P                  V P"                  ^ ,          ,          P                  WpP                  R)7      pV P                   ^8  d   \        P                  R*VV4       V Pc                  4       '       Ed9   V P                   ^8  d   \        P                  R+4       VP                  '       d   VPd                  '       d   VPt                  '       d   V P                   ^8  d!   \        P                  R,VPd                  4       VVPt                  R p\f        SV `  \
        Pj                  Pm                  VPd                  4      4       V P                  V P"                  ^ ,          ,          P                  VV P                  R)7      pM&V P                   ^8  d   \        P                  R-4       VP                  '       Eg   V P                  P                  '       d   V P                   ^8  d   \        P                  R.4       V P                  PM                  4        V P                  PO                  R4       V P                  4        V P                  \
        Pj                  Pm                  R/4      R4       RV P                  nO        \@        PR                  V P                  n        \z        P|                  ! 4       V n        VPd                  R/8X  d   VPt                  ^ 8X  d   VPX                  R/8X  d   VPZ                  ^ 8X  d   VP                  R08X  d   V P"                  ^ ,          R@9   go   V P                   ^8  d   \        P                  R1V4       V P^                  V P`                  R V n/        ^ V n0        V Py                  4        V P                  4        R# V P                   ^8  d   \        P                  R24       R# VV P^                  V P`                  R ,           V n/        \U        V4      V n0        V Py                  4        Wn        V P                   ^8  d   \        P                  R34       \@        PR                  V P                  n        . V n%        V P                  PM                  4        V P                  PO                  R4       V P                  4        V P                  \
        Pj                  Pm                  R/4      R4       V P                  P                   FV  p	V	'       g   K  \        P                  ! V	^ R/RRR47      p
V PJ                  P                  V
4       V P                  V	R/R57       KX  	  V P                  P                  4       '       g   \        P                  R64       V P                  PM                  4        V P                  PO                  R4       V P                  4        V P                  \
        Pj                  Pm                  R/4      R4       RV P                  nO        \@        PR                  V P                  n        \z        P|                  ! 4       V n        R# V P                  '       d(   \        P                  ! V P                  4       ^ V nS        RV P                  nO        V P                  '       dK   V P                  '       g9   V P                   ^8  d   \        P                  R74       V P                  4        R# V P                  P                  '       d   V P                   ^8  d   \        P                  R84       \@        PB                  V P                  n        V PQ                  4        V P                  PO                  R4       RV n
        V P                  V P                  4       R4       R# V P                   ^8  d   \        P                  R94       V P"                  ^ ,          R<9   dK   V P                   ^8  d(   \        P                  R:V P"                  ^ ,          4       V P                  4        R# V P                   ^8  d   \        P                  R;4       V P                  4        R# )Ark  rK  z&Do not interfere with compose sequenceFIgnoring release event.z=Manual selection in lookup table. Do not interfere with that.z9Empty key.msymbol cannot start a m17n candidate sequence.r  r5  zdCommit trigger keys usually cannot start a m17n candidate sequence except the space key for ja-anthyz0Inside m17n candidates sequence, ignoring key %sTr3  zhotkey matched %s %sz m17n candidate manually selectedzja-anthy: select next candidatez"Candidate selected -> typed stringc              3   r  r:   rK  r  r  r   r  Z>TypingBoosterEngine._handle_m17n_candidates.<locals>.<genexpr> %  r   r!  Nr"  r#  zEarly commit %rz7NEW:self._typed_string=%s, self._typed_string_cursor=%sr  z.zh: manually selected m17n commit, avoid spacez5ja-anthy: manually selected m17n commit, avoid Returnz,Manually selected m17n commit, try recursionr  z"m17n candidates commit trigger keyzja-anthy: enable lookupzphrase=%s, trans_parts=%sz1zh: commit key triggered m17n commit, avoid spacez8ja-anthy: commit key triggered m17n commit, avoid Returnztyped_string_up_to_cursor=%sr  zja-anthy: continue henkan modez"ja-anthy: BackSpace in henkan modez"ja-anthy: other key in henkan modezja-anthy: start henkan modez ja-anthy: BackSpace in kana modez ja-anthy: other key in kana moder&  zMAfter processing key: typed_string_up_to_cursor=%r -> transliterated_parts=%rzMaybe commit early.zCommit %r early.zNothing to commit early.z+Clear and hide m17n candidates lookup tablerB   Zz3Removing input which changed only m17n-lib state %rzNo m17n candidates.z$Filling m17n candidate lookup table.rJ  r  z4All m17n candidates were empty. Should never happen.z#Tab enable set, just update preeditz Show m17n candidate lookup tablez0m17n candidate lookup table exists but is hiddenzJust update preedit for %sz"Show standard lookup table instead)r  )r2  commitr|  commit_raw_inputr  rz  enable_lookupselect_next_candidateselect_previous_candidatelookup_table_page_downlookup_table_page_upcommit_candidate_1commit_candidate_1_plus_spacecommit_candidate_2commit_candidate_2_plus_spacecommit_candidate_3commit_candidate_3_plus_spacecommit_candidate_4commit_candidate_4_plus_spacecommit_candidate_5commit_candidate_5_plus_spacecommit_candidate_6commit_candidate_6_plus_spacecommit_candidate_7commit_candidate_7_plus_spacecommit_candidate_8commit_candidate_8_plus_spacecommit_candidate_9commit_candidate_9_plus_space)z	t-lsymbolrQ  )	rP  zvi-hanzvi-nomtelexzvi-nomviz
zh-cangjiezzh-quickz	zh-tonepyz	zh-zhuyinzzh-py)\r  r1   r'  r1  r   r   r:  r]  r0  r:  r  rA  r   r   msymbolrR  rV  r  rO  r6  r7  r8  r9  r:  r;  r<  r=  r>  r?  r@  keyval_namer5  r{   r   rU  r  rl  r=  r   r   r  r   r  r'  r  rH   r0   r2  r3  r  r  r  r&  r   r   r6  r7  r  r  r  r  r.  r/  rV  r  rQ  rR  r  _handle_m17n_candidatesr  rn  r  r  r>  r;  r  r  rg  ro  r   r  rU  rE  r  r   r  r  rx  r   r  rj  rp  )rO   rv  r`  rA  r)  r*  r   r  r  r  Zprediction_candidater  r  s   &&         @r   r  Z+TypingBoosterEngine._handle_m17n_candidates$  s   q LL.4'''  1$EF99t((5555  1$67&&111444"";;==""4466  1$ ; <&&111KKK  1$ : ;&&1114444""1%]:4>>)s"
   1$ 0 1 ""---&&^^^^____
&   1$O!--cgg68!!,,,$($8$8 #D %9 %E!U< $$q(LL!7M##$$(8(H(HH""4466444 2 244  1$?@""1%3GGt~~-#++2D$$q(LL!BC335  1$AB!%!M!M!O!D$$&11%8--/'7'>'>D$(+,>(?%'9$ G$($:$:$E$EG G$($:$:$E$EG G G **22://::<5c"4557 )) ,,44..99:<	< )   1$F,T$2H2H-IK N&&(A(AC %%''$$q(LL)..88234
 &&t'@'@'AB ",-)#II--..882345 

499: &&'N(>(>(N(NO345(()B)B)CDE "
 **::$789: )   1$M&&(A(AC //1%2%G%G%ID"""1%0066GGt~~-#++2D$$q(LLHJ!""1%3GG$"3"3T5G5GHI$$q(LLOQ!   1$KL//44""---4444''*n<++3$33557S:>AUC 2 244(   1$AB""1%3GGt~~-#++2D$$q(LL!:;++-++33F!D$$&11%8--/'7'>'>D$  1$8#T$*@*@%ACN&&(A(AC %%''$$q(LL!2 $ 6 6 @ @6 IK &&t'@'@'AB ",-)#II--..886ACD 

499: &&'N(>(>(N(NO6l#(()B)B)CDE "
 **::&k" )   1$M&&(A(AC //1%2%G%G%ID"""1%0066GGt~~-#++2D $$q(LLKM!""1%3GG$"3"3T5G5GHI$$q(LLRT! 9 9 9: 	"q LL778:a J.)3x/I/I+J*J*KL--.$$q(LLGI,E5c(4455-7) .(()B)B)CDE " -00I,J)77dnn,1C ((1,%EF-1K1KK-WW!3!3 55((1,%IJ-113((1,%IJ-44S[[ADNN*s{{c/A$$q(LL!>?0 *cUX5O5O-OO)T//11$$q(LL!CD)--/$$q(LL!CD)00=*%,,S[[9WW++--%))+%,,S[[9#44" $$7$7*9K9K %8 %M 	 q LL 6 3-	/
 !!##  1$23$///(222(888$$q(LL!3!5!?!?A,E(889-;)#II--,6689 (,'<'<&&q)(++>+>1%)%7%7 ,? ,9 % ""Q&78#...%%000$$q(LL!NO ""((*""55e<&&(**II--b15:49""1+;+B+B""(%2%G%G%ID"$.."4(88A=(00B6(33q8+!//2 	7& 	& $$q(LLM13 &*%7%78Q8Q8R%S",-)335 !  1$237 $ 2 243L3L3M NO$'(A$B!++-!5q LL?@#3#:#:   "--e4 ""II%%b)5	2//::Iy'/'C'C$!&#((*$   ''(<=66$b 7 2 ; !!::<< LLFH$$&11%8""$&&II--b15:05D-'7'>'>D$%2%G%G%ID""""
 t667&'D#,1)DLLL  1$BC  "!!000  1$?@'7'G'GD$--/ 11$7/3D,$$T%:%:%<dCq LLKLa M1  1$0$2D2DQ2GI  " q LL=>r    c                s@   < V ^8  d   QhRS[ P                  RS[RS[/# )r   rv  add_to_preeditr   rI  rD   rF   r   r   r	  &  s.     G G8#4#4 Gd GVZ Gr    c                s  < V P                   ^8  d   \        P                  RV4       V P                  P                  '       d)   V P                   ^8  d   \        P                  R4       R# VP
                  \        P                  P                  ,          '       d)   V P                   ^8  d   \        P                  R4       R# V P                  '       gU   V P                  P                  VP                  4      '       g*   V P                   ^8  d   \        P                  RV4       R# V P                  4       '       dK   V P                  '       g9   V P                  '       g'   V P                   '       g   V P"                  '       g   RpV P                  '       g   V P                  P                  '       g   V P$                  '       gy   V P&                  P)                  4       '       dY   V P&                  P+                  4       '       d9   \-        V P/                  4       4      V n        \3        V P0                  4      V n        VP                  \        P6                  \        P8                  \        P:                  \        P<                  \        P>                  \        P@                  \        PB                  \        PD                  \        PF                  \        PH                  \        PJ                  39   dH   V P                   ^8  d5   \        P                  R\        PL                  ! VP                  4      4       R# V PO                  4       ^ ,          pVP                  \        PP                  39   d   V P                  PS                  4        EM9V PT                  '       d   VR,          R59   d'   V P                  PW                  VP                  4       MV PX                  V,          P[                  VP\                  .V P^                  R	7      pWAP\                  8w  d   \3        V4      ^8X  dv   \        P`                  ! V4      pV P                   ^8  d3   \        P                  R
\c        V4      R\e        V4      R 2RVR 24       V P                  PW                  V4       M%V P                  PW                  VP                  4       V P                  '       gh   V P                   ^8  d   \        P                  R4       \f        Ph                  V P&                  n        V Pk                  4        V Pm                  4        R# V P                  Po                  V P                  4      pV P                   ^8  dO   \        P                  RV P                   Uu. uF  p\        PL                  ! V4      NK  	  up\c        V4      4       V Pq                  V. RNRNRNRNRNRNRNRNRNRNRNRNRNRNRNRNR NR!NR"NR#NR$NR%NR&NR'NR(NR)NR*NR+NR,NR-NR.NR/NR07      w  rV'       d   V	# V P&                  P
                  \f        Pr                  8X  Ed.   V P&                  P+                  4       '       Ed   \f        Ph                  V P&                  n        V P/                  4       p. V n:        V P&                  Pw                  4        V P&                  Py                  R4       V P{                  4        . V n	        V Pk                  4        V P}                  4        V'       d-   V P                  \-        V4      4       V Pm                  4        R# \        SV E`  \        P                  P                  V4      4       RV nD        R# \f        Ph                  V P&                  n        . V n:        V P&                  Pw                  4        V P&                  Py                  R4       V P                  4        V P                  \        P                  P                  R14      R4       \        V\        4      '       g#   V Pk                  4        V P}                  4        R# V'       EgD   V P                   ^8  d   \        P                  R24       V P                  PS                  4        V Pk                  4        V P}                  4        VP                  V P                  9   d   V P                  P                  V P                  4      p
. V n	        V Pk                  4        V P}                  4        V'       d-   V P                  \-        V
4      4       V Pm                  4        R# \        SV E`  \        P                  P                  V
4      4       RV nD        R# V P                  4        R# V P                   ^8  d   \        P                  R34       . V n	        V Pk                  4        V'       d-   V P                  \-        V4      4       V Pm                  4        R# \        SV E`  \        P                  P                  V4      4       RV nD        V P                  P                  R18X  d)   V P                   ^8  d   \        P                  R44       R# V P                  \        P                  P                  R14      ^ R\        P                  P                  4       R# u upi )6zmInternal method to handle possible compose keys

:return: True if the key event has been handled, else False
rK  z&Do not interfere with m17n candidates.Fr  zbNot in a compose sequence and the key cannot start a compose sequence either. Key Event object: %sz(Inside compose sequence, ignoring key %sTr  r&  z-Using transliterated key for compose %s %s %sz
Unicode 0xrf  znew_keyval=0xz(Editing made the compose sequence empty.z<Inside compose sequence.key value names=%s compose_result=%sr2  #change_line_direction_left_to_right#change_line_direction_right_to_leftchange_line_direction_toggler  r|  r  r  rz  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r3  rB   z2Last key made compose sequence invalid, remove it.zCompose sequence finished.r  )r  r  )Qr  r1   r'  r0  r:  r   r   r:  r]  r1  r  Zis_start_keyrR  r  r  r  r  r  r  rA  r   r   r  rl  r2  r  r3  r6  r7  r8  r9  r:  r;  r<  r=  r>  r?  r@  r  r  rU  r  r  r>  r;  r'  r  r  Zunicode_to_keyvalr0   r9  r{   r   r  r  r  r5  r   r=  r   r   r  r   r  r  r&  r   r   r+  rg  ro  ri  r   rV  r)  r  r  r  rt  r   r  )rO   rv  r  r  Ztransliterated_msymbolZ
new_keyvalr  rR  r`  rA  r)  r  s   &&&        r   _handle_composeZ#TypingBoosterEngine._handle_compose&  sS	   
 q LL.4!!,,,  1$EF99t((5555  1$67,,,++88AA  1$+,/1 MMOO***444+++555 #N,,,**555444"";;==""4466
 "&<<>"@D(+D,>,>(?D%GG&&^^^^____
&   1$G!--cgg68##%a(77t))++((,,.!!!SW%<D ((//8%)%:%:&"]CKK=040B0B # D # '++5./14!334JK
$$q(LLG34$S)?%@$CD'
1~6	8
 ,,33J?,,33CGG<+++  1$GH'7'>'>D$//1OO0088((*q LL$ !88:8S !!#&8:^$& !% 4 4 @x @D@D@  >@  (	@
  8@  2@  B@  :@  /@  7@  ;@  8@  6@  4@  ?@   4!@"  ?#@$  4%@&  ?'@(  4)@*  ?+@,  4-@.  ?/@0  41@2  ?3@4  45@6  ?7@8  49@:  ?;@<  4=@>  ??@ !5  !AB $$(8(L(LL""4466'7'>'>D$!IIKN!D$$&11%8--/+-D(//1  "--d>.BC!G		)).9;37D0#3#:#:   "--e4 ""II%%b)5	2.#..//1  "~  1$HJ((,,.//1  "ww$333 ++BB446 ' 02,335$$&! 11$7M2NOOO%  #II--.DEG7;4""$q LL56')$++-))$~*>?OOII%%n5	7/3,%%.."4  1$DE**II%%b)1e!!((	* A:s   k
c                sN   < V ^8  d   QhRS[ P                  RS[ P                  /# rH  )rn  rJ  rD   rF   r   r   r	  '  s-     S S((S-5->->Sr    c                sv   V P                   f   V# V P                  pVP                  '       d"   V\        P                  P
                  ,          p\        P                  ! \        P                  P                  V P                   VP                  V4      VP                  V4      pRVn        VP                  R9   g   VP                  \        P                  8X  ga   VP                  VP                  8X  dH   VP                  \        P                   ,          VP                  \        P                   ,          8X  d   TpVP                  R9   dw   VP                  '       d4   V ;P                  \        P                  P"                  ( ,          un        M1V ;P                  \        P                  P"                  ,          un        VP                  R9   dw   VP                  '       d4   V ;P                  \        P                  P$                  ( ,          un        M1V ;P                  \        P                  P$                  ,          un        VP                  R9   dw   VP                  '       d4   V ;P                  \        P                  P&                  ( ,          un        M1V ;P                  \        P                  P&                  ,          un        VP                  R9   dw   VP                  '       d4   V ;P                  \        P                  P(                  ( ,          un        M1V ;P                  \        P                  P(                  ,          un        VP                  R9   dw   VP                  '       d4   V ;P                  \        P                  P*                  ( ,          un        M1V ;P                  \        P                  P*                  ,          un        V ;P                  \        P                   ,          un        V P,                  ^8  d!   \.        P1                  RW0P                  4       V# )	z)Translate key to the selected IBus keymapTr  z!new_key: %s state for next key=%x)r  	Multi_key)r  r  )r  r  )r  r  )r  r  )r  r-  releaser   r:  r]  rn  rJ  r  Zlookup_keysymr  Z
translatedr}   rR  ZKEY_VoidSymbolr   r  r;  r\  r  Z
SUPER_MASKZ	MOD5_MASKr  r1   r'  )rO   rv  r   Znew_keys   &&  r   _translate_to_ibus_keymapZ-TypingBoosterEngine._translate_to_ibus_keymap'  s    ##+J**;;;T&&333E##KK%%((#((E;HHe "HH99KK4...[[CGG#]]X;;;		H:::;, G <<11**t/@/@/K/K.KK***d.?.?.J.JJ*<<55**t/@/@/M/M.MM***d.?.?.L.LL*<<--**t/@/@/J/J.JJ***d.?.?.I.II*<<11**t/@/@/K/K.KK***d.?.?.J.JJ*<<./**t/@/@/J/J.JJ***d.?.?.I.II*""h&D&DD"q LL< "<"<>r    c                s2   < V ^8  d   QhRS[ RS[ RS[ RS[/# )r   r  r  r   r   ri  rD   rF   r   r   r	  (  s3     Q' Q'Q'(+Q'47Q'<@Q'r    c           
     s:   \         P                  ! WV4      pV P                  ^8  d   \        P	                  RV4       \        P	                  RV P
                  4       V P                  ^8  df   \         P                   FQ  pV P                  V,          '       g   K  \        P	                  R\        V4      \        \        V4      R4      4       KS  	  V P                  '       d   V P                  V4      pV P                  '       d:   V P                  V4      '       d   V P                  V4      # V P!                  V4      # RpV P"                  '       g+   V P                  ^ 8  d   \        P	                  R4       RpEMdV P$                  '       de   \         P&                  ! V P(                  V P*                  P,                  4      '       d*   V P                  ^ 8  d   \        P	                  R4       RpMV P.                  '       d^   V P(                  \         P0                  P2                  P4                  39   d*   V P                  ^ 8  d   \        P	                  R	4       RpMV P(                  \         P0                  P6                  P4                  \         P0                  P8                  P4                  39   d)   V P                  ^ 8  d   \        P	                  R
4       RpV P;                  WF'       * R7      '       d   V P                  V4      # V P=                  V. ROR7      w  rxV'       d+   V'       d   V P                  V4      # V P!                  V4      # V'       d   V P!                  V4      # V P?                  V4      '       d   V P                  V4      # V P=                  V4      w  rxV'       d+   V'       d   V P                  V4      # V P!                  V4      # V PA                  V4      p	V	'       d   V P                  V4      # V P!                  V4      # )z\Process Key Events
Key Events include Key Press and Key Release,
modifier means Key Pressed
rK  r  zcapability: %s %s016bFzDirect input modeTz@Terminal detected and the option to disable in terminals is set.zoOSK is visible and input purpose is TERMINAL, disable to avoid showing passwords in the OSK completion buttons.z0Disable because of input purpose PASSWORD or PIN)r  r3  )rz  r  r  r  )!rn  rJ  r  r1   r'  rW  rw  rv  r   r   r>   r  r  r  rB  r  r  r  r  Zdetect_terminalr  r  r]   rx  rB  rC  r   ZPASSWORDZPINr  r5  r  _process_key_event)
rO   r  r  r   rv  ZcapZdisabledr`  rA  r  s
   &&&&      r   do_process_key_eventZ(TypingBoosterEngine.do_process_key_event(  sK    7q LL.4LL4d6L6LM  1$#..C//#55%8%(Xvc#h/GI /
    005C)))22377((--%%c**  1$01H(((**4+>+>@Q@Q@X@XYY  1$67 Hlll""x'<'<'E'E'K'K&LL  1$./ H!!''0066''++1133   1$FHHLAA$$S)) $ 4 4 ; !5 !<
 ((--%%c**%%c**'',,$$S)) $ 4 4S 9((--%%c**((-$$S))!!#&&r    c                r  rH  rI  rD   rF   r   r   r	  b(  s%     i
 i
h&7&7 i
D i
r    c                sB<  < VP                   '       d   V P                  V4      '       d'   V P                  ^8  d   \        P	                  R4       V P
                  e   V P
                  P                  '       dj   V P
                  P                   '       gN   V P
                  P                  VP                  8X  d)   V P                  ^ 8  d   \        P                  R4       R# R# V P                  4       '       Edc   V P                  P                  4       '       EgB   V P                  ^8  d   \        P	                  RV4       VP                  ^ 8  d   V P                  4        R# VP                  \        P                  8X  dY   VP                  '       gG   VP                   '       g5   V P#                  VP$                  .4      '       g   V P                  4        R# VP                  ^ 8  Edo   VP&                  '       Eg\   V P(                  '       EgI   V P*                  '       Eg6   VP$                  R%9   Ed$   VP                  \        P,                  \        P.                  \        P0                  \        P2                  \        P4                  \        P6                  \        P8                  \        P:                  \        P<                  \        P>                  3
9   d   V P@                  '       g   VP                  \        PB                  \        PD                  \        PF                  \        PH                  \        PJ                  \        PL                  \        PN                  \        PP                  \        PR                  \        PT                  3
9   d   V PV                  '       d   V PY                  4       ^ ,          R8X  d   V P                  4        R# V PZ                  V PY                  4       ^ ,          ,          P]                  VP$                  .V P^                  R7      pV Pa                  VVR	7       V Pc                  4        V P                  4        R# VP$                  R&9  Ed   VP                  V Pd                  9   d#   V P#                  VP$                  .4      '       d   \g        VP$                  4      ^8X  dm   VP&                  '       g   VPh                  '       g   VPj                  '       g   VPl                  '       go   VPn                  '       g]   VPp                  '       gK   \r        Pt                  ! VP$                  4      '       Ed   V P#                  VP$                  .4      '       Eg   V P                  4       '       d3   V P                  P                  4       '       g   V P                  4        R# V Pv                  ^ ,          pV P                  4       '       g   VP$                  R
8X  d   V PZ                  V,          P]                  V Px                  VP$                  .,           V P^                  R7      V Pz                  V,          R
,           8w  d/   V P}                  VP$                  .4       V P                  4        R# VP                   '       Eg   V P                  P                  4       '       d   V P                  '       Ed   VP                  \        P                  \        P                  39   d   V P                  \g        V Px                  4      8  di   VP&                  '       d   \g        V Px                  4      V nC        MV ;P                  ^,          unC        V P                  4        V P                  4        R# VP                  \        P                  \        P                  39   dg   V P                  ^ 8  dV   VP&                  '       d	   ^ V nC        MV ;P                  ^,          unC        V P                  4        V P                  4        R# VP                  \        P                  39   d   V P                  ^ 8  d   RV P                  nI        RV P                  nJ        VP&                  '       d   V P                  4        MV P                  4        V P                  4       '       d   RV nM        RV nN        V P                  4        R# VP                  \        P                  \        P                  39   d   V P                  \g        V Px                  4      8  d   RV P                  nI        RV P                  nJ        VP&                  '       d   V P                  4        MV P                  4        V P                  4       '       d   RV nM        RV nN        V P                  4        R# VP                   '       Eg   V P                  P                  4       '       Ed   V P                  '       Eg   VP                  \        P                  \        P                  \        P                  39   dI   \        V P                  4       4      V n<        \g        V Px                  4      V nC        V P                  4        VP                  \        P                  \        P                  39   dy   V P                  ^ 8  dh   RV P                  nI        RV P                  nJ        VP&                  '       d	   ^ V nC        MV ;P                  ^,          unC        V P                  4        R# VP                  \        P                  39   d   V P                  ^ 8  d   RV P                  nI        RV P                  nJ        VP&                  '       d   V P                  4        MV P                  4        V P                  4       '       d   RV nM        RV nN        V P                  4        R# V P                  ^8  d   \        P	                  R4       V Pz                  V,          pV P                  V P                  ,          R,          ! V4      pV Pv                  ^ ,          R8X  EgD   V PZ                  V,          P]                  V Px                  VP$                  .,           V P^                  R7      pVP$                  '       Ed   VP                  VP$                  4      '       Ed   VR\g        VP$                  4      )  pV P                  V P                  ,          R,          ! V4      pVR8X  Ed   V P                  ^8  d   \        P	                  R4       V P                  P                  4       '       EdC   V P                  P                  4       '       Ed"   V P                  4       ;rEV Pa                  WTR	7       \        P                  ! V P                  4       VP                  \        P                  \        P                  39   d   VP&                  '       g   VPh                  '       gz   VPl                  '       gh   VPn                  '       gV   VPp                  '       gD   V Pc                  4        V P                  4        \        P                  ! ^V P                  4       R# V P                  4        R# V P                  4        R# MVP$                  R8X  dn   V Px                  R.8X  d\   VR8X  dU   \        P	                  R4       \l        SV E`  \        P                  P                  R4      4       V P                  4        R# V P                  ^8  d!   \        P	                  RVP$                  4       V P}                  VP$                  .4       V P                  4        R# V P                  P                  4       '       d3   V P                  P                  4       '       d   V P                  4       pEMyVP                  \        P                  \        P                  39   Ed   VP&                  '       g   VPh                  '       g   VPj                  '       g   VPl                  '       g   VPn                  '       g   VPp                  '       g   V P                  ^ 8X  d   VP                  \        P                  8X  d/   \l        SV E`  \        P                  P                  R4      4       M-\l        SV E`  \        P                  P                  R4      4       RV ne        V P                  4        R# VP                  \        P                  \        P                  \        P                  \        P                  39   Ed   VP&                  '       Eg   VPh                  '       Eg   VPj                  '       Eg   VPl                  '       Eg   VPn                  '       Eg   VPp                  '       Egx   V P                  \g        V Px                  4      8  EdS   V PZ                  V,          P]                  V Px                  RV P                   V P^                  R7      pV P                  V P                  ,          R,          ! V4      pV PZ                  V,          P]                  V Px                  V P                  R V P^                  R7      pV P                  R8X  d+   V P                  V P                  ,          R,          ! V4      pV'       d   V Pa                  WfRR7       V'       d   V Pa                  WwRRR7       V P                  4        \        P                  ! V P                  4       V F"  pV P                  \        P                  4       K$  	  V Pv                  ^ ,          R8X  dA   VP                  \        P                  \        P                  \        P                  39   d   R# V Pv                  ^ ,          P                  R4      '       d3   VP                  \        P                  8X  d   VP$                  R8X  d   R# \        P                  ! V P                  4       R# TpV'       g9   V P                  ^ 8  d   \        P                  R4       V P                  4        R# Rp	V P                  P                  4       '       d   Rp	\r        P                  ! WPP                  VP$                  R7      4      p
V'       g   TpV Pa                  WTR	7       VP                  \        P                  \        P                  39   d   VP&                  '       g   VPh                  '       gy   VPl                  '       gg   VPn                  '       gU   VPp                  '       gC   V Pc                  4        V P                  4        \        P                  ! ^V P                  4       MV P                  4        V Pv                  ^ ,          R8X  dA   VP                  \        P                  \        P                  \        P                  39   d   R# V Pv                  ^ ,          P                  R4      '       d3   VP                  \        P                  8X  d   VP$                  R8X  d   R# VP                  \        P                  39   d   V P                  P                  R8X  g,   V P                  P                  P                  R4      '       d   \        P                  R4       \        P                  ! V P                  4       V P                  \        P                  ^ 4       V P                  \        P                  \        P                  P                  4       \        P                  ! V P                  4       V	'       g3   \        ^ V
4       F"  pV P                  \        P                  4       K$  	  R# VP                  '       g7   VP$                  '       Ed   V P#                  VP$                  .4      '       Ed   RV P                  nI        V P                  4       '       d   V P                  4        V P                  '       d   V P                  '       d   R V nN        V P                  \r        P                  P                  ,          '       d   R V nN        V P                  \r        P                  P                  ,          '       d   RV nN        V P                  \r        P                  P                  ,          '       d   R!V nN        VP$                  R&9   d0   V P#                  VP$                  .4      '       g   VP                  pMVP$                  pV P                  '       gy   V P                  P                  4       '       dY   V P                  P                  4       '       d9   \        V P                  4       4      V n<        \g        V Px                  4      V nC        V P}                  V.4       V Pz                  V PY                  4       ^ ,          ,          p\g        VP$                  4      ^8X  d   VP$                  R8w  d   VP$                  V P                  9   d   V'       d   VR',          VP$                  8X  dx   \r        P                  ! V4      '       d\   V P                  ^8  d!   \        P	                  R"VP$                  4       V Pa                  VR,           VR	7       V Pc                  4        V P                  4       '       Ed   V PZ                  V PY                  4       ^ ,          ,          P                  V Px                  V P^                  R7      pV P                  ^8  d-   \        P	                  R#V Px                  V P                  V4       VEP                   '       Ed   VEP                  '       Ed   V Px                  VEP                  R V n<        \g        V Px                  4      V nC        V P                  4        . V n        V EP                  '       gg   VEP                  ^8X  dU   VEP                   VP                  8X  d9   VEP                  '       g&   VEP
                  '       g   V P                  4        R# \l        SV E`  \        P                  P                  VEP                   4      4       V P                  P                  R8X  g,   V P                  P                  P                  R4      '       d   \        P                  R$4       \        P                  ! V P                  4       V P                  \        P                  ^ 4       V P                  \        P                  \        P                  P                  4       V P                  4        R# V P                  4       '       d   V P                  4        R# )(a  Internal method to process key event

:return: True if the key event has been completely handled by
         ibus-typing-booster and should not be passed through anymore.
         False if the key event has not been handled completely
         and is passed through.
zPreedit reopened successfully.Nz;Press key event was handled. Do not pass release key event.TFz$self.is_empty(): KeyEvent object: %sr  r&  r$  z
S-C-Returnr`  z'_process_key_event() commit triggered.
rd  r  rB   zCutting off the commit key made the transliteration empty. If anything is selected in the lookup table, commit it. Then call clear input and update UI to removeany remaining preedit or lookup table.r5  r  u   　z^Fullwidth space typed by typing Z+space on empty input. Commit it, clear input, and update UI.u.   Insert instead of commit: key.msymbol=“%s”Z	ri  )r%  r-  )r%  rx  r-  r  r}  r  rc  rZ  zmCommit triggered by space: Apply workaround for libreoffice autocorrection: Sleep, press and release Shift_L.rb  r~   z+auto committing because of key.msymbol = %szaMaybe commit early: self._typed_string=%r self._typed_string_cursor=%s -> transliterated_parts=%rz`Early commit: Apply workaround for libreoffice autocorrection: Sleep, press and release Shift_L.r  )zG- zG-_rQ  )r  r_  r  r1   r'  r,  r  rR  r  r  rA  r   r  r   rO  rW  rS  r  r  rT  r  rx  ZKEY_0ZKEY_1ZKEY_2ZKEY_3ZKEY_4ZKEY_5ZKEY_6ZKEY_7ZKEY_8ZKEY_9r  r  r  r  r  r  r  r  r  r  r  r  r  r;  r'  r  r(  r  rV  r  rU  rV  r  rX  rY  rn  Zmsymbol_triggers_commitr  r2  r8  r  r  r  rK  rL  r3  r   r  rM  rN  rU  r   r   r  r"  r7  r?  rS  rT  r!  r#  r  rl  r  r@  r(  r   r6  r7  r  rP  rz  r   r  r  r\  r&  r   r   r+  rQ  rR  rZ  r  rV  r2   r~  r.  r  rr   r7  r:  r]  r   r  r
  r  r  r<  ZUPPERCASE_WORDSZUPPERCASE_CHARSZ	LOWERCASEr  Zcontains_letterr  r  r  r  r=  r  r  rH   )rO   rv  Ztransliterated_digitr*  r%  r{  Zinput_phrase_leftZinput_phrase_rightZ
dummy_charr  r  r%   Zinsert_msymbolr  r  s   &&            r   r  Z&TypingBoosterEngine._process_key_eventb(  s    ;;;))#..$$q(LL!AB*NN***...NN&&#''1$$q(KK !A B==??4#5#5#G#G#I#I  1$:CA ww|
 ++-4>>)			113;;-@@ ++-2ckkk(((KKEF WWjj$**djj$**jj$**djj$**jj$**.. @@@WWiiDIItyyiiDIItyyii,, @@@& ,,.q1W< 335$ ,0+@+@--/2,#mS[[M151C1C $ E ) '',%9 ( ; %%'//1 KK~-''T66633S[[MBB%*+++ XXX XXX YYY#)))sxxx55ckkBB!66}EEr }}t'9'9'K'K'M'M++-,,Q/K MMOO|(C%%!!.**ckk]:%)%7%7 "/ "9 //<|K	L
 --s{{m<!IIIt'9'9'K'K'M'M&*&F&F&F GG0A0ABB22t1123{{{478J8J4K111Q61((*557GGt/?/?@@11A5{{{45111Q61((*557GG 2 24411A58=D&&5FKD&&C{{{99;<<>}}-2*28/OO%GG1C1CDD11C8J8J4KK8=D&&5FKD&&C{{{88:;;=}}-2*28/OO%III4#5#5#G#G#I#I+/+K+K+K 77t}}d.>.>#113 3 *.DDF*HD&03D4F4F0GD-779GGt/?/?@@11A58=D&&5FKD&&C{{{45111Q61OO%GG 2 24411A58=D&&5FKD&&C{{{99;<<>}}-2*28/OO%   1$GH77DL++''))355ACL" %%a(J6#44 !!.**ckk]:%)%7%7 "/ "9  ;;;#,,S[[99
 (44Fc#++6F5F'G'+'7'7 33(55?(AAM(O'2-#0014 &%M!N !% 2 2 K K M M$($6$6$H$H$J$J %)$P$P$R!T $ 3 3$1 !4 !N !%

4+I+I J$'GG/M$M-0[[[0303			03			03$($5$5$7$($I$I$K %)$4$4()4+U+U%W (- %)$C$C$E', ;;=#(I .J ++,"00SE9*h6  &6 7 +DII,E,Eh,OP779#
  ,,q0"LL P #- 55s{{mD)#"";;==&&88:: !% L L N''dnndll;;;;;!hhh!hhh!iii!iii!hhh//14 77dll*G'		(A(A$(GHG'		(A(A#(FG7;4!''dnndll"oot/@/@B B;;;!hhh!hhh!iii!iii!hhh00T//01 ))+6DD**+ED,E,EF%)%7%7 E 9 " %)$4$4++%--7%99J%L! ))+6DD**4+D+D+EF%)%7%7 E 9 # **g5)-)9)9//*11;*=.*0& %'')). ( 0 &''*%*). ( 0 //1
 

499:"4J55dmmD #5
 &&q)Z7DOO$($5$5t7I7I$K K&&q)44T::4>>1ckkS6H 

499: !-  $$q(LL!DE++- &+"!!3355)-&!55~~CKK~HJJ,IDNNDLL99HHHIIIIIIHHH!!#557   D$N$NO//1
 ""1%3GG $ 1 143E3E G G""1%0066GGt~~-#++2DDNN,,&&33y@))66AA-PP @ A 

499:11$2B2BAF11$$d&7&7&D&DF JJt556)q*-A55dmmD .KKK 9 93;;- H H
 16D-}}   "((()))2>/((8+>+>+N+NNN2>/((8+>+>+N+NNN29/((8+>+>+H+HHH29/~-113;;-@@!$!$444&&??AA&&88:: &*@@B&D",/0B0B,C)))>*:; ,,))+A.0  CKK A%KK3&KK4#?#??  $3,,\::$$q(LLE% ## 3&\ $ C!!#%%'''+'<'<))+A.(00C0C**9K9K 1D 1M % $$q(LL5 **D,E,E,. )222,<<<)-););,<<=*?D&03D4F4F0GD-779 (*D$ ///0@@AE0::ckkI 4 < < < 4 ? ? ?)$G'		110::<= ))66)C,,99DD]SS@A 

4#A#AB99$:J:JAN99 ,,d.?.?.L.LNOO ==??'')r    c                rC   r   r'   rD   rF   r   r   r	  +  s     $ $T $r    c                sv    V P                   ^8  d   \        P                  R4       V P                  RR4       R# )zV
Called for ibus < 1.5.27 when a window gets focus while
this input engine is enabled
zentering do_focus_in()
rB   N)r  r1   r'  do_focus_in_idrm   r$   r   do_focus_inZTypingBoosterEngine.do_focus_in+  s/    
 q LL34B#r    c                r  )r   r  r]   r   Nr   rD   rF   r   r   r	  +  s*     F# F#"F#,/F#48F#r    c                s\   V P                   ^8  d$   \        P                  RWV P                  R 4       \	        4       V n        \	        4       V n        V P                  4        \        P                  ! 4       w  ppV P                   ^8  d   \        P                  RW44       TpRV9  d    VRV,           R,           V,           ,          pMVRV,           ,          pWPP                  n        V P                   ^8  d+   \        P                  RV P                  P                  4       \        P                  ! 4       V n        V P                   ^8  d   V P                  P                  4        Fl  p\         P"                  ! V4      pVP%                  R4      '       g   VR8X  d   \        P                  RV4       VR9   g   KV  \        P                  R	V4       Kn  	  V P'                  V P(                  4       V P+                  4        R
V n        V P/                  4        V P1                  4        R# )uu  Called for ibus >= 1.5.27 when a window gets focus while
this input engine is enabled

:param object_path: Example:
                    '/org/freedesktop/IBus/InputContext_23'
:param client: Possible values and examples where these values occur:
               '': unknown
               'fake': focus where input is impossible
                       (e.g. desktop background)
               'xim': XIM
                     (Gtk3 programs in a Gnome Xorg session
                      when GTK_IM_MODULE is unset also use xim)
               'gtk-im:<program-name>':  Gtk2 input module
               'gtk3-im:<program-name>': Gtk3 input module
               'gtk4-im:<program-name>': Gtk4 input module
               'gnome-shell': Entries handled by gnome-shell
                              (like the command line dialog
                              opened with Alt+F2 or the search
                              field when pressing the Super
                              key.) When GTK_IM_MODULE is
                              unset in a Gnome Wayland session
                              all programs which would show
                              'gtk3-im' or 'gtk4-im' with
                              GTK_IM_MODULE=ibus then show
                              'gnome-shell' instead.
               'Qt':      Qt4 input module
               'QIBusInputContext': Qt5 input module
               'SDL2_Application': SDL2 input module

               In case of the Gtk input modules, the name of the
               client is also shown after the “:”, for example
               like 'gtk3-im:firefox', 'gtk4-im:gnome-text-editor', …
z5object_path=%s client=%s self.client_capabilities=%s
Z010bu+   program_name=“%s” window_title=“%s”rf   zself._client_info.client=%r
Zdead_r  zAvailable compose key: %szAvailable key: %sFN)ZaZGreek_alphaZCyrillic_ef)r  r1   r'  rv  rA   rW  rX  rz  itb_active_windowZget_active_windowr  r]   rn  r  r  r  r   r  rV  r  r  ry  r+  r  _apply_autosettings)rO   r  r]   rr   rt   Zclient_info_strr  r}   r  r   r  Z"TypingBoosterEngine.do_focus_in_id+  s   F q LLH(@(@'FI "1!2%4%6"--/*<<>		q LL=, !o%s\1C7,FFOs\11O#2 q LL/1B1B1I1IK$,$>$>$@!q 33;;=''/OOG,,{*LL!<dC>>LL!4d; > 	  !4!45/4,  "r    c                rC   r   r'   rD   rF   r   r   r	  ^+  s     </ </T </r    c                s   V P                   ^ 8  d+   \        P                  RV P                  P                  4       V P
                  '       d   V P                  4        V P                  P                  '       g   R# / pV P                   EF  w  r#pV'       dA   W P                  9  g1   RV P                  V,          9  g   RV P                  V,          9  d   KQ  \        P                  ! V4      pVP                  V P                  P                  4      '       g   K  V P                  V,          R,          ! 4       pVR9   d   RP                  V4      p\        V4      \        \        \         \"        39  d   K  Rp\%        V\        4      '       d   TpM\%        V\         4      '       d-   VP'                  4       R9   d   VP'                  4       R8H  pMLEKN  \%        V\        4      '       d    \        V4      pM&\%        V\"        4      '       d    \#        V4      pMEK  \        P1                  R	W@P                  P                  W#4       WqV&   W`P
                  V&   EK  	  VP3                  4        FO  w  r#\        P1                  R
W P
                  V,          V4       V P                  V,          R,          ! VRR7       KQ  	  R#   \(        3 d8   p\        P+                  RTP,                  P.                  T4        Rp?EK|  Rp?ii ; i  \(        3 d8   p\        P+                  RTP,                  P.                  T4        Rp?EK  Rp?ii ; i)zCApply automatic setting changes for the window which just got focuszself._client_info.client=%sNr}  r~  r\  rB   truez:Exception converting autosettings value to integer: %s: %suD   regexp “%s” matches “%s”, trying to set “%s” to “%s”zApply autosetting: %s: %s -> %sFrN  )r_  r[  )r  Zfalse)r  r1   r'  r  r]   r  _revert_autosettingsr  r  r	  rD  r  r  r  r   r>   r   r3  ri  r~   r  r  r  rR   r  rX  )	rO   Zautosettings_applysettingr   rG  r  Zcurrent_valueZ	new_valuer2   r  r   r  Z'TypingBoosterEngine._apply_autosettings^+  s   q LL68I8I8P8PQ$$$%%'  '''-/(,(:(:$WV"5"55!)<)<W)EE!)<)<W)EEjj(G>>$"3"3":":;; //8HJM77 # 7M"3T5*AA68I---!	M400;;=$55 % 7IM3// #E
I M511 %eI KKV))00'B +4w'1>%%g.] );^ 1668NGKK9!:!:7!CUL(8/ 9- #} $$!00%9  #} $$!00%9 s0   /KLL+LLM+MMc                r  )r   r,  r%  r   Nr   rD   rF   r   r   r	  +  s*     X2 X2!$X29<X2FJX2r    c                s>   V P                   ^8  d   \        P                  RW4       V'       g)   V P                  V P	                  4       ^ ,          ,          pV'       g   \
        P                  ! V4      pRpV P                  '       d   V P                  ^ ,          P                  pV P                  '       dW   V P                  '       gE   V P                  P                  4       ^ 8w  g&   V'       d   VP                  V4      '       d   WC8X  d   TpMTp\
        P                  ! V4      p\
        P                  ! V4      p\
        P                  ! V4      pV P                  '       gU   V P                   ^8X  gD   V P"                  '       g2   V P$                  \
        P&                  P(                  ,          '       d)   V P                   ^8  d   \        P                  R4       R# V P                   ^8  d~   \        P                  RWVV P+                  4       V P-                  4       V P                   V P.                  P0                  P3                  V4      V P.                  P5                  V4      4       V'       d	   V'       g)   V P                   ^8  d   \        P                  R4       R# V P                   ^8X  d   V P.                  P5                  V4      '       g`   V P.                  P0                  P3                  V4      '       g5   V P                   ^8  d"   \        P                  RV P                   V4       R# V P                   ^8X  d`   V P.                  P0                  P3                  V4      '       g5   V P                   ^8  d"   \        P                  RV P                   V4       R# V P                   ^8  d   \        P                  R4       V P.                  P7                  VVV P+                  4       V P-                  4       R	7       V P9                  V4       R# )
u*  Record an commit_phrase/input_phrase pair in the user database.

This function does *not* do the actual commit, it assumes that
the commit has already happened! If the preëdit has already
been committed because the focus has been moved to another
window or to a different cursor position in the same window by
using a mouse click, this function should be called with both
parameters empty. In this case it records what has been in the
already committed preëdit into the user database.

:param commit_phrase: The phrase which has been committed already.
                      This parameter can be empty, then it is made
                      equal to what has been in the preedit.
:param input_phrase: The typed input. This parameter can be empty,
                     then the transliterated input is used.
z commit_phrase=%r input_phrase=%rrB   r0  Nzstripped_input_phrase=%r stripped_commit_phrase=%r p_phrase=%r pp_phrase=%r record_mode=%d spellcheck=%r previously recorded=%dz8Empty input or commit: NOT recording and pushing contextr1  r2  r3  )r  r1   r'  r8  r  rn  ro  r=  r   r  rx  rA  r   rV  r  r  r  r  r  r<  r=  rr  rt  r  r#  r  r>  r?  rx  )rO   r,  r%  r+  r]  Zstripped_input_phraser@  r3   r   $_record_in_database_and_push_contextZ8TypingBoosterEngine._record_in_database_and_push_context+  s(   $ q LL;&677%%'*,L#LLL O"&"2"21"5"<"<+++<<<%%446!;&&11,??"2 !- / II ( 4 4\ B!)!5!5m!D     A%  8#6#6#>#>>>  1$JKq LL7 &!!#T%7%7%94;L;L**55mD++M:< %,B  1$NP"MM//0FGGMM..99:PQQ  1$F!..0FH"MM..99:PQQ  1$F!..0FHq LL9:77.)&&(((*	 	8 	,
 	01r    c                rC   r   r'   rD   rF   r   r   r	  +  s     ! !d !r    c                st    V P                   ^8  d   \        P                  R4       V P                  R4       R# )zW
Called for ibus < 1.5.27 when a window loses focus while
this input engine is enabled
zentering do_focus_out()
rB   N)r  r1   r'  do_focus_out_idrm   r$   r   r  Z TypingBoosterEngine.do_focus_out+  s-    
 q LL45R r    c                r[   )r   r  r   Nr   rD   rF   r   r   r	  +  s     #2 #2"#2'+#2r    c                s   V P                   ^8  d   \        P                  RV4       V P                  '       d   V P	                  RR7       RV P
                  n        V P                  4       '       g   V P                  4        V P                  4        V P                  4        V P                  4        V P                   F$  pV P                  V,          P                  4        K&  	  R# )z
Called for ibus >= 1.5.27 when a window loses focus while
this input engine is enabled

:param object_path: Example:
                    '/org/freedesktop/IBus/InputContext_23'
zobject_path=%s
Fr  rB   N)r  r1   r'  r  r  r  r]   r  r  ry  r\  r  r  r;  reset_ic)rO   r  r  ri   r   r  Z#TypingBoosterEngine.do_focus_out_id+  s     q LL+[9)))**E*B
 $&  }}557'')!!#%%C !!#&//1 &r    c                rC   r   r'   rD   rF   r   r   r	  $,  s     ' 'd 'r    c                s    V P                   P                  4        F=  w  r\        P                  RW4       V P                  V,          R,          ! VRR7       K?  	  / V n         R# )z<Revert automatic setting changes which were done on focus inzRevert autosetting: %s: -> %sr}  FrN  N)r  rX  r1   r  r  )rO   r  r   rg  r   r  Z(TypingBoosterEngine._revert_autosettings$,  sT    "77==?NGKK7H(8/ @ %'!r    c                rC   r   r'   rD   rF   r   r   r	  ,,  s     t* t*$ t*r    c           	     s	   V P                   ^8  dw   \        P                  RV P                  P                  \        V P                  4      \        V P                  4      V P                  P                  V P                  4      4       V P                  '       d   V P                  RR7       R# \        4       V n        V P                  4        V P                   F$  pV P                   V,          P#                  4        K&  	  V P                  P                  R8X  Ed   V P                   ^8  d   \        P                  R4       V P$                  P'                  4        V P$                  P)                  R4       V P+                  4        V P-                  \.        P0                  P3                  R4      R4       RV P$                  n        \6        P8                  V P$                  n        V P<                  '       dq   V P<                  P>                  \.        P@                  \.        PB                  \.        PD                  39   d)   V P                   ^8  d   \        P                  R4       R# V P                   ^8  d   \        P                  R4       V PG                  4        R# V PH                  '       Ed   V PJ                  \L        PN                  PP                  PR                  39  d   V P                  PT                  pV P                  PV                  pVRV pV P                   ^8  d!   \        P                  R	V P                  4       V PX                  PZ                  R
8X  dm   VP]                  V P                  P                  4      '       gB   \        P                  RV P                  P                  4       \        P                  R4       R# RpV P<                  '       d1   \^        P^                  ! 4       V P<                  P^                  ,
          pRTu;8:  d   R8:  d+   M M'V P                   ^8  d   \        P                  R4       M&V P                   ^8  d   \        P                  R4       V Pa                  4       '       g   V Pc                  4        V P                   ^8  d   \        P                  R4       V PG                  4        V Pe                  4        R# )a  Called when the mouse pointer is used to move to cursor to a
different position in the current window.

Also called when certain keys are pressed:

    Return, KP_Enter, ISO_Enter, Up, Down, (and others?)

Even some key sequences like space + Left and space + Right
seem to call this.

z~self._current_preedit_text.text_str=%r self._typed_string=%s self._typed_compose_sequence=%s compose preedit representation=%rFr  NrB   z@Current preedit is empty: do not record, clear input, update UI.z,Avoid clearing context after Return or EnterzIClear context: cursor might have moved, remembered context might be wrongr  rd  u,   self._current_preedit_text.text_str=“%s”zWhatever caused the reset did not commit the preedit. A reset seems to happen sometimes right after reopening a preedit. In that case nothing should be recorded, nothing cleared, nothing updated.rI  rL  zprobably triggered by keyzprobably triggered by mousezClearing context and input.)3r  r1   r'  r  r  r0   r2  r1  r  r)  r  r  rA   rW  rz  r  r;  r  rA  r   r   rg  ro  r   r   r   r   r{   r   r   r,  rR  rQ  rR  r  ry  ry  r  rn  rB  rC  r   r   rH   r  rp   r(  r6  r  r  r\  )rO   r  r   rH   Ztext_to_cursorZtime_since_prev_key_handledr  r   do_resetZTypingBoosterEngine.do_reset,,  s    q LL = 33<<d001d::;00GG!99;< )))**E*B "1!2--/%%C !!#&//1 & %%.."4  1$ F G $$&11%8""$&&		))"-u605D-'7'>'>D$""OOT%6%68J8J'L L$$q(LLFH  1$ A B %%%(=(=(F(F(L(L'MM))..D//::J!+:.N  1$8!335!!++y8&//0J0J0S0STT K!77@@BLM
 &)#>>>*.))+8K8K*K'-44  1$89  1$:; }}557q LL67'')r    c                r  )r   purposehintsr   Nr   rD   rF   r   r   r	  ,  s*     G GG'*G/3Gr    c           
     s   \         P                  RV\        VR4      4       Wn        W n        V P
                  ^8  Ed&   V P                  \        \        P                  4       Uu. uF  p\        V4      NK  	  up9  d!   \         P                  RV P                  4       \        \        P                  4       F@  pV P                  V8X  g   K  \         P                  RV P                  \        V4      4       KB  	  \        P                   FQ  pV P                  V,          '       g   K  \         P                  R\        V4      \        \        V4      R4      4       KS  	  R# R# u upi )z-Called when the input purpose or hints changezpurpose=%s hints=%s
r  z"self._input_purpose = %s (Unknown)zself._input_purpose = %s (%s)zhint: %s %sN)r1   r'  r   r  r  r  r  rn  rB  r>   r   r<  )rO   r  r  rf  Zinput_purposeZhintr  r   do_set_content_typeZ'TypingBoosterEngine.do_set_content_type,  s    	,gveV7LM%!q ##(,X-B-B(CD(C1A(CDEA!002!%h&;&;!<&&-7LL!@!%!4!4c-6HJ "= !++$$t++LL!$TF3t9f,EG , !Ds   &E'c                rC   r   r'   rD   rF   r   r   r	  ,  s      4 r    c                s    V P                   ^8  d   \        P                  R4       \        4       V n        \        4       V n        V P                  4        V P                  4        R# )z(Called when this input engine is enabledzdo_enable()
N)r  r1   r'  rA   rW  rX  rz  r  rm   r$   r   	do_enableZTypingBoosterEngine.do_enable,  sJ    q LL)!0!2%4%6"--/r    c                rC   r   r'   rD   rF   r   r   r	  ,  s     * *D *r    c                sr    V P                   ^8  d   \        P                  R4       V P                  4        R# )z)Called when this input engine is disabledzdo_disable()
N)r  r1   r'  r\  rm   r$   r   
do_disableZTypingBoosterEngine.do_disable,  s)    q LL)*'')r    c                rj   rk   r   rD   rF   r   r   r	  ,  s      D r    c                sV    V P                  4       '       d   V P                  4        R# R# )zNCalled when the page up button in the lookup table is clicked with
the mouse

T)re  r  rm   r$   r   
do_page_upZTypingBoosterEngine.do_page_up,  s!    
 ==??--/r    c                rj   rk   r   rD   rF   r   r   r	  ,  s      d r    c                sV    V P                  4       '       d   V P                  4        R# R# )zPCalled when the page down button in the lookup table is clicked with
the mouse

TF)rd  r  rm   r$   r   do_page_downZ TypingBoosterEngine.do_page_down,  s#    
 ??--/r    c                r  )r   _args_kwargsr   r   r   rD   rF   r   r   r	  ,  s"      3 3 4 r    c                sF    V P                  4       pV P                  4        V# )zTCalled when the mouse wheel is rolled up in the candidate area of
the lookup table

)rb  r  )rO   r  r  ress   &*, r   do_cursor_upZ TypingBoosterEngine.do_cursor_up,  s!    
 nn))+
r    c                rj   rk   r   rD   rF   r   r   r	  ,  s       r    c                sF    V P                  4       pV P                  4        V# )zVCalled when the mouse wheel is rolled down in the candidate area of
the lookup table

)r`  r  )rO   r  rP   r   do_cursor_downZ"TypingBoosterEngine.do_cursor_down,  s#    
  ))+
r    c                r  r   r   rO  r   Nr  rD   rF   r   r   r	  ,  s%     * **04*AE*r    c                s    \         P                  R4       V P                  P                  P	                  4        V P                  4        R# )z(re)load all dictionaries

Needs to be called when a dictionary has been updated or
installed.

:param value: ignored
:param update_gsettings: ignored
zReloading dictionaries ...N)r1   r  r  r#  Zinit_dictionariesr\  rO   r   rO  r   r   r  Z(TypingBoosterEngine._reload_dictionaries,  s3     	01""446'')r    c                r  r  r  rD   rF   r   r   r	  ,  s%     * **04*AE*r    c                s    \         P                  R4       \        P                  ! 4        \        P                  ! 4        V P                  4        V P                  4        R# )z(re)load all input_methods

Needs to be called when an input method has been changed,
usually because an optional variable of an input method was changed.

:param value: ignored
:param update_gsettings: ignored
zReloading input methods ...N)r1   r  r.  ZfiniZinitr<  r\  r  r   r   r  Z)TypingBoosterEngine._reload_input_methods,  sA     	12""$'')r    c          
      s^   < V ^8  d   QhRS[ P                  RS[ P                  RS[RS[RR/# )r   _enginer   rH   rI   r   N)r   r  r   r>   rD   rF   r   r   r	  -  sC     "+ "+)-"+&*ii"+ -0"+ -0	"+ 59	"+r    c                s8   V P                   ^8  d&   \        P                  RVP                  4       W44       VP                  4       V P                  n        W0P                  n        W@P                  n        V P                  P                  P                  4        R# )aM  Called when the surrounding text has changed.

Useful especially in debugging for stuff like this:

self._surrounding_text.event.clear()

or get a new object which has the event cleared:

self._surrounding_text = SurroundingText()
... some stuff ...

# Now check whether at  least one set-surrounding-text signal
# has occured:
self._set_surrounding_text.event.is_set()

or:

# If at least one set-surrounding-text signal
# has already occured, continue immediately, else
# wait for such a signal to occur but continue after
# a timeout:
self._set_surrounding_text.event.wait(timeout=0.1)
z#text=%r cursor_pos=%s anchor_pos=%sN)
r  r1   r'  Zget_textrW  r   rH   rI   rJ   rN   )rO   r   r   rH   rI   s   &&&&&r   rY  Z,TypingBoosterEngine._on_set_surrounding_text-  sq    8 q LL>*B&*mmo#,6),6)$$((*r    c                rn  )r   	_settingsrv  r   N)r   r  r   rD   rF   r   r   r	  1-  s)       \\038<r    c                sR   \         P                  ! V P                  P                  V4      4      p\        P                  RW#4       W P                  9   d=   RV P                  V,          9   d%   V P                  V,          R,          ! VRR7       R# \        P                  R4       R# )z
Called when a value in the settings has been changed.

:param settings: The settings object
:param key: The key of the setting which has changed
z"Settings changed: key=%s value=%s
r}  FrN  NzUnknown key
)rn  r
  r  Z	get_valuer1   r'  r  r  )rO   r  rv  r   r  r   r[  Z/TypingBoosterEngine._on_gsettings_value_changed1-  s     ))$//*C*CC*HI:CG&&&$"5"5c"::$^4/'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  r  r  r  r  r  r  r  r  r  r+  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  rZ  r  r  r  r
  r  r  r  r  r  r  r  r  r  r  rA  r  r  r  r0  r  r7  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r4  r  r5  r6  r  r  r  r,  r  r  r  r  r  r  r  r  r  r  r  r  rW  rX  r  r  r  r  r-  r8  r9  r:  r;  r1  r2  r3  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  )r  Frx   )rB   rI  rB   FF)T)i    )ra  )rB   TT)Zin)r'   )rB   rB   r6   (k  rR   rS   r,   rT   rU   re   rc  rg  rj  rl  rm  ro  rp  rq  rs  rt  ry   rx  ry  rz  r  r<  r  r  r  r  r  r  r!  r"  r#  r.  rE  r_  r`  rb  rd  re  rh  rk  rl  rm  ro  r   rp  rr  rt  rv  rx  ry  r  r  r  r$  r  r  r  r  r  rH  rI  r  r  r  r  r  r  rJ  r   r  r  r  r  r  r  r\  r  r  r  r  r  r  r   r  r  r  r	  r  r  r  r  rY  r  r  r+  r(  r4  r_  r
  r  rk  r  r  r  r  r  r  rs  r  r  ru  r  r  rx  r  r  rz  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  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  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  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  Zstaticmethodr  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  r  r
  r  r  r  r  r  r$  r)  r*  r+  r  r1  rB  rD  rE  rH  rI  r  rL  rM  rN  rO  rP  rR  rS  rT  rU  rV  rW  rX  rh  rl  rn  ro  rr  rt  rv  rx  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  r5  r  r  rZ  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rY  r[  rV   rW   Z__classcell__)r  rE   s   @@r   r   r   B  s    1w( w(r* *) )? ?4 45 57 72 23 35 5; ; H H M M
$ $q qf	. .*/ / U U, ,2 28. .2 22 22 22 2A AFZ5 Z5xw wr    	 	 $3 3> >N N`8 8" "        
# 
#. .@% %)9 )9V-E -E^) ) <) )J$ J$X( (: :@; ;<+7 +7Z+7 +7Z-< -<^-< -<^7< 7<r:< :<xF6 F6V *.)A)A7 7r' '42 2/ /& &  > 2 &# #J .  .D6= 6=pS2 S2j_ _B'$ '$RJ J22 2(N6 N6`-E -E^| ||= =~ " *i iVH6 H6T
T TlQ Qf06 06d0 04= =) ). .2' '. .8! !0 00
9 
9% %0 00A A- -0 007 7# #0 00C C/ /* *;A ;Az% %6D D
   2 2(I I2 2&J J0 0.: :& & 0  0D; ;' '0 0@: :& &0 088 8$ $C C4. .)0 )0V &! !A A4, ,0 00. .7 7@5 5
0 00- -7 7@4 40 00+ +7 7@2 20 00( (7 7@/ /0 00" "7 7@) )0 00& &7 7@- -0 00& &7 7@- -0 00" "7 70) )0 00& &7 70- -0 00& &#7 #7J- -0 02% %0 00   7 70' '0 00$ $< <0' '7 70" "6 60( (/ /24 40 00   0 00* *0 02" "
6 
60 00% %
9 
90 024 40 00) )7 78 9 9>. .< <B' '0 024 4? ?:' '
9 96! !N N.3 3I I.. .0 0,    1 12% %! !7 7,! !/ /<& &/ /:# #0 04/ /
0 0>8 8. .8$ $. .4+ +A AF &m m^    C CJc cJ	 	W Wr	 		 	= =~P Pd  (0 (0TP Pd+ +Z#L #LJ$ $L 6  > > >(
 
2 2h 2 2 $ "             { {z 
 
     8 89 9) )8 89 9) )8 89 9) )8 89 9) )8 89 9) )8 89 9) )8 89 9) )8 89 9) )8 89 9) )K KZ  n n`? ?2B Bg gRG G GRS SjQ' Q'fi
 i
V$ $F# F#P</ </|X2 X2t! !#2 #2J' 't* t*lG G( * *    * * * *""+ "+H  r    )rg   i   )r   )`rU   Ztypingr   r   r   r   r   r   r   r   r.   Zversion_infor	   Ztyping_extensionsrS  r  rA  r  r6  rQ   r   ZloggingrK   r  r  r!   Zdataclassesr
   r   Zgir   Zgi.repositoryr   r   r   r.  rn  r  r  r(  r]  r  r  ZImportErrorr2   r  ZregexZVERSION1ZDEFAULT_VERSIONr	  r  r  r  r  r  Zgoogle.cloudr   Zgoogle.cloud.speechr   r  r   r  rf  Zbidi.algorithmrg  Z	getLoggerr1   Z__all__r"   r%   r(   rD  rF  rE  rG  ZMAJOR_VERSIONZMINOR_VERSIONZMICRO_VERSIONr  r4   r9   r  r;   r  r?   r<   r@   rA   rZ   ZEnumr{   r   r   r   r  r   r'   r    r   <module>r     s  *         
v)  	  
         (     u            $"  !NNE	BK # '!% +0 '4#99.2+ $)  -'+$ 
		0	1 #
.  
  & 
 $ ""D$6$68J8JK7"
 $$ FS $ 
%% % %N.9 .9`	!tyy 	!@' @'D   <7" 7"rk$++ ks 	~ $#$  K 	[*- '!&' 	~ 4.3+4 	~ -',$-s`   H $H3  I 	I  I+ H0#H++H03IIII
I('I(+
I98I9