Пример #1
0
void* FullWidthCharCreate(FcitxInstance* instance)
{
    FcitxFullWidthChar* fwchar = fcitx_utils_malloc0(sizeof(FcitxFullWidthChar));
    FcitxGlobalConfig* config = FcitxInstanceGetGlobalConfig(instance);
    fwchar->owner = instance;
    FcitxStringFilterHook hk;
    hk.arg = fwchar;
    hk.func = ProcessFullWidthChar;
    FcitxInstanceRegisterCommitFilter(instance, hk);

    FcitxKeyFilterHook phk;
    phk.arg = fwchar;
    phk.func = FullWidthPostFilter;
    FcitxInstanceRegisterPostInputFilter(instance, phk);

    FcitxHotkeyHook hotkey;
    hotkey.hotkey = config->hkFullWidthChar;
    hotkey.hotkeyhandle = ToggleFullWidthStateWithHotkey;
    hotkey.arg = fwchar;

    FcitxInstanceRegisterHotkeyFilter(instance, hotkey);

    FcitxUIRegisterStatus(instance, fwchar, "fullwidth", _("Full Width Character"), _("Full Width Character"),  ToggleFullWidthState, GetFullWidthState);

    return fwchar;
}
Пример #2
0
void* ChttransCreate(FcitxInstance* instance)
{
    FcitxChttrans* transState = fcitx_utils_malloc0(sizeof(FcitxChttrans));
    FcitxAddon* transAddon = FcitxAddonsGetAddonByName(FcitxInstanceGetAddons(instance), FCITX_CHTTRANS_NAME);
    transState->owner = instance;
    if (!LoadChttransConfig(transState)) {
        free(transState);
        return NULL;
    }

    FcitxHotkeyHook hk;
    hk.arg = transState;
    hk.hotkey = transState->hkToggle;
    hk.hotkeyhandle = HotkeyToggleChttransState;

    FcitxStringFilterHook shk;
    shk.arg = transState;
    shk.func = ChttransOutputFilter;

    FcitxInstanceRegisterHotkeyFilter(instance, hk);
    FcitxInstanceRegisterOutputFilter(instance, shk);
    FcitxInstanceRegisterCommitFilter(instance, shk);
    FcitxUIRegisterStatus(instance, transState, "chttrans",
                          transState->enabled ? _("Convert to Traditional Chinese") :  _("Convert to Simplified Chinese"),
                          _("Toggle Simp/Trad Chinese Conversion"),
                          ToggleChttransState,
                          GetChttransEnabled);

    FcitxInstanceWatchContext(instance, CONTEXT_IM_LANGUAGE, ChttransLanguageChanged, transState);

    AddFunction(transAddon, ChttransS2T);
    AddFunction(transAddon, ChttransT2S);

    return transState;
}
Пример #3
0
void* FullWidthCharCreate(FcitxInstance* instance)
{
    FcitxFullWidthChar* fwchar = fcitx_utils_malloc0(sizeof(FcitxFullWidthChar));
    FcitxGlobalConfig* config = FcitxInstanceGetGlobalConfig(instance);
    fwchar->owner = instance;
    FcitxStringFilterHook hk;
    hk.arg = fwchar;
    hk.func = ProcessFullWidthChar;
    FcitxInstanceRegisterCommitFilter(instance, hk);

    FcitxKeyFilterHook phk;
    phk.arg = fwchar;
    phk.func = FullWidthPostFilter;
    FcitxInstanceRegisterPostInputFilter(instance, phk);

    FcitxHotkeyHook hotkey;
    hotkey.hotkey = config->hkFullWidthChar;
    hotkey.hotkeyhandle = ToggleFullWidthStateWithHotkey;
    hotkey.arg = fwchar;

    FcitxInstanceRegisterHotkeyFilter(instance, hotkey);

    FcitxProfile* profile = FcitxInstanceGetProfile(instance);
    FcitxUIRegisterStatus(instance, fwchar, "fullwidth",
                          profile->bUseFullWidthChar ? _("Full width Character") :  _("Half width Character"),
                          _("Toggle Half/Full width Character"),
                          ToggleFullWidthState, GetFullWidthState);

    FcitxInstanceRegisterWatchableContext(instance, CONTEXT_DISABLE_FULLWIDTH, FCT_Boolean, FCF_ResetOnInputMethodChange);
    FcitxInstanceWatchContext(instance, CONTEXT_DISABLE_FULLWIDTH, DisableFullWidthCharChanged, fwchar);

    return fwchar;
}
Пример #4
0
void *ChttransCreate(FcitxInstance* instance)
{
    FcitxChttrans *transState = fcitx_utils_new(FcitxChttrans);
    transState->owner = instance;
    transState->enableIM = fcitx_string_map_new(NULL, '\0');
    if (!LoadChttransConfig(transState)) {
        fcitx_string_map_free(transState->enableIM);
        free(transState);
        return NULL;
    }

    FcitxHotkeyHook hk;
    hk.arg = transState;
    hk.hotkey = transState->hkToggle;
    hk.hotkeyhandle = HotkeyToggleChttransState;

    FcitxStringFilterHook shk;
    shk.arg = transState;
    shk.func = ChttransOutputFilter;

    FcitxIMEventHook imhk;
    imhk.arg = transState;
    imhk.func = ChttransIMChanged;

    FcitxInstanceRegisterHotkeyFilter(instance, hk);
    FcitxInstanceRegisterOutputFilter(instance, shk);
    FcitxInstanceRegisterCommitFilter(instance, shk);
    FcitxInstanceRegisterIMChangedHook(instance, imhk);
    FcitxUIRegisterStatus(instance, transState, "chttrans",
                          ChttransEnabled(transState) ? _("Traditional Chinese") :  _("Simplified Chinese"),
                          _("Toggle Simp/Trad Chinese Conversion"),
                          ToggleChttransState,
                          GetChttransEnabled);

    FcitxInstanceWatchContext(instance, CONTEXT_IM_LANGUAGE,
                              ChttransLanguageChanged, transState);

    FcitxChttransAddFunctions(instance);
    return transState;
}