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; }
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; 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; }
boolean UnicodePreFilter(void* arg, FcitxKeySym sym, unsigned int state, INPUT_RETURN_VALUE *r) { INPUT_RETURN_VALUE retVal = IRV_TO_PROCESS; do { UnicodeModule *uni = arg; if (!uni->enable) { return false; } FcitxInstance *instance = uni->owner; FcitxInputState *input = FcitxInstanceGetInputState(instance); FcitxGlobalConfig *fc = FcitxInstanceGetGlobalConfig(instance); FcitxCandidateWordList *candList; FcitxCandidateWord *candWord; candList = FcitxInputStateGetCandidateList(input); FcitxCandidateWordSetPageSize(candList, fc->iMaxCandWord); FcitxCandidateWordSetChooseAndModifier(candList, DIGIT_STR_CHOOSE, FcitxKeyState_Alt); if (FcitxHotkeyIsHotKey(sym, state, FcitxConfigPrevPageKey(instance, fc))) { if (FcitxCandidateWordGoPrevPage(candList)) retVal = IRV_DISPLAY_MESSAGE; else retVal = IRV_DO_NOTHING; } else if (FcitxHotkeyIsHotKey(sym, state, FcitxConfigNextPageKey(instance, fc))) { if (FcitxCandidateWordGoNextPage(candList)) retVal = IRV_DISPLAY_MESSAGE; else retVal = IRV_DO_NOTHING; } else if (FcitxHotkeyIsHotKey(sym, state, FCITX_BACKSPACE)) { size_t len = strlen(uni->buffer); if (len > 0) uni->buffer[--len] = '\0'; if (len == 0) { retVal = IRV_CLEAN; } else { retVal = UnicodeGetCandWords(uni); } } else if (FcitxHotkeyIsHotKey(sym, state, FCITX_ESCAPE)) { retVal = IRV_CLEAN; } else if (FcitxHotkeyIsHotKey(sym, state, fc->nextWord)) { candWord = FcitxCandidateWordGetFocus(candList, true); candWord = FcitxCandidateWordGetNext(candList, candWord); if (!candWord) { FcitxCandidateWordSetPage(candList, 0); candWord = FcitxCandidateWordGetFirst(candList); } else { FcitxCandidateWordSetFocus( candList, FcitxCandidateWordGetIndex(candList, candWord)); } if (candWord) { FcitxCandidateWordSetType(candWord, MSG_CANDIATE_CURSOR); retVal = IRV_FLAG_UPDATE_INPUT_WINDOW; } } else if (FcitxHotkeyIsHotKey(sym, state, fc->prevWord)) { candWord = FcitxCandidateWordGetFocus(candList, true); candWord = FcitxCandidateWordGetPrev(candList, candWord); if (!candWord) { FcitxCandidateWordSetPage( candList, FcitxCandidateWordPageCount(candList) - 1); candWord = FcitxCandidateWordGetLast(candList); } else { FcitxCandidateWordSetFocus( candList, FcitxCandidateWordGetIndex(candList, candWord)); } if (candWord) { FcitxCandidateWordSetType(candWord, MSG_CANDIATE_CURSOR); retVal = IRV_FLAG_UPDATE_INPUT_WINDOW; } } else if (FcitxHotkeyIsHotKey(sym, state, FCITX_ENTER)) { candWord = FcitxCandidateWordGetFocus(candList, true); if (candWord) { retVal = FcitxCandidateWordChooseByTotalIndex( candList, FcitxCandidateWordGetIndex(candList, candWord)); } } if (retVal == IRV_TO_PROCESS) { int index = FcitxCandidateWordCheckChooseKey(candList, sym, state); if (index >= 0) retVal = FcitxCandidateWordChooseByIndex(candList, index); } FcitxKeySym keymain = FcitxHotkeyPadToMain(sym); if (retVal == IRV_TO_PROCESS && FcitxHotkeyIsHotKeySimple(keymain, state)) { char buf[2]; buf[0] = keymain; buf[1] = '\0'; if (strlen(uni->buffer) < MAX_USER_INPUT) strcat(uni->buffer, buf); retVal = UnicodeGetCandWords(uni); } } while(0); if (retVal == IRV_TO_PROCESS) { retVal = IRV_DO_NOTHING; } *r = retVal; return true; }
static boolean ClipboardPreHook(void *arg, FcitxKeySym sym, unsigned int state, INPUT_RETURN_VALUE *ret_val) { FcitxClipboard *clipboard = arg; FcitxInstance *instance = clipboard->owner; if (!clipboard->active) return false; FcitxInputState *input = FcitxInstanceGetInputState(instance); FcitxCandidateWordList *cand_list = FcitxInputStateGetCandidateList(input); FcitxGlobalConfig *fc = FcitxInstanceGetGlobalConfig(instance); *ret_val = IRV_TO_PROCESS; int key; FcitxCandidateWord *cand_word; if (FcitxHotkeyIsHotKey(sym, state, fc->nextWord)) { cand_word = FcitxCandidateWordGetFocus(cand_list, true); cand_word = FcitxCandidateWordGetNext(cand_list, cand_word); if (!cand_word) { FcitxCandidateWordSetPage(cand_list, 0); cand_word = FcitxCandidateWordGetFirst(cand_list); } else { FcitxCandidateWordSetFocus( cand_list, FcitxCandidateWordGetIndex(cand_list, cand_word)); } } else if (FcitxHotkeyIsHotKey(sym, state, fc->prevWord)) { cand_word = FcitxCandidateWordGetFocus(cand_list, true); cand_word = FcitxCandidateWordGetPrev(cand_list, cand_word); if (!cand_word) { FcitxCandidateWordSetPage( cand_list, FcitxCandidateWordPageCount(cand_list) - 1); cand_word = FcitxCandidateWordGetLast(cand_list); } else { FcitxCandidateWordSetFocus( cand_list, FcitxCandidateWordGetIndex(cand_list, cand_word)); } } else if (FcitxHotkeyIsHotKey(sym, state, FcitxConfigPrevPageKey(instance, fc))) { cand_word = FcitxCandidateWordGetFocus(cand_list, true); if (!FcitxCandidateWordGoPrevPage(cand_list)) { FcitxCandidateWordSetType(cand_word, MSG_CANDIATE_CURSOR); *ret_val = IRV_DO_NOTHING; return true; } cand_word = FcitxCandidateWordGetCurrentWindow(cand_list) + FcitxCandidateWordGetCurrentWindowSize(cand_list) - 1; } else if (FcitxHotkeyIsHotKey(sym, state, FcitxConfigNextPageKey(instance, fc))) { cand_word = FcitxCandidateWordGetFocus(cand_list, true); if (!FcitxCandidateWordGoNextPage(cand_list)) { FcitxCandidateWordSetType(cand_word, MSG_CANDIATE_CURSOR); *ret_val = IRV_DO_NOTHING; return true; } cand_word = FcitxCandidateWordGetCurrentWindow(cand_list); } else if ((key = FcitxCandidateWordCheckChooseKey(cand_list, sym, state)) >= 0) { *ret_val = FcitxCandidateWordChooseByIndex(cand_list, key); return true; } else if (FcitxHotkeyIsHotKey(sym, state, FCITX_SPACE)) { cand_word = FcitxCandidateWordGetFocus(cand_list, true); *ret_val = FcitxCandidateWordChooseByTotalIndex( cand_list, FcitxCandidateWordGetIndex(cand_list, cand_word)); return true; } else if (FcitxHotkeyIsHotKey(sym, state, FCITX_ESCAPE)) { *ret_val = IRV_FLAG_RESET_INPUT | IRV_FLAG_UPDATE_INPUT_WINDOW; return true; } else { *ret_val = IRV_DO_NOTHING; return true; } FcitxCandidateWordSetType(cand_word, MSG_CANDIATE_CURSOR); *ret_val = IRV_FLAG_UPDATE_INPUT_WINDOW; return true; }
static INPUT_RETURN_VALUE AutoEngCheckSelect(FcitxAutoEngState *autoEngState, FcitxKeySym sym, unsigned int state) { FcitxInstance *instance = autoEngState->owner; FcitxCandidateWordList *cand_list = FcitxInputStateGetCandidateList( FcitxInstanceGetInputState(autoEngState->owner)); if (!FcitxCandidateWordGetListSize(cand_list)) return IRV_TO_PROCESS; FcitxInputState *input = FcitxInstanceGetInputState(instance); FcitxGlobalConfig *fc = FcitxInstanceGetGlobalConfig(instance); int key; FcitxCandidateWord *cand_word; if (FcitxHotkeyIsHotKey(sym, state, fc->nextWord)) { if (!autoEngState->cursor_moved) { cand_word = FcitxCandidateWordGetCurrentWindow(cand_list); } else { cand_word = FcitxCandidateWordGetFocus(cand_list, true); cand_word = FcitxCandidateWordGetNext(cand_list, cand_word); if (!cand_word) { FcitxCandidateWordSetPage(cand_list, 0); } else { FcitxCandidateWordSetFocus( cand_list, FcitxCandidateWordGetIndex(cand_list, cand_word)); } } } else if (FcitxHotkeyIsHotKey(sym, state, fc->prevWord)) { if (!autoEngState->cursor_moved) { cand_word = FcitxCandidateWordGetByIndex( cand_list, FcitxCandidateWordGetCurrentWindowSize(cand_list) - 1); } else { cand_word = FcitxCandidateWordGetFocus(cand_list, true); cand_word = FcitxCandidateWordGetPrev(cand_list, cand_word); if (cand_word) { FcitxCandidateWordSetFocus( cand_list, FcitxCandidateWordGetIndex(cand_list, cand_word)); } } } else if (FcitxHotkeyIsHotKey(sym, state, FcitxConfigPrevPageKey(instance, fc))) { boolean has_prev_page; cand_word = FcitxCandidateWordGetFocus(cand_list, true); has_prev_page = FcitxCandidateWordGoPrevPage(cand_list); if (!autoEngState->cursor_moved) { cand_word = NULL; } else if (has_prev_page) { cand_word = FcitxCandidateWordGetCurrentWindow(cand_list) + FcitxCandidateWordGetCurrentWindowSize(cand_list) - 1; } } else if (FcitxHotkeyIsHotKey(sym, state, FcitxConfigNextPageKey(instance, fc))) { boolean has_next_page; cand_word = FcitxCandidateWordGetFocus(cand_list, true); has_next_page = FcitxCandidateWordGoNextPage(cand_list); if (!autoEngState->cursor_moved) { cand_word = NULL; } else if (has_next_page) { cand_word = FcitxCandidateWordGetCurrentWindow(cand_list); } } else if ((key = FcitxCandidateWordCheckChooseKey(cand_list, sym, state)) >= 0) { return FcitxCandidateWordChooseByIndex(cand_list, key); } else { return IRV_TO_PROCESS; } if (cand_word) { FcitxCandidateWordSetType(cand_word, MSG_CANDIATE_CURSOR); if (!autoEngState->cursor_moved) AutoEngSwapBuff(autoEngState); AutoEngSetBuff(autoEngState, cand_word->strWord, '\0'); autoEngState->cursor_moved = true; } else if (autoEngState->cursor_moved) { AutoEngSwapBuff(autoEngState); autoEngState->cursor_moved = false; } else { return IRV_FLAG_UPDATE_INPUT_WINDOW; } FcitxMessages *client_preedit = FcitxInputStateGetClientPreedit(input); FcitxMessages *preedit = FcitxInputStateGetPreedit(input); FcitxMessagesSetMessageCount(client_preedit, 0); FcitxMessagesSetMessageCount(preedit, 0); FcitxMessagesAddMessageStringsAtLast(client_preedit, MSG_INPUT, autoEngState->buf); FcitxMessagesAddMessageStringsAtLast(preedit, MSG_INPUT, autoEngState->buf); FcitxInputStateSetCursorPos(input, autoEngState->index); FcitxInputStateSetClientCursorPos(input, autoEngState->index); return IRV_FLAG_UPDATE_INPUT_WINDOW; }
boolean InputWindowEventHandler(void *arg, XEvent* event) { FcitxXlibWindow* window = arg; InputWindow* inputWindow = arg; FcitxInstance* instance = window->owner->owner; FcitxInputState* input = FcitxInstanceGetInputState(instance); if (event->xany.window == window->wId) { switch (event->type) { case MotionNotify: { FcitxCandidateWordList* candList = FcitxInputStateGetCandidateList(input); int x, y; x = event->xbutton.x; y = event->xbutton.y; boolean flag = false; int i; FcitxCandidateWord* candWord; uint32_t newHighlight = 0; for (candWord = FcitxCandidateWordGetCurrentWindow(candList), i = 0; candWord != NULL; candWord = FcitxCandidateWordGetCurrentWindowNext(candList, candWord), i ++) { if (IsInRect(x - window->contentX, y - window->contentY, &inputWindow->candRect[i])) { newHighlight = CANDIDATE_HIGHLIGHT(i); flag = true; break; } } if (!flag) { if (IsInRect(x - window->contentX, y - window->contentY, &inputWindow->prevRect)) { newHighlight = PREVNEXT_HIGHLIGHT(true); } else if (IsInRect(x - window->contentX, y - window->contentY, &inputWindow->nextRect)) { newHighlight = PREVNEXT_HIGHLIGHT(false); } } if (newHighlight != inputWindow->highlight) { inputWindow->highlight = newHighlight; FcitxXlibWindowPaint(&inputWindow->parent); } } break; case Expose: FcitxXlibWindowPaint(&inputWindow->parent); break; case ButtonPress: switch (event->xbutton.button) { case Button1: { MainWindowSetMouseStatus(window->owner->mainWindow, NULL, RELEASE, RELEASE); int x, y; x = event->xbutton.x; y = event->xbutton.y; FcitxCandidateWordList* candList = FcitxInputStateGetCandidateList(input); boolean flag = false; int i; FcitxCandidateWord* candWord; for (candWord = FcitxCandidateWordGetCurrentWindow(candList), i = 0; candWord != NULL; candWord = FcitxCandidateWordGetCurrentWindowNext(candList, candWord), i ++) { if (IsInRect(x - window->contentX, y - window->contentY, &inputWindow->candRect[i])) { FcitxInstanceChooseCandidateByIndex(instance, i); flag = true; break; } } if (flag) break; if (IsInRect(x - window->contentX, y - window->contentY, &inputWindow->prevRect)) { FcitxCandidateWordGoPrevPage(candList); FcitxInstanceProcessInputReturnValue(window->owner->owner, IRV_DISPLAY_CANDWORDS); } else if (IsInRect(x - window->contentX, y - window->contentY, &inputWindow->nextRect)) { FcitxCandidateWordGoNextPage(candList); FcitxInstanceProcessInputReturnValue(window->owner->owner, IRV_DISPLAY_CANDWORDS); } else if (ClassicUIMouseClick(window->owner, window->wId, &x, &y)) { FcitxInputContext* ic = FcitxInstanceGetCurrentIC(window->owner->owner); if (ic) { FcitxInstanceSetWindowOffset(window->owner->owner, ic, x - inputWindow->iOffsetX, y - inputWindow->iOffsetY); } FcitxXlibWindowPaint(&inputWindow->parent); } } break; } break; } return true; } return false; }
/** * @brief Process Key Input and return the status * * @param keycode keycode from XKeyEvent * @param state state from XKeyEvent * @param count count from XKeyEvent * @return INPUT_RETURN_VALUE **/ __EXPORT_API INPUT_RETURN_VALUE FcitxChewingDoInput(void* arg, FcitxKeySym sym, unsigned int state) { FcitxChewing* chewing = (FcitxChewing*) arg; FcitxInputState *input = FcitxInstanceGetInputState(chewing->owner); ChewingContext * ctx = chewing->context; int zuin_len; FcitxCandidateWordList* candList = FcitxInputStateGetCandidateList(input); if (FcitxCandidateWordGetListSize(candList) > 0) { if (FcitxHotkeyIsHotKeyDigit(sym, state) || FcitxHotkeyIsHotKey(sym, state, FCITX_RIGHT) || FcitxHotkeyIsHotKey(sym, state, FCITX_LEFT)) return IRV_TO_PROCESS; if (FcitxHotkeyIsHotKey(sym, state, FCITX_SPACE)) { if (FcitxCandidateWordGoNextPage(candList)) return IRV_DISPLAY_MESSAGE; else return IRV_DO_NOTHING; } } if (FcitxHotkeyIsHotKeySimple(sym, state)) { int scan_code = (int) sym & 0xff; chewing_handle_Default(ctx, scan_code); } else if (FcitxHotkeyIsHotKey(sym, state, FCITX_BACKSPACE)) { char * zuin_str = chewing_zuin_String(ctx, &zuin_len); chewing_free(zuin_str); if (chewing_buffer_Len(ctx) + zuin_len == 0) return IRV_TO_PROCESS; chewing_handle_Backspace(ctx); if (chewing_buffer_Len(ctx) + zuin_len == 0) return IRV_CLEAN; } else if (FcitxHotkeyIsHotKey(sym, state, FCITX_ESCAPE)) { chewing_handle_Esc(ctx); } else if (FcitxHotkeyIsHotKey(sym, state, FCITX_DELETE)) { char * zuin_str = chewing_zuin_String(ctx, &zuin_len); chewing_free(zuin_str); if (chewing_buffer_Len(ctx) + zuin_len == 0) return IRV_TO_PROCESS; chewing_handle_Del(ctx); if (chewing_buffer_Len(ctx) + zuin_len == 0) return IRV_CLEAN; } else if (FcitxHotkeyIsHotKey(sym, state, FCITX_SPACE)) { chewing_handle_Space(ctx); } else if (FcitxHotkeyIsHotKey(sym, state, FCITX_CHEWING_UP)) { chewing_handle_Up(ctx); } else if (FcitxHotkeyIsHotKey(sym, state, FCITX_CHEWING_DOWN)) { chewing_handle_Down(ctx); } else if (FcitxHotkeyIsHotKey(sym, state, FCITX_CHEWING_PGUP)) { chewing_handle_PageDown(ctx); } else if (FcitxHotkeyIsHotKey(sym, state, FCITX_CHEWING_PGDN)) { chewing_handle_PageUp(ctx); } else if (FcitxHotkeyIsHotKey(sym, state, FCITX_RIGHT)) { chewing_handle_Right(ctx); } else if (FcitxHotkeyIsHotKey(sym, state, FCITX_LEFT)) { chewing_handle_Left(ctx); } else if (FcitxHotkeyIsHotKey(sym, state, FCITX_ENTER)) { chewing_handle_Enter(ctx); } else if (state == FcitxKeyState_Ctrl && FcitxHotkeyIsHotKeyDigit(sym, FcitxKeyState_None)) { chewing_handle_CtrlNum(ctx, sym); } else { // to do: more chewing_handle return IRV_TO_PROCESS; } if (chewing_keystroke_CheckAbsorb(ctx)) { return IRV_DISPLAY_CANDWORDS; } else if (chewing_keystroke_CheckIgnore(ctx)) { return IRV_TO_PROCESS; } else if (chewing_commit_Check(ctx)) { char* str = chewing_commit_String(ctx); FcitxInputContext* ic = FcitxInstanceGetCurrentIC(chewing->owner); FcitxInstanceCommitString(chewing->owner, ic, str); chewing_free(str); return IRV_DISPLAY_CANDWORDS; } else return IRV_DISPLAY_CANDWORDS; }
boolean UnicodePreFilter(void* arg, FcitxKeySym sym, unsigned int state, INPUT_RETURN_VALUE *r) { INPUT_RETURN_VALUE retVal = IRV_TO_PROCESS; do { UnicodeModule *uni = arg; if (!uni->enable) break; FcitxInstance *instance = uni->owner; FcitxInputState *input = FcitxInstanceGetInputState(instance); FcitxGlobalConfig *fc = FcitxInstanceGetGlobalConfig(instance); FcitxCandidateWordList *candList; candList = FcitxInputStateGetCandidateList(input); FcitxCandidateWordSetPageSize(candList, 4); FcitxCandidateWordSetChooseAndModifier(candList, DIGIT_STR_CHOOSE, FcitxKeyState_Alt); if (FcitxHotkeyIsHotKey(sym, state, FcitxConfigNextPageKey(instance, fc))) { if (FcitxCandidateWordGoPrevPage(candList)) retVal = IRV_DISPLAY_MESSAGE; else retVal = IRV_DO_NOTHING; } else if (FcitxHotkeyIsHotKey(sym, state, FcitxConfigNextPageKey(instance, fc))) { if (FcitxCandidateWordGoNextPage(candList)) retVal = IRV_DISPLAY_MESSAGE; else retVal = IRV_DO_NOTHING; } else if (FcitxHotkeyIsHotKey(sym, state, FCITX_BACKSPACE)) { size_t len = strlen(uni->buffer); if (len > 0) uni->buffer[--len] = '\0'; if (len == 0) { retVal = IRV_CLEAN; } else { retVal = UnicodeGetCandWords(uni); } } else if (FcitxHotkeyIsHotKey(sym, state, FCITX_ESCAPE)) { retVal = IRV_CLEAN; } if (retVal == IRV_TO_PROCESS) { int index = FcitxCandidateWordCheckChooseKey(candList, sym, state); if (index >= 0) retVal = FcitxCandidateWordChooseByIndex(candList, index); } FcitxKeySym keymain = FcitxHotkeyPadToMain(sym); if (retVal == IRV_TO_PROCESS && FcitxHotkeyIsHotKeySimple(keymain, state)) { char buf[2]; buf[0] = keymain; buf[1] = '\0'; if (strlen(uni->buffer) < MAX_USER_INPUT) strcat(uni->buffer, buf); retVal = UnicodeGetCandWords(uni); } } while(0); *r = retVal; if (retVal == IRV_TO_PROCESS) return false; return true; }