Example #1
0
    def __init__(self, client):
        TextService.__init__(self, client)

        # 輸入法模組自訂區域
        self.imeDirName = "cheliu"
        self.maxCharLength = 4 # 輸入法最大編碼字元數量
        self.cinFileList = ["liu.json"]

        self.cinbase = CinBase
        self.curdir = os.path.abspath(os.path.dirname(__file__))

        # 初始化輸入行為設定
        self.cinbase.initTextService(self, TextService)

        # 載入用戶設定值
        CinBaseConfig.__init__()
        self.configVersion = CinBaseConfig.getVersion()
        self.cfg = copy.deepcopy(CinBaseConfig)
        self.cfg.imeDirName = self.imeDirName
        self.cfg.cinFileList = self.cinFileList
        self.cfg.load()
        self.jsondir = self.cfg.getJsonDir()
        self.cindir = self.cfg.getCinDir()
        self.ignorePrivateUseArea = self.cfg.ignorePrivateUseArea
        self.cinbase.initCinBaseContext(self)

        # 載入輸入法碼表
        if not CinTable.curCinType == self.cfg.selCinType and not CinTable.loading:
            loadCinFile = LoadCinTable(self, CinTable)
            loadCinFile.start()
        else:
            while CinTable.loading:
                continue
            self.cin = CinTable.cin
Example #2
0
    def __init__(self, client):
        TextService.__init__(self, client)

        # 輸入法模組自訂區域
        self.imeDirName = "cheliu"
        self.maxCharLength = 5  # 輸入法最大編碼字元數量
        self.cinFileList = ["liu.json"]

        self.cinbase = CinBase
        self.curdir = os.path.abspath(os.path.dirname(__file__))

        # 初始化輸入行為設定
        self.cinbase.initTextService(self, TextService)

        # 載入用戶設定值
        CinBaseConfig.__init__()
        self.configVersion = CinBaseConfig.getVersion()
        self.cfg = copy.deepcopy(CinBaseConfig)
        self.cfg.imeDirName = self.imeDirName
        self.cfg.cinFileList = self.cinFileList
        self.cfg.load()
        self.jsondir = self.cfg.getJsonDir()
        self.cindir = self.cfg.getCinDir()
        self.ignorePrivateUseArea = self.cfg.ignorePrivateUseArea
        self.cinbase.initCinBaseContext(self)

        # 載入輸入法碼表
        if not CinTable.curCinType == self.cfg.selCinType and not CinTable.loading:
            loadCinFile = LoadCinTable(self, CinTable)
            loadCinFile.start()
        else:
            while CinTable.loading:
                continue
            self.cin = CinTable.cin
Example #3
0
    def __init__(self, client):
        TextService.__init__(self, client)

        # 輸入法模組自訂區域
        self.imeDirName = "chepinyin"
        self.maxCharLength = 7 # 輸入法最大編碼字元數量
        self.cinFileList = ["thpinyin.cin", "pinyin.cin", "roman.cin"]

        self.cinbase = CinBase
        self.curdir = os.path.abspath(os.path.dirname(__file__))
        self.datadir = os.path.join(self.curdir, "data")
        self.cindir = os.path.join(self.curdir, "cin")
        self.icon_dir = self.curdir

        # 初始化輸入行為設定
        self.cinbase.initTextService(self, TextService)

        # 載入用戶設定值
        CinBaseConfig.__init__()
        self.configVersion = CinBaseConfig.getVersion()
        self.cfg = copy.deepcopy(CinBaseConfig)
        self.cfg.imeDirName = self.imeDirName
        self.cfg.cinFileList = self.cinFileList
        self.cfg.cindir = self.cindir
        self.cfg.load()

        # 載入輸入法碼表
        if not CinTable.curCinType == self.cfg.selCinType and not CinTable.loading:
            loadCinFile = LoadCinTable(self, CinTable)
            loadCinFile.start()
        else:
            while CinTable.loading:
                continue
            self.cin = CinTable.cin
Example #4
0
    def __init__(self, client):
        TextService.__init__(self, client)

        # 輸入法模組自訂區域
        self.imeDirName = "chephonetic"
        self.maxCharLength = 4 # 輸入法最大編碼字元數量
        self.cinFileList = ["thphonetic.json", "CnsPhonetic.json", "bpmf.json"]

        self.cinbase = CinBase
        self.curdir = os.path.abspath(os.path.dirname(__file__))

        # 初始化輸入行為設定
        self.cinbase.initTextService(self, TextService)

        # 載入用戶設定值
        CinBaseConfig.__init__()
        self.configVersion = CinBaseConfig.getVersion()
        self.cfg = copy.deepcopy(CinBaseConfig)
        self.cfg.imeDirName = self.imeDirName
        self.cfg.cinFileList = self.cinFileList
        self.cfg.load()
        self.jsondir = self.cfg.getJsonDir()
        self.cindir = self.cfg.getCinDir()
        self.ignorePrivateUseArea = self.cfg.ignorePrivateUseArea
        self.cinbase.initCinBaseContext(self)

        self.keyboardLayout = self.cfg.keyboardLayout
        self.kbtypelist = [
            "1qaz2wsxedcrfv5tgbyhnujm8ik,9ol.0p;/-7634",        # standard kb
            "bpmfdtnlvkhg7c,./j;'sexuaorwiqzy890-=1234",        # ET
            "1234567890-qwertyuiopasdfghjkl;zxcvbn/m,.",        # IBM
            "2wsx3edcrfvtgb6yhnujm8ik,9ol.0p;/-['=1qaz"         # Gin-yieh
        ]

        self.zhuintab = [
            "1qaz2wsxedcrfv5tgbyhn",    # ㄅㄆㄇㄈㄉㄊㄋㄌㄍㄎㄏㄐㄑㄒㄓㄔㄕㄖㄗㄘㄙ
            "ujm",                      # ㄧㄨㄩ
            "8ik,9ol.0p;/-",            # ㄚㄛㄜㄝㄞㄟㄠㄡㄢㄣㄤㄥㄦ
            "7634"                      # ˙ˊˇˋ
        ]

        # 載入輸入法碼表
        if not CinTable.curCinType == self.cfg.selCinType and not CinTable.loading:
            loadCinFile = LoadCinTable(self, CinTable)
            loadCinFile.start()
        else:
            while CinTable.loading:
                continue
            self.cin = CinTable.cin

        self.useEndKey = True
        self.autoShowCandWhenMaxChar = True

        self.endKeyList = []
        self.endKey = self.kbtypelist[self.keyboardLayout][-4:]

        for key in self.endKey:
            self.endKeyList.append(key)
Example #5
0
    def __init__(self, client):
        TextService.__init__(self, client)

        # 輸入法模組自訂區域
        self.imeDirName = "chephonetic"
        self.maxCharLength = 4  # 輸入法最大編碼字元數量
        self.cinFileList = ["thphonetic.json", "CnsPhonetic.json", "bpmf.json"]

        self.cinbase = CinBase
        self.curdir = os.path.abspath(os.path.dirname(__file__))

        # 初始化輸入行為設定
        self.cinbase.initTextService(self, TextService)

        # 載入用戶設定值
        CinBaseConfig.__init__()
        self.configVersion = CinBaseConfig.getVersion()
        self.cfg = copy.deepcopy(CinBaseConfig)
        self.cfg.imeDirName = self.imeDirName
        self.cfg.cinFileList = self.cinFileList
        self.cfg.load()
        self.jsondir = self.cfg.getJsonDir()
        self.cindir = self.cfg.getCinDir()
        self.ignorePrivateUseArea = self.cfg.ignorePrivateUseArea
        self.cinbase.initCinBaseContext(self)

        self.keyboardLayout = self.cfg.keyboardLayout
        self.kbtypelist = [
            "1qaz2wsxedcrfv5tgbyhnujm8ik,9ol.0p;/-7634",  # standard kb
            "bpmfdtnlvkhg7c,./j;'sexuaorwiqzy890-=1234",  # ET
            "1234567890-qwertyuiopasdfghjkl;zxcvbn/m,.",  # IBM
            "2wsx3edcrfvtgb6yhnujm8ik,9ol.0p;/-['=1qaz"  # Gin-yieh
        ]

        self.zhuintab = [
            "1qaz2wsxedcrfv5tgbyhn",  # ㄅㄆㄇㄈㄉㄊㄋㄌㄍㄎㄏㄐㄑㄒㄓㄔㄕㄖㄗㄘㄙ
            "ujm",  # ㄧㄨㄩ
            "8ik,9ol.0p;/-",  # ㄚㄛㄜㄝㄞㄟㄠㄡㄢㄣㄤㄥㄦ
            "7634"  # ˙ˊˇˋ
        ]

        # 載入輸入法碼表
        if not CinTable.curCinType == self.cfg.selCinType and not CinTable.loading:
            loadCinFile = LoadCinTable(self, CinTable)
            loadCinFile.start()
        else:
            while CinTable.loading:
                continue
            self.cin = CinTable.cin

        self.useEndKey = True
        self.autoShowCandWhenMaxChar = True

        self.endKeyList = []
        self.endKey = self.kbtypelist[self.keyboardLayout][-4:]

        for key in self.endKey:
            self.endKeyList.append(key)
Example #6
0
    def __init__(self, client):
        TextService.__init__(self, client)

        # 輸入法模組自訂區域
        self.imeDirName = "checj"
        self.maxCharLength = 5  # 輸入法最大編碼字元數量
        self.cinFileList = [
            "checj.cin", "mscj3.cin", "mscj3-ext.cin", "cj-ext.cin",
            "cnscj.cin", "thcj.cin", "newcj3.cin", "cj5.cin", "newcj.cin",
            "scj6.cin"
        ]

        self.cinbase = CinBase
        self.curdir = os.path.abspath(os.path.dirname(__file__))

        # 初始化輸入行為設定
        self.cinbase.initTextService(self, TextService)

        # 載入用戶設定值
        CinBaseConfig.__init__()
        self.configVersion = CinBaseConfig.getVersion()
        self.cfg = copy.deepcopy(CinBaseConfig)
        self.cfg.imeDirName = self.imeDirName
        self.cfg.cinFileList = self.cinFileList
        self.cfg.load()

        # 載入輸入法碼表
        self.cindir = self.cfg.getCinDir()
        if not CinTable.curCinType == self.cfg.selCinType and not CinTable.loading:
            loadCinFile = LoadCinTable(self, CinTable)
            loadCinFile.start()
        else:
            while CinTable.loading:
                continue
            self.cin = CinTable.cin

        # 反查輸入法字根
        if self.cfg.imeReverseLookup:
            self.imeReverseLookup = self.cfg.imeReverseLookup
            self.rcinFileList = self.cfg.rcinFileList
            self.selRCinType = self.cfg.selRCinType
            if not self.rcinFileList:
                self.cinbase.updateRcinFileList(self)

            if not RCinTable.curCinType == self.cfg.selRCinType and not RCinTable.loading:
                loadRCinFile = LoadRCinTable(self, RCinTable)
                loadRCinFile.start()
            else:
                while RCinTable.loading:
                    continue
                self.rcin = RCinTable.cin
Example #7
0
    def onKeyDown(self, keyEvent):
        # Num鍵盤對映
        candidates = []
        if keyEvent.isKeyToggled(
                VK_NUMLOCK
        ) and keyEvent.keyCode >= VK_NUMPAD0 and keyEvent.keyCode <= VK_DIVIDE and self.langMode == CHINESE_MODE and not self.tempEnglishMode:
            charStr = chr(keyEvent.keyCode - 48)
            if self.isShowCandidates and self.isInSelKeys(
                    self, keyEvent.keyCode - 48
            ) and not keyEvent.isKeyDown(VK_SHIFT):  # 使用選字鍵執行項目或輸出候選字
                if self.selKeys.index(
                        charStr) < self.candPerPage and self.selKeys.index(
                            charStr) < len(self.candidateList):
                    # print("選字", charStr, self.selKeys.index(charStr))
                    candCursor = self.selKeys.index(charStr)
                    itemName = self.candidateList[candCursor]
                    self.switchmenu = True
                    i = self.selKeys.index(charStr)
                    if i < self.candPerPage and i < len(self.candidateList):
                        commitStr = self.candidateList[i]
                        self.lastCommitString = commitStr
                        self.setOutputString(self, RCinTable, commitStr)
                        if self.showPhrase and not self.selcandmode:
                            self.phrasemode = True
                        self.resetComposition(self)
                        candCursor = 0
                        currentCandPage = 0
            #  組字字根超過最大值
            elif len(self.compositionChar) >= self.maxCharLength:
                if self.cin.isInKeyName(
                        self.compositionChar[len(self.compositionChar) - 1:]):
                    keyLength = len(
                        self.cin.getKeyName(
                            self.compositionChar[len(self.compositionChar) -
                                                 1:]))
                else:
                    keyLength = 1
                if self.compositionBufferMode:
                    self.removeCompositionBufferString(self, keyLength, False)
                else:
                    self.setCompositionString(
                        self.compositionString[:-keyLength])
                self.compositionChar = self.compositionChar[:-1]
            elif not keyEvent.isKeyDown(VK_SHIFT) and not keyEvent.isKeyDown(
                    VK_CONTROL):
                if keyEvent.keyCode == VK_DECIMAL:
                    self.compositionChar += "*"
                    self.useMagicKey = True
                else:
                    self.compositionChar += charStr
                if self.compositionBufferMode:
                    self.cinbase.setCompositionBufferString(
                        self, self.compositionChar, 0)
                else:
                    self.setCompositionString(self.compositionChar)
                if (self.langMode == CHINESE_MODE
                        and len(self.compositionChar) >= 1
                        and not self.menumode) or (self.tempEnglishMode
                                                   and self.isComposing()):
                    # 載入輸入法碼表
                    try:
                        if self.cin.isInCharDef(self.compositionChar):
                            candidates = self.cin.getCharDef(
                                self.compositionChar)
                    except:
                        if not CinTable.curCinType == self.cfg.selCinType and not CinTable.loading:
                            loadCinFile = LoadCinTable(self, CinTable)
                            loadCinFile.start()
                        else:
                            while CinTable.loading:
                                continue
                            self.cin = CinTable.cin
                            if self.cin.isInCharDef(self.compositionChar):
                                candidates = self.cin.getCharDef(
                                    self.compositionChar)
                    print("候選字", candidates)
                    # 字滿及符號處理 (大易、注音、輕鬆)
                    if len(self.compositionChar) == self.maxCharLength:
                        if self.useMagicKey:
                            candidates = self.cin.getWildcardCharDefs(
                                self.compositionChar, "*", 9)
                        if candidates and not self.phrasemode:
                            if len(candidates) > 1:
                                self.setCandidateList(candidates)
                                self.setShowCandidates(True)
                                self.canSetCommitString = False
                                self.isShowCandidates = True
                                self.useMagicKey = False
                            else:
                                commitStr = candidates[0]
                                self.lastCommitString = commitStr
                                self.setOutputString(self, RCinTable,
                                                     commitStr)
                                if self.showPhrase and not self.selcandmode:
                                    self.phrasemode = True
                                self.resetComposition(self)
                                candCursor = 0
                                currentCandPage = 0
                                self.canSetCommitString = True
                                self.isShowCandidates = False
                                self.useMagicKey = False
                            return True
        # 如果數字不滿,則後面補零
        if keyEvent.keyCode == VK_RETURN and not self.showCandidates and (
                self.langMode == CHINESE_MODE
                and len(self.compositionChar) >= 1 and not self.menumode) or (
                    self.tempEnglishMode
                    and self.isComposing()) and not self.showmenu:
            # while len(self.compositionChar) < self.maxCharLength and self.compositionChar != "":
            # self.compositionChar += str(0)
            # 載入輸入法碼表
            try:
                if self.useMagicKey:
                    candidates = self.cin.getWildcardCharDefs(
                        self.compositionChar, "*", 9)
                elif self.cin.isInCharDef(self.compositionChar):
                    candidates = self.cin.getCharDef(self.compositionChar)
            except:
                if not CinTable.curCinType == self.cfg.selCinType and not CinTable.loading:
                    loadCinFile = LoadCinTable(self, CinTable)
                    loadCinFile.start()
                else:
                    while CinTable.loading:
                        continue
                    self.cin = CinTable.cin
                    if self.useMagicKey:
                        candidates = self.cin.getWildcardCharDefs(
                            self.compositionChar, "*", 9)
                    elif self.cin.isInCharDef(self.compositionChar):
                        candidates = self.cin.getCharDef(self.compositionChar)
            print("候選字", candidates)
            if candidates and not self.phrasemode:
                if len(candidates) > 1:
                    self.setCandidateList(candidates)
                    self.setShowCandidates(True)
                    self.canSetCommitString = False
                    self.isShowCandidates = True
                    self.useMagicKey = False
                else:
                    commitStr = candidates[0]
                    self.lastCommitString = commitStr

                    self.setOutputString(self, RCinTable, commitStr)
                    if self.showPhrase and not self.selcandmode:
                        self.phrasemode = True
                    self.resetComposition(self)
                    candCursor = 0
                    currentCandPage = 0
                    self.canSetCommitString = True
                    self.isShowCandidates = False
                    self.useMagicKey = False
                return True
                # if not self.isShowCandidates:
                #     if self.compositionBufferMode:
                # if not len(self.compositionChar) == 1:

                # if len(candidates) > 1:
                #     self.isShowCandidates = True
                #     self.canUseSelKey = True
                #     self.canSetCommitString = True
                #     self.setCandidateList(candidates)
                #     self.setShowCandidates(True)
                # else:
                #     commitStr = candidates[0]
                #     self.lastCommitString = commitStr
                #     self.setOutputString(self, RCinTable, commitStr)
                #     if self.showPhrase and not self.selcandmode:
                #         self.phrasemode = True
                #     self.resetComposition(self)
                #     candCursor = 0
                #     currentCandPage = 0
                #     self.canSetCommitString = True
                #     self.isShowCandidates = True
                # # else:
                #     self.isShowCandidates = True
                #     self.canUseSelKey = True
        KeyState = self.cinbase.onKeyDown(self, keyEvent, CinTable, RCinTable,
                                          HCinTable)
        return KeyState