Exemplo n.º 1
0
static boolean PreInputProcessAutoEng(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;

    FcitxKeySym keymain = FcitxHotkeyPadToMain(sym);
    if (autoEngState->active) {
        if ((*retval = AutoEngCheckSelect(autoEngState, sym, state))) {
            return true;
        } else if (FcitxHotkeyIsHotKeySimple(keymain, state)) {
            *retval = AutoEngPushKey(autoEngState, keymain);
        } else if (FcitxHotkeyIsHotKey(sym, state, FCITX_BACKSPACE)) {
            AutoEngSetBuffLen(autoEngState, --autoEngState->index);
            if (autoEngState->index == 0) {
                ResetAutoEng(autoEngState);
                *retval = IRV_CLEAN;
            } else {
                *retval = IRV_DISPLAY_MESSAGE;
            }
        } else if (FcitxHotkeyIsHotKey(sym, state, FCITX_ENTER)) {
            AutoEngCommit(autoEngState);
            ResetAutoEng(autoEngState);
            *retval = IRV_FLAG_UPDATE_INPUT_WINDOW | IRV_FLAG_RESET_INPUT;
        } else if (FcitxHotkeyIsHotkeyCursorMove(sym, state)) {
            *retval = IRV_DO_NOTHING;
            return true;
        } else if (FcitxHotkeyIsHotKey(sym, state, FCITX_ESCAPE)) {
            *retval = IRV_CLEAN;
            return true;
        }
        ShowAutoEngMessage(autoEngState, retval);
        return true;
    }
    if (FcitxHotkeyIsHotKeySimple(sym, state)) {
        AutoEngSetBuff(autoEngState, FcitxInputStateGetRawInputBuffer(input),
                       keymain);

        if (SwitchToEng(autoEngState, autoEngState->buf)) {
            *retval = IRV_DISPLAY_MESSAGE;
            FcitxInputStateSetShowCursor(input, false);
            autoEngState->active = true;
            ShowAutoEngMessage(autoEngState, retval);
            return true;
        }
    }
    return false;
}
Exemplo n.º 2
0
static void
AutoEngActivate(FcitxAutoEngState *autoEngState, FcitxInputState* input,
                INPUT_RETURN_VALUE *retval)
{
    FcitxInputStateSetShowCursor(input, false);
    *retval = IRV_DISPLAY_MESSAGE;
    autoEngState->active = true;
    autoEngState->cursor_moved = false;
    ShowAutoEngMessage(autoEngState, retval);
}
Exemplo n.º 3
0
static INPUT_RETURN_VALUE
AutoEngGetCandWordCb(FcitxAutoEngState *autoEngState, const char *commit)
{
    INPUT_RETURN_VALUE res = IRV_DO_NOTHING;
    if (autoEngState->config.maxKeep == 0 &&
        !autoEngState->config.selectAddSpace) {
        return IRV_TO_PROCESS;
    }
    AutoEngSetBuff(autoEngState, commit, '\0');
    if (autoEngState->config.selectAddSpace) {
        autoEngState->auto_space = false;
        res |= AutoEngPushKey(autoEngState, ' ');
        if (!(res & IRV_FLAG_RESET_INPUT)) {
            autoEngState->auto_space = true;
        }
    }
    if (!(res & IRV_FLAG_RESET_INPUT)) {
        ShowAutoEngMessage(autoEngState, &res);
    }
    return res;
}
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;
}