Exemplo n.º 1
0
Arquivo: hotkey.c Projeto: Axure/fcitx
/*
 * Do some custom process
 */
FCITX_EXPORT_API
void FcitxHotkeyGetKey(FcitxKeySym keysym, unsigned int iKeyState, FcitxKeySym* outk, unsigned int* outs)
{
    /* key state != 0 */
    if (iKeyState) {
        if (iKeyState != FcitxKeyState_Shift && FcitxHotkeyIsHotKeyLAZ(keysym, 0))
            keysym = keysym + FcitxKey_A - FcitxKey_a;
        /*
         * alt shift 1 shoud be alt + !
         * shift+s should be S
         */

        if (FcitxHotkeyIsHotKeyLAZ(keysym, 0) || FcitxHotkeyIsHotKeyUAZ(keysym, 0)) {
            if (iKeyState == FcitxKeyState_Shift)
                iKeyState &= ~FcitxKeyState_Shift;
        }
        else {
            if ((iKeyState & FcitxKeyState_Shift)
                && (((FcitxHotkeyIsHotKeySimple(keysym, 0) || FcitxKeySymToUnicode(keysym) != 0)
                    && keysym != FcitxKey_space && keysym != FcitxKey_Return)
                    || (keysym >= FcitxKey_KP_0 && keysym <= FcitxKey_KP_9)))
                iKeyState &= ~FcitxKeyState_Shift;
        }
    }

    if (keysym == FcitxKey_ISO_Left_Tab)
        keysym = FcitxKey_Tab;

    *outk = keysym;

    *outs = iKeyState;
}
Exemplo n.º 2
0
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;
}
Exemplo n.º 3
0
Arquivo: punc.c Projeto: adaptee/fcitx
boolean IsHotKeyPunc(FcitxKeySym sym, unsigned int state)
{
    if (FcitxHotkeyIsHotKeySimple(sym, state)
            && !FcitxHotkeyIsHotKeyDigit(sym, state)
            && !FcitxHotkeyIsHotKeyLAZ(sym, state)
            && !FcitxHotkeyIsHotKeyUAZ(sym, state)
            && !FcitxHotkeyIsHotKey(sym, state, FCITX_SPACE))
        return true;

    return false;
}
Exemplo n.º 4
0
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 (FcitxHotkeyIsHotKeyUAZ(sym, state) &&
        (FcitxInputStateGetRawInputBufferSize(input) != 0 ||
         (FcitxInputStateGetKeyState(input) & FcitxKeyState_CapsLock) == 0) &&
        AutoEngCheckPreedit(autoEngState)) {
        *retval = IRV_DISPLAY_MESSAGE;
        FcitxInputStateSetShowCursor(input, false);
        AutoEngSetBuff(autoEngState, FcitxInputStateGetRawInputBuffer(input),
                       FcitxHotkeyPadToMain(sym));
        autoEngState->active = true;
        ShowAutoEngMessage(autoEngState, retval);
        return true;
    }

    return false;
}
Exemplo n.º 5
0
static boolean ProcessAutoEng(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->active) {
        FcitxKeySym keymain = FcitxHotkeyPadToMain(sym);
        if (FcitxHotkeyIsHotKeySimple(keymain, state)) {
            if (autoEngState->index < MAX_USER_INPUT) {
                autoEngState->buf[autoEngState->index] = keymain;
                autoEngState->index++;
                autoEngState->buf[autoEngState->index] = '\0';
                *retval = IRV_DISPLAY_MESSAGE;
            } else
                *retval = IRV_DO_NOTHING;
        } else if (FcitxHotkeyIsHotKey(sym, state, FCITX_BACKSPACE)) {
            autoEngState->index -- ;
            autoEngState->buf[autoEngState->index] = '\0';
            if (autoEngState->index == 0) {
                ResetAutoEng(autoEngState);
                *retval = IRV_CLEAN;
            } else
                *retval = IRV_DISPLAY_MESSAGE;
        } else if (FcitxHotkeyIsHotKey(sym, state, FCITX_ENTER)) {
            strcpy(FcitxInputStateGetOutputString(input), autoEngState->buf);
            ResetAutoEng(autoEngState);
            *retval = IRV_COMMIT_STRING;
        }
        ShowAutoEngMessage(autoEngState);
        return true;
    }
    if (FcitxHotkeyIsHotKeySimple(sym, state)) {
        if (FcitxInputStateGetRawInputBufferSize(input) == 0 && FcitxHotkeyIsHotKeyUAZ(sym, state)) {
            autoEngState->index = 1;
            autoEngState->buf[0] = sym;
            autoEngState->buf[1] = '\0';
            *retval = IRV_DISPLAY_MESSAGE;
            FcitxInputStateSetShowCursor(input, false);
            autoEngState->index = strlen(autoEngState->buf);
            autoEngState->active = true;
            ShowAutoEngMessage(autoEngState);
            return true;
        }

        strncpy(autoEngState->buf, FcitxInputStateGetRawInputBuffer(input), MAX_USER_INPUT);
        if (strlen(autoEngState->buf) >= MAX_USER_INPUT - 1)
            return false;

        autoEngState->index = strlen(autoEngState->buf);
        autoEngState->buf[autoEngState->index ++ ] = sym;
        autoEngState->buf[autoEngState->index] = '\0';

        if (SwitchToEng(autoEngState, autoEngState->buf)) {
            *retval = IRV_DISPLAY_MESSAGE;
            FcitxInputStateSetShowCursor(input, false);
            autoEngState->index = strlen(autoEngState->buf);
            autoEngState->active = true;
            ShowAutoEngMessage(autoEngState);
            return true;
        }
    }
    return false;
}