void ReloadPunc(void* arg) { FcitxPuncState* puncState = (FcitxPuncState*) arg; FreePunc(puncState); LoadPuncDict(puncState); PuncLanguageChanged(puncState, FcitxInstanceGetContextString(puncState->owner, CONTEXT_IM_LANGUAGE)); }
void* PuncCreate(FcitxInstance* instance) { FcitxPuncState* puncState = fcitx_utils_malloc0(sizeof(FcitxPuncState)); FcitxAddon* puncaddon = FcitxAddonsGetAddonByName(FcitxInstanceGetAddons(instance), FCITX_PUNC_NAME); puncState->owner = instance; LoadPuncDict(puncState); FcitxKeyFilterHook hk; hk.arg = puncState; hk.func = ProcessPunc; FcitxInstanceRegisterPostInputFilter(instance, hk); hk.func = PuncPreFilter; FcitxInstanceRegisterPreInputFilter(instance, hk); puncState->cLastIsAutoConvert = '\0'; puncState->bLastIsNumber = false; FcitxHotkeyHook hotkey; hotkey.hotkey = FcitxInstanceGetGlobalConfig(instance)->hkPunc; hotkey.hotkeyhandle = TogglePuncStateWithHotkey; hotkey.arg = puncState; FcitxInstanceRegisterHotkeyFilter(instance, hotkey); FcitxIMEventHook hook; hook.arg = puncState; hook.func = ResetPunc; FcitxInstanceRegisterResetInputHook(instance, hook); hook.func = ResetPuncWhichStatus; FcitxInstanceRegisterInputUnFocusHook(instance, hook); FcitxInstanceWatchContext(instance, CONTEXT_IM_LANGUAGE, PuncLanguageChanged, puncState); FcitxProfile* profile = FcitxInstanceGetProfile(instance); FcitxUIRegisterStatus(instance, puncState, "punc", profile->bUseWidePunc ? _("Full width punct") : _("Latin punct"), _("Toggle Full Width Punctuation"), TogglePuncState, GetPuncState); puncState->slot = FcitxInstanceAllocDataForIC(instance, PuncWhichAlloc, PuncWhichCopy, PuncWhichFree, puncState); FcitxModuleAddFunction(puncaddon, PuncGetPunc); FcitxModuleAddFunction(puncaddon, PuncGetPunc2); return puncState; }
int main_PY() { // int c; //用于保存用户输入的参数 // Bool bBackground = True; // char *imname=(char *)NULL; extern Bool bPYBaseDictLoaded; extern Bool bPYOtherDictLoaded; initConfig(); //szj initConfig2(); //szj if (!InitX ()){}; //exit (1); /*加载用户配置文件,通常是“~/.fcitx/config”,如果该文件不存在就从安装目录中拷贝 * “/data/config”到“~/.fcitx/config” */ LoadConfig (True); /*创建字体。实际上,就是根据用户的设置,使用xft读取字体的相关信息。 * xft是x11提供的处理字体的相关函数集 */ CreateFont (); //根据字体计算输入窗口的高度 CalculateInputWindowHeight (); /*加载配置文件,这个配置文件不是用户配置的,而是用于记录fctix的运行状态的, * 比如是全角还是半角等等。通常是“~/.fcitx/profile”,如果该文件不存在就从安装 * 目录中拷贝“/data/profile”到“~/.fcitx/profile” */ LoadProfile (); //加载标点字典文件 LoadPuncDict (); //加载成语 LoadQuickPhrase (); /*从 ~/.fcitx/AutoEng.dat (如果不存在, * 则从 /usr/local/share/fcitx/data/AutoEng.dat) * 读取需要自动转换到英文输入状态的情况的数据 */ LoadAutoEng (); //以下是界面的处理 CreateMainWindow (); //创建主窗口,即输入法状态窗口 CreateVKWindow (); //创建候选词窗口 CreateInputWindow (); //创建输入窗口 //szj CreateAboutWindow (); //创建关于窗口 //处理颜色,即候选词窗口的颜色,也就是我们在“~/.fcitx/config”定义的那些颜色信息 InitGC (inputWindow); //将本程序加入到输入法组,告诉系统,使用我输入字符 SetIM (); //处理主窗口的显示 if (hideMainWindow != HM_HIDE) { DisplayMainWindow (); DrawMainWindow (); } if (!bPYBaseDictLoaded) LoadPYBaseDict (); if (!bPYOtherDictLoaded) LoadPYOtherDict (); //以后台方式运行 #ifdef _ENABLE_TRAY CreateTrayWindow (); //创建系统托盘窗口 DrawTrayWindow (INACTIVE_ICON); //显示托盘图标 #endif return 0; }