INPUT_RETURN_VALUE QuickPhraseDoInput(void* arg, FcitxKeySym sym, int state) { QuickPhraseState *qpstate = (QuickPhraseState*) arg; FcitxInputState *input = FcitxInstanceGetInputState(qpstate->owner); FcitxGlobalConfig* fc = FcitxInstanceGetGlobalConfig(qpstate->owner); int retVal = IRV_TO_PROCESS; const FcitxHotkey* hkPrevPage = FcitxInstanceGetContextHotkey(qpstate->owner, CONTEXT_ALTERNATIVE_PREVPAGE_KEY); if (hkPrevPage == NULL) hkPrevPage = fc->hkPrevPage; const FcitxHotkey* hkNextPage = FcitxInstanceGetContextHotkey(qpstate->owner, CONTEXT_ALTERNATIVE_NEXTPAGE_KEY); if (hkNextPage == NULL) hkNextPage = fc->hkNextPage; if (FcitxHotkeyIsHotKey(sym, state, hkPrevPage)) { if (FcitxCandidateWordGoPrevPage(FcitxInputStateGetCandidateList(input))) retVal = IRV_DISPLAY_MESSAGE; } else if (FcitxHotkeyIsHotKey(sym, state, hkNextPage)) { if (FcitxCandidateWordGoNextPage(FcitxInputStateGetCandidateList(input))) retVal = IRV_DISPLAY_MESSAGE; } else if (FcitxHotkeyIsHotKeyDigit(sym, state)) { int iKey = FcitxHotkeyCheckChooseKey(sym, state, DIGIT_STR_CHOOSE); if (iKey >= 0) retVal = FcitxCandidateWordChooseByIndex(FcitxInputStateGetCandidateList(input), iKey); } else if (FcitxHotkeyIsHotKey(sym, state, FCITX_SPACE)) { if (FcitxCandidateWordPageCount(FcitxInputStateGetCandidateList(input)) != 0) retVal = FcitxCandidateWordChooseByIndex(FcitxInputStateGetCandidateList(input), 0); } return retVal; }
boolean IMSelectorPreFilter(void* arg, FcitxKeySym sym, unsigned int state, INPUT_RETURN_VALUE* retval) { IMSelector* imselector = arg; FcitxInstance* instance = imselector->owner; FcitxInputState *input = FcitxInstanceGetInputState(instance); FcitxGlobalConfig* fc = FcitxInstanceGetGlobalConfig(instance); if (!imselector->triggered) return false; FcitxCandidateWordList* candList = FcitxInputStateGetCandidateList(input); if (FcitxHotkeyIsHotKey(sym, state, FcitxConfigPrevPageKey(instance, fc))) { FcitxCandidateWordGoPrevPage(candList); *retval = IRV_DISPLAY_MESSAGE; } else if (FcitxHotkeyIsHotKey(sym, state, FcitxConfigNextPageKey(instance, fc))) { FcitxCandidateWordGoNextPage(candList); *retval = IRV_DISPLAY_MESSAGE; } else if (FcitxHotkeyIsHotKey(sym, state, FCITX_SPACE)) { if (FcitxCandidateWordPageCount(candList) != 0) *retval = FcitxCandidateWordChooseByIndex(candList, 0); } else if (FcitxHotkeyIsHotKeyDigit(sym, state)) { int iKey = FcitxHotkeyCheckChooseKey(sym, state, DIGIT_STR_CHOOSE); if (iKey >= 0) *retval = FcitxCandidateWordChooseByIndex(candList, iKey); } else if (FcitxHotkeyIsHotKey(sym, state, FCITX_ESCAPE)) { *retval = IRV_CLEAN; } if (*retval == IRV_TO_PROCESS) *retval = IRV_DO_NOTHING; return true; }
boolean IMSelectorPreFilter(void* arg, FcitxKeySym sym, unsigned int state, INPUT_RETURN_VALUE* retval) { IMSelector* imselector = arg; FcitxInstance* instance = imselector->owner; FcitxInputState *input = FcitxInstanceGetInputState(instance); FcitxGlobalConfig* fc = FcitxInstanceGetGlobalConfig(instance); if (!imselector->triggered) return false; const FcitxHotkey* hkPrevPage = FcitxInstanceGetContextHotkey(instance, CONTEXT_ALTERNATIVE_PREVPAGE_KEY); if (hkPrevPage == NULL) hkPrevPage = fc->hkPrevPage; const FcitxHotkey* hkNextPage = FcitxInstanceGetContextHotkey(instance, CONTEXT_ALTERNATIVE_NEXTPAGE_KEY); if (hkNextPage == NULL) hkNextPage = fc->hkNextPage; FcitxCandidateWordList* candList = FcitxInputStateGetCandidateList(input); if (FcitxHotkeyIsHotKey(sym, state, hkPrevPage)) { FcitxCandidateWordGoPrevPage(candList); *retval = IRV_DISPLAY_MESSAGE; } else if (FcitxHotkeyIsHotKey(sym, state, hkNextPage)) { FcitxCandidateWordGoNextPage(candList); *retval = IRV_DISPLAY_MESSAGE; } else if (FcitxHotkeyIsHotKey(sym, state, FCITX_SPACE)) { if (FcitxCandidateWordPageCount(candList) != 0) *retval = FcitxCandidateWordChooseByIndex(candList, 0); } else if (FcitxHotkeyIsHotKeyDigit(sym, state)) { int iKey = FcitxHotkeyCheckChooseKey(sym, state, DIGIT_STR_CHOOSE); if (iKey >= 0) *retval = FcitxCandidateWordChooseByIndex(candList, iKey); } else if (FcitxHotkeyIsHotKey(sym, state, FCITX_ESCAPE)) { *retval = IRV_CLEAN; } else { *retval = IRV_DO_NOTHING; } return true; }