本文整理汇总了C++中FcitxInstanceGetInputState函数的典型用法代码示例。如果您正苦于以下问题:C++ FcitxInstanceGetInputState函数的具体用法?C++ FcitxInstanceGetInputState怎么用?C++ FcitxInstanceGetInputState使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FcitxInstanceGetInputState函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LuaCallCommand
static void* LuaCallCommand(void* arg, FcitxModuleFunctionArg args) {
LuaModule *luamodule = (LuaModule *)arg;
UT_array *result = InputCommand(luamodule, (const char *)args.args[0]);
if (result) {
FcitxInputState* input = FcitxInstanceGetInputState(GetFcitx(luamodule));
LuaResultItem *p = NULL;
while ((p = (LuaResultItem *)utarray_next(result, p))) {
FcitxCandidateWord candWord;
if (args.args[1] && args.args[2]) {
candWord.callback = args.args[1];
candWord.owner = args.args[2];
}
else {
candWord.callback = LuaGetCandWord;
candWord.owner = luamodule;
}
candWord.priv = p->help ? strdup(p->help) : NULL;
if (p->help || p->tip) {
asprintf(&candWord.strExtra, "%s%s%s", p->help ? p->help : "", p->help && p->tip ? " " : "", p->tip ? p->tip : "");
} else {
candWord.strExtra = NULL;
}
candWord.strWord = strdup(p->result);
candWord.wordType = MSG_TIPS;
candWord.extraType = MSG_CODE;
FcitxCandidateWordAppend(FcitxInputStateGetCandidateList(input), &candWord);
}
utarray_free(result);
}
return NULL;
}
示例2: CloudPinyinAddCandidateWord
void CloudPinyinAddCandidateWord(void* arg)
{
FcitxCloudPinyin* cloudpinyin = (FcitxCloudPinyin*) arg;
FcitxIM* im = FcitxInstanceGetCurrentIM(cloudpinyin->owner);
FcitxInputState* input = FcitxInstanceGetInputState(cloudpinyin->owner);
if (cloudpinyin->initialized == false)
return;
/* check whether the current im is pinyin */
if (CHECK_VALID_IM)
{
/* there is something pending input */
if (FcitxInputStateGetRawInputBufferSize(input) >= cloudpinyin->config.iMinimumPinyinLength)
{
char* strToFree = NULL, *inputString;
strToFree = GetCurrentString(cloudpinyin);
inputString = SplitHZAndPY(strToFree);
if (inputString)
{
CloudPinyinCache* cacheEntry = CloudPinyinCacheLookup(cloudpinyin, inputString);
FcitxLog(LOGLEVEL, "%s", inputString);
if (cacheEntry == NULL)
CloudPinyinAddInputRequest(cloudpinyin, inputString);
_CloudPinyinAddCandidateWord(cloudpinyin, inputString);
}
if (strToFree)
free(strToFree);
}
}
return;
}
示例3: QuickPhraseDoInput
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;
}
示例4: QWGetCandWords
INPUT_RETURN_VALUE QWGetCandWords(void *arg)
{
FcitxQWState* qwstate = (FcitxQWState*) arg;
FcitxInputState* input = FcitxInstanceGetInputState(qwstate->owner);
int iQu, iWei;
int i;
FcitxCandidateWordSetPageSize(FcitxInputStateGetCandidateList(input), 10);
FcitxCandidateWordSetChoose(FcitxInputStateGetCandidateList(input), DIGIT_STR_CHOOSE);
if (FcitxInputStateGetRawInputBufferSize(input) == 3) {
iQu = (FcitxInputStateGetRawInputBuffer(input)[0] - '0') * 10 + FcitxInputStateGetRawInputBuffer(input)[1] - '0';
iWei = (FcitxInputStateGetRawInputBuffer(input)[2] - '0') * 10;
for (i = 0; i < 10; i++) {
FcitxCandidateWord candWord;
candWord.callback = QWGetCandWord;
candWord.owner = qwstate;
candWord.priv = NULL;
candWord.strExtra = NULL;
candWord.strWord = strdup(GetQuWei(qwstate, iQu, iWei + i + 1));
candWord.wordType = MSG_OTHER;
FcitxCandidateWordAppend(FcitxInputStateGetCandidateList(input), &candWord);
}
}
FcitxInputStateSetCursorPos(input, FcitxInputStateGetRawInputBufferSize(input));
FcitxMessagesSetMessageCount(FcitxInputStateGetPreedit(input), 0);
FcitxMessagesAddMessageAtLast(FcitxInputStateGetPreedit(input), MSG_INPUT, "%s", FcitxInputStateGetRawInputBuffer(input));
return IRV_DISPLAY_CANDWORDS;
}
示例5: _CloudPinyinAddCandidateWord
void _CloudPinyinAddCandidateWord(FcitxCloudPinyin* cloudpinyin, const char* pinyin)
{
CloudPinyinCache* cacheEntry = CloudPinyinCacheLookup(cloudpinyin, pinyin);
FcitxInputState* input = FcitxInstanceGetInputState(cloudpinyin->owner);
FcitxCandidateWordList* candList = FcitxInputStateGetCandidateList(input);
int order = (cloudpinyin->config.iCandidateOrder <= 2) ?
1 : (cloudpinyin->config.iCandidateOrder - 1);
if (cacheEntry) {
FcitxCandidateWord* cand;
/* only check the first three page */
int pagesize = FcitxCandidateWordGetPageSize(candList);
int size = pagesize * CLOUDPINYIN_CHECK_PAGE_NUMBER;
int i;
if (cloudpinyin->config.iCandidateOrder <= 1) {
order = 0;
}
for (i = 0;i < size &&
(cand = FcitxCandidateWordGetByTotalIndex(candList, i));i++) {
if (strcmp(cand->strWord, cacheEntry->str) == 0) {
if (i > order && i >= pagesize) {
FcitxCandidateWordMoveByWord(candList, cand, order);
if (order == 0) {
CloudSetClientPreedit(cloudpinyin, cacheEntry->str);
}
}
return;
}
}
if (order == 0) {
CloudSetClientPreedit(cloudpinyin, cacheEntry->str);
}
}
FcitxCandidateWord candWord;
CloudCandWord* cloudCand = fcitx_utils_malloc0(sizeof(CloudCandWord));
if (cacheEntry) {
cloudCand->filled = true;
cloudCand->timestamp = 0;
candWord.strWord = strdup(cacheEntry->str);
} else {
cloudCand->filled = false;
cloudCand->timestamp = CloudGetTimeStamp();
candWord.strWord = strdup("..");
}
candWord.callback = CloudPinyinGetCandWord;
candWord.owner = cloudpinyin;
candWord.priv = cloudCand;
candWord.wordType = MSG_TIPS;
if (cloudpinyin->config.bDontShowSource)
candWord.strExtra = NULL;
else {
candWord.strExtra = strdup(_(" (via cloud)"));
candWord.extraType = MSG_TIPS;
}
FcitxCandidateWordInsert(candList, &candWord, order);
}
示例6: XimUpdatePreedit
void XimUpdatePreedit(void* arg, FcitxInputContext* ic)
{
FcitxXimFrontend* xim = (FcitxXimFrontend*) arg;
FcitxInputState* input = FcitxInstanceGetInputState(xim->owner);
char* strPreedit = FcitxUIMessagesToCString(FcitxInputStateGetClientPreedit(input));
char* str = FcitxInstanceProcessOutputFilter(xim->owner, strPreedit);
if (str) {
free(strPreedit);
strPreedit = str;
}
if (strlen(strPreedit) == 0 && GetXimIC(ic)->bPreeditStarted == true) {
XimPreeditCallbackDraw(xim, GetXimIC(ic), strPreedit, 0);
XimPreeditCallbackDone(xim, GetXimIC(ic));
GetXimIC(ic)->bPreeditStarted = false;
}
if (strlen(strPreedit) != 0 && GetXimIC(ic)->bPreeditStarted == false) {
XimPreeditCallbackStart(xim, GetXimIC(ic));
GetXimIC(ic)->bPreeditStarted = true;
}
if (strlen(strPreedit) != 0) {
XimPreeditCallbackDraw(xim, GetXimIC(ic), strPreedit, FcitxInputStateGetClientCursorPos(input));
}
free(strPreedit);
}
示例7: IMSelectorPreFilter
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;
}
示例8: FcitxTabletGetCandWords
// This function is called from within fcitx. It is called when the
// list of input candidates has changed. It extracts the candidates
// from the recognition engine and puts them into the format required
// by fcitx for displaying in its popup window
INPUT_RETURN_VALUE FcitxTabletGetCandWords(void* arg) {
FcitxTablet* tablet = (FcitxTablet*) arg;
FcitxInputState *input = FcitxInstanceGetInputState(tablet->fcitx);
FcitxInstanceCleanInputWindow(tablet->fcitx);
char* c = tablet->engineInstance->GetCandidates(tablet->engineData);
int len = strlen(c);
int i = 0;
do {
int n = mblen(&c[i], len);
if(n <= 0) break;
FcitxCandidateWord cw;
cw.callback = FcitxTabletGetCandWord;
cw.strExtra = NULL;
cw.priv = NULL;
cw.owner = tablet;
cw.wordType = MSG_OTHER;
// TODO does fcitx free this?
cw.strWord = (char*) malloc(n+1);
memcpy(cw.strWord, &c[i], n);
cw.strWord[n] = 0;
FcitxCandidateWordAppend(FcitxInputStateGetCandidateList(input), &cw);
i += n;
} while(1);
return IRV_DISPLAY_CANDWORDS;
}
示例9: UnicodeGetCandWord
INPUT_RETURN_VALUE UnicodeGetCandWord(void* arg, FcitxCandidateWord* candWord)
{
UnicodeModule* uni = arg;
FcitxInputState *input = FcitxInstanceGetInputState(uni->owner);
strcpy(FcitxInputStateGetOutputString(input), candWord->strWord);
return IRV_COMMIT_STRING;
}
示例10: PostInputProcessAutoEng
boolean PostInputProcessAutoEng(void* arg, FcitxKeySym sym, unsigned int state, INPUT_RETURN_VALUE* retval)
{
FcitxAutoEngState* autoEngState = (FcitxAutoEngState*) arg;
FcitxInputState* input = FcitxInstanceGetInputState(autoEngState->owner);
//boolean disableCheckUAZ = FcitxInstanceGetContextBoolean(autoEngState->owner, CONTEXT_DISABLE_AUTOENG);
//if (disableCheckUAZ)
// return false;
if (autoEngState->enable == false)
return false;
FcitxIM *im = FcitxInstanceGetCurrentIM(autoEngState->owner);
if (im == NULL || strcmp("sogoupinyin", im->uniqueName) != 0)
return false;
if (FcitxHotkeyIsHotKeyUAZ(sym, state) &&
(FcitxInputStateGetRawInputBufferSize(input) != 0 ||
(FcitxInputStateGetKeyState(input) & FcitxKeyState_CapsLock) == 0) &&
AutoEngCheckPreedit(autoEngState)) {
AutoEngSetBuff(autoEngState, FcitxInputStateGetRawInputBuffer(input),
FcitxHotkeyPadToMain(sym));
AutoEngActivate(autoEngState, input, retval);
return true;
}
return false;
}
示例11: UnicodeGetCandWords
INPUT_RETURN_VALUE UnicodeGetCandWords(UnicodeModule* uni)
{
FcitxInputState *input = FcitxInstanceGetInputState(uni->owner);
FcitxInstanceCleanInputWindow(uni->owner);
FcitxMessagesAddMessageStringsAtLast(FcitxInputStateGetPreedit(input),
MSG_INPUT, uni->buffer);
FcitxInputStateSetShowCursor(input, true);
FcitxInputStateSetCursorPos(input, strlen(uni->buffer));
FcitxCandidateWordList* candList = FcitxInputStateGetCandidateList(input);
FcitxCandidateWordSetLayoutHint(candList, CLH_Vertical);
UT_array* result = CharSelectDataFind(uni->charselectdata, uni->buffer);
utarray_foreach(c, result, uint32_t) {
char* s = fcitx_utils_malloc0(sizeof(char) * (UTF8_MAX_LENGTH + 1));
fcitx_ucs4_to_utf8(*c, s);
FcitxCandidateWord candWord;
candWord.callback = UnicodeGetCandWord;
candWord.owner = uni;
candWord.priv = NULL;
candWord.extraType = MSG_OTHER;
candWord.wordType = MSG_CODE;
candWord.strWord = s;
char* name = CharSelectDataName(uni->charselectdata, *c);
fcitx_utils_alloc_cat_str(candWord.strExtra, " ", name);
free(name);
FcitxCandidateWordAppend(candList, &candWord);
}
示例12: QuickPhraseGetCandWord
INPUT_RETURN_VALUE QuickPhraseGetCandWord(void* arg, FcitxCandidateWord* candWord)
{
QuickPhraseState *qpstate = (QuickPhraseState*) arg;
QuickPhraseCand* qpcand = candWord->priv;
FcitxInputState *input = FcitxInstanceGetInputState(qpstate->owner);
strcpy(FcitxInputStateGetOutputString(input), qpcand->cand->strPhrase);
return IRV_COMMIT_STRING;
}
示例13: FcitxKkcDoInput
INPUT_RETURN_VALUE FcitxKkcDoInput(void* arg, FcitxKeySym _sym, unsigned int _state)
{
FcitxKkc *kkc = (FcitxKkc*)arg;
FcitxInputState* input = FcitxInstanceGetInputState(kkc->owner);
FcitxKeySym sym = (FcitxKeySym) FcitxInputStateGetKeySym(input);
uint32_t state = FcitxInputStateGetKeyState(input);
return FcitxKkcDoInputReal(arg, sym, state);
}
示例14: IMSelectorGetCands
void IMSelectorGetCands(IMSelector* imselector)
{
FcitxInstance* instance = imselector->owner;
FcitxInputState *input = FcitxInstanceGetInputState(instance);
UT_array* imes = FcitxInstanceGetIMEs(instance);
FcitxInstanceCleanInputWindow(instance);
FcitxCandidateWordList* candList = FcitxInputStateGetCandidateList(input);
FcitxCandidateWordSetPageSize(candList, 10);
FcitxCandidateWordSetChoose(candList, DIGIT_STR_CHOOSE);
FcitxInputStateSetShowCursor(input, false);
FcitxCandidateWordSetOverrideDefaultHighlight(candList, false);
FcitxCandidateWordSetLayoutHint(candList, CLH_Vertical);
FcitxIM* im = FcitxInstanceGetCurrentIM(instance);
FcitxInputContext* ic = FcitxInstanceGetCurrentIC(instance);
FcitxInputContext2* ic2 = (FcitxInputContext2*) ic;
if (!ic)
return;
FcitxMessages *aux_up = FcitxInputStateGetAuxUp(input);
FcitxMessagesAddMessageStringsAtLast(aux_up, MSG_TIPS, imselector->global ?
_("Select global input method: ") :
_("Select local input method: "));
if (ic2->imname) {
int idx = FcitxInstanceGetIMIndexByName(instance, ic2->imname);
FcitxIM *im = fcitx_array_eltptr(imes, idx);
if (im) {
FcitxMessagesAddMessageStringsAtLast(aux_up, MSG_TIPS,
_("Current local input method is "), im->strName);
}
} else {
FcitxMessagesAddMessageStringsAtLast(aux_up, MSG_TIPS,
_("No local input method"));
}
utarray_foreach(pim, imes, FcitxIM) {
FcitxCandidateWord candWord;
candWord.callback = IMSelectorGetCand;
candWord.owner = imselector;
candWord.strExtra = NULL;
if (ic2->imname && strcmp(ic2->imname, pim->uniqueName) == 0) {
candWord.priv = NULL;
candWord.strWord = strdup(_("Clear local input method"));
}
else {
candWord.priv = strdup(pim->uniqueName);
candWord.strWord = strdup(pim->strName);
}
if (im && strcmp(im->uniqueName, pim->uniqueName) == 0) {
candWord.wordType = MSG_CANDIATE_CURSOR;
} else {
candWord.wordType = MSG_OTHER;
}
FcitxCandidateWordAppend(candList, &candWord);
}
示例15: ShowQuickPhraseMessage
void ShowQuickPhraseMessage(QuickPhraseState *qpstate)
{
FcitxInputState *input = FcitxInstanceGetInputState(qpstate->owner);
FcitxInputStateSetCursorPos(input, strlen(FcitxInputStateGetRawInputBuffer(input)));
FcitxInstanceCleanInputWindowUp(qpstate->owner);
FcitxMessagesAddMessageAtLast(FcitxInputStateGetAuxUp(input), MSG_TIPS, "%s", _("Quick Phrase: "));
FcitxMessagesAddMessageAtLast(FcitxInputStateGetPreedit(input), MSG_INPUT, "%s", FcitxInputStateGetRawInputBuffer(input));
FcitxMessagesAddMessageAtLast(FcitxInputStateGetClientPreedit(input), MSG_INPUT, "%s", FcitxInputStateGetRawInputBuffer(input));
}