__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

[email protected]: ~ $
�

q�g���B�%SrSrSSKJr SSKJr SSKJr SSKJr SSKJr SSKJr SS	KJ	r	 SS
KJ
r
 SSKrSSKrSSK
r
SSKrSSKrSSKrSrSSKrS
rSSKJr Sr\
\/\4\S'Sr\
\/\4\S'SSKJr \"SS5 SSKJr \"SS5 SSKJr \"SS5 SSKJr SSKJ r  SSK!r!SSK"r"SSK#r#\RH"S5r%\&"S5q'S\S\(4S jr)S\!RT"S!5\!RT"S"5\!RT"S#5\!RT"S"5\!RT"S$5\!RT"S%5\!RT"S&5\!RT"S'5\!RT"S(5S).
r+\\\\(\&44\S*'S
\!RT"S+5\!RT"S,5\!RT"S-5\!RT"S.5\!RT"S$5\!RT"S/5\!RT"S&5\!RT"S'5\!RT"S05S).
r,\\\\(\&44\S1'/S2Qr-\\\&\&\&4\S3'S4\S\4S5jr.S4\S\4S6jr/S7r0S8r1\Rd\Rf\Rh4r5"S9S:\Rl5r7\8S;:Xaq\Rr"\RtS<9r;\%Ry\Rz5 \%R}\;5 SSK?r?\?R�"5urArB\R�"\A5 gg!\4a SrGN�f=f)=z5
This file implements the ibus engine for ibus-table
)�	TabEngine�)�Any)�List)�Tuple)�Iterable)�Dict)�Union)�Optional)�CallableNFT��dgettextc��[SU5$)N�
ibus-tabler��as �%/usr/share/ibus-table/engine/table.py�<lambda>r5s��H�\�1�$=��_c��U$)N�rs rrr6s��Qr�N_)�require_version�IBusz1.0)r�Gioz2.0)r�GLib)r)�GObjectr�	character�returnc��[US;5$)u~
Use our own function instead of ascii.ispunct()
from “from curses import ascii” because the behaviour
of the latter is kind of weird. In Python 3.3.2 it does
for example:

    # >>> from curses import ascii
    # >>> ascii.ispunct('.')
    # True
    # >>> ascii.ispunct(u'.')
    # True
    # >>> ascii.ispunct('a')
    # False
    # >>> ascii.ispunct(u'a')
    # False
    # >>>
    # >>> ascii.ispunct(u'あ')
    # True
    # >>> ascii.ispunct('あ')
    # True
    # >>>

あ isn’t punctuation. ascii.ispunct() only really works
in the ascii range, it returns weird results when used
over the whole unicode range. Maybe we should better use
unicodedata.category(), which works fine to figure out
what is punctuation for all of unicode. But at the moment
I am only porting from Python2 to Python3 and just want to
preserve the original behaviour for the moment.

By the way, Python 3.6.6 does not seem the  above bug
anymore, in Python 3.6.6 we  get

    # >>> from curses import ascii
    # >>> ascii.ispunct('あ')
    # False
    # >>>

Examples:

>>> ascii_ispunct('.')
True
>>> ascii_ispunct('a')
False
>>> ascii_ispunct('あ')
False
z !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~)�bool)rs r�
ascii_ispunctr"Hs��`�	�D�D�E�Erz#1973a2z#000000z#7700c3z#00ff00z#f90f0fz#1edc1az#ff00ffz#9515b5)
�dark�candidate_text�
system_phrase�user_phrase�system_phrase_unused�
debug_text�preedit_left�
preedit_right�preedit_invalid�aux_text�THEMEz#7bc8f0z#ffffffz#c078eez#f0f0f0z#f9f90fz#dd70f9�
THEME_DARK)=)� i0�)�!i��^)�i��)�i�r0)�i�r0)�i�r0)�i�r0)i� i�r0)ia�i0r0)ib�i0r4)id�i0r0)ie�i�0r0)if�i�0r0)ig�i�0r0)ih�i�0r0)ii�i�0r0)ij�i�0r0)ik�i�0r0)il�i�0r0)im�i�0r0)in�i�0r0)io�i�0r0)ip�i�0r0)iq�i�0r0)ir�i�0r0)is�i�0r0)it�i�0r0)iu�i�0r4)iw�i�0r0)ix�i�0r0)iy�i�0r0)iz�i�0r0)i{�i�0r0)i|�i�0r0)i}�i�0r0)i~�i�0r0)i�i�0r0)i��i�0r0)i��i�0r0)i��i�0r0)i��i�0r0)i��i�0r0)i��i�0�)i��i�0r0)i��i�0r0)i��i�0r0)i��i�0r0)i��i�0�)i��i�0r0)i��i�0r0)i��i�0r9)i��i�0r0)i��i�0r0)i��id1r0)i��i11�)i�iO1r9)i�iU1r9)i�i[1�	)i�i�!�)i�i�%r0)i�i�%r0�__HALF_FULL_TABLE�charc��[U5n[H*up#nX!s=::a
X$-:dMO M[X1-U-
5s $ U$)u�
Convert a character to full width if possible.

:param char: A character to convert to full width

Examples:

>>> unichar_half_to_full('a')
'a'
>>> unichar_half_to_full('a')
'a'
>>> unichar_half_to_full('☺')
'☺'
��ordr>�chr�r?�code�half�full�sizes     r�unichar_half_to_fullrI�sE���t�9�D�-���D��%�$�+�%�%��t�{�T�)�*�*�.��Krc��[U5n[H*up#nX1s=::a
X4-:dMO M[X!-U-
5s $ U$)u�
Convert a character to half width if possible.

:param char: A character to convert to half width
:type char: String
:rtype: String

Examples:

>>> unichar_full_to_half('a')
'a'
>>> unichar_full_to_half('a')
'a'
>>> unichar_full_to_half('☺')
'☺'
rArDs     r�unichar_full_to_halfrK�sE��"�t�9�D�-���D��%�$�+�%�%��t�{�T�)�*�*�.��Kr�r;c�2^�\rSrSrSrS�S\RS\S\S\	SS4
U4S	jjjr
S\R4S
jrS�Sjr
S\	4SjrS�S
jrS\S\	4SjrS\4SjrS\4SjrS\S\SS4SjrS�SjrS�SjrS�SjrS�SjrS\\\S4\\\S444SjrS\4SjrS\\\S4\\\S444SjrS\4SjrS\4SjrS�SjrS�S jr S�S!jr!S�S"jr"S�S#\S$\S%\S&\SS4
S'jjr#\$S(\%\S\%\4S)j5r&S(\%\S*\%\S\4S+jr'S�S#\S$\S%\S&\SS4
S,jjr(S�S-\S$\S%\S&\SS4
S.jjr)S�S/\	S\	4S0jjr*S\	4S1jr+S\S\	4S2jr,S\4S3jr-S�S4jr.S\	4S5jr/S\	4S6jr0S\	4S7jr1S\	4S8jr2S\S\	4S9jr3S\4S:jr4S\R4S;jr5S�S<jr6S�S=jr7S\	4S>jr8S\	4S?jr9S\	4S@jr:S�SAjr;S�U4SBjjr<S�SC\SD\	SS4SEjjr=S\4SFjr>S�SG\	SD\	SS4SHjjr?S\	4SIjr@S�SJ\	SD\	SS4SKjjrAS\	4SLjrBS�SM\SD\	SS4SNjjrCS\4SOjrDS�SP\E\\4SD\	SS4SQjjrFS\4SRjrGS�SS\E\H\\%\4\4SD\	SS4STjjrIS\H\\%\44SUjrJS�SV\SD\	SS4SWjjrKS�SX\	SD\	SS4SYjjrLS\	4SZjrMS�S[\	SD\	SS4S\jjrNS\4S]jrOS�S^\	SS4S_jjrPS\	4S`jrQS�S^\	SS4SajjrRS\	4SbjrSS�S^\	SD\	SS4ScjjrTS\	4SdjrUS�S^\	SD\	SS4SejjrVS\	4SfjrWS�S^\SD\	SS4SgjjrXS\4ShjrYS�S^\	SD\	SS4SijjrZS\	4Sjjr[S�S^\	SD\	SS4Skjjr\S\	4Sljr]S�S\SD\	SS4Smjjr^S\4Snjr_S�S\SD\	SS4Sojjr`S\4SpjraS�S^\	SD\	SS4SqjjrbS\	4SrjrcS�Ss\SD\	SS4StjjrdS\4SujreS�Sv\SD\	SS4SwjjrfS\4SxjrgS�S^\	SV\SD\	SS4SyjjrhS\%\i\	4SzjrjS�S^\	SV\SD\	SS4S{jjrkS\%\i\	4S|jrlS�S^\SD\	SS4S}jjrmS\4S~jrnS�S\H\\4S�\E\\	S4SS4S�jjroS�S�\S�\H\\4S�\SS4S�jjrpS�S�jrq\R�R�4S�\S�\R�SS4S�jjrtS�S�jruS�S�jrvS�S�jrwS�U4S�jjrxS�S�jryS�S�jrzS�S#\S$\SS4S�jjr{S\	4S�jr|S�S$\S#\SS4U4S�jjjr}S\	4S�jr~S\S\4S�jrS\S�\S�\S\	4S�jr�S\	4S�jr�S\	4S�jr�S\	4S�jr�S\	4S�jr�S\	4S�jr�S\	4S�jr�S\	4S�jr�S\	4S�jr�S\	4S�jr�S\	4S�jr�S\	4S�jr�S\	4S�jr�S\	4S�jr�S\	4S�jr�S\	4S�jr�S\	4S�jr�S�\S\	4S�jr�S\	4S�jr�S\	4S�jr�S\	4S�jr�S\	4S�jr�S\	4S�jr�S\	4S�jr�S\	4S�jr�S\	4S�jr�S\	4S�jr�S\	4S�jr�S�\S\	4S�jr�S\	4S�jr�S\	4S�jr�S\	4S�jr�S\	4S�jr�S\	4S�jr�S\	4S�jr�S\	4S�jr�S\	4S�jr�S\	4S�jr�S\	4S�jr�S�\S\	4S�jr�S\	4S�jr�S\	4S�jr�S\	4S�jr�S\	4S�jr�S\	4S�jr�S\	4S�jr�S\	4S�jr�S\	4S�jr�S\	4S�jr�S\	4S�jr�S�S�\�GRfS�\�\S\\	\	44S�jjr�S�\S�\S�\S\	4S�jr�S�\GRnS�\S�\S�\S\	4
S�jr�S�\S�\S�\S\	4S�jr�S�\�GRfS\	4S�jr�S\S\4S�jr�S\S\4S�jr�S�\�GRfS\	4S�jr�S�\�GRfS\	4S�jr�S�S�jr�S�\S�\SS4S�jr�S�S�jr�S�\SS4S�jr�S�S�jr�S�\S�\SS4S�jr�S�S�jr�S�S�jr�S\	4S�jr�S\	4S�jr�S\	4S�jr�S\	4S�jr�S�\�GR�S�\SS4S�jr�S�r�U=r�$)�rizThe IM Engine for Tables�bus�obj_path�database�	unit_testrNc��2>�[[[R"S555q[S:�a[RSXU5 [RSSR[[[555 [[RR S5(a3["TU]IUR'5USS	9 [RS
5 O1["TU]IUR'5US9 [RS5 UR)S5 X@lSUlSUlXlX0lSUlS
R7[R"S5[R8R:S[R8R:5Ul[R8R?UR2R@5RCSS5RCSS5Ul"[S:�a [RSURD5 [FRH"SSURD-S9Ul%URJRMSURN5 0Ul(0Ul)/Ul*0Ul+0Ul,0Ul-0Ul.0Ul/0Ul00Ul10Ul20Ul30Ul40Ul50Ul60Ul70Ul80Ul90Ul:SUl;SUl<[zUl>0Ul?SUl@UR2R�R�S5UlCUR�(a,[�UR�R�5S:H5UlCO[RS5 SUlCUR2R�R�S5UlFUR�(a,[�UR�R�5S:H5UlFO[RS5 SUlFUR2R�R�S5UlGUR�bUR�S:Xa*UR2R�R�S 5UlGUR�cSUlGUR�S!:XaS"UlGUR�S#:XaS$UlGUR�S%:XaS&UlGUR2R�R�S'5UlHS(UlI[�R�"URJR�S)55UlMUR�S:aSUlMUR�S*:�aS*UlMUR�q[�R�"URJR�S+55nUc�UR2R�R�S,5(aLUR2R�R�S,5R�5S:Hn[RS-5 O[RS.5 Uc/[�R�"URJR�S+55nXPlO[�R�"URJR�S/55nUcUR2R�R�S05(a&UR2R�R�S05nO/[�R�"URJR�S/55nX`lP[�UR�5S:�aUR�SUlP[�R�"URJR�S155nUcUR2R�R�S25(a&UR2R�R�S25nO/[�R�"URJR�S155nXplR[�UR�5S:�aUR�SUlR[�R�"URJR�S355nUc�UR2R�R�S45(aLUR2R�R�S45R�5S:Hn[RS55 O/[�R�"URJR�S355nX�lS[UR2R�R�S655UlTS7UlU[�R�"URJR�S855UlVSUlWUR�(a4[�R�"URJR�S955UlW[�R�"URJR�S:55UlXSUlYSUlZ[�R�"URJR�S;55Ul[UR�[�R�"URJR�S<55SS=9 SUl]SUl^SUl_SUl`SUlaSUlbSUlcSUldSS/Ule[�R�"URJR�S>55[�R�"URJR�S?55/UleUR�ScmUR2R�R�S@5(aCUR2R�R�S@5R�5S:HUR�S'UR�Sc<[�R�"URJR�S?55UR�S'SS/Ulf[�R�"URJR�SA55[�R�"URJR�SB55/UlfUR�ScmUR2R�R�SC5(aCUR2R�R�SC5R�5S:HUR�S'UR�Sc<[�R�"URJR�SB55UR�S'[�R�"URJR�SD55n	U	c�UR2R�R�SE5(a7UR2R�R�SE5R�5S:Hn	O/[�R�"URJR�SD55n	X�lg[�R�"URJR�SF55Ulh[�R�"URJR�SG55n
U
c�UR2R�R�SH5(aLUR2R�R�SH5R�5S:Hn
[RSI5 O/[�R�"URJR�SG55n
X�li[�R�"URJR�SJ55nUc�UR2R�R�SK5(aLUR2R�R�SK5R�5S:Hn[RSL5 O/[�R�"URJR�SJ55nX�ljSUlkSUllSUlmSUln/Ulo/Ulp/Ulq/UlrSUls[�UR2R�R�SM55Ulu[�R�"URJR�SN55Ulv[�R�"URJR�SO55nUc![�R�"UR25nO [S:�a[RSPU5 X�lx[�R�"URJR�SG55UliUR�caUR2R�R�SH5b;UR2R�R�SH5R�5S:HUliUR�c4[�R�"URJR�SG55Uli0Uly[�R�"URJUR25Uly[�R�"URJR�SQ55Ul|[�SSR5H9n
UR�SSU
S--(aM[�X�R�5Ul| O [�R�"URJR�SQ55nUbX�l|[�R�"URJR�ST55nUcUR2R�5nX�l�[�R�"URJR�SU55nU(d0nUGRUSS=9 [�R�"URJR�SV55nU(aUGRSSS=9 UGR5Ul�SSWSXG[SY5G[SZ5S[.SS\S]G[S^5G[S_5S[.S`SaSbG[Sc5G[Sd5S[.SeSfSgG[Sh5G[Si5S[.SjSkSlG[Sm5G[Sn5S[.So.Ul,SpG[Sq5G[Sr5G[
UR~Ss5URXSt.Ul+UR2GR(aASSuSvG[Sw5G[Sx5S[.SS"S"SySzG[S{5G[S|5S}.S~.Ul.OXSSUR�-SvG[S�5G[S�5S[.SS�UR�-S�G[S�5G[S�5S[.S~.Ul.S�G[S�5G[S�5G[
UR~S�5UR\St.Ul-SS�S�G[S�5G[S�5S[.SS�S�G[S�5G[S�5S[.S�.Ul0S�G[S�5G[S�5G[
UR~S�5UR`St.Ul/SS�S�G[S�5G[S�5S[.SS�S�G[S�5G[S�5S[.S�.Ul2S�G[S�5G[S�5G[
UR~S�5URdSt.Ul1SS�S�G[S�5G[S�5S[.SS�S�G[S�5G[S�5S[.S�.Ul4S�G[S�5G[S�5G[
UR~S�5URhSt.Ul3SS�S�G[S�5G[S�5S[.SS�S�G[S�5G[S�5S[.S�.Ul6S�G[S�5G[S�5G[
UR~S�5URlSt.Ul5SS�S�G[S�5G[S�5S[.SS�S�G[S�5G[S�5S[.S�.Ul8S�G[S�5G[S�5G[
UR~S�5URpSt.Ul7SS�S�G[S�5G[S�5S[.SS�S�G[S�5G[S�5S[.S�.Ul:S�G[S�5G[S�5G[
UR~S�5URtSt.Ul9UGR5 SUl�G[GR"5Ul�G[Ul�G[Ul�UGR!5 G["GR$"SUGR&5Ul�URMS�UGR*5 [RS�5 g![
[4a [S5qGNHf=f)�N�IBUS_TABLE_DEBUG_LEVELrr0z4TabEngine.__init__(bus=%s, obj_path=%s, database=%s)zibus version = %s�.�has_focus_idT)�
connection�object_pathrUzThis ibus version has focus id.)rVrWz+This ibus version does *not* have focus id.z{}{}{}{}�IBUS_TABLE_LOCATION�iconsz.db�� rzself._engine_name = %sz!org.freedesktop.ibus.engine.tablez&/org/freedesktop/ibus/engine/table/%s/)�schema�path�changed�pinyin_mode�truezNWe could not find "pinyin_mode" entry in database, is it an outdated database?F�suggestion_modezRWe could not find "suggestion_mode" entry in database, is it an outdated database?�symbol�
status_prompt�CNu中�YauЯ�YiuЇ�valid_input_charszabcdefghijklmnopqrstuvwxyz!@#$%�
debuglevel��
dynamicadjust�dynamic_adjustz)Got "dynamic_adjust" entry from database.zPCould not find "dynamic_adjust" entry from database, is it an outdated database?�singlewildcardchar�single_wildcard_char�multiwildcardchar�multi_wildcard_char�autowildcard�
auto_wildcardz(Got "auto_wildcard" entry from database.�max_key_length��rememberinputmode�	inputmode�soundbackend�
errorsound�errorsoundfile��update_gsettings�endeffullwidthletter�tabdeffullwidthletter�def_full_width_letter�endeffullwidthpunct�tabdeffullwidthpunct�def_full_width_punct�
autocommit�auto_commit�commitinvalidmode�
autoselect�auto_selectz&Got "auto_select" entry from database.�alwaysshowlookup�always_show_lookupz-Got "always_show_lookup" entry from database.�char_prompts�onechar�chinesemodez(Chinese mode found in Gsettings, mode=%s�lookuptablepagesize�
�commit_candidate_%s�lookuptableorientation�keybindings�	darkthemeu簡zsc-mode.svgzSimplified Chineseu(Switch to “Simplified Chinese only”.)�numberrb�icon�label�tooltipu繁ztc-mode.svgzTraditional Chineseu)Switch to “Traditional Chinese only”.r4u簡/大zscb-mode.svgzSimplified Chinese firstu6Switch to “Simplified Chinese before traditional”.�u繁/大ztcb-mode.svgzTraditional Chinese firstu6Switch to “Traditional Chinese before simplified”.r=u大zcb-mode.svgzAll Chinese charactersu'Switch to “All Chinese characters”.)zChineseMode.SimplifiedzChineseMode.TraditionalzChineseMode.SimplifiedFirstzChineseMode.TraditionalFirstzChineseMode.All�ChineseModezChinese modezSwitch Chinese mode�switch_to_next_chinese_mode)�keyr�r��
shortcut_hint�sub_propertiesu英zenglish.svg�EnglishzSwitch to English inputu拼音zchinese.svg�ChinesezSwitch to Chinese input)r�rb�symbol_table�
symbol_pinyinr�r�r�)zInputMode.Direct�InputMode.Tableu☐�DirectzSwitch to direct inputu☑zibus-table.svg�TablezSwitch to table input�	InputModez
Input modezSwitch Input mode�toggle_input_mode_on_offu◑zhalf-letter.svg�HalfzSwitch to halfwidth lettersu●zfull-letter.svg�FullzSwitch to fullwidth letters)zLetterWidth.HalfzLetterWidth.Full�LetterWidthzLetter widthzSwitch letter width�toggle_letter_widthz,.zhalf-punct.svgzSwitch to halfwidth punctuationu、。zfull-punct.svgzSwitch to fullwidth punctuation)zPunctuationWidth.HalfzPunctuationWidth.Full�PunctuationWidthzPunctuation widthzSwitch punctuation width�toggle_punctuation_widthu
☐ 拼音ztab-mode.svgzSwitch to table modeu
☑ 拼音zpy-mode.svg�PinyinzSwitch to pinyin mode)zPinyinMode.TablezPinyinMode.Pinyin�
PinyinModezPinyin modezSwitch pinyin mode�toggle_pinyin_modeu
☐ 联想zSuggestion disabledzSwitch to suggestion modeu
☑ 联想zSuggestion enabled)zSuggestionMode.DisabledzSuggestionMode.Enabled�SuggestionModezSuggestion modezSwitch suggestion mode�toggle_suggestion_modeu☐ 1z
phrase.svgzMultiple character matchz.Switch to matching multiple characters at onceu☑ 1zonechar.svgzSingle character matchz)Switch to matching only single characters)zOneCharMode.PhrasezOneCharMode.OneChar�OneCharModezOnechar modezSwitch onechar mode�toggle_onechar_modeu☐ ↑zncommit.svg�Normalz�Switch to normal commit mode (automatic commits go into the preedit instead of into the application. This enables automatic definitions of new shortcuts)u☑ ↑zacommit.svgzQSwitch to direct commit mode (automatic commits go directly into the application))zAutoCommitMode.DirectzAutoCommitMode.Normal�AutoCommitModezAuto commit modezSwitch autocommit mode�toggle_autocommit_modezprocess-key-eventz6********** Initialized and ready for input: **********)��int�str�os�getenv�DEBUG_LEVEL�	TypeError�
ValueError�LOGGER�debug�info�join�map�IBUS_VERSION�hasattrr�Engine�props�super�__init__�get_connection�add_table_by_locale�
_unit_test�_input_purpose�_input_hints�_busrP�
_setup_pid�formatr]�sep�	_icon_dir�basename�filename�replace�_engine_namer�Settings�
_gsettings�connect�on_gsettings_value_changed�
_prop_dict�_sub_props_dict�main_prop_list�chinese_mode_menu�chinese_mode_properties�input_mode_menu�input_mode_properties�letter_width_menu�letter_width_properties�punctuation_width_menu�punctuation_width_properties�pinyin_mode_menu�pinyin_mode_properties�suggestion_mode_menu�suggestion_mode_properties�onechar_mode_menu�onechar_mode_properties�autocommit_mode_menu�autocommit_mode_properties�_setup_property�
_im_clientr-�theme�_keybindings�_hotkeys�ime_properties�get�_ime_pyr!�lower�_ime_sg�_symbol�_valid_input_chars�_pinyin_valid_input_chars�it_util�variant_to_value�	get_value�_debug_level�get_user_value�_dynamic_adjust�_single_wildcard_char�len�_multi_wildcard_char�_auto_wildcard�_max_key_length�_max_key_length_pinyin�_remember_input_mode�_input_mode�_sound_backend�_error_sound_object�_error_sound_file�_error_sound�set_error_sound_file�	_prev_key�
_prev_char�_double_quotation_state�_single_quotation_state�_prefix�_py_mode�_sg_mode�_sg_mode_active�_full_width_letter�_full_width_punct�_auto_commit�_commit_invalid_mode�_auto_select�_always_show_lookup�_chars_valid�_chars_invalid�#_chars_valid_update_candidates_last�%_chars_invalid_update_candidates_last�_candidates�_candidates_previous�_u_chars�_strings�_cursor_precommit�eval�_prompt_characters�_onechar�get_default_chinese_mode�
_chinese_mode�_default_keybindings�get_default_keybindings�get_default_value�
_page_size�range�min�get_orientation�_orientation�set_keybindings�set_dark_theme�get_new_lookup_table�
_lookup_tabler�repr�_is_chinese�_init_properties�_save_user_count�time�_save_user_start�SAVE_USER_COUNT_MAX�_save_user_count_max�SAVE_USER_TIMEOUT�_save_user_timeout�resetr�timeout_add_seconds�
_sync_user_db�sync_timeout_id� _TabEngine__do_process_key_event)�selfrNrOrPrQrkrmrorqr�r�r��chinese_mode�index�user_page_size�orientation�user_keybindings�use_dark_theme�	__class__s                  �rr��TabEngine.__init__s����	!��c�"�)�)�,D�"E�F�G�K���?��L�L�F��x�
)�	���'����#�c�<�2H�)I�J��4�;�;�$�$�n�5�5��G���-�-�/�$�!�
�
#�
�K�K�9�:��G���-�-�/�$�
�
&�
�K�K�E�F�� � ��&�#��#$���!"����	�!�
����#�*�*�2�9�9�5J�+K�')�w�w�{�{�G�R�W�W�[�[�J����G�G�,�,��M�M�"�"�$�$+�G�E�2�$6�w�w�s�C�7H�	
����?��L�L�(�$�*;�*;�
=�),���6�9�4�;L�;L�L�)N���	
�����	�4�+J�+J�K�46���9;���35���13���79��$�/1���57��"�13���79��$�68��#�<>��)�02���68��#�46��!�:<��'�13���79��$�46��!�:<��'�8<���!�����
�24���37��
��}�}�3�3�7�7�
�F����<�<����� 2� 2� 4�� >�?�D�L��K�K�6�
7� �D�L��}�}�3�3�7�7�8I�J����<�<����� 2� 2� 4�� >�?�D�L��K�K�.�
/�!�D�L��}�}�3�3�7�7��A����<�<��4�<�<�2�#5��=�=�7�7�;�;�O�L�D�L��<�<���D�L��<�<�4�� �D�L�
�<�<�4���D�L��<�<�4���D�L�"&�-�-�">�">�"B�"B��#!���)J��&�!(�!9�!9��O�O�%�%�l�3�"5������q� � !�D�����s�"� #�D���'�'��)0�)A�)A��O�O�*�*�?�;�*=���!��}�}�+�+�/�/�0@�A�A�!%���!=�!=�!A�!A�$�"&�&+�e�g��"8�����G�H����2�3��!�$�5�5����)�)�/�:�<�N�%3��.5�.F�.F��O�O�*�*�+?�@�/B���'��}�}�+�+�/�/�0F�G�G�'+�}�}�'C�'C�'G�'G�*�(,�$�(/�'?�'?��O�O�-�-�.B�C�(E�$�*>�"��t�)�)�*�Q�.�)-�)C�)C�A�)F�D�&�-4�-E�-E��O�O�*�*�+>�?�.A���&��}�}�+�+�/�/�0E�F�F�&*�m�m�&B�&B�&F�&F�)�'+�#�'.�&>�&>��O�O�-�-�.A�B�'D�#�)<�!��t�(�(�)�A�-�(,�(A�(A�!�(D�D�%�(/�(@�(@��O�O�*�*�>�:�)<�
�� ��}�}�+�+�/�/��@�@� $�
�
� <� <� @� @�#�!%�%*�U�W��!7�
����F�G� '� 8� 8��O�O�-�-�n�=�!?�
�$1��"��M�M�(�(�,�,�-=�>� @���&'��#�*1�*B�*B��O�O�%�%�&9�:�+<��!�!"����$�$�&�7�7����)�)�+�6� 8�D��$+�#;�#;��O�O�%�%�n�5�$7���CG�� �&(���")�":�":��O�O�%�%�l�3�#5����!�!��$�$����)�)�*:�;�
=�"�	"�	$�6:���)-���',��$�',��$������
���
�$���9=�t�����$�$����)�)�*@�A�
C��$�$����.�.�/F�G�
I�#����"�"�1�%�-��}�}�+�+�/�/�0G�H�H�-1�]�]�-I�-I�-M�-M�+�.-�-2�U�W��.?��'�'��*��"�"�1�%�-�)0�)A�)A����)�)�*A�B�*D�D�#�#�A�&�9=�d�|����$�$����)�)�*?�@�
B��$�$����.�.�/E�F�
H�"����!�!�!�$�,��}�}�+�+�/�/�0F�G�G�,0�M�M�,H�,H�,L�,L�*�-,�,1�E�G�v�->��&�&�q�)��!�!�!�$�,�(/�(@�(@����)�)�*@�A�)C�D�"�"�1�%�'.�&>�&>��O�O�*�*�<�8�':�����}�}�+�+�/�/�
�>�>�"�m�m�:�:�>�>�!�#�#(�5�7�f�5��&�6�6��O�O�-�-�l�;�=��"-��*1�)A�)A��O�O�%�%�&9�:�*<��!�'.�&>�&>��O�O�*�*�<�8�':�����}�}�+�+�/�/�
�>�>�"�m�m�:�:�>�>�!�#�#(�5�7�f�5�����D�E�%�6�6��O�O�-�-�l�;�=��"-��-4�-E�-E��O�O�*�*�+=�>�.@���%��}�}�+�+�/�/�0D�E�E�%)�]�]�%A�%A�%E�%E�(�&*�*/�%�'�V�&<�"����K�L�%,�%=�%=��O�O�-�-�.@�A�&C�"�);� ���� ���35��0�57��2�=?���EG��!�
$&��
�4$&��
�"#���"&��M�M�(�(�,�,�^�<�#>���&�6�6��O�O�%�%�i�0�2��
�'.�&>�&>��O�O�*�*�=�9�';����"�;�;��
�
��L�
�1�_��L�L�:�L�
J�".��
$�4�4��O�O�*�*�<�8�:������$��}�}�+�+�/�/�
�>�J�$(�M�M�$@�$@�$D�$D�!�%#�#(�5�7�f�%5��!����$� '� 8� 8����)�)�,�7�!9�D��;=��!�$+�$C�$C��O�O�T�]�]�%,��!� '�7�7��O�O�-�-�.C�D� F����1�b�\�E��,�,�)�U�Q�Y�7�9�9�"%�e�_�_�"=����	"�
)0�(@�(@��O�O�*�*�+@�A�)C���%�,�O�%,�%=�%=��O�O�*�*�+C�D�&F�����-�-�7�7�9�K�!,��"�3�3��O�O�*�*�=�9�;���!�����-���F� �1�1��O�O�*�*�;�7�9�������u��=�!�6�6�8�����%��/�0��<�=�'?���%��0�1��=�>�(@��#�&��5�6��J�K�,M��#�&��6�7��J�K�-M���%��3�4��F�G�
 I�W6(
��$�p!��~�&��.�/�!��!�!�"?�@�B�"�:�:�
"
����=�=�$�$�$� �#�)��y�\� �!:�;�%=� �#�$)�%-�)��y�\� �!:�;�$=�*�D�&�& �#�d�l�l�2�)��x�[� �!9�:�%<� �#�d�l�l�2�,��w�Z� �!8�9�$;�
*�D�&�&��|�_��,�-�!��!�!�"<�=�?�"�8�8�
 
�����)��6���:�;�!=���)��6���:�;�!=�
(
��$�!��~�&��.�/�!��!�!�"7�8�:�"�:�:�
"
�����(��6���>�?�&A��"�(��6���>�?�&A�
-
��)�&��*�+��3�4�!��!�!�"<�=�?�"�?�?�
'
��#��&�&��7���3�4�!6��&�%��8���4�5�"7�
'
��#� ��}�%��-�.�!��!�!�"6�7�9�"�9�9�
!
����&�&��0�1��8�9�(;��&�&��/�0��8�9�';�
+
��'�$��(�)��1�2�!��!�!�":�;�=�"�=�=�
%
��!��!�$��5�6��B�C�
#E��!�%��3�4��=�>�
$@�(
��$�"!��~�&��.�/�!��!�!�"7�8�:�"�:�:�
"
����#�%��8���K�L�
	&M��#�%��8���K�L�
&M�+
��'�*$��)�*��1�2�!��!�!�":�;�=�"�=�=�
%
��!�	
���� !��� $�	�	����$7��!�"3����
�
��&�:�:�
�t�!�!� #���	
���(�$�*E�*E�F����D�	F��w�:�&�	!��a�&�K�	!�s�(Ae�eAe4�e3Ae4c��[R"5nUR5 URUR5 URUR5 URS5 URS5 [SS5H�nSnURSUS--(amURSUS--Sn[R"U5nUnUR(a,URRS5(dURnUR![R"R%U55 M� U$)z
Get a new lookup table
Trr�rZr�r0�KP_)r�LookupTable�clear�
set_page_sizer*�set_orientationr.�set_cursor_visible�	set_roundr+r�r��keybinding_to_keyevent�unicode�name�
startswith�append_label�Text�new_from_string)rB�lookup_tablerDr��
keybindingr�s      rr1�TabEngine.get_new_lookup_table�s���'�'�)�������"�"�4�?�?�3��$�$�T�%6�%6�7��'�'��-����t�$��1�b�\�E��E�� � �!6�%�!�)�!D�E�!�.�.�)�U�Q�Y�7�9�9:�<�
��4�4�Z�@��"���;�;�s�x�x�':�':�5�'A�'A��K�K�E��%�%�d�i�i�&?�&?��&F�G�"��rc���[S:�a[RS5 UR5 /Ul/UlSUlSUlSUlUR5 g)u8
Clear all input, whether committed to preëdit or not.
r0zclear_all_input_and_preedit()rrZFN)
r�r�r��$clear_input_not_committed_to_preeditrr r!rr�update_candidates�rBs r�clear_all_input_and_preedit�%TabEngine.clear_all_input_and_preedit�sU����?��L�L�8�9��1�1�3���
���
�!"������$������ rc�:�URUR-S:H$)u[Checks whether the preëdit is empty

Returns True if the preëdit is empty, False if not.
rZ�rrr`s r�is_empty�TabEngine.is_empty�s ��
� � �4�#6�#6�6�"�<�<rc��[S:�a[RS5 SUlSUlSUlSUlURR5 URRS5 /Ul
/Ulg)u?
Clear the input which has not yet been committed to preëdit.
r0z&clear_input_not_committed_to_preedit()rZTN)r�r�r�rrrrr2rNrQrrr`s rr^�.TabEngine.clear_input_not_committed_to_preedit�sn����?��L�L�A�B���� ���35��0�57��2���� � �"����-�-�d�3����$&��!rr?c��UR(dvUR(d*UURUR-UR-;d;UR(a@UUR
UR-UR-;aU=RU-
slOU=RU-
slUR5nU$)un
Add input character and update candidates.

Returns “True” if candidates were found, “False” if not.
)rrr�r�rr�rr_)rBr?�ress   r�	add_input�TabEngine.add_input�s���
����
�
���0�0��5�5�6��4�4�5�5��M�M���7�7��5�5�6��4�4�5�5�
���4�'������%���$�$�&���
rc��SnUR(a$URSnURSSUlO�UR(a�URSnURSSUlUR(d{UR(ajURRURS-
5UlUR
RURS-
5 U=RS-slUR
5 U$)z'remove and display last input char heldrZ���Nr0)rrr�popr!r r_)rB�last_input_chars  r�	pop_input�TabEngine.pop_input�s��������"�1�1�"�5�O�"&�"5�"5�c�r�":�D��
�
�
�"�/�/��3�O� $� 1� 1�#�2� 6�D���%�%�4�=�=�$(�M�M�$5�$5��*�*�Q�.�%0��!��
�
�!�!�$�"8�"8�1�"<�=��&�&�!�+�&���� ��rc�4�URUR-$)z&get characters held, valid and invalidrdr`s r�get_input_chars�TabEngine.get_input_charss��� � �4�#6�#6�6�6rrD�index_in_phrasec��URUSUnURUUSnURRU5 URRU5 URRXRRU55 URRX5 URRUS-URRU55 URRUS-U5 g)Nr0)r rro�insertrP�parse_phrase)rBrDrv�head�tails     r�"split_strings_committed_to_preedit�,TabEngine.split_strings_committed_to_preedits����}�}�U�#�$4�_�5���}�}�U�#�O�$4�5���
�
���%� ��
�
���%� ��
�
���U�M�M�$>�$>�t�$D�E��
�
���U�)��
�
���U�1�W�d�m�m�&@�&@��&F�G��
�
���U�1�W�d�+rc�>�UR(agUR5(aUR5 UR(dgURS::agUR
URSUlURURSUlSUlg)uRemove preëdit left of cursorNr)rrt�commit_to_preeditr r!rr`s r�remove_preedit_before_cursor�&TabEngine.remove_preedit_before_cursors~���������!�!��"�"�$��}�}���!�!�Q�&���
�
�d�&<�&<�&=�>��
��
�
�d�&<�&<�&=�>��
�!"��rc��UR(agUR5(aUR5 UR(dgUR[UR5:�agURSURUlURSURUl[UR5Ulg)uRemove preëdit right of cursorN)rrtrr r!r�rr`s r�remove_preedit_after_cursor�%TabEngine.remove_preedit_after_cursor-s����������!�!��"�"�$��}�}���!�!�S����%7�7���
�
�&=�t�'=�'=�>��
��
�
�&=�t�'=�'=�>��
�!$�T�]�]�!3��rc��UR(agUR5(aUR5 UR(dgURS:agU=RS-slUR
R
UR5UlURR
UR5 UR5 g)u>Remove character before cursor in strings comitted to preëditNr0)	rrtrr r!rrorr_r`s r�&remove_preedit_character_before_cursor�0TabEngine.remove_preedit_character_before_cursor;s����������!�!��"�"�$��}�}���!�!�A�%�����!�#�� �M�M�-�-�d�.D�.D�E����
�
���$�0�0�1���� rc�x�UR(agUR5(aUR5 UR(dgUR[UR5S-
:�agURRUR5 URRUR5 g)u>Remove character after cursor in strings committed to preëditNr0)rrtrr r!r�rror`s r�%remove_preedit_character_after_cursor�/TabEngine.remove_preedit_character_after_cursorJs����������!�!��"�"�$��}�}���!�!�C��
�
�$6��$:�:���
�
���$�0�0�1��
�
���$�0�0�1r.c�
�SnSnSnUR5(aUR5nUR(aD[URSUR5n[URURS5nXU4$)u�Returns the tabkeys which were used to type the parts
of the preëdit string.

Such as “(left_of_current_edit, current_edit, right_of_current_edit)”

“left_of_current_edit” and “right_of_current_edit” are
strings of tabkeys which have been typed to get the phrases
which have already been committed to preëdit, but not
“really” committed yet. “current_edit” is the string of
tabkeys of the part of the preëdit string which is not
committed at all.

For example, the return value could look like:

(('gggg', 'aahw'), 'adwu', ('ijgl', 'jbus'))

See also get_preedit_string_parts() which might return something
like

(('王', '工具'), '其', ('漫画', '最新'))

when the wubi-jidian86 table is used.
rrZN)rtr�tupler!�rB�left_of_current_edit�current_edit�right_of_current_edits    r�get_preedit_tabkeys_parts�#TabEngine.get_preedit_tabkeys_partsWs���213����13�����!�!��/�/�1�L��=�=�#(��
�
�5�t�5�5�6�$8� �$)��
�
�d�4�4�5�6�%8�!�$�4I�J�Jrc�v�UR5unnnSRU5U-SRU5-$)uXReturns the tabkeys which belong to the parts of the preëdit
string as a single string
rZ)r�r�)rB�left_tabkeys�current_tabkeys�
right_tabkeyss    r�get_preedit_tabkeys_complete�&TabEngine.get_preedit_tabkeys_complete|sG���8�8�:�	��	�	�����&�"�#��7�7�=�)�*�	+rc��SnSnSnUR(a4UR[URR55SnO%UR	5(aUR	5nUR
(aD[
UR
SUR5n[
UR
URS5nXU4$)u�Returns the phrases which are parts of the preëdit string.

Such as “(left_of_current_edit, current_edit, right_of_current_edit)”

“left_of_current_edit” and “right_of_current_edit” are
tuples of strings which have already been committed to preëdit, but not
“really” committed yet. “current_edit” is the phrase in the part of the
preëdit string which is not yet committed at all.

For example, the return value could look like:

(('王', '工具'), '其', ('漫画', '最新'))

See also get_preedit_tabkeys_parts() which might return something
like

(('gggg', 'aahw'), 'adwu', ('ijgl', 'jbus'))

when the wubi-jidian86 table is used.
rrZr0N)rr�r2�get_cursor_posrtr r�r!r�s    r�get_preedit_string_parts�"TabEngine.get_preedit_string_parts�s���,13����13������+�+��D�&�&�5�5�7�8�:�:;�=�L�
�
!�
!�
#�
#��/�/�1�L��=�=�#(��
�
�5�t�5�5�6�$8� �$)��
�
�d�4�4�5�6�%8�!�$�4I�J�Jrc�"�UR(aEUR(a3UR[URR	55S$gUR5unnnSR
U5U-SR
U5-$)uOReturns the phrases which are parts of the preëdit string as a
single string

rrZ)rrr�r2r�r�r�)rB�left_strings�current_string�
right_stringss    r�get_preedit_string_complete�%TabEngine.get_preedit_string_complete�s���
�������'�'���*�*�9�9�;�<�>�>?�A�A���7�7�9�	��	�	�����%� �!��'�'�-�(�)�	*rc��SnUR(a?UR(a.URSURHnU[U5-
nM UR(aAU[UR[	UR
R
55S5-
nU$U[UR55-
nU$)u%Get caret position in preëdit stringrNr0)r!r r�rr�r2r�rt)rB�caret�parts   r�	get_caret�TabEngine.get_caret�s������!�!�d�m�m��
�
�&=�t�'=�'=�>����T��"��?�����S�� � ��T�%7�%7�%F�%F�%H�!I�J�1�M�O�
O�E���
�S��-�-�/�0�0�E��rc��UR(agUR5(aUR5 UR(dgURS::ag[URURS-
5S::aU=RS-slOUR
URS-
S5 UR5 g)u(Move cursor left in the preëdit string.Nrr0rn�rrtrr r!r�r|r_r`s r�
arrow_left�TabEngine.arrow_left�s����������!�!��"�"�$��}�}���!�!�Q�&���t�}�}�T�3�3�A�5�6�7�1�<��"�"�a�'�"��3�3��&�&�q�(�"�
.���� rc��UR(agUR5(aUR5 UR(dgUR[UR5:�agU=RS-
sl[URURS-
5S:�aUR
URS-
S5 UR5 g)u)Move cursor right in the preëdit string.Nr0r�r`s r�arrow_right�TabEngine.arrow_right�s����������!�!��"�"�$��}�}���!�!�S����%7�7�����!�#���t�}�}�T�3�3�A�5�6�7�!�;��3�3��&�&�q�(�!�
-���� rc���UR(agUR5(aUR5 UR(dgSUlUR5 g)u4Move cursor to the beginning of the preëdit string.Nr)rrtrr r!r_r`s r�control_arrow_left�TabEngine.control_arrow_left�sG���������!�!��"�"�$��}�}��!"������ rc���UR(agUR5(aUR5 UR(dg[	UR5UlUR
5 g)u-Move cursor to the end of the preëdit stringN)rrtrr r�r!r_r`s r�control_arrow_right�TabEngine.control_arrow_right�sP���������!�!��"�"�$��}�}��!$�T�]�]�!3������ r�tabkeys�phrase�freq�	user_freqc	��URS:Xde[S:�a[RSXX45 U(aU(dgURnUR
nU(aXPR;dU(aX`R;aUnOXURn[R"U5n[R"SU-U5n	U	(aXR5SnOUn[S:�a![RSXpRU5 Sn
UR(d3SnUH)nX�R;aX�RU-
nM%X�-
nM+ UnUS-U-n
U
(aU
S-U
-n
[R"5nUR[R "UR"S	S
[%U
555 US
:a>UR[R "UR"SS
[%U555 O�US
:�a>UR[R "UR"SS
[%U555 O=UR[R "UR"S
S
[%U555 [S
:�asS['U5-S-['U5-nX�-
n
UR[R "UR"S[%U
5[%U5-
[%U
555 [R(R+U
5nS
nUR-U5bvUR-U5nUR/UR15UR35UR55UR755 US-
nUR-U5bMvUR8R;U5 UR8R=S5 g)z&append table candidate to lookup tabler0�)tabkeys=%s phrase=%s freq=%s user_freq=%sN�^�3remaining_tabkeys=%s self._chars_valid=%s phrase=%srZr[�   r$rr&r%r'r(T)rr�r�r�rr�r�re�escape�match�endrr#r�AttrList�append�attr_foreground_newr�r�r�rXrYr��append_attribute�
get_attr_typer��get_start_index�
get_end_indexr2�append_candidaterQ)rBr�r�r�r��mwild�swild�remaining_tabkeys�regexpr��
table_code�remaining_tabkeys_newr?r$�attrsr(�text�i�attrs                   r�append_table_candidate� TabEngine.append_table_candidatesK�����1�$�$�$���?��L�L�;���
2��f���)�)���*�*��
�u� 1� 1�1��e�'8�'8�8� '���&�&�F��Y�Y�v�&�F��H�H�T�F�]�G�4�E��$+�I�I�K�L�$9�!�%,�!���?��L�L�1�!�#4�#4�f�
>��
��}�}�$&�!�)���2�2�2�)�-D�-D�T�-J�J�)�)�1�)�	*�
!6���#��(9�9���+�e�3�j�@�N��
�
���
���T�-�-��J�J�'�(�!�S��-@�B�	C��!�8��L�L��(�(��J�J�}�-�q�#�f�+�?�
@���]��L�L��1�1��
�
�?�+�Q��F��=�
>�
�L�L��1�1��
�
�1�2�A�s�6�{�D�
E���?��s�4�y��3�.��Y��?�J��(�N��L�L��1�1��
�
�<�(��N�#�c�*�o�5��N�#�%�
&��y�y�(�(��8��
���i�i��l�&��9�9�Q�<�D��!�!�$�"4�"4�"6�"&�.�.�"2�"&�"6�"6�"8�"&�"4�"4�"6�
8�
��F�A�
�i�i��l�&�	
���+�+�D�1����-�-�d�3r�asc_table_codesc�p�/nSnSn[[U55H�n[U5nXnUS-
nSnUS:�a�Xn	[U	5nUS-
nUS:�akX�n
URU
S5(aAX�S-
:XaU	RXdU
SS-45 OXx4XdU
SS-4/nURU5 O
US-nUS:�aMkUS:�aO
US-nUS:�aM�US:XdM�Xx4XdS4/nURU5 M� UVs/sHo�SPM	 n
n[	U
SSS9n
U
V
s/sHo�SPM	 nn
U$s snfs sn
f)Nrnr0rr4c�B�[US5S-[US5-$)Nr4rLr0�r�)�ns rr�9TabEngine.get_common_prefix_sorted_list.<locals>.<lambda>�s��S��1��Y��^�c�!�A�$�i�%?rT)r��reverse)r+r�rVr��sorted)r��prefix_tree�idx�count�code_idx�branch_countrE�
branch_idx�node_idx�
prefix_branch�node�
new_branch�branch�nodes�	idx_arrays               r�get_common_prefix_sorted_list�'TabEngine.get_common_prefix_sorted_list\s���35������	��c�/�2�3�H��{�+�L�"�,�D�%��)�J��H���/� +� 7�
�"�=�1��'�!�+����l�(�2�D����t�A�w�/�/�#�a�'7�7�)�0�0�$�$�q�'�A�+�1N�O�,6�*@�4�SW�XY�SZ�]^�S^�B_�)`�J�'�.�.�z�:��!�A�
����l�"�a�<���!�O�J�5��/�8�1�}�)�4�t�q�6I�J�
��"�"�:�.�M4�R+6�6�+����+��6��u�?�#�%��*/�/���!�W��	�/����7��0s�<D.�D3�sorted_idx_listc�`�URS:XaUHnXSnUS;aMUs $ US$)Nzerbi-qsr)r��u�v)r�)rBr�r�r��
first_chars     r� select_best_idx_from_prefix_list�*TabEngine.select_best_idx_from_prefix_list�sD�����	�)�$��,�/��2�
���0���H�%��q�!�!rc	��URS:XdeUR(de[S:�a[R	SXX45 U(aU(dgUR
n[R"U5n[R"SU-U5nU(aXR5SnOUn[S:�a![R	SXpR
U5 SnURR(a�UR(a�URSS5RS	S
5RSS5RS
S5RSS5nURRU5n	U	(a&URU	5n
URX�5nX�nSnUH)n
X�R ;aX�R U
-
nM%X�-
nM+ UnUS-U-nU(aUS-U-n["R$"5nUR'["R("UR*SS[-U555 UR'["R("UR*SS[-U555 [S:�atS[/U5-S-[/U5-nUU-
nUR'["R("UR*S[-U5[-U5-
[-U555 ["R0R3U5nSnUR5U5bvUR5U5nUR7UR95UR;5UR=5UR?55 US-
nUR5U5bMvUR@RCU5 UR@RES5 g)z'append pinyin candidate to lookup tabler0r�Nr�r�rZ�!u↑1�@u↑2�#u↑3�$u↑4�%u↑5r[r�r$rr%r(T)#rrr�r�r�rr�r�r�r�rPr4r��find_zi_coder�r�r#rr�r�r�r�r�r�rXrYr�r�r�r�r�r�r2r�rQ)rBr�r�r�r�r�r�r�r��possible_table_codesr�r��table_code_newr?r$r�r(r�r�r�s                    r�append_pinyin_candidate�!TabEngine.append_pinyin_candidate�sR�����1�$�$�$��}�}��}���?��L�L�;���
2��f���"�"�����6�"������f��g�.��� '�	�	��� 5��!(����?��L�L�1�!�#4�#4�f�
>�
�
��=�=�$�$���� 1� 9� 9��V�!�$�W���!�!(���V�"%�%,�W���&)�)0�� #�V�*-�	
�$$(�=�=�#=�#=�f�#E� �#� �>�>�?S�T�	��;�;�<P�\��1�6�
��N�"���2�2�2�"�&=�&=�d�&C�C�N�"�*�N�	#�
(�J��#��(9�9���+�e�3�j�@�N��
�
���
���T�-�-��J�J�'�(�!�S��-@�B�	C�	���T�-�-��J�J��'��C��K�9�	:���?��s�4�y��3�.��Y��?�J��j�(�N��L�L��1�1��
�
�<�(��N�#�c�*�o�5��N�#�%�
&��y�y�(�(��8��
���i�i��l�&��9�9�Q�<�D��!�!�$�"4�"4�"6�"&�.�.�"2�"&�"6�"6�"8�"&�"4�"4�"6�
8�
��F�A�
�i�i��l�&�	
���+�+�D�1����-�-�d�3r�prefixc	��URS:XdeUR(de[S:�a[R	SXX45 U(aU(dgURU5(dgUn[R"5nUR[R"URSS[U555 UR[R"URSS[U555 [S:�asS[U5-S-[U5-nXW-
nUR[R"URS[U5[U5-
[U555 [RRU5nSn	URU	5bvURU	5n
UR!U
R#5U
R%5U
R'5U
R)55 U	S-
n	URU	5bMvUR*R-U5 UR*R/S	5 g)
z+append suggestion candidate to lookup tabler0r�Nr$rr%r[r(T)rrr�r�r�rVrr�r�r�r�r�r�rXrYr�r�r�r�r�r�r2r�rQ)rBr�r�r�r�r$r�r(r�r�r�s           r�append_suggestion_candidate�%TabEngine.append_suggestion_candidates������1�$�$�$��}�}��}���?��L�L�;���
1��V��� � ��(�(�����
�
���
���T�-�-��J�J�'�(�!�S��-@�B�	C�	���T�-�-��J�J��'��C��K�9�	:���?��s�4�y��3�.��Y��?�J��(�N��L�L��1�1��
�
�<�(��N�#�c�*�o�5��N�#�%�
&��y�y�(�(��8��
���i�i��l�&��9�9�Q�<�D��!�!�$�"4�"4�"6�"&�.�.�"2�"&�"6�"6�"8�"&�"4�"4�"6�
8�
��F�A�
�i�i��l�&�	
���+�+�D�1����-�-�d�3r�forcec
�~�[S:�al[RSURURUR
URURURRUR5 U(dZUR(dIURUR
:Xa/URUR:Xa[UR5$URUlURUlURR5 URRS5 UR(d;UR(dUR(d/UlURUlgUR(dvUR"(aeURR$(aJURR'URUR(UR*UR,S9UlO�UR(dkURR/URUR0UR(UR*UR,UR2UR4S9UlOOUR(a<UR6(a+URR9UR:5UlOeUR(d�URUR*UR,4;a�URnURn[=U5(a,UR>S(a[AU5nO7[CU5nO+URDS(a[AU5nO[CU5nURRGSX#SS45 UR(a"URI5 URUlgUR(aXU=RURS	-
slURS
S	UlURUlURUlg)u�
Searches for candidates and updates the lookuptable.

:param force: Force update candidates even if no change to input

Returns “True” if candidates were found and “False” if not.
r0z�self._chars_valid=%s self._chars_invalid=%s self._chars_valid_update_candidates_last=%s self._chars_invalid_update_candidates_last=%s self._candidates=%s self.database.startchars=%s self._strings=%sTF)r�rCrmro)r�r�rCrmrorqrkriʚ;rnN)%r�r�r�rrrrrrP�
startcharsr rr!r2rNrQrrr4�#select_chinese_characters_by_pinyinr&r�r�select_wordsr$rr�r�select_suggestion_candidaterr"rrIrKrrx�fill_lookup_table)rBr�wildcard_key�wildcard_phrases    rr_�TabEngine.update_candidates@sM����?��L�L�#��!�!��#�#��8�8��:�:�� � ��
�
�(�(��
�
�
��d�2�2�����!I�!I�I����4�#M�#M�M���(�(�)�)�37�3D�3D��0�59�5H�5H��2���� � �"����-�-�d�3��#�#��"�"�$�*;�*;�#%�� �,0�,<�,<��)���$�$��
�
��
�
�)�)��
�
�A�A� �-�-�!%�!3�!3�)-�)C�)C�(,�(A�(A�	B�C�
���%�%�#�}�}�9�9��)�)��
�
�!�/�/�%)�%?�%?�$(�$=�$=�"�1�1�#�3�3� :� 5�D���
!�
!�d�m�m�#�}�}�H�H���� �D��
�5��#�#��!�!��.�.��0I�0I�J�K�#�0�0��"&�"3�"3�� ��.�.��-�-�a�0�*>��*O��*>��*O���.�.�q�1�*>��*O��*>��*O��� � �'�'���q�*�E�G�����"�"�$�(,�(8�(8�D�%��������4�#4�#4�R�#8�8�� $� 1� 1�#�2� 6�D��7;�7H�7H�D�4�9=�9L�9L�D�6�rc�h�UR(dUR(dgUR(Ga]UR(d�URUR5SnURRURURUR5S5 URRURU5 XlO�UR(a�URUR5SnU[UR5SnURRURS5 URRURU5 SUlSUlOeU=RS-
slUR5 UR5 g)u6Add selected phrase in lookup table to preëdit stringFr0rNrZT)rrrr�rrxr!r rr�r^r_)rBr�s  rr�TabEngine.commit_to_preedit�s]���#�#��$�$�������'�'��)�)�$�*=�*=�*?�@��C���
�
�$�$��*�*��$�$�T�%8�%8�%:�;�A�>�@��
�
�$�$��*�*�F�4�%���%�%��)�)�$�*=�*=�*?�@��C����D�L�L� 1� 2�3���
�
�$�$�T�%;�%;�%'�)��
�
�$�$�T�%;�%;�%+�-�!���',��$��u��"�"�a�'�"��1�1�3���� �rc��URR5nURR5nX#-
nXA-nU[UR5:�agURRU5 UR
5$)u�
Commits the candidate at position “index” in the current
page of the lookup table to the preëdit. Does not yet “really”
commit the candidate, only to the preëdit.
F)r2r��get_cursor_in_pager�r�set_cursor_posr)rBrD�
cursor_pos�cursor_in_page�current_page_start�
real_indexs      r�commit_to_preedit_current_page�(TabEngine.commit_to_preedit_current_page�sv���'�'�6�6�8�
��+�+�>�>�@��'�8��'�/�
���T�-�-�.�.�����)�)�*�5��%�%�'�'rc��UR5nU(GaGUn[S:�a�UR(a�UR5unnnUR	5unnnSn[S[
U55Hn	USX9-S-Xi-S--
nM X!-
n[S[
U55Hn	USXY-S-X�-S--
nM UR(aTURSS	5RS
S5RSS
5RSS5RSS5nU$Sn
UH)nX�R;aX�RU-
n
M%X�-
n
M+ U
nU$SnUR(a|UR[
UR5:�aURSSnOURURSnSRURRU55nSRUR5nURR(a0[
U5S:�a!USURR!U5--
nSn
UH)nX�R;aX�RU-
n
M%X�-
n
M+ U
$)zGet aux stringsrrZ�(r[z) z (�)r��1r��2r��3r��4r��5rnr0z	#: )rtr�rr�r�r+r�rr�r#r r!r�rPr��user_can_define_phrasery)
rB�input_chars�
aux_string�tabkeys_left�dummy_tabkeys_current�
tabkeys_right�strings_left�dummy_string_current�
strings_rightr��aux_string_newr?�cstrs
             r�get_aux_strings�TabEngine.get_aux_strings�s����*�*�,���$�J��Q��4�=�=�#'�"@�"@�"B� ��&��#'�"?�"?�"A� ��%���
��q�#�l�"3�4�A���&�/�*�,/�0�1=��A��� �J�5�
�)�
��q�#�m�"4�5�A���'�*�+�+.�/�/<�/?�@����J�6�
�}�}�'�/�/����%�g��S�"�")�'���#&�&-�g� #�S�'*�*1�'�$'��+.�	���"$��&�D��6�6�6�&�*A�*A�$�*G�G��&�.��	'�
,�
����
��=�=��%�%��T�]�]�);�;��}�}�R�(��+���}�}�T�%;�%;�<�Q�?�����$�-�-�"<�"<�T�"B�C�J��w�w�t�}�}�%���=�=�/�/��4�y�1�}��w����)C�)C�D�)I�I�J�
����D��.�.�.��"9�"9�$�"?�?���&��	�
�rc	��URR5nURR5nURR5U-U:�Ga+U[	UR
5:GaX-nUR
XnUH�nUR(aBUR(d1UR(d URUSUSUSUSS9 MVUR(aBUR(a1UR(d URUSUSUSUSS9 M�UR(a=UR(a,URURUS[US5S9 M�e ggg)z�Fill more entries to self._lookup_table if needed.

If the cursor in _lookup_table moved beyond current length,
add more entries from _candidiate[0] to _lookup_table.rr0r4r�)r�r�r�r�)r�r�r�N)r2�get_number_of_candidates�
get_page_sizer�r�rrrrr�r�rrr�)rB�looklen�psize�endpos�batch�	candidates      rr	�TabEngine.fill_lookup_table$s^���$�$�=�=�?���"�"�0�0�2�����-�-�/�%�7�7�B��#�d�.�.�/�/��_�F��$�$�W�4�E�"�	��$�$� �M�M�$�2F�2F��/�/� )�!��(��|�&�q�\�"+�A�,�	0�0�
�&�&��-�-��0D�0D��0�0� )�!��(��|�&�q�\�"+�A�,�	1�0�
�%�%�$�*>�*>��4�4�#�|�|�(��|� ��1��.�5�0�
!�5�+#�0�
Crc��UR5 [URR55nU(dUR(agU$)z:Process Arrow Down Key Event
Move Lookup Table cursor downT)r	r!r2�cursor_downr�rBrjs  rr7�TabEngine.cursor_downGs<��	
��� ��4�%�%�1�1�3�4���t�'�'���
rc�~�[URR55nU(dUR(agU$)z6Process Arrow Up Key Event
Move Lookup Table cursor upT)r!r2�	cursor_uprr8s  rr;�TabEngine.cursor_upQs0���4�%�%�/�/�1�2���t�'�'���
rc��UR5 [URR55nU(dUR(agU$)z7Process Page Down Key Event
Move Lookup Table page downT)r	r!r2�	page_downrr8s  rr>�TabEngine.page_downYs<��	
��� ��4�%�%�/�/�1�2���t�'�'���
rc�~�[URR55nU(dUR(agU$)z3Process Page Up Key Event
move Lookup Table page upT)r!r2�page_uprr8s  rrA�TabEngine.page_upbs0���4�%�%�-�-�/�0���t�'�'���
rc��[S:�a[RSU5 URR	5nURR5nX#-
nXA-n[
UR5U:�aOURUnURRUSUSSS9 SUl
SUlUR5 gg)u�Remove the candidate shown at index in the lookup table
from the user database.

If that candidate is not in the user database at all, nothing
happens.

If this is a candidate which is also in the system database,
removing it from the user database only means that its user
frequency data is reset. It might still appear in subsequent
matches but with much lower priority.

If this is a candidate which is user defined and not in the system
database, it will not match at all anymore after removing it.

:param index: The index in the current page of the lookup table.
              The topmost candidate has the index 0 (and usually the
              label “1”)
:return: True if successful, False if not
r0zindex=%srT)r�r��commitrZF)
r�r�r�r2r�rr�rrP�
remove_phraserrr_)rBrDrrrrr4s       r�#remove_candidate_from_user_database�-TabEngine.remove_candidate_from_user_databasejs���(��?��L�L��U�+��'�'�6�6�8�
��+�+�>�>�@��'�8��'�/�
��t��� �:�-��(�(��4�I��M�M�'�'�!�!��Y�q�\�$�
(�
H�8:�D�4�9;�D�6��"�"�$��rc�H�[URR55$)z get lookup table cursor position)r�r2r�r`s rr��TabEngine.get_cursor_pos�s���4�%�%�4�4�6�7�7rc��UR$)zGet lookup table)r2r`s r�get_lookup_table�TabEngine.get_lookup_table�s���!�!�!rc��[S:�a[RS5 UR5(aUR	5 gUR5 g)zProcess remove_char Key Eventr0z
remove_char()N)r�r�r�rtrqr�r`s r�remove_char�TabEngine.remove_char�s=����?��L�L��)����!�!��N�N����3�3�5rc�P�UR5(agUR5 g)zProcess delete Key EventN)rtr�r`s r�delete�TabEngine.delete�s �����!�!���2�2�4rc�&�[UR5nUS:�avURR5nURR	5n[X2-5nUS-
nX4S-U-:�dX1:�aXB-nURR
U5 gg)z+Cycle cursor to next candidate in the page.rr0TF)r�rr2r/r�r�r�rB�total�	page_size�pos�pages     r�%select_next_candidate_in_current_page�/TabEngine.select_next_candidate_in_current_page�s����D�$�$�%���1�9��*�*�8�8�:�I��$�$�3�3�5�C��s�}�%�D��1�H�C��A�v�y�(�(�C�L��n�����-�-�c�2��rc�D�[UR5nUS:�a�URR5nURR	5n[X2-5nUS-nX4U-:dUS:a[
US-U-S-
U5nURRU5 gg)z/Cycle cursor to previous candidate in the page.rr0TF)r�rr2r/r�r�r,rrTs     r�)select_previous_candidate_in_current_page�3TabEngine.select_previous_candidate_in_current_page�s����D�$�$�%���1�9��*�*�8�8�:�I��$�$�3�3�5�C��s�}�%�D��1�H�C��)�^�#�s�Q�w��D�1�H�	�1�Q�6��>�����-�-�c�2��rc�2�[UR5S:H$)z*Return true if there is only one candidater0)r�rr`s r�
one_candidate�TabEngine.one_candidate�s���4�#�#�$��)�)rc�n�UR5 SUlSUlSUlUR	5 g)u6Clear the preëdit and close the lookup table
        FN)rar
rr�
_update_uir`s rr=�TabEngine.reset�s1��	
�(�(�*�',��$�',��$�������rc�2>�URS:�a'[R"UR5 SUlUR5 UR	5 UR
S:�a!URR5 SUl[TU]%5 g)z3Called when this input engine is destroyed
        rN)
r@r�
source_remover=�do_focus_outr6rP�
sync_usrdbr��destroy)rBrIs �r�
do_destroy�TabEngine.do_destroy�st������!�#��!�!�$�"6�"6�7�#$�D� ��
�
������� � �1�$��M�M�$�$�&�$%�D�!�
���r�debug_levelrzc�8�[S:�a[RSX5 XR:XagSUs=::aS::a]O gXlUqUR	5 U(a:UR
R
S[RRU55 ggg)a�Sets the debug level

:param debug_level: The debug level (>= 0 and <= 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.
r0�(%s, update_gsettings = %s)Nrrirh)
r�r�r�r�r=r��	set_valuer�Variant�	new_int32)rBrkrzs   r�set_debug_level�TabEngine.set_debug_level�s�����?��L�L�-�{�
N��+�+�+����"�s�"� +��%�K��J�J�L�����)�)� ��L�L�*�*�;�7�9� �	#rc��UR$)zReturns the current debug level)r�r`s r�get_debug_level�TabEngine.get_debug_level����� � � rrkc�&�[S:�a[RSX5 XR:XagXlURR5 U(a:URRS[RRU55 gg)a�Sets whether dynamic adjustment of the candidates is used.

:param dynamic_adjust: True if dynamic adjustment is used, 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.
r0rmNrj)r�r�r�r�rP�reset_phrases_cacher�rnrro�new_boolean)rBrkrzs   r�set_dynamic_adjust�TabEngine.set_dynamic_adjustss����?��L�L�-��
2��1�1�1��-���
�
�)�)�+���O�O�%�%�����(�(��8�
:�rc��UR$)z=Returns whether dynamic adjustment of the candidates is used.)r�r`s r�get_dynamic_adjust�TabEngine.get_dynamic_adjusts���#�#�#r�error_soundc���[S:�a[RSX5 XR:XagXlU(a:URRS[RRU55 gg)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.
r0rmNrw)	r�r�r�r	r�rnrrory)rBrrzs   r�set_error_sound�TabEngine.set_error_soundsa����?��L�L�-�{�
N��+�+�+��'����O�O�%�%�����(�(��5�
7�rc��UR$)z1Returns whether a sound is played on error or not)r	r`s r�get_error_sound�TabEngine.get_error_sound2rvrr]c�r�[S:�a[RSX5 XR:XagXlU(a9URRS[RRU55 [R"[RRU5URS9Ulg)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.
r0rmNrx��
audio_backend)r�r�r�rr�rnrro�
new_string�it_sound�SoundObjectr�r]�
expanduserrr)rBr]rzs   rr
�TabEngine.set_error_sound_file6s�����?��L�L�-�t�
G��)�)�)��!%����O�O�%�%� ����'�'��-�
/�$,�#7�#7��G�G���t�$��-�-�$/�� rc��UR$)z>
Return the path of the .wav file containing the error sound.
)rr`s r�get_error_sound_file�TabEngine.get_error_sound_filePs���%�%�%r�
sound_backendc��[S:�a[RSX5 [U[5(dgXR
:XagXlU(a9URRS[RRU55 [R"[RRUR 5UR
S9Ulg)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.
r0rmNrvr�)r�r�r��
isinstancer�rr�rnrror�r�r�r�r]r�rr)rBr�rzs   r�set_sound_backend�TabEngine.set_sound_backendVs�����?��L�L�-�}�
P��-��-�-���/�/�/��+����O�O�%�%�����'�'�
�6�
8�$,�#7�#7��G�G���t�5�5�6��-�-�$/�� rc��UR$)z5
Return the name of the currently used sound backend
)rr`s r�get_sound_backend�TabEngine.get_sound_backendss���"�"�"rr�c
�<�[S:�a[RSX5 [U[5(dg[
R"U5n[
R"UR5Ul[R"URU5 [R"UR5UlUR5UlUR(Ga�UR (a%[#URS5UR S'UR$(a%[#URS5UR$S'UR&(a%[#URS5UR&S'UR((a%[#URS5UR(S'UR*(a%[#URS	5UR*S'UR,(a%[#URS
5UR,S'UR.(a%[#URS5UR.S'UR0(a%[#URS5UR0S'UR35 U(a�[4R6"[4R8"S
055n[;UR5H�n[4R8R=[4R>"S5URUVs/sH"n[4R8RAU5PM$ sn5nURCXF5 M� URDRGSURI55 ggs snf)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.
r0rmNr�r�r�r�r�r�r�r�r�za{sv}�sr�)%r�r�r�r��dict�copy�deepcopyr'r�r��dict_update_existing_keys�HotKeysr�r1r2r�r�r3r�r�r�r�r�r�r�r5r�VariantDictror��	new_array�VariantTyper��insert_valuer�rnr�)rBr�rz�variant_dict�command�x�
variant_arrays       rr/�TabEngine.set_keybindingsys�����?��L�L�-�{�
N��+�t�,�,���m�m�K�0�� �M�M�$�*C�*C�D����)�)�$�*;�*;�[�I�����(9�(9�:��
�"�6�6�8����?�?�?��%�%���*�*�+H�I�J��&�&��7��#�#���*�*�+E�F�G��$�$�_�5��%�%���*�*�+@�A�B��&�&��7��*�*���*�*�+E�F�G��+�+�O�<��$�$���*�*�+?�@�A��%�%�o�6��(�(���*�*�+C�D�E��)�)�/�:��%�%���*�*�+@�A�B��&�&��7��(�(���*�*�+C�D�E��)�)�/�:��!�!�#���+�+�D�L�L��"�,E�F�L�!�$�"3�"3�4�� $��� 6� 6��$�$�S�)�"�/�/��8�:�8���\�\�,�,�Q�/�8�:�!;�
��)�)�'�A�5�
�O�O�%�%��� � �"�
$���
:s�()Nc�6�URR5$)zGet current key bindings)r�r�r`s r�get_keybindings�TabEngine.get_keybindings�s��� � �%�%�'�'r�
input_modec��XR:XagXlU(aCURRS[RRUR55 UR
URUR5 UR
URURUR5 UR
URURUR5 UR5 g)z�Sets whether direct input or the current table is used.

:param input_mode: Whether to use direct input.
                   0: Use direct input.
                   1: Use the current table.
Nru)
rr�rnrrorp�_init_or_update_property_menur�r�rr�rr=)rBr�rzs   r�set_input_mode�TabEngine.set_input_mode�s����)�)�)��%����O�O�%�%�����&�&�t�'7�'7�8�
:�	
�*�*�� � ����	�	
�*�*��"�"��#�#�D�$4�$4�5�	7�	
�*�*��'�'��"�"�4�#3�#3�4�	6�	
�
�
�r�remember_input_modec���[RSX5 [U5nXR:XagXlU(a:URRS[RRU55 gg)a!Sets whether the input mode (direct or table) is remembered

:param remember_input_mode: Whether to remember the input mode.
                            False: Do not remember
                            True:  Remember.
: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.
rmNrt)	r�r�r!rr�rnrrory)rBr�rzs   r�set_remember_input_mode�!TabEngine.set_remember_input_mode�sh��	���)�+>�	R�"�#6�7���";�";�;��$7�!���O�O�%�%�#����(�(�)<�=�
?�rc��UR$)z.
Return whether the input mode is remembered.
)rr`s r�get_remember_input_mode�!TabEngine.get_remember_input_mode	s���(�(�(rrHc��U(a[nO[nX0RLaX0lUR5 U(a:URRS[RRU55 gg)z"Set theme to dark theme on requestr�N)	r.r-r�rbr�rnrrory)rBrHrzr�s    rr0�TabEngine.set_dark_theme	sY��
��E��E��
�
�"��J��O�O����O�O�%�%�����(�(��8�
:�rc��UR$)zA
Return the current input mode, direct input: 0, table input: 1.
)rr`s r�get_input_mode�TabEngine.get_input_mode	s�����r�modec��UR(dgXR:XagXlURURU5 U(a#URSSURSS'O"URSSURSS'URUR
UR5 UR5 g)z�Sets whether Pinyin is used.

:param mode: Whether to use Pinyin.
             True: Use Pinyin.
             False: Use the current table.
:type mode: Boolean
Nr�r�rbr�)r�rr�r�r�r�rrb�rBr�s  r�set_pinyin_mode�TabEngine.set_pinyin_mode	s����|�|���=�=� ���
��*�*��!�!�4�	)���*�*�+<�=�o�N�
�&�&�'8�9�(�C��*�*�+<�=�n�M�
�&�&�'8�9�(�C��*�*�� � ����	�	
���rc��UR$)zReturn the current pinyin mode)rr`s r�get_pinyin_mode�TabEngine.get_pinyin_mode:	����}�}�rc���UR(dgXR:XagUR5 XlURURU5 UR5 g)z�Sets whether Suggestion is used.

:param mode: Whether to use Suggestion.
             True: Use Suggestion.
             False: Not use Suggestion.
N)r�rrr�r�rbr�s  r�set_suggestion_mode�TabEngine.set_suggestion_mode>	sO���|�|���=�=� ����� ��
��*�*��%�%�t�	-����rc��UR$)z"Return the current suggestion mode)rr`s r�get_suggestion_mode�TabEngine.get_suggestion_modeO	r�rc��XR:XagXlURURU5 URR	5 U(a:UR
R
S[RRU55 gg)a4Sets whether only single characters should be matched in
the database.

:param mode: Whether only single characters should be matched.
             True: Match only single characters.
             False: Possibly match multiple characters at once.
: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.
Nr�)
r$r�r�rPrxr�rnrrory�rBr�rzs   r�set_onechar_mode�TabEngine.set_onechar_modeS	sn���=�=� ���
��*�*��"�"�D�	*��
�
�)�)�+���O�O�%�%�����(�(��.�
0�rc��UR$)zE
Returns whether only single characters are matched in the database.
)r$r`s r�get_onechar_mode�TabEngine.get_onechar_model	s���}�}�rc���XR:XagXlURURU5 U(a:URR	S[
RRU55 gg)u>Sets whether automatic commits go into the preëdit or into the
application.

:param mode: Whether automatic commits  go into the  preëdit
             or into the application.
             True: Into the application.
             False: Into the preëdit.
: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.
Nr�)rr�r�r�rnrroryr�s   r�set_autocommit_mode�TabEngine.set_autocommit_moder	sa���$�$�$�� ���*�*��%�%�t�	-���O�O�%�%�����(�(��.�
0�rc��UR$)z$Returns the current auto-commit mode)rr`s r�get_autocommit_mode�TabEngine.get_autocommit_mode�	rvrc���[S:�a[RSU5 XR:XagXlU(a:URRS[RRU55 gg)akSets the commit invalid mode

This selects what is committed when a character which is not
in the set of valid input characters for the current table is
typed.

0 means to commit the current candidate
1 means to commit the raw characters typed so far

:param mode:             The mode (0 <= mode <= 1)
: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.
r0�mode=%sNr�)	r�r�r�rr�rnrrorpr�s   r�set_commit_invalid_mode�!TabEngine.set_commit_invalid_mode�	s]��$��?��L�L��D�)��,�,�,��$(�!���O�O�%�%�#����&�&�t�,�
.�rc��UR$)z&Return the current comimt invalid mode)rr`s r�get_commit_invalid_mode�!TabEngine.get_commit_invalid_mode�	s���(�(�(rc��XR:XagXlU(a:URRS[RRU55 gg)aSets whether the first candidate will be selected
automatically during typing.

:param mode: Whether to select the first candidate automatically.
:type mode: Boolean
: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.
:type update_gsettings: Boolean
Nr�)rr�rnrroryr�s   r�set_autoselect_mode�TabEngine.set_autoselect_mode�	sH���$�$�$�� ����O�O�%�%�����(�(��.�
0�rc��UR$)z$Returns the current auto-select mode)rr`s r�get_autoselect_mode�TabEngine.get_autoselect_mode�	rvrc���XR:XagXlURR5 U(a:URR	S[
RRU55 gg)a�Sets whether a wildcard should be automatically appended
to the input.

:param mode: Whether to append a wildcard automatically.
: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.
Nrp)rrPrxr�rnrroryr�s   r�set_autowildcard_mode�TabEngine.set_autowildcard_mode�	sX���&�&�&��"���
�
�)�)�+���O�O�%�%�����(�(��.�
0�rc��UR$)z,Returns the  current automatic wildcard mode)rr`s r�get_autowildcard_mode�TabEngine.get_autowildcard_mode�	s���"�"�"rc���XR:XagXlURR5 U(a:URR	S[
RRU55 gg)a�Sets the single wildchard character.

:param char: The character to use as a single wildcard
             (String  of length 1).
: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.
Nrl)r�rPrxr�rnrror��rBr?rzs   r�set_single_wildcard_char�"TabEngine.set_single_wildcard_char�	sX���-�-�-��%)�"��
�
�)�)�+���O�O�%�%�$����'�'��-�
/�rc��UR$)zR
Return the character currently used as a single wildcard.

(String of length 1.)
)r�r`s r�get_single_wildcard_char�"TabEngine.get_single_wildcard_char�	s���)�)�)rc��[U5S:�aUSnXR:XagXlURR5 U(a:URRS[RRU55 gg)a�Sets the multi wildchard character.

:param char: The character to use as a multi wildcard.
             (String  of length 1.)
: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.
r0rNrn)	r�rrPrxr�rnrror�r�s   r�set_multi_wildcard_char�!TabEngine.set_multi_wildcard_char�	sl���t�9�q�=���7�D��,�,�,��$(�!��
�
�)�)�+���O�O�%�%�#����'�'��-�
/�rc��UR$)zP
Return the character currently used as a multi wildcard.
(String of length 1.)
)rr`s r�get_multi_wildcard_char�!TabEngine.get_multi_wildcard_char
s��
�(�(�(rc��XR:XagXlU(a:URRS[RRU55 gg)a�Sets the whether the lookup table is shown.

:param mode: Whether to show the lookup table.
             True: Lookup table is shown
             False: Lookup table is hidden
: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.
Nr�)rr�rnrroryr�s   r�set_always_show_lookup� TabEngine.set_always_show_lookup
sH���+�+�+��#'� ���O�O�%�%�"����(�(��.�
0�rc��UR$)z3Returns whether the lookup table is shown or hidden)rr`s r�get_always_show_lookup� TabEngine.get_always_show_lookup2
s���'�'�'rrFc�J�[S:�a[RSU5 XR:XagSUs=::aS::afO gXlURRU5 U(a:URRS[RRU55 ggg)agSets 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 dconf key changed
                         to avoid endless loops when the dconf
                         key is changed twice in a short time.
r0zorientation(%s)Nrr4r�)r�r�r�r.r2rPr�rnrrorp)rBrFrzs   r�set_lookup_table_orientation�&TabEngine.set_lookup_table_orientation6
s�����?��L�L�*�K�8��+�+�+���� �q� � +�����.�.�{�;�����)�)�,��L�L�*�*�;�7�9� �!rc��UR$)z3Returns the current orientation of the lookup table)r.r`s r�get_lookup_table_orientation�&TabEngine.get_lookup_table_orientationQ
rvrrVc��[S:�a[RSU5 XR:Xag[	SS5H*nUR
SUS--(aM[
X15n O US:aSnXlUR5UlUR5 U(a:URRS[RRU55 gg)a�Sets the page size of the lookup table

:param page_size: The page size of the lookup table
                  1 <= page size <= number of select keys
: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.
r0zpage_size=%sNr�r�r�)r�r�r�r*r+r'r,r1r2r=r�rnrrorp)rBrVrzrDs    rrO�TabEngine.set_page_sizeU
s�����?��L�L���3����'���1�b�\�E��,�,�)�U�Q�Y�7�9�9���1�	��	"�
�q�=��I�#��!�6�6�8����
�
����O�O�%�%�%����&�&�y�1�
3�rc��UR$)z1Returns the current page size of the lookup table)r*r`s rr/�TabEngine.get_page_sizeu
s�����rc��XRU:XagXRU'X R:XaURURU5 U(a{U(a:URRS[RRU55 gURRS[RRU55 gg)a#
Sets whether full width letters should be used.

:param mode: Whether to use full width letters
:param input_mode: The input mode (direct input: 0, table: 1)
                   for which to set the full width letter mode.
: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.
Nr|r{)	rrr�r�r�rnrrory�rBr�r�rzs    r�set_letter_width�TabEngine.set_letter_widthy
s���"�*�*�:�6�6��.2���
�+��)�)�)��.�.��&�&��
.������)�)�+��L�L�,�,�T�2�4����)�)�*��L�L�,�,�T�2�4�
rc��UR$)z>Return the current full width letter modes: [Boolean, Boolean])rr`s r�get_letter_width�TabEngine.get_letter_width�
s���&�&�&rc��XRU:XagXRU'X R:XaURURU5 U(a{U(a:URRS[RRU55 gURRS[RRU55 gg)a0
Sets whether full width punctuation should be used.

:param mode: Whether to use full width punctuation
:param input_mode: The input mode (direct input: 0, table: 1)
                   for which to set the full width punctuation mode.
: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.
Nrr~)	rrr�r�r�rnrroryr
s    r�set_punctuation_width�TabEngine.set_punctuation_width�
s���"�)�)�*�5�5��-1���z�*��)�)�)��.�.��+�+�T�
3������)�)�*��L�L�,�,�T�2�4����)�)�)��L�L�,�,�T�2�4�
rc��UR$)zLReturn the current full width punctuation modes: [Boolean, Boolean]
        )rr`s r�get_punctuation_width�TabEngine.get_punctuation_width�
s���%�%�%rc�^�[S:�a[RSU5 XR:XagXlURR5 UR
URU5 U(a:URRS[RRU55 gg)a�Sets the candidate filter mode used for Chinese

0 means to show simplified Chinese only
1 means to show traditional Chinese only
2 means to show all characters but show simplified Chinese first
3 means to show all characters but show traditional Chinese first
4 means to show all characters

:param mode: The Chinese filter mode, 0 <= mode <= 4
: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.
r0r�Nr�)
r�r�r�r&rPrxr�r�r�rnrrorpr�s   r�set_chinese_mode�TabEngine.set_chinese_mode�
s���"��?��L�L��D�)��%�%�%��!���
�
�)�)�+��*�*��"�"�D�	*���O�O�%�%�����&�&�t�,�
.�rc��UR$)a
Return the current Chinese mode.

0 means to show simplified Chinese only
1 means to show traditional Chinese only
2 means to show all characters but show simplified Chinese first
3 means to show all characters but show traditional Chinese first
4 means to show all characters
)r&r`s r�get_chinese_mode�TabEngine.get_chinese_mode�
s���!�!�!r�menu�current_modec
�6�[S:�a [RS[U5U5 U(dSnUSnUSnUHTnXES[	U5:XdMXESnXESnS	RUS
UUSS9nS
RUSUSS9n	MV Sn
UR
X4US9 X0R;Ga[R"U[RR[RRW5[RRW5[RR!UR"W5[RRW	5U
U
[R$R&UR(US9
URU'UR*R-URU5 gURUR/[RRW55 URUR1[RRW55 URUR3[RR!UR"W55 URUR5[RRW	55 URUR7U
5 URUR9U
5 UR;URU5 g)z+
Initialize or update a ibus property menu
r0zmenu=%s current_mode=%srr�r�r�rbr�z"{label} ({symbol}) {shortcut_hint}r�r�)r�rbr�z{tooltip}
{shortcut_hint}r�)r�r�T)r)
r��	prop_typer�rbr�r��	sensitive�visible�state�	sub_propsN)r�r�r�r3r�r��_init_or_update_sub_propertiesr�r�Property�PropType�MENUrXrYr�r]r�r��	PropState�	UNCHECKEDr�r�r��	set_label�
set_symbol�set_icon�set_tooltip�
set_sensitive�set_visible�update_property)rBrr�menu_key�sub_properties_dict�proprbr�r�r�r!s           rr��'TabEngine._init_or_update_property_menu�
s�����?��L�L�)�4��:�|�
E���L���;��"�#3�4��'�D�"�(��2�c�,�6G�G�,�2�8�<��*�0��8��<�C�C��w�-�!�"&��"7�D�9��7�=�=� ��O�"&��"7�>�9��(����+�+���	,�	F��?�?�*�(,�
�
���-�-�,�,��i�i�/�/��6��y�y�0�0��8��W�W�\�\�$�.�.�$�7��	�	�1�1�'�:�!���n�n�.�.��.�.�x�8�
):�D�O�O�H�%�
���&�&�t���x�'@�A��O�O�H�%�/�/��	�	�)�)�%�0�
2��O�O�H�%�0�0��	�	�)�)�&�1�
3��O�O�H�%�.�.������T�^�^�T�2�
4��O�O�H�%�1�1��	�	�)�)�'�2�
4��O�O�H�%�3�3�G�<��O�O�H�%�1�1�'�:�� � �����!:�;rr1�modesc
��^�XR;a%Sn[R"5URU'OSnSn[TU4SjS9GH+nTUS[	U5:Xa[R
RnO[R
RnTUSnSTU;a	TUSn	OSn	U(d�[R"U[RR[RRU5[RRTUS	5[RRU	5UUUS
S9	UR U'URUR#UR U5 GM=UR UR%[RRU55 UR UR'[RRU	55 UR UR)U5 UR UR+U5 UR UR-U5 UR/UR U5 GM. g
)zC
Initialize or update the sub-properties of a property menu entry.
FTc�&>�[TUS5$)Nr�r�)r�r5s �rr�:TabEngine._init_or_update_sub_properties.<locals>.<lambda>2s����U�1�X�h�5G�1Hr)r�r�r�r�rZr�N)	r�rr�r�r�r r!r"r#)r�r�PropListr�r�r(�CHECKEDr)r%r&�RADIOrXrYr�r]r�r�r�r*r-r.r/�	set_stater0)
rBr1r5r�updater!r�r"r�r�s
  `       rr$�(TabEngine._init_or_update_sub_properties$s�����/�/�/��F�-1�]�]�_�D� � ��*��F����5�&I�J�D��T�{�8�$��L�(9�9����.�.�����0�0���$�K��(�E��E�$�K�'���+�i�0�����(,�
�
��"�m�m�1�1��)�)�3�3�E�:������e�D�k�&�&9�:� �I�I�5�5�g�>�%�#��"�	)$�����%��$�$�X�.�5�5��O�O�D�)�+�����%�/�/��I�I�-�-�e�4�6�����%�1�1��I�I�-�-�g�6�8�����%�3�3�G�<�����%�1�1�'�:�����%�/�/��6��$�$�T�_�_�T�%:�;�?Krc
���0Ul0Ul[R"5UlURURUR5 URR(a6URS:wa&URURUR5 URR(afURURURUR5 URURUR UR5 UR"(a&URUR$UR&5 UR((a&URUR*UR,5 URR(a&URUR.UR05 URR2(aAURR4(a&URUR6UR85 [R:"S[R<R?[AS55S[R<R?[AS5SURB0-5SSS9Ul"URRGURD5 URIUR5 g	)
z$
Initialize the ibus property menus
rn�setup�Setupzgtk-preferencesu*Configure ibus-table “%(engine-name)s”zengine-nameT)r�r�r�r�r r!N)%r�r�rr9r�r�r�rrPr4r&r��_is_cjkr�rr�rr�r�rr�r�rr�r$r �rulesr�rr%rXrYrr�r�r��register_propertiesr`s rr5�TabEngine._init_propertiesSs/�����!���"�m�m�o����*�*�� � ����	��=�=�$�$��);�);�r�)A��.�.��&�&��"�"�
$��=�=� � ��.�.��&�&��'�'��(8�(8�9�
;�
�.�.��+�+��&�&�t�'7�'7�8�
:��<�<��.�.��%�%��
�
�
��<�<��.�.��)�)��
�
�
��=�=� � ��.�.��&�&��
�
�
��=�=�/�/�D�M�M�4G�4G��.�.��)�)��!�!�
#� $�}�}���)�)�+�+�A�g�J�7�"��I�I�-�-��>�?� �$�"3�"3�4�5�6��� ���	
���"�"�4�#7�#7�8�� � ��!4�!4�5r�
ibus_property�
prop_statec�l�[S:�a[RSX5 US:XaUR5 gU[R
R:wagURURSS-5(a"URURUS5 gURURSS-5(a<UR(a+UR[URUS55 gURUR SS-5(a<UR"(a+UR%[UR&US55 gURUR(SS-5(aFUR*R,(a+UR/[UR0US55 gURUR2SS-5(aaUR*R4(aFUR*R6(a+UR9[UR:US55 gURUR<SS-5(aOUR*R,(a4UR?[UR@US5URBS9 gURURDSS-5(aOUR*R,(a4URG[URHUS5URBS9 gURURJSS-5(aOUR*RL(a3URNS	:wa"URQURRUS5 gggg)
z
Handle clicks on properties
r0zibus_property=%s prop_state=%sr@Nr�rTr��r�rn)*r�r�r��_start_setuprr(r:rVr�r�r�r�r�r�r!r�r�r�r�r�r�rPrBr�r�r�r rCr�r�r�rr�rr�rr�r�r4r&rr�)rBrFrGs   r�do_property_activate�TabEngine.do_property_activate�s9����?��L�L�0�-�
M��G�#����������/�/�/�
��#�#�D�$8�$8��$?��$C�D�D�����*�*�=�9�(�C�
E���$�$�T�%:�%:�5�%A�#�%E�F�F��L�L�� � ��T�0�0��?��I�J�
L���$�$�T�%>�%>�u�%E�c�%I�J�J��L�L��$�$��T�4�4�]�C�H�M�N�
P���$�$�T�%;�%;�E�%B�3�%F�G�G��M�M�)�)��!�!��T�1�1�-�@��J�K�
M���$�$�T�%>�%>�u�%E�c�%I�J�J��M�M�8�8��M�M�'�'��$�$��T�4�4�]�C�H�M�N�
P���$�$�T�%;�%;�E�%B�3�%F�G�G��M�M�)�)��!�!��T�1�1�-�@��J�K��+�+�
"�
-�
��$�$�T�%@�%@��%G��%K�L�L��M�M�)�)��&�&��T�6�6�!�#�#+�-�.��+�+�
'�
-�
��$�$�T�%;�%;�E�%B�3�%F�G�G��M�M�-�-��&�&�"�,��!�!��,�,�]�;�H�E�
G��-�.�
Hrc��URS:waH[R"UR[R5upXR:wagSUl[RR[
[R"S55S5n[R"[RUSSUR-5Ulg)z0
Start the setup tool if it is not running yet.
rN�IBUS_TABLE_LIB_LOCATIONzibus-setup-tablez--engine-name table:%s)
r�r��waitpid�P_NOWAITr]r�r�r��spawnlr�)rB�pid�dummy_state�	setup_cmds    rrJ�TabEngine._start_setup�s����?�?�a��!�z�z�$�/�/�2�;�;�G��C��o�o�%�
��D�O��G�G�L�L���	�	�3�4�5�� �	��)�)��K�K���$�d�&7�&7�7�	9��rc��UR(a.UR(aURR5 ggg! [R	S5 g=f)z+Play an error sound if enabled and possiblezPlaying error sound failed.N)r	r�playr��	exceptionr`s r�_play_error_sound�TabEngine._play_error_sound�sJ������!9�!9�
@��(�(�-�-�/�":���
@�� � �!>�?�s�A�Ac
�*�UR(aUR5 gUR5nSRUS5nUSnSRUS5nUR(aDUR(d3SnUH)nX`R
;aXPR
U-
nM%XV-
nM+ UnX#-U-nU(dY[RRU[RRS5SS[RR5 gURSnURSn	URS	n
[R"5nUR[R "US[#U555 UR[R "U	[#U5[#U5-[#U555 UR$(awUR'5 UR[R "U
[#U5[#U5-[#UR$5-
[#U5[#U5-55 UR[R("[R*R,S[#U555 [RRU5nSn
UR/U
5bvUR/U
5nUR1UR35UR55UR75UR955 U
S-
n
UR/U
5bMv[RRUX�R;5S
[RR5 g)zUpdate Preedit String in UINrZrr0r4Fr)r*r+T)r�hide_preedit_textr�r�rr#rr��update_preedit_text_with_moderXrY�PreeditFocusMode�COMMITr�r�r�r�r�rrY�attr_underline_new�
AttrUnderline�SINGLEr�r�r�r�r�r�r�)rB�preedit_string_partsr�r�r��current_edit_newr?�preedit_string_complete�
color_left�color_right�
color_invalidr�r�r�r�s               r�_update_preedit�TabEngine._update_preedit�s������"�"�$��#�<�<�>��!�w�w�';�A�'>�?��+�A�.�� "���(<�Q�(?� @�����D�$8�$8�!��$���2�2�2�$�(?�(?��(E�E�$�$�,�$�	%�
,�L� �/�2G�G�	 �&�
�K�K�5�5���	�	�)�)�"�-�q�%��%�%�,�,�
.�
��Z�Z��/�
��j�j��1���
�
�#4�5�
��
�
���
����$�$����(�)�
+�	,�
	����$�$���(�)�C��,=�=��+�,�
.�	/�
����"�"�$��L�L��(�(�!��,�-��L�0A�A��$�-�-�.�/��,�-��L�0A�A�	�
�	����#�#��"�"�)�)���+�,�
.�	/�
�y�y�(�(�)@�A��
���i�i��l�&��9�9�Q�<�D��!�!�$�"4�"4�"6�"&�.�.�"2�"&�"6�"6�"8�"&�"4�"4�"6�
8�
��F�A�
�i�i��l�&�	
���1�1���.�.�"�D�$�*?�*?�*F�*F�	Hrc	�>�UR(agUR5nUR(a=USURR	5S-URR54--
nU(GaU[S:�a$UR(dSUR3nX-
n[R"5nUR[R"URSS[U555 [RR!U5nSnUR#U5bvUR#U5nUR%UR'5UR)5UR+5UR-55 US-
nUR#U5bMvSnU(aUR.(dSn[0TU]eXG5 gUR55 g)	zUpdate Aux String in UINz
 (%d / %d)r0ru🪟r,TF)rr+rr2r�r.r�r�r�rr�r�r�r�r�rXrYr�r�r�r�r�r�rr��update_auxiliary_text�hide_auxiliary_text)	rBr"�clientr�r�r�r�r!rIs	        �r�_update_aux�TabEngine._update_aux0s���������)�)�+�
�����,��"�"�1�1�3�Q�6��"�"�;�;�=�*?�?�
?�J���Q��t�������0�1���$�
��M�M�O�E��L�L��1�1��
�
�:�&��3�z�?�<�
=��9�9�,�,�Z�8�D��A��)�)�A�,�*��y�y��|���%�%�d�&8�&8�&:�&*�n�n�&6�&*�&:�&:�&<�&*�&8�&8�&:�<��Q���
�)�)�A�,�*��G��T�%=�%=����G�)�$�8��$�$�&rc�\�UR(dUR5 gUR(a7UR(d&UR	5(aUR5 gUR
(dUR5 gUR
UR5S5 g)zUpdate Lookup Table in UINT)r�hide_lookup_tablerrrer�update_lookup_tablerKr`s r�_update_lookup_table�TabEngine._update_lookup_tableQsx�����
�"�"�$�����D�$8�$8��}�}����&�&�(���'�'��"�"�$��� � ��!6�!6�!8�$�?rc�d�UR5 UR5 UR5 g)zUpdate User InterfaceN)rtriror`s rrb�TabEngine._update_uigs&���!�!�#��������rc���U(aU(dgURRUUURS9 URS::a[R"5UlU=RS-
slg)z3Check the given phrase and update save user db infoN)r�r�rkrr0)rP�check_phraser�r6r7r8)rBr�r�s   r�
_check_phrase�TabEngine._check_phrasems_���f���
�
�"�"����/�/�	#�	1�
� � �A�%�$(�I�I�K�D�!�����"�rc�
�URS:�as[R"5nXR-
nURUR:�dX R:�a'UR
R
5 SUlXlg)zSave user db to diskrT)r6r7r8r:r<rPrg)rB�now�
time_deltas   rr?�TabEngine._sync_user_dbzsj��� � �A�%��)�)�+�C��4�4�4�J��%�%��(A�(A�A��"9�"9�9��
�
�(�(�*�()��%�(+�%�rc�:>�[S:�a[RSU5 UR5 UR	5 Xl[TU][RRU55 U(aUSUlOSUlURX!S9 g)u�
Commit the string “phrase”, update the user database,
and clear the preëdit.

:param phrase: The text to commit
:param tabkeys: The keys typed to produce this text
r0z	phrase=%srnN)r�r�)
r�r�r�rarbrr��commit_textrrXrYrrz)rBr�r�rIs   �r�
commit_string�TabEngine.commit_string�sw�����?��L�L��f�-��(�(�*�������
���D�I�I�5�5�f�=�>��$�R�j�D�O�"�D�O����7��:rc��[S:�a [RSUR5 UR(agUR(a!UR
(aUR
5 UR5(dUR
5 URUR5UR5S9 g)u�
Commits the current input to the preëdit and then
commits the preëdit to the application unless there are
invalid input characters.

Returns “True” if something was committed, “False” if not.
r0zself._chars_invalid=%sF�r�T)r�r�r�rrrrrer�r�r�r`s r� commit_everything_unless_invalid�*TabEngine.commit_everything_unless_invalid�s�����?��L�L�1��,�,�
.��������� 4� 4��"�"�$��}�}����"�"�$����4�;�;�=�#'�#D�#D�#F�	�	H�rc�>�SSSSSSSSS	S
S.
nXR5;aUS;aX!$UR(aX!$US
:XapUR(a^URR5(a?UR(a.[URR5UR:Xag
gUS:Xa)UR(+UlUR(aggUS:Xa)UR(+UlUR(agg[U5$)z*Convert half width character to full widthu《u》u「u」u『u』u、u……u——u¥)
�<�>�[�]�{�}�\r�rr�)r�r�rr�rTu。�"u“u”�'u‘u’)
�keysrr�isdigitrrC�valr
rrI)rBr?�special_punct_dicts   r�_convert_to_full_width� TabEngine._convert_to_full_width�s��$)�#(�#(�#(�#(�#(�$)�#+�#+�#(�
���*�*�,�,��,�,�)�/�/����)�/�/��3�;�������/�/�1�1�����D�N�N�.�.�/�4�?�?�B����4�<�/3�/K�/K�+K�D�(��+�+����3�;�/3�/K�/K�+K�D�(��+�+���#�D�)�)r�_button�_statec���[S:�a[RSXU5 URU5(a-UR	UR5UR
5S9 gg)Nr0zindex=%s _button=%s state=%sr�TF)r�r�r�rr�r�r�)rBrDr�r�s    r�do_candidate_clicked�TabEngine.do_candidate_clicked�s^����?��L�L�7���P��.�.�u�5�5�����0�0�2��9�9�;�
�
=��rc�$�UR5 g)ujHandle hotkey for the command “setup”

:return: True if the key was completely handled, False if not.
T)rJr`s r�_command_setup�TabEngine._command_setup�s��
	
����rc���UR5(d!UR5nURU5 UR[	UR
(+55 g)u}Handle hotkey for the command “toggle_input_mode_on_off”

:return: True if the key was completely handled, False if not.
T)rer�r�r�r�r)rBr�s  r�!_command_toggle_input_mode_on_off�+TabEngine._command_toggle_input_mode_on_off�sJ��
�}�}��� �=�=�?�M����}�-����C�D�$4�$4� 4�5�6�rc��URR(dgURURUR(+URS9 g)uxHandle hotkey for the command “toggle_letter_width”

:return: True if the key was completely handled, False if not.
FrIT)rPrBrrrr`s r�_command_toggle_letter_width�&TabEngine._command_toggle_letter_width
sL��
�}�}�$�$������'�'��(8�(8�9�9��'�'�	�	)�rc��URR(dgURURUR(+URS9 g)u}Handle hotkey for the command “toggle_punctuation_width”

:return: True if the key was completely handled, False if not.
FrIT)rPrBrrrr`s r�!_command_toggle_punctuation_width�+TabEngine._command_toggle_punctuation_width
sL��
�}�}�$�$���"�"��&�&�t�'7�'7�8�8��'�'�	#�	)�rc�p�UR5(agUR5 UR5 g)ukHandle hotkey for the command “cancel”

:return: True if the key was completely handled, False if not.
FT)rer=rbr`s r�_command_cancel�TabEngine._command_cancel
s(��
�=�=�?�?���
�
������rc�h�UR(dgURUR(+5 g)u{Handle hotkey for the command “toggle_suggestion_mode”

:return: True if the key was completely handled, False if not.
FT)r�r�rr`s r�_command_toggle_suggestion_mode�)TabEngine._command_toggle_suggestion_mode%
s&��
�|�|��� � �T�]�]�!2�3�rc�r�UR5(agUR5nUR5 U$)uvHandle hotkey for the command “commit_to_preedit”

:return: True if the key was completely handled, False if not.
F)rerrbr8s  r�_command_commit_to_preedit�$TabEngine._command_commit_to_preedit/
s/��
�=�=�?�?���$�$�&�������
rc�R�UR(dgURUR(+5 UR5(d`URUR
-nSUlSUlUHnUR
U5 M URSS9 UR5 g)uwHandle hotkey for the command “toggle_pinyin_mode”

:return: True if the key was completely handled, False if not.
FrZT)r)	r�r�rrerrrkr_rb)rB�charsr?s   r�_command_toggle_pinyin_mode�%TabEngine._command_toggle_pinyin_mode:
s���
�|�|��������.�/��}�}����%�%��(;�(;�;�E� "�D��"$�D�������t�$���"�"��"�.��O�O��rc�F�UR5nUR5 U$)u�Handle hotkey for the command
“select_next_candidate_in_current_page”

:return: True if the key was completely handled, False if not.
)rYrbr8s  r�._command_select_next_candidate_in_current_page�8TabEngine._command_select_next_candidate_in_current_pageO
s!���8�8�:�������
rc�F�UR5nUR5 U$)u�Handle hotkey for the command
“select_previous_candidate_in_current_page”

:return: True if the key was completely handled, False if not.
)r\rbr8s  r�2_command_select_previous_candidate_in_current_page�<TabEngine._command_select_previous_candidate_in_current_pageY
s!���<�<�>�������
rc���URR(dgURUR(+5 UR	5(d!URS5 UR
5 g)uxHandle hotkey for the command “toggle_onechar_mode”

:return: True if the key was completely handled, False if not.
FT)rPrBr�r$rer_rbr`s r�_command_toggle_onechar_mode�&TabEngine._command_toggle_onechar_modec
sO��
�}�}�$�$�����$�-�-�/�0��}�}����"�"�4�(��O�O��rc��URR(a<URR(a!URUR(+5 gg)u{Handle hotkey for the command “toggle_autocommit_mode”

:return: True if the key was completely handled, False if not.
TF)rPr rCr�rr`s r�_command_toggle_autocommit_mode�)TabEngine._command_toggle_autocommit_modeq
s:��
�=�=�/�/�D�M�M�4G�4G��$�$��):�):�%:�;��rc���URR(dgURURS-S-5 UR	5(d!URS5 UR
5 g)u�Handle hotkey for the command “switch_to_next_chinese_mode”

:return: True if the key was completely handled, False if not.
Fr0r:T)rPr4rr&rer_rbr`s r�$_command_switch_to_next_chinese_mode�.TabEngine._command_switch_to_next_chinese_mode{
sX��
�}�}�(�(�����t�1�1�!�3�q�8�9��}�}����"�"�4�(��O�O��rc��UR(d&UR5(aUR(a�UR5(a"UR(aURS5 UR(a)UR(aUR(dSUlUR5 UR5 gg)ukHandle hotkey for the command “commit”

:return: True if the key was completely handled, False if not.
r[TF)
rrerr�rr�rrr_rbr`s r�_command_commit�TabEngine._command_commit�
s���

�M�M��=�=�?�?��#�#��4�4�6�6��$�$��&�&�s�+��
�
��$�$��,�,�'+��$��"�"�$��O�O���rc�j�UR(dgUR5nUR5 U$)u{Handle hotkey for the command “lookup_table_page_down”

:return: True if the key was completely handled, False if not.
F)rr>rbr8s  r�_command_lookup_table_page_down�)TabEngine._command_lookup_table_page_down�
s+��
�����n�n��������
rc�j�UR(dgUR5nUR5 U$)uyHandle hotkey for the command “lookup_table_page_up”

:return: True if the key was completely handled, False if not.
F)rrArbr8s  r�_command_lookup_table_page_up�'TabEngine._command_lookup_table_page_up�
s*��
�����l�l�n�������
rr�c��UR[RR-(a[RSU5 gUR(dgUS-
nURU5nUR5 U$)u�Execute the hotkey command “commit_candidate_to_preedit_<number>”

:return: True if the key was completely handled, False if not.
:param number: The number of the candidate
z?OSK is visible: do not commit candidate to preedit by number %sFr0)	�client_capabilitiesr��
Capabilite�OSKr�r�rrrb�rBr�rDrjs    r�+_execute_commit_candidate_to_preedit_number�5TabEngine._execute_commit_candidate_to_preedit_number�
sm���#�#�g�&8�&8�&<�&<�<��K�K�B�CI�
K��������
���1�1�%�8�������
rc�$�URS5$)u�Handle hotkey for the command “commit_candidate_to_preedit_1”

:return: True if the key was completely handled, False if not.
r0�r�r`s r�&_command_commit_candidate_to_preedit_1�0TabEngine._command_commit_candidate_to_preedit_1�
���
�?�?��B�Brc�$�URS5$)u�Handle hotkey for the command “commit_candidate_to_preedit_2”

:return: True if the key was completely handled, False if not.
r4r�r`s r�&_command_commit_candidate_to_preedit_2�0TabEngine._command_commit_candidate_to_preedit_2�
r�rc�$�URS5$)u�Handle hotkey for the command “commit_candidate_to_preedit_3”

:return: True if the key was completely handled, False if not.
r�r�r`s r�&_command_commit_candidate_to_preedit_3�0TabEngine._command_commit_candidate_to_preedit_3�
r�rc�$�URS5$)u�Handle hotkey for the command “commit_candidate_to_preedit_4”

:return: True if the key was completely handled, False if not.
r=r�r`s r�&_command_commit_candidate_to_preedit_4�0TabEngine._command_commit_candidate_to_preedit_4�
r�rc�$�URS5$)u�Handle hotkey for the command “commit_candidate_to_preedit_5”

:return: True if the key was completely handled, False if not.
r:r�r`s r�&_command_commit_candidate_to_preedit_5�0TabEngine._command_commit_candidate_to_preedit_5�
r�rc�$�URS5$)u�Handle hotkey for the command “commit_candidate_to_preedit_6”

:return: True if the key was completely handled, False if not.
r9r�r`s r�&_command_commit_candidate_to_preedit_6�0TabEngine._command_commit_candidate_to_preedit_6�
r�rc�$�URS5$)u�Handle hotkey for the command “commit_candidate_to_preedit_7”

:return: True if the key was completely handled, False if not.
rsr�r`s r�&_command_commit_candidate_to_preedit_7�0TabEngine._command_commit_candidate_to_preedit_7�
r�rc�$�URS5$)u�Handle hotkey for the command “commit_candidate_to_preedit_8”

:return: True if the key was completely handled, False if not.
�r�r`s r�&_command_commit_candidate_to_preedit_8�0TabEngine._command_commit_candidate_to_preedit_8�
r�rc�$�URS5$)u�Handle hotkey for the command “commit_candidate_to_preedit_9”

:return: True if the key was completely handled, False if not.
r<r�r`s r�&_command_commit_candidate_to_preedit_9�0TabEngine._command_commit_candidate_to_preedit_9�
r�rc�$�URS5$)u�Handle hotkey for the command “commit_candidate_to_preedit_10”

:return: True if the key was completely handled, False if not.
r�r�r`s r�'_command_commit_candidate_to_preedit_10�1TabEngine._command_commit_candidate_to_preedit_10s��
�?�?��C�Crc��UR[RR-(a[RSU5 gUR(dgUS-
nURU5nUR5 U$)u�Execute the hotkey command “remove_candidate_<number>”

:return: True if the key was completely handled, False if not.
:param number: The number of the candidate
z4OSK is visible: do not remove candidate by number %sFr0)	r�r�r�r�r�r�rrFrbr�s    r� _execute_remove_candidate_number�*TabEngine._execute_remove_candidate_number
sg���#�#�g�&8�&8�&<�&<�<��K�K�F��
P��������
���6�6�u�=�������
rc�$�URS5$)uwHandle hotkey for the command “remove_candidate_1”

:return: True if the key was completely handled, False if not.
r0�r�r`s r�_command_remove_candidate_1�%TabEngine._command_remove_candidate_1���
�4�4�Q�7�7rc�$�URS5$)uwHandle hotkey for the command “remove_candidate_2”

:return: True if the key was completely handled, False if not.
r4r�r`s r�_command_remove_candidate_2�%TabEngine._command_remove_candidate_2%r�rc�$�URS5$)uwHandle hotkey for the command “remove_candidate_3”

:return: True if the key was completely handled, False if not.
r�r�r`s r�_command_remove_candidate_3�%TabEngine._command_remove_candidate_3,r�rc�$�URS5$)uwHandle hotkey for the command “remove_candidate_4”

:return: True if the key was completely handled, False if not.
r=r�r`s r�_command_remove_candidate_4�%TabEngine._command_remove_candidate_43r�rc�$�URS5$)uwHandle hotkey for the command “remove_candidate_5”

:return: True if the key was completely handled, False if not.
r:r�r`s r�_command_remove_candidate_5�%TabEngine._command_remove_candidate_5:r�rc�$�URS5$)uwHandle hotkey for the command “remove_candidate_6”

:return: True if the key was completely handled, False if not.
r9r�r`s r�_command_remove_candidate_6�%TabEngine._command_remove_candidate_6Ar�rc�$�URS5$)uwHandle hotkey for the command “remove_candidate_7”

:return: True if the key was completely handled, False if not.
rsr�r`s r�_command_remove_candidate_7�%TabEngine._command_remove_candidate_7Hr�rc�$�URS5$)uwHandle hotkey for the command “remove_candidate_8”

:return: True if the key was completely handled, False if not.
r�r�r`s r�_command_remove_candidate_8�%TabEngine._command_remove_candidate_8Or�rc�$�URS5$)uwHandle hotkey for the command “remove_candidate_9”

:return: True if the key was completely handled, False if not.
r<r�r`s r�_command_remove_candidate_9�%TabEngine._command_remove_candidate_9Vr�rc�$�URS5$)uxHandle hotkey for the command “remove_candidate_10”

:return: True if the key was completely handled, False if not.
r�r�r`s r�_command_remove_candidate_10�&TabEngine._command_remove_candidate_10]s��
�4�4�R�8�8rc�Z�UR[RR-(a[RSU5 gUR(aU[UR5:�agUS-
nSUs=::aUR:dg gURU5(a�URUR5UR5S9 UR(a)UR(aUR(dSUlUR!5 UR#5 gg)u�Execute the hotkey command “commit_candidate_<number>”

:return: True if the key was completely handled, False if not.
:param number: The number of the candidate
z4OSK is visible: do not commit candidate by number %sFr0rr�T)r�r�r�r�r�r�rr�r*rr�r�r�rrrr_rb)rBr�rDs   r�(_execute_command_commit_candidate_number�2TabEngine._execute_command_commit_candidate_numberds����#�#�g�&8�&8�&<�&<�<��K�K�F��
P�����6�C��0@�0@�,A�#A����
���E�+�D�O�O�+��,���.�.�u�5�5�����0�0�2��9�9�;�
�
=��
�
��$�$��,�,�'+��$��"�"�$��O�O���rc�$�URS5$)uwHandle hotkey for the command “commit_candidate_1”

:return: True if the key was completely handled, False if not.
r0�rr`s r�_command_commit_candidate_1�%TabEngine._command_commit_candidate_1����
�<�<�Q�?�?rc�$�URS5$)uwHandle hotkey for the command “commit_candidate_2”

:return: True if the key was completely handled, False if not.
r4rr`s r�_command_commit_candidate_2�%TabEngine._command_commit_candidate_2�r rc�$�URS5$)uwHandle hotkey for the command “commit_candidate_3”

:return: True if the key was completely handled, False if not.
r�rr`s r�_command_commit_candidate_3�%TabEngine._command_commit_candidate_3�r rc�$�URS5$)uwHandle hotkey for the command “commit_candidate_4”

:return: True if the key was completely handled, False if not.
r=rr`s r�_command_commit_candidate_4�%TabEngine._command_commit_candidate_4�r rc�$�URS5$)uwHandle hotkey for the command “commit_candidate_5”

:return: True if the key was completely handled, False if not.
r:rr`s r�_command_commit_candidate_5�%TabEngine._command_commit_candidate_5�r rc�$�URS5$)uwHandle hotkey for the command “commit_candidate_6”

:return: True if the key was completely handled, False if not.
r9rr`s r�_command_commit_candidate_6�%TabEngine._command_commit_candidate_6�r rc�$�URS5$)uwHandle hotkey for the command “commit_candidate_7”

:return: True if the key was completely handled, False if not.
rsrr`s r�_command_commit_candidate_7�%TabEngine._command_commit_candidate_7�r rc�$�URS5$)uwHandle hotkey for the command “commit_candidate_8”

:return: True if the key was completely handled, False if not.
r�rr`s r�_command_commit_candidate_8�%TabEngine._command_commit_candidate_8�r rc�$�URS5$)uwHandle hotkey for the command “commit_candidate_9”

:return: True if the key was completely handled, False if not.
r<rr`s r�_command_commit_candidate_9�%TabEngine._command_commit_candidate_9�r rc�$�URS5$)uxHandle hotkey for the command “commit_candidate_10”

:return: True if the key was completely handled, False if not.
r�rr`s r�_command_commit_candidate_10�&TabEngine._command_commit_candidate_10�s��
�<�<�R�@�@rr��commandsc�>�[S:�a[RSU5 [S:�a)[RS[UR55 U(d#[URR55nUHrnURX4UR;dM![S:�a[RSU5 SU-n[X5nU"5(dM`URS	;a g
 g g![4a [RSU5  gf=f)a�Handle hotkey commands

:return: True if the key was completely handled, False if not.
: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.
r0zKeyEvent object: %s
r:zself._hotkeys=%s
zmatched command=%sz_command_%szThere is no function %s)FF)�Shift_L�Shift_R�	Control_L�	Control_R�Alt_L�Alt_R�Meta_L�Meta_R�Super_L�Super_R�ISO_Level3_Shift)TF�TT)
r�r�r�r�r�r�r�r�r�getattr�AttributeErrorrXrU)rBr�r<r��command_function_name�command_functions      r�_handle_hotkeys�TabEngine._handle_hotkeys�s��� ��?��L�L�0�#�6���?��L�L�-�s�4�=�=�/A�B���d�/�/�4�4�6�7�H��G�����-����>���?��L�L�!5�w�?�(5��(?�%�*�'.�t�'K�$�
$�%�%��x�x�$8�8�,�'�' �(��'�(�*��$�$�%>�%:�<�)�*�s�C7�7!D�D�keyval�keycoder"c�L�UR(aURXU5 gg)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” 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. Instead of “return False”, one can also use
self.forward_key_event(keyval, keycode, keystate) to pass the
key to the application. And 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.

Unfortunately, “forward_key_event()” does not work in Qt5
applications because the ibus module in Qt5 does not implement
“forward_key_event()”. Therefore, always using
“forward_key_event()” instead of “return False” in
“do_process_key_event()” would break ibus-typing-table
completely for all Qt5 applictions.

To work around this problem and make unit testing possible
without breaking Qt5 applications, we use this helper function
which uses “forward_key_event()” when unit testing and “return
False” during normal usage.

TF)r��forward_key_event)rBrPrQr"s    r�
_return_false�TabEngine._return_false�s"��@�?�?��"�"�6�E�:��r�_objc�&�URX#U5$)z=This function is connected to the 'process-key-event' signal.)�_do_process_key_event)rBrVrPrQr"s     r�__do_process_key_event� TabEngine.__do_process_key_events��
�)�)�&�5�A�Arc��[R"XU5n[S:�a[R	SU5 UR
[RRR[RRR4;a1[S:�a[R	S5 URXU5$URU5nX@lU$)z\Process Key Events
Key Events include Key Press and Key Release,
modifier means Key Pressed
r0zKeyEvent object: %srz0Disable because of input purpose PASSWORD or PIN)
r��KeyEventr�r�r�r��InputPurpose�PASSWORD�value�PINrT�_process_key_eventr)rBrPrQr"r��results      rrX�TabEngine._do_process_key_event&s������v��6����?��L�L�.��4�����$�$�-�-�3�3��$�$�(�(�.�.�0�
0��Q�����F�H��%�%�f�u�=�=��(�(��-�����
rc���URU/SQS9up#U(aU$UR(a-URU5up#U(aU$URU5$URU5$)z�
Internal method to process key event

Returns True if the key event has been completely handled by
ibus-table and should not be passed through anymore.
Returns False if the key event has not been handled completely
and is passed through.
)r�r�r�r@)r<)rNr�_table_mode_process_key_event�_english_mode_process_key_event)rBr�r��return_values    rra�TabEngine._process_key_event<sv��!%� 4� 4��$�!5�!%���
������$(�$8�$8��$=�!�U��#�#��5�5�c�:�:��3�3�C�8�8rc��URUR(a,URR(aUR	U5$U$)u�Converts “char” to full width *if* full width letter mode is on for
the current input mode (direct input or table mode) *and* if
the current table is for CJK.

:param char: The character to maybe convert to full width
)rrrPrBr��rBr?s  r�cond_letter_translate�TabEngine.cond_letter_translateSs:���"�"�4�#3�#3�4����9N�9N��.�.�t�4�4��rc��URUR(a,URR(aUR	U5$U$)u�Converts “char” to full width *if* full width punctuation mode is
on for the current input mode (direct input or table mode)
*and* if the current table is for CJK.

:param char: The character to maybe convert to full width
)rrrPrBr�rjs  r�cond_punct_translate�TabEngine.cond_punct_translate^s:���!�!�$�"2�"2�3��
�
�8M�8M��.�.�t�4�4��rc�d�UR[RR-(a1UR	UR
URUR5$UR
S:�a1UR	UR
URUR5$UR[RR[RR--(a1UR	UR
URUR5$[R"UR
5n[U5(aURU5nOURU5nX2:Xa1UR	UR
URUR5$URU5 g)uA
Process a key event in “English” (“Direct input”) mode.
�T)r"r�ModifierType�RELEASE_MASKrTr�rE�CONTROL_MASK�	MOD1_MASK�keyval_to_unicoder"rnrkr�)rBr��keychar�
trans_chars    rrf�)TabEngine._english_mode_process_key_eventis2��
�9�9�t�(�(�5�5�5��%�%�c�g�g�s�x�x����C�C��7�7�c�>��%�%�c�g�g�s�x�x����C�C��I�I��$�$�1�1��%�%�/�/�0�
1��%�%�c�g�g�s�x�x����C�C��(�(����1����!�!��2�2�7�;�J��3�3�G�<�J�� ��%�%�c�g�g�s�x�x����C�C����:�&�rc��[S:�a[RS[U55 UR[
RR-(a1URURURUR5$[
R"UR5nUR5(Ga]UR5(GdGUURUR-UR -;d5UR"R$(GaX R"R$;a�UR[
RR&[
RR(--(d�[S:�a[RSU5 [+U5(aUR-U5nOUR/U5nX2:Xa7X0lURURURUR5$UR3U5 gUR[
R4[
R64;a�UR5(aFUR5(d1URURURUR5$UR8(abUR;5 UR5nUR3U5 URURURUR5$UR=5nUR3U5 gUR[
R>[
R@4;aqUR8(a`UR;5 UR3UR55 URURURUR5$UR[
RB[
RD4;ahUR5(d1URURURUR5$URG5nURI5 U$UR[
RJ[
RL4;ahUR5(d1URURURUR5$URO5nURI5 U$UR[
RP[
RR4;a�UR[
RR(-(agUR5(d1URURURUR5$URU5 URI5 gUR[
RV[
RX4;a�UR[
RR(-(agUR5(d1URURURUR5$UR[5 URI5 gUR[
RP[
RR4;agUR5(d1URURURUR5$UR]5 URI5 gUR[
RV[
RX4;agUR5(d1URURURUR5$UR_5 URI5 gUR[
R`:Xa�UR[
RR(-(agUR5(d1URURURUR5$URc5 URI5 gUR[
R`:XagUR5(d1URURURUR5$URe5 URI5 gUR[
Rf:Xa�UR[
RR(-(agUR5(d1URURURUR5$URi5 URI5 gUR[
Rf:XagUR5(d1URURURUR5$URk5 URI5 gUR[
RR([
RR&--(a1URURURUR5$UR[
RR&-(a1URURURUR5$U(Ga�X RUR-UR -;d4URl(Ga�URn(Ga�X Rp;Ga�[S:�a[RSU5 URl(a(URr(aURu5 SUl9URl(a�URn(a�[wURx5URz:Xd,[wURx5S:�aEURxSS	;a2UR|(aUR5 O�UR;5 O�URl(a�URn(d�[wURx5UR�:Xd-[wURx5UR"R�;a2UR|(aUR5 OUR;5 OeUR�U5nU(dtUR8(aBUR�(a1UR�5 UR5 UR�U5$UR5 URI5 gUR|(aEUR�5(a0URxUR�SS:XaUR5 URI5 gU(a�[S:�a[RS
U5 UR�(aUR�S:Xa UR3UR=55 O/UR;5 UR3UR55 [+U5(a!UR3UR-U55 gUR3UR/U55 gURURURUR5$)u{
Process a key event in “Table” mode, i.e. when the
table is actually used and not switched off by using
direct input.
rzrepr(key)=%sz!leading invalid input: keychar=%sTzvalid input: keychar=%sFr0rnz!@#$%z"trailing invalid input: keychar=%s)Ir�r�r�r3r"rrrrsrTr�rErvrer�r�r�rrPrrurtr"rnrkrr��
KEY_Return�KEY_KP_Enterrrr��KEY_Tab�
KEY_KP_Tab�KEY_Down�KEY_KP_Downr7rb�KEY_Up�	KEY_KP_Upr;�KEY_Left�KEY_KP_Leftr��	KEY_Right�KEY_KP_Rightr�r�r��
KEY_BackSpacer�rN�
KEY_Deleter�rQrrr�rrar�rrrr�r�possible_tabkeys_lengthsrkrrqrer_rr)rBr�rwrxr�rjs      rre�'TabEngine._table_mode_process_key_event�sl
����?��L�L���c��3��9�9�t�(�(�5�5�5��%�%�c�g�g�s�x�x����C�C��(�(����1��
�M�M�O�O��8�8�:�:���+�+��0�0�1��/�/�0�1��]�]�-�-�-� �
�
�(@�(@�@� �Y�Y��+�+�5�5��+�+�8�8�9�:���?��L�L�%��!�!��)�)�!%�!:�!:�7�!C�J�!%�!;�!;�G�!D�J��(�&0�O��-�-�c�g�g�s�x�x����K�K��"�"�:�.���7�7�t����(9�(9�:�:��
�
��� �<�<�>�>��)�)�#�'�'�3�8�8�S�Y�Y�G�G�� � ��&�&�(� $� @� @� B�
��"�"�=�1��)�)�#�'�'�3�8�8�S�Y�Y�G�G� �=�=�?�M����}�-���7�7�t�|�|�T�_�_�5�5�$�:K�:K�(
�"�"�$����t�?�?�A�B��%�%�c�g�g�s�x�x����C�C��7�7�t�}�}�d�&6�&6�7�7��3�3�5�5��)�)�#�'�'�3�8�8�S�Y�Y�G�G��"�"�$�C��O�O���J��7�7�t�{�{�D�N�N�3�3��3�3�5�5��)�)�#�'�'�3�8�8�S�Y�Y�G�G��.�.�"�C��O�O���J��G�G��
�
�t�'7�'7�8�8��I�I�� 1� 1� >� >�>��3�3�5�5��)�)�#�'�'�3�8�8�S�Y�Y�G�G��#�#�%��O�O����G�G�����(9�(9�:�:��I�I�� 1� 1� >� >�>��3�3�5�5��)�)�#�'�'�3�8�8�S�Y�Y�G�G��$�$�&��O�O����7�7�t�}�}�d�&6�&6�7�7��3�3�5�5��)�)�#�'�'�3�8�8�S�Y�Y�G�G��O�O���O�O����7�7�t�~�~�t�'8�'8�9�9��3�3�5�5��)�)�#�'�'�3�8�8�S�Y�Y�G�G������O�O����G�G�t�)�)�)��I�I�� 1� 1� >� >�>��3�3�5�5��)�)�#�'�'�3�8�8�S�Y�Y�G�G��-�-�/��O�O����7�7�d�(�(�(��3�3�5�5��)�)�#�'�'�3�8�8�S�Y�Y�G�G������O�O����G�G�t���&��I�I�� 1� 1� >� >�>��3�3�5�5��)�)�#�'�'�3�8�8�S�Y�Y�G�G��,�,�.��O�O����7�7�d�o�o�%��3�3�5�5��)�)�#�'�'�3�8�8�S�Y�Y�G�G��K�K�M��O�O���
�I�I��$�$�1�1��%�%�/�/�0�
1��%�%�c�g�g�s�x�x����C�C��9�9�t�(�(�2�2�2��%�%�c�g�g�s�x�x����C�C�
��!8�!8�#'�#=�#=�">�#'�#<�#<�"=�>��)�)�)�d�m�m�m�$�(F�(F�F��Q�����-�w�8����D�$8�$8��0�0�2�',��$����D�M�M���*�*�+��3�3�4��� 1� 1�2�Q�6� $� 1� 1�"� 5�� @��(�(��=�=�?��.�.�0���!�!�$�-�-���*�*�+��,�,�-��� 1� 1�2�#�}�}�E�E�F��(�(��=�=�?��.�.�0���u��.�.��)�C���$�$��)B�)B�.�N�N�$��9�9�;��=�=�c�B�B��5�5�7����!���!�!�d�&8�&8�&:�&:��&�&��(�(��+�A�.�/��5�5�7��O�O�����Q�����8�'�C��#�#�t�'@�'@�A�'E��"�"�4�#D�#D�#F�G��&�&�(��"�"�4�#C�#C�#E�F��W�%�%��"�"�4�#<�#<�W�#E�F���"�"�4�#=�#=�g�#F�G���!�!�#�'�'�3�8�8�S�Y�Y�?�?rc�f�[S:�a[RS5 URSS5 g)zV
Called for ibus < 1.5.27 when a window gets focus while
this input engine is enabled
r0zentering do_focus_in()
rZN)r�r�r��do_focus_in_idr`s r�do_focus_in�TabEngine.do_focus_in�s(��
��?��L�L�3�4����B��#rrWrnc��[S:�a[RSX5 X lSUR;aa[R
"5unnU(aU=RSU--
sl[S:�a [RSUR5 UR
UR5 UR5 g)u@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

               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', …
r0zobject_path=%s client=%s
�:zself._im_client=%s
N)	r�r�r�r��it_active_window�get_active_windowrDr�rb)rBrWrn�program_name�
_window_titles     rr��TabEngine.do_focus_in_id�s���B��?��L�L�5�{�K� ���d�o�o�%�.�@�@�B�
�\�
�����3��#5�5���Q�����3�T�_�_�E�� � ��!4�!4�5����rc�d�[S:�a[RS5 URS5 g)zW
Called for ibus < 1.5.27 when a window loses focus while
this input engine is enabled
r0zentering do_focus_out()
rZN)r�r�r��do_focus_out_idr`s rrf�TabEngine.do_focus_out�s&��
��?��L�L�4�5����R� rc��[S:�a[RSU5 SUlUR	5 UR5 g)zX
Called for ibus >= 1.5.27 when a window loses focus while
this input engine is enabled
r0zobject_path=%s
rZN)r�r�r�r�rarb)rBrWs  rr��TabEngine.do_focus_out_id�s9��
��?��L�L�+�[�9����
	
�(�(�*����rc�b�[S:�a[RS5 UR5 g)aCalled 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.

r0zdo_reset()
N)r�r�r�r=r`s r�do_reset�TabEngine.do_reset�s ����?��L�L��(��
�
�r�purpose�hintsc
��[RSU[US55 XlX l[
S:�GaUR[
[R5Vs/sHn[U5PM sn;a][
[R5H?nURU:XdM[RSUR[U55 MA O [RSUR5 [RHLnURU-(dM[RS[U5[[U5S55 MN ggs snf)z-Called when the input purpose or hints changezpurpose=%s hints=%s
�016br0zself._input_purpose = %s (%s)z"self._input_purpose = %s (Unknown)zhint: %s %sN)r�r�r�r�r�r��listr�r]r�r��
InputHints)rBr�r�r��
input_purpose�hints      r�do_set_content_type�TabEngine.do_set_content_type�s�����,�g�v�e�V�7L�M�%��!����?��#�#�$(��)=�)=�$>�?�$>�q�C��F�$>�?�@�%)�'�*>�*>�%?�M��*�*�m�;����;� �/�/��]�1C�E�&@����8��'�'�)� �*�*���$�$�t�+�+��L�L�%��D�	�6�#�d�)�V�#<�>�+���?s�Ec��[S:�a[RS5 UR5 UR	5 g)z(Called when this input engine is enabledr0zdo_enable()
N)r�r�r��get_surrounding_textr�r`s r�	do_enable�TabEngine.do_enables/����?��L�L��)�	
�!�!�#����rc��[S:�a[RS5 UR5 UR	5 g)z)Called when this input engine is disabledr0z
do_disable()
N)r�r�r�rarbr`s r�
do_disable�TabEngine.do_disables,����?��L�L�)�*��(�(�*����rc�P�UR5(aUR5 gg)zNCalled when the page up button in the lookup table is clicked with
the mouse

TF)rArbr`s r�
do_page_up�TabEngine.do_page_up#s��
�<�<�>�>��O�O���rc�P�UR5(aUR5 gg)zPCalled when the page down button in the lookup table is clicked with
the mouse

TF)r>rbr`s r�do_page_down�TabEngine.do_page_down-s!��
�>�>����O�O���rc�F�UR5nUR5 U$)zTCalled when the mouse wheel is rolled up in the candidate area of
the lookup table

)r;rbr8s  r�do_cursor_up�TabEngine.do_cursor_up7s��
�n�n��������
rc�F�UR5nUR5 U$)zVCalled when the mouse wheel is rolled down in the candidate area of
the lookup table

)r7rbr8s  r�do_cursor_down�TabEngine.do_cursor_down@s!��
��� �������
r�	_settingsc
�j�[R"URRU55n[RSURX#5 0SUR0S._SUR0S._SUR0S._SUR0S._SUR0S._SUR0S._S	UR0S._S
UR0S._SUR0S._SUR 0S._S
UR"0S._SUR$0S._SUR&0S._SUR(0S._SUR*0S._SUR,0S._SUR.0S._UR0[3SS9S.UR4[3SS9S.UR0[3SS9S.UR4[3SS9S.UR60S.UR80S.UR:0S.S.EnX$;a6XBSnXBSnUS:waUR=[3SS95 U"U40UD6 g[RS5 g)z7
Called when a value in the settings has been changed.
u5Settings changed for engine “%s”: key=%s value=%srh)�set_function�kwargsrjrwrxrvr�r�r�r�r�r�r�r�r�rlrnrprrIr0)r{r~r|rrurtr�r�r�ruFryNzUnknown key)r�r�r�r�r�r�r�rqrzr�r
r�r/r�r�r�rrrOr�r�r�r�r�rr�rr�r�r0r=)rBr�r�r_�
set_functionsr�r�s       rr��$TabEngine.on_gsettings_value_changedIs���
�(�(����)B�)B�3�)G�H�����L��&�&��	4�5
��!�1�1�R�@�5
�
�!�4�4��C�	5
�

�!�1�1�R�@�
5
�
�!�6�6�"�E�5
�
�!�3�3�r�B�5
�
�!�1�1�R�@�5
�
�!�5�5��D�5
�
�!�5�5��D�!5
�"
 �!�9�9�R�H�%5
�&
�!�2�2�b�A�)5
�*
%�!�>�>�"�M�-5
�.
"�!�/�/�2�>�15
�2
�!�2�2�b�A�55
�6
�!�8�8�B�G�95
�:
!�!�:�:�b�I�=5
�>
 �!�9�9�R�H�A5
�B
�!�7�7�2�F�E5
�H"�2�2��q�)�
+�"�7�7��q�)�
+�"�2�2��q�)�
+�"�7�7��q�)�
+�"�0�0�B�?�!�9�9�R�H�!�0�0�B�?�i5
�
�l��(�-�n�=�L�"�'��1�F��k�!��
�
�d�E�:�;���)�&�)�����]�#�r)Vrrrrr�rrrrrrr&rr!r�r'r
r�r�r	rrrrr�r�r�r�r�r�r�rr�r�r2rrrr$r.r*r�rrrr#r�rrr6r:r8r<r�r�rrrr�rr r�r�rr�r�r�r�r�r�rPr�r�r�r�r�r�r�r�r�r�r�r�r�r@r�)F)rN)rZrZrr)T)rZT)r0TrI)FT)rT)FrT)r)rZrZ)rZ)r)��__name__�
__module__�__qualname__�__firstlineno__�__doc__r�Busr�rr!r�rMr1rarer^rkrqrtr�r|r�r�r�r�rr�r�r�r�r�r�r�r�r�r��staticmethodrr�r�r�rr_rrr+r	r7r;r>rArFr�rKrNrQrYr\r_r=rirqrtrzr}r�r�r
r�r	r�r�rr/r�r�r�r�r0r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrOr/rr
rrrrrr�r$r5r(r)rKrJrYrirortrbrzr?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�rrrrrrrrrrr"r%r(r+r.r1r4r7r:r�r\rrNrT�EngineSimplerArXrarkrnrfrer�r�rfr�r�r�r�r�r�r�r�r�rr�r��__static_attributes__�
__classcell__)rIs@rrrs���"�$�e
F����e
F��e
F��	e
F�
�e
F�
)-�e
F�e
F�N�d�&6�&6��,!�=�$�=�
'��c��d��.�3��"7��7�	,��	,�/2�	,�7;�	,�#�4�
!�2�#K��5��c��?�C��s�C�x��@�A�#K�J	+�c�	+�#K��5��c��?�C��s�C�x��@�A�#K�J*�S�*�&�3��!�"!� 	!�	!�����W4��W4��W4��	W4�
�W4�
$(�W4�r�B�t�C�y�B�T�#�Y�B��B�H
"��S�	�
"�\`�ad�\e�
"�jm�
"�����a4��a4��a4��	a4�
�a4�
$(�a4�J����.4��.4��.4��	.4�
�.4�
$(�.4�`k�t�k��k�Z�4��<(�C�(�D�(� G��G�R!!�F�T���4���4�����'��'��'�R8��8�"�$�"2�"2�"�6�5�
�t�
�
�4�
�*�t�*���>B�9�"�9�6:�9�FJ�9�4!��!�
BF�:�"&�:�:>�:�JN�:�0$�D�$�
?C�7�#�7�7;�7�GK�7�,!��!�
<@�/��/�48�/�DH�/�4&�c�&�&*�/� ��c��?�/�#�/�/3�/�:#�3�#�26�I$�%*�4��T�#�Y��+?��+D�%E�I$�*.�I$�:>�I$�V(��c�4��9�n�!5�(�*+�04��#&��)-��9=��>=A�9=�?�59�?�26�?�BF�?�2)��)�$)�%)�:� �:�#�:�/3�:�$ �� ��D��T��6��������"�T��
@D�0��0�8<�0�HL�0�2�$��@D�0��0�8<�0�HL�0�2!�T�!�
;?�.��.�37�.�CG�.�8)��)�
@D�0��0�8<�0�HL�0�,!�T�!�
@D�0��0�8<�0�HL�0�*#�t�#�
<@�/��/�48�/�DH�/�**�#�*�<@�/��/�48�/�DH�/�.)��)�@D�0��0�8<�0�HL�0�*(��(�
>B�9�"�9�6:�9�FJ�9�6!�c�!�
<@�3� �3�48�3�DH�3�@�s����%)�	4��4��4�#�	4�/3�	4�B'�$�x��~�"6�'���%)�	4��4��4�#�	4�/3�	4�B&�t�H�T�N�';�&�;?�.��.�37�.�CG�.�<
"�#�
"�45�4<��s�C�x�.�4<� ��T�4��0�4<�:>�4<�t!"�	-<��-<���S��>�-<��	-<�'+�	-<�^76�x*.���)A�)A�<��<����<�GK�<�|9�,@�FH�P'�B@�,�#�S�#�s�#�D�#�
�t�
�;�C�;�#�;�t�;�;�*�$��0.*�3�.*�3�.*�`
��
�'*�
�47�
�<@�
����	�4�	�
�d�
�
�4�
�	��	����	�D�	��T��*����D���d������d�����,	��	�	�t�	��#��$��$C��C�C��C�C��C�C��C�C��C�C��C�C��C�C��C�C��C�D��D��s��t��"8�T�8�8�T�8�8�T�8�8�T�8�8�T�8�8�T�8�8�T�8�8�T�8�8�T�8�9�d�9��s��t��<@�T�@�@�T�@�@�T�@�@�T�@�@�T�@�@�T�@�@�T�@�@�T�@�@�T�@�A�d�A�')�0��!�!�0��s�m�0�.3�4��:�->�0�d#�C�#�#�#�c�#�d�#�JB��#�#�B��B�#&�B�/2�B�7;�B����(+��47��<@��,9�g�&6�&6�9�4�9�.	�#�	�#�	�	��	��	��7�3C�3C����0Z@��1A�1A�Z@�d�Z@�x$�,�#�,�s�,�t�,�\!�
�3�
�4�
�� >�3�>�s�>�t�>�.���D���d���d�����F� �\�\�F�03�F�8<�F�Frr�__main__)�stream)Dr��__all__�typingrrrrrr	r
r�sysr�r�r�r7�logging�IMPORT_SIMPLEAUDIO_SUCCESSFUL�simpleaudio�ImportError�gettextr
rr��__annotations__r�gir�
gi.repositoryrrrrr�r�r��	getLoggerr�r�r�r!r"�color_string_to_argbr-r.r>rIrKr9r;�
MAJOR_VERSION�
MINOR_VERSION�
MICRO_VERSIONr�r�rr��
StreamHandler�stderr�LOG_HANDLER�setLevel�DEBUG�
addHandler�doctest�testmod�FAILED�	ATTEMPTED�exitrrr�<module>r�s4��.�����������
�	�	���� %��*��$(�!��=��8�S�E�3�J��=�&��H�c�U�C�Z��&���������u��������!����	�	�	�<�	(���!�f��0F�S�0F�T�0F�f�!�6�6�y�A� �5�5�i�@��3�3�I�>� '� <� <�Y� G��2�2�9�=��4�4�Y�?� �5�5�i�@�"�7�7�	�B��0�0��;�&��t�C��t�S�y�!�!�"���!�6�6�y�A� �5�5�i�@��3�3�I�>� '� <� <�Y� G��2�2�9�=��4�4�Y�?� �5�5�i�@�"�7�7�	�B��0�0��;�+�
�D��e�D�#�I�&�&�'��=1��4��c�3��m�,�-�=�~�s��s��*�s��s��.�����"�"�D�$6�$6��8J�8J�K��KB��!�!�KB�ZD�z���'�'�s�z�z�:�K�
�O�O�G�M�M�"�
���k�"��!�/�/�+��V�Y��H�H�V��
��AK	�~�*�$)�!�*�s�L�	L�L

Filemanager

Name Type Size Permission Actions
chinese_variants.cpython-313.pyc File 434.02 KB 0644
factory.cpython-313.pyc File 5.61 KB 0644
ibus_table_location.cpython-313.pyc File 4.87 KB 0644
it_active_window.cpython-313.pyc File 13.01 KB 0644
it_sound.cpython-313.pyc File 23.38 KB 0644
it_util.cpython-313.pyc File 45.11 KB 0644
main.cpython-313.pyc File 18.03 KB 0644
tabcreatedb.cpython-313.pyc File 23.86 KB 0644
table.cpython-313.pyc File 188.3 KB 0644
tabsqlitedb.cpython-313.pyc File 68.79 KB 0644
version.cpython-313.pyc File 423 B 0644
Filemanager